From 3397b7ae045f708f85182708059cbec2ff988687 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Tue, 27 Aug 2024 12:18:14 +0200 Subject: [PATCH 1/2] Automatically enable JITPROFILING with ITTAPI --- src/codegen.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index 3645a0b25827e..8935670ed7a3b 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -81,6 +81,10 @@ #include #include +#ifdef USE_ITTAPI +#include "ittapi/ittnotify.h" +#endif + using namespace llvm; static bool jl_fpo_disabled(const Triple &TT) { @@ -10425,8 +10429,14 @@ 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 + jl_using_intel_jitevents = __itt_get_collection_state() == __itt_collection_init_successful; +#endif } #endif From 4356ea15da02f8c54bae319e89d3e9502d1771fb Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Tue, 27 Aug 2024 13:31:47 +0200 Subject: [PATCH 2/2] fixup! Automatically enable JITPROFILING with ITTAPI --- src/codegen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index 8935670ed7a3b..99bd98f0123a1 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -10435,7 +10435,9 @@ extern "C" void jl_init_llvm(void) } } else { #ifdef USE_ITTAPI - jl_using_intel_jitevents = __itt_get_collection_state() == __itt_collection_init_successful; + __itt_collection_state state = __itt_get_collection_state(); + jl_using_intel_jitevents = state == __itt_collection_init_successful || + state == __itt_collection_collector_exists; #endif } #endif