Skip to content

Commit

Permalink
liblikwid_available check + minor code reorg (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenbauer committed Dec 5, 2022
1 parent 36f9346 commit c7df8e8
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/LIKWID.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export OrderedDict
const liblikwid = "liblikwid"
include("LibLikwid.jl")

const perf_paranoid_path = "/proc/sys/kernel/perf_event_paranoid"

# Julia types
include("types.jl")

Expand Down Expand Up @@ -75,27 +77,23 @@ import .GPUMarker: gpumarker, @gpumarker
export GPUMarker, gpumarker, @gpumarker
include("frequency.jl")

const perf_paranoid_path = "/proc/sys/kernel/perf_event_paranoid"

function perf_event_paranoid()
open(perf_paranoid_path, "r") do io
parse(Int, readline(io))
end
end

function __init__()
if gpusupport()
init_topology_gpu()
end
if accessmode() == LibLikwid.ACCESSMODE_PERF && ispath(perf_paranoid_path)
perf_paranoid = perf_event_paranoid()
uid = Libc.getuid()
@debug "/proc/sys/kernel/perf_event_paranoid is set to" perf_paranoid uid
if perf_paranoid > 0 && uid != 0 && !haskey(ENV, "LIKWID_PERF_PID")
pid = getpid()
@debug "Setting environment variable LIKWID_PERF_PID" pid
ENV["LIKWID_PERF_PID"] = pid
if liblikwid_available()
if gpusupport()
init_topology_gpu()
end
if accessmode() == LibLikwid.ACCESSMODE_PERF && ispath(perf_paranoid_path)
perf_paranoid = perf_event_paranoid()
uid = Libc.getuid()
@debug "/proc/sys/kernel/perf_event_paranoid is set to" perf_paranoid uid
if perf_paranoid > 0 && uid != 0 && !haskey(ENV, "LIKWID_PERF_PID")
pid = getpid()
@debug "Setting environment variable LIKWID_PERF_PID" pid
ENV["LIKWID_PERF_PID"] = pid
end
end
else
@warn("The library `liblikwid`` couldn't be found. Don't expect anything to work.", liblikwid)
end
return nothing
end
Expand Down

2 comments on commit c7df8e8

@carstenbauer
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/73481

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.3 -m "<description of version>" c7df8e8b815e3d068f85e4c2a4fbd0668f1d5c1e
git push origin v0.4.3

Please sign in to comment.