Using the Intel VTune Profiler with julia

I’m not sure. I’d go with JuliaLang/julia for now.

@giordano Maybe you can point us to the right repo here?

LLVM nowadays is built in Yggdrasil

1 Like

Unfortunately building with USE_BINARYBUILDER=0 in cygwin on Windows fails for me, so I can’t get it to work. I’m wondering whether compiling LLVM with LLVM_USE_INTEL_JITEVENTS would be safe as a default (does it come with a performance penalty or something similar?)

I opened an issue to discuss whether it makes sense to set the flag for the prebuilt binaries.

1 Like

I think this already was the intention, but fails due to a typo of using USE_INTEL_JITEVENTS instead of LLVM_USE_INTEL_JITEVENTS (which is why the pre-build-cmake log contains this warning)

Not adding anything to the discussion. Using Intel VTune with Julia is impressive! Its something I though about recently. I hope to get hands on with some bigger systems soon so could help with this.

Also Yggdrasil was the original Linux distribution on floppy disks. I thought it was long dead. Is the Julia builder related in some way?

No

With the latest VTune, I also need to set the following environment variable to see the JITed codes showing up in the profile: INTEL_JIT_BACKWARD_COMPATIBILITY=1

3 Likes

I tried to work on Intel VTune profiler with, but I did not know how to connect it to Julia (run via VS code).
Any step-by-step documentation for it? or could anyone help me in this please ?
Thank you very much!

Played around this morning with it.

ENABLE_JITPROFILING=1
INTEL_JIT_BACKWARD_COMPATIBILITY=0

I see:

With

ENABLE_JITPROFILING=1
INTEL_JIT_BACKWARD_COMPATIBILITY=1

I see:

This is on Intel VTune 2022 and Julia 1.9

So the biggest annoyance is that it doesn’t automatically find the source file.

1 Like

Would be interesting to see if GitHub - intel/ittapi: Intel® Instrumentation and Tracing Technology (ITT) and Just-In-Time (JIT) API is enough and we could use Yggdrasil to provide the libs instead of having to pick them up from VTune in the environment.

1 Like

Did you run a julia script from the GUI or the CLI?

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!