# Using the Intel VTune Profiler with julia

**URL:** <https://discourse.julialang.org/t/using-the-intel-vtune-profiler-with-julia/34327>\
**Category:** Tooling\
**Tags:** profiling\
**Created:** [February 7, 2020, 9:55pm UTC](https://discourse.julialang.org/t/using-the-intel-vtune-profiler-with-julia/34327 "2020-02-07T21:55:14Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)\
**Post date:** [November 17, 2022, 5:13pm UTC](https://discourse.julialang.org/t/using-the-intel-vtune-profiler-with-julia/34327/21 "2022-11-17T17:13:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)\
**Post date:** [November 18, 2022, 7:44pm UTC](https://discourse.julialang.org/t/using-the-intel-vtune-profiler-with-julia/34327/22 "2022-11-18T19:44:10Z")

</div>

```julia
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”.

---

<div class="post-metadata">

**Author:** ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)\
**Post date:** [November 18, 2022, 7:57pm UTC](https://discourse.julialang.org/t/using-the-intel-vtune-profiler-with-julia/34327/23 "2022-11-18T19:57:18Z")

</div>

Just uploaded it to [GitHub - JuliaPerf/ITT.jl: ITT](https://github.com/JuliaPerf/ITT.jl)

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [December 13, 2022, 11:58am UTC](https://discourse.julialang.org/t/using-the-intel-vtune-profiler-with-julia/34327/24 "2022-12-13T11:58:09Z")

</div>

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](https://github.com/carstenbauer/julia-intelvtune)

---

<div class="post-metadata">

**Author:** ![anon28281882](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@anon28281882](https://discourse.julialang.org/u/anon28281882)\
**Post date:** [December 15, 2022, 9:22pm UTC](https://discourse.julialang.org/t/using-the-intel-vtune-profiler-with-julia/34327/25 "2022-12-15T21:22:37Z")

</div>

@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](https://github.com/JuliaPerf/IntelITT.jl) 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](https://github.com/carstenbauer/julia-intelvtune), 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.

---

<div class="post-metadata">

**Author:** ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)\
**Post date:** [December 19, 2022, 2:14pm UTC](https://discourse.julialang.org/t/using-the-intel-vtune-profiler-with-julia/34327/26 "2022-12-19T14:14:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [December 19, 2022, 3:36pm UTC](https://discourse.julialang.org/t/using-the-intel-vtune-profiler-with-julia/34327/27 "2022-12-19T15:36:37Z")

</div>

> [@anon28281882](#):
>
> 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?

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.

---

<div class="post-metadata">

**Author:** ![anon28281882](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@anon28281882](https://discourse.julialang.org/u/anon28281882)\
**Post date:** [December 19, 2022, 9:14pm UTC](https://discourse.julialang.org/t/using-the-intel-vtune-profiler-with-julia/34327/28 "2022-12-19T21:14:43Z")

</div>

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!

[Previous page](https://discourse.julialang.org/t/using-the-intel-vtune-profiler-with-julia/34327.md?page=1)
