Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[deps]
DocOpt = "968ba79b-81e4-546f-ab3a-2eecfa62a9db"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
4 changes: 4 additions & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
VTUNE_DIR := /opt/intel/oneapi/vtune/latest

itt.so: itt.c
gcc -shared -fPIC $< -I$(VTUNE_DIR)/include -L$(VTUNE_DIR)/lib64 -l:libittnotify.a -o $@
17 changes: 17 additions & 0 deletions lib/itt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <ittnotify.h>

__itt_domain* gc_domain = 0;
__itt_string_handle* handle_main = 0;

void init() {
gc_domain = __itt_domain_create("org.julialang.gc");
handle_main = __itt_string_handle_create("collect");
}

void gc_begin() {
__itt_task_begin(gc_domain, __itt_null, __itt_null, handle_main);
}

void gc_end() {
__itt_task_end(gc_domain);
}
18 changes: 18 additions & 0 deletions utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@ using Pkg
Pkg.instantiate() # It is dumb that I have to do this
using Serialization

module ITT
import Libdl
const GC_LIB = joinpath(@__DIR__, "lib/itt.so")

function __init__()
lib = Libdl.dlopen(GC_LIB)
sym_init = Libdl.dlsym(lib, :init)
sym_begin = Libdl.dlsym(lib, :gc_begin)
sym_end = Libdl.dlsym(lib, :gc_end)

ccall(sym_init, Cvoid, ())
ccall(:jl_gc_set_cb_pre_gc, Cvoid, (Ptr{Cvoid}, Cint),
sym_begin, true)
ccall(:jl_gc_set_cb_post_gc, Cvoid, (Ptr{Cvoid}, Cint),
sym_end, true)
end
end

macro gctime(ex)
fc = isdefined(Base.Experimental, Symbol("@force_compile")) ?
:(Base.Experimental.@force_compile) :
Expand Down