Revision bc7ba3d5c8b2dab1c0e19537739b67c2da902d11 authored by Keno Fischer on 20 March 2024, 06:35:46 UTC, committed by GitHub on 20 March 2024, 06:35:46 UTC
This passes slightly more information into this function (the full
`inst` rather than just the `stmt`) in order to allow external absint to
access additional fields (the flags and the info) if necessary to make
concrete evaluation decisions. It also splits out the actual concrete
evaluation from the part that just maps the `inst` to a CodeInstance.
1 parent e0bb95a
Raw File
print_process_affinity.jl
# This file is a part of Julia. License is MIT: https://julialang.org/license

const uv_thread_t = UInt # TODO: this is usually correct (or tolerated by the API), but not guaranteed

function uv_thread_getaffinity()
    masksize = ccall(:uv_cpumask_size, Cint, ())
    self = ccall(:uv_thread_self, uv_thread_t, ())
    ref = Ref(self)
    cpumask = zeros(Bool, masksize)
    err = ccall(
        :uv_thread_getaffinity,
        Cint,
        (Ref{uv_thread_t}, Ptr{Bool}, Cssize_t),
        ref,
        cpumask,
        masksize,
    )
    Base.uv_error("getaffinity", err)
    n = something(findlast(cpumask)) # we must have at least one active core
    resize!(cpumask, n)
    return cpumask
end

function print_process_affinity()
    join(stdout, findall(uv_thread_getaffinity()), ",")
    println()
end

if Base.Filesystem.samefile(PROGRAM_FILE, @__FILE__)
    print_process_affinity()
end
back to top