Skip to content

Commit

Permalink
Automatically enable JITPROFILING with ITTAPI (#55598)
Browse files Browse the repository at this point in the history
This helps when profiling remotely since VTunes doesn't support
setting environment variables on remote systems.

Will still respect `ENABLE_JITPROFILING=0`.
  • Loading branch information
vchuravy authored Nov 30, 2024
1 parent c1f806d commit d32843b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
#include <llvm/Bitcode/BitcodeReader.h>
#include <llvm/Linker/Linker.h>

#ifdef USE_ITTAPI
#include "ittapi/ittnotify.h"
#endif

using namespace llvm;

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

#if defined(JL_USE_INTEL_JITEVENTS)
if (jit_profiling && atoi(jit_profiling)) {
jl_using_intel_jitevents = 1;
if (jit_profiling) {
if (atoi(jit_profiling)) {
jl_using_intel_jitevents = 1;
}
} else {
#ifdef USE_ITTAPI
__itt_collection_state state = __itt_get_collection_state();
jl_using_intel_jitevents = state == __itt_collection_init_successful ||
state == __itt_collection_collector_exists;
#endif
}
#endif

Expand Down

0 comments on commit d32843b

Please sign in to comment.