Skip to content

Commit d32843b

Browse files
authored
Automatically enable JITPROFILING with ITTAPI (#55598)
This helps when profiling remotely since VTunes doesn't support setting environment variables on remote systems. Will still respect `ENABLE_JITPROFILING=0`.
1 parent c1f806d commit d32843b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/codegen.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@
8181
#include <llvm/Bitcode/BitcodeReader.h>
8282
#include <llvm/Linker/Linker.h>
8383

84+
#ifdef USE_ITTAPI
85+
#include "ittapi/ittnotify.h"
86+
#endif
87+
8488
using namespace llvm;
8589

8690
static bool jl_fpo_disabled(const Triple &TT) {
@@ -10427,8 +10431,16 @@ extern "C" void jl_init_llvm(void)
1042710431
const char *jit_profiling = getenv("ENABLE_JITPROFILING");
1042810432

1042910433
#if defined(JL_USE_INTEL_JITEVENTS)
10430-
if (jit_profiling && atoi(jit_profiling)) {
10431-
jl_using_intel_jitevents = 1;
10434+
if (jit_profiling) {
10435+
if (atoi(jit_profiling)) {
10436+
jl_using_intel_jitevents = 1;
10437+
}
10438+
} else {
10439+
#ifdef USE_ITTAPI
10440+
__itt_collection_state state = __itt_get_collection_state();
10441+
jl_using_intel_jitevents = state == __itt_collection_init_successful ||
10442+
state == __itt_collection_collector_exists;
10443+
#endif
1043210444
}
1043310445
#endif
1043410446

0 commit comments

Comments
 (0)