diff options
author | Nicolas Vasilache <ntv@google.com> | 2022-01-03 11:38:59 -0500 |
---|---|---|
committer | Nicolas Vasilache <nicolas.vasilache@google.com> | 2022-01-04 02:11:02 -0500 |
commit | f68ecdd45812021b32b738df3bee602ca5042bb4 (patch) | |
tree | fcae57364f63787d90ee07a9d326756c92c33aa2 | |
parent | c64ffa22d143fc58858bdb1105a22a5fc73ad26e (diff) | |
download | llvm-f68ecdd45812021b32b738df3bee602ca5042bb4.tar.gz |
[mlir] Add CMake flags to properly enable Jit event listeners.
By default, the listeners do nothing unless linked in.
This revision allows the "Perf" and "Intel" Jit event listeners to be used.
The "OProfile" event listener is not enabled at this time,
the associated library structure is not well-isolated.
Differential Revision: https://reviews.llvm.org/D116552
-rw-r--r-- | mlir/lib/ExecutionEngine/CMakeLists.txt | 11 | ||||
-rw-r--r-- | mlir/lib/ExecutionEngine/ExecutionEngine.cpp | 12 |
2 files changed, 20 insertions, 3 deletions
diff --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt index c52837c2e9ad..7d758fdbdd61 100644 --- a/mlir/lib/ExecutionEngine/CMakeLists.txt +++ b/mlir/lib/ExecutionEngine/CMakeLists.txt @@ -13,6 +13,16 @@ set(LLVM_OPTIONAL_SOURCES JitRunner.cpp ) +if(LLVM_USE_INTEL_JITEVENTS) + set(LLVM_JIT_LISTENER_LIB + IntelJITEvents) +endif(LLVM_USE_INTEL_JITEVENTS) + +if(LLVM_USE_PERF) + set(LLVM_JIT_LISTENER_LIB + PerfJITEvents) +endif(LLVM_USE_PERF) + add_mlir_library(MLIRExecutionEngine ExecutionEngine.cpp OptUtils.cpp @@ -42,6 +52,7 @@ add_mlir_library(MLIRExecutionEngine TransformUtils nativecodegen IPO + ${LLVM_JIT_LISTENER_LIB} LINK_LIBS PUBLIC MLIRLLVMIR diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp index ead15152162e..00569e1d4242 100644 --- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp @@ -217,9 +217,15 @@ ExecutionEngine::ExecutionEngine(bool enableObjectCache, gdbListener(enableGDBNotificationListener ? llvm::JITEventListener::createGDBRegistrationListener() : nullptr), - perfListener(enablePerfNotificationListener - ? llvm::JITEventListener::createPerfJITEventListener() - : nullptr) {} + perfListener(nullptr) { + if (enablePerfNotificationListener) { + if (auto *listener = llvm::JITEventListener::createPerfJITEventListener()) + perfListener = listener; + else if (auto *listener = + llvm::JITEventListener::createIntelJITEventListener()) + perfListener = listener; + } +} Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create( ModuleOp m, |