Skip to content

Commit 5f99b5c

Browse files
authored
Enable symbols in the JIT for the Intel Vtune profiler (#830)
* Enable helpful symbols in the JIT for Intel Vtune profiler * Bump which compiler SPI uses
1 parent 5fe0c5b commit 5f99b5c

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

site/spi/Makefile-bits

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ifeq ($(SP_OS), rhel7)
1818

1919
## If not overridden, here is our preferred LLVM installation
2020
## (may be changed as new versions are rolled out to the facility)
21-
LLVM_DIRECTORY ?= /shots/spi/home/lib/arnold/rhel7/llvm_5.0.0
21+
LLVM_DIRECTORY ?= /shots/spi/home/lib/arnold/rhel7/llvm_5.0.1_rc2
2222

2323
# A variety of tags can be used to try specific versions of gcc or
2424
# clang from the site-specific places we have installed them.
@@ -28,8 +28,8 @@ ifeq ($(SP_OS), rhel7)
2828
-DCMAKE_CXX_COMPILER=/shots/spi/home/lib/arnold/rhel7/llvm_4.0_final/bin/clang++
2929
else ifeq (${COMPILER}, clang5)
3030
MY_CMAKE_FLAGS += \
31-
-DCMAKE_C_COMPILER=/shots/spi/home/lib/arnold/rhel7/llvm_5.0.0/bin/clang \
32-
-DCMAKE_CXX_COMPILER=/shots/spi/home/lib/arnold/rhel7/llvm_5.0.0/bin/clang++
31+
-DCMAKE_C_COMPILER=/shots/spi/home/lib/arnold/rhel7/llvm_5.0.1_rc2/bin/clang \
32+
-DCMAKE_CXX_COMPILER=/shots/spi/home/lib/arnold/rhel7/llvm_5.0.1_rc2/bin/clang++
3333
else ifeq (${COMPILER},clang)
3434
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
3535
else ifeq (${COMPILER}, gcc490)

src/liboslexec/llvm_util.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6161
#include <llvm/Support/ManagedStatic.h>
6262
#include <llvm/Support/MemoryBuffer.h>
6363
#include <llvm/ExecutionEngine/GenericValue.h>
64+
#include <llvm/ExecutionEngine/JITEventListener.h>
6465
#include <llvm/ExecutionEngine/MCJIT.h>
6566
#include <llvm/Support/raw_ostream.h>
6667
#include <llvm/Support/TargetSelect.h>
@@ -449,6 +450,17 @@ LLVM_Util::make_jit_execengine (std::string *err)
449450
if (! m_llvm_exec)
450451
return NULL;
451452

453+
// These magic lines will make it so that enough symbol information
454+
// is injected so that running vtune will kinda tell you which shaders
455+
// you're in, and sometimes which function (only for functions that don't
456+
// get inlined. There doesn't seem to be any perf hit from this, either
457+
// in code quality or JIT time. It is only enabled, however, if your copy
458+
// of LLVM was build with -DLLVM_USE_INTEL_JITEVENTS=ON, otherwise
459+
// createIntelJITEventListener() is a stub that just returns nullptr.
460+
auto vtuneProfiler = llvm::JITEventListener::createIntelJITEventListener();
461+
if (vtuneProfiler)
462+
m_llvm_exec->RegisterJITEventListener (vtuneProfiler);
463+
452464
// Force it to JIT as soon as we ask it for the code pointer,
453465
// don't take any chances that it might JIT lazily, since we
454466
// will be stealing the JIT code memory from under its nose and

0 commit comments

Comments
 (0)