Using the Intel VTune Profiler with julia

From the GUI. Also set the environment flags there under advance.

1 Like
module ITT
    # Notes:
    # Only supports Linux for now.
    # ENABLE_JITPROFILING=1
    # INTEL_JIT_BACKWARD_COMPATIBILITY
    # 0: Resolves inlined call-stacks
    # 1: Groups at the level of LLVM functions compiled
    # 
    # IMPORTANT: Do not use `detach`, doing so causes VTunes
    #            to not resolve jitted functions.
    libittnotify::String = ""
    available() = !isempty(libittnotify)


    function __init()
        global libittnotify
        libittnotify = get(ENV, "INTEL_JIT_PROFILER64", "")
        if isempty(libittnotify)
            libittnotify = get(ENV, "INTEL_JIT_PROFILER32", "")
        end
        if isempty(libittnotify)
            libittnotify = get(ENV, "VS_PROFILER", "")
        end
    end

    # TODO: Initalize

    __itt_resume() = ccall((:__itt_resume, libittnotify), Cvoid,())
    __itt_pause() = ccall((:__itt_pause, libittnotify), Cvoid,())
    # __itt_detach() = ccall((:__itt_detach, libittnotify), Cvoid,())
    resume() = available() && __itt_resume()
    pause() = available() && __itt_pause()
    # detach() = available() && __itt_detach()
end
@assert ITT.available()

function profile_test(n)
    for i = 1:n
        A = randn(100,100,20)
        m = maximum(A)
        Am = mapslices(sum, A; dims=2)
        B = A[:,:,5]
        Bsort = mapslices(sort, B; dims=1)
        b = rand(100)
        C = B.*b
    end
end

profile_test(1)

ITT.resume()
profile_test(100)
ITT.pause()

Rough sketch for something that “just works”.

2 Likes

Just uploaded it to GitHub - JuliaPerf/ITT.jl: ITT

FWIW, I’ve just reproduced what Valentin got above on our Noctua 1 cluster and documented the steps here: GitHub - carstenbauer/julia-intelvtune: Running Julia under Intel VTune

2 Likes

@carstenbauer

About a year ago I did some tries with Intel VTune Profiler and just learnt about this new IntelITT.jl package and I’d like to give it a try again.

At GitHub - JuliaPerf/IntelITT.jl: ITT it is written:

You need to compile Julia locally with USE_INTEL_JITEVENTS=1 and set the environment variable ENABLE_JITPROFILING=1

however

In your documentation at GitHub - carstenbauer/julia-intelvtune: Running Julia under Intel VTune, you are referring:

Build Julia from source (This is only necessary for Julia <= 1.8)

I’d like to ask for a clarification related to the building requirement. If I am using Julia =>1.8, not on Noctua 1 cluster, do I have to build or it is not required?

Edit: I will follow IntelITT.jl recommendations, should it be otherwise pls let me know.

Julia 1.9 and above will have VTune support enabled by default.

5 Likes

Sorry for the late reply. The comment is not specific to Noctua. As Valentin already mentioned above, for Julia >= 1.9 the JIT events flag is enabled already in the default build and makes compiling from source unnecessary.

Ah! Ok. No need to feel sorry. Seems like the next line of your guide maybe being slightly misleading as it seems you are building there with 1.9 so not all seem to be mutually exclusive and collectively exhaustive. Thank you and @vchuravy for the clarification!