[Mlir-commits] [mlir] f68ecdd - [mlir] Add CMake flags to properly enable Jit event listeners.

Nicolas Vasilache llvmlistbot at llvm.org
Mon Jan 3 23:11:12 PST 2022


Author: Nicolas Vasilache
Date: 2022-01-04T02:11:02-05:00
New Revision: f68ecdd45812021b32b738df3bee602ca5042bb4

URL: https://github.com/llvm/llvm-project/commit/f68ecdd45812021b32b738df3bee602ca5042bb4
DIFF: https://github.com/llvm/llvm-project/commit/f68ecdd45812021b32b738df3bee602ca5042bb4.diff

LOG: [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

Added: 
    

Modified: 
    mlir/lib/ExecutionEngine/CMakeLists.txt
    mlir/lib/ExecutionEngine/ExecutionEngine.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt
index c52837c2e9ad9..7d758fdbdd619 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 ead15152162e5..00569e1d4242c 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,


        


More information about the Mlir-commits mailing list