Skip to content

Commit

Permalink
Add profiling support for Intel Parallel Amplifier XE (VTune) for JIT…
Browse files Browse the repository at this point in the history
…ted code in LLVM.

Also refactor the existing OProfile profiling code to reuse the same interfaces with the VTune profiling code.
In addition, unit tests for the profiling interfaces were added.

This patch was prepared by Andrew Kaylor and Daniel Malea, and reviewed in the llvm-commits list by Jim Grosbach



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152620 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Eli Bendersky committed Mar 13, 2012
1 parent c007ba8 commit 61b1851
Show file tree
Hide file tree
Showing 34 changed files with 2,243 additions and 341 deletions.
38 changes: 38 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,44 @@ else()
option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
endif()

option(LLVM_USE_INTEL_JITEVENTS
"Use Intel JIT API to inform Intel(R) VTune(TM) Amplifier XE 2011 about JIT code"
OFF)

if( LLVM_USE_INTEL_JITEVENTS )
# Verify we are on a supported platform
if( CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "Linux" )
# Directory where Intel Parallel Amplifier XE 2011 is installed.
if ( WIN32 )
set(LLVM_INTEL_JITEVENTS_DIR $ENV{VTUNE_AMPLIFIER_XE_2011_DIR})
else ( WIN32 )
set(LLVM_INTEL_JITEVENTS_DIR "/opt/intel/vtune_amplifier_xe_2011")
endif ( WIN32 )

# Set include and library search paths for Intel JIT Events API
set(LLVM_INTEL_JITEVENTS_INCDIR "${LLVM_INTEL_JITEVENTS_DIR}/include")

if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(LLVM_INTEL_JITEVENTS_LIBDIR "${LLVM_INTEL_JITEVENTS_DIR}/lib64")
else ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(LLVM_INTEL_JITEVENTS_LIBDIR "${LLVM_INTEL_JITEVENTS_DIR}/lib32")
endif ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
else()
message(FATAL_ERROR
"Intel JIT API support is available on Linux and Windows only.")
endif()
endif( LLVM_USE_INTEL_JITEVENTS )

option(LLVM_USE_OPROFILE
"Use opagent JIT interface to inform OProfile about JIT code" OFF)

# If enabled, ierify we are on a platform that supports oprofile.
if( LLVM_USE_OPROFILE )
if( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
message(FATAL_ERROR "OProfile support is available on Linux only.")
endif( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
endif( LLVM_USE_OPROFILE )

# Define an option controlling whether we should build for 32-bit on 64-bit
# platforms, where supported.
if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
Expand Down
8 changes: 8 additions & 0 deletions Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,11 @@ LLVM_HAS_POLLY = @LLVM_HAS_POLLY@
# Flags supported by the linker.
# bfd ld / gold --version-script=file
HAVE_LINK_VERSION_SCRIPT = @HAVE_LINK_VERSION_SCRIPT@

# Flags to control building support for Intel JIT Events API
USE_INTEL_JITEVENTS := @USE_INTEL_JITEVENTS@
INTEL_JITEVENTS_INCDIR := @INTEL_JITEVENTS_INCDIR@
INTEL_JITEVENTS_LIBDIR := @INTEL_JITEVENTS_LIBDIR@

# Flags to control building support for OProfile JIT API
USE_OPROFILE := @USE_OPROFILE@
88 changes: 71 additions & 17 deletions autoconf/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1183,29 +1183,83 @@ AC_ARG_WITH(oprofile,
*) llvm_cv_oppath="${withval}/lib/oprofile"
CPPFLAGS="-I${withval}/include";;
esac
if test -n "$llvm_cv_oppath" ; then
LIBS="$LIBS -L${llvm_cv_oppath} -Wl,-rpath,${llvm_cv_oppath}"
dnl Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=537744:
dnl libbfd is not included properly in libopagent in some Debian
dnl versions. If libbfd isn't found at all, we assume opagent works
dnl anyway.
AC_SEARCH_LIBS(bfd_init, bfd, [], [])
AC_SEARCH_LIBS(op_open_agent, opagent, [], [
echo "Error! You need to have libopagent around."
exit -1
])
AC_CHECK_HEADER([opagent.h], [], [
echo "Error! You need to have opagent.h around."
exit -1
])
fi
case $llvm_cv_os_type in
Linux)
if test -n "$llvm_cv_oppath" ; then
LIBS="$LIBS -lopagent -L${llvm_cv_oppath} -Wl,-rpath,${llvm_cv_oppath}"
dnl Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=537744:
dnl libbfd is not included properly in libopagent in some Debian
dnl versions. If libbfd isn't found at all, we assume opagent works
dnl anyway.
AC_SEARCH_LIBS(bfd_init, bfd, [], [])
AC_SEARCH_LIBS(op_open_agent, opagent, [], [
echo "Error! You need to have libopagent around."
exit -1
])
AC_CHECK_HEADER([opagent.h], [], [
echo "Error! You need to have opagent.h around."
exit -1
])
fi ;;
*)
AC_MSG_ERROR([OProfile support is available on Linux only.]) ;;
esac
],
[
AC_SUBST(USE_OPROFILE, [0])
])
AC_DEFINE_UNQUOTED([USE_OPROFILE],$USE_OPROFILE,
AC_DEFINE_UNQUOTED([LLVM_USE_OPROFILE],$USE_OPROFILE,
[Define if we have the oprofile JIT-support library])

dnl Enable support for Intel JIT Events API.
AC_ARG_WITH(intel-jitevents,
AS_HELP_STRING([--with-intel-jitevents=<vtune-amplifier-dir>],
[Specify location of run-time support library for Intel JIT API (default=/opt/intel/vtune_amplifier_xe_2011)]),
[
case $llvm_cv_os_type in
Linux|Win32|Cygwin|MingW) ;;
*)
AC_MSG_ERROR([
Intel JIT API support is available on Linux and Windows only."]) ;;
esac
AC_SUBST(USE_INTEL_JITEVENTS, [1])
case "$llvm_cv_target_arch" in
x86) llvm_intel_jitevents_archdir="lib32";;
x86_64) llvm_intel_jitevents_archdir="lib64";;
*) echo "Target architecture $llvm_cv_target_arch does not support Intel JIT Events API"
exit -1;;
esac
INTEL_JITEVENTS_INCDIR="/opt/intel/vtune_amplifier_xe_2011/include"
INTEL_JITEVENTS_LIBDIR="/opt/intel/vtune_amplifier_xe_2011/$llvm_intel_jitevents_archdir"
case "$withval" in
/* | [[A-Za-z]]:[[\\/]]*) INTEL_JITEVENTS_INCDIR=$withval/include
INTEL_JITEVENTS_LIBDIR=$withval/$llvm_intel_jitevents_archdir ;;
*) ;;
esac
AC_SUBST(INTEL_JITEVENTS_INCDIR)
AC_SUBST(INTEL_JITEVENTS_LIBDIR)
LIBS="$LIBS -L${INTEL_JITEVENTS_LIBDIR}"
CPPFLAGS="$CPPFLAGS -I$INTEL_JITEVENTS_INCDIR"
AC_SEARCH_LIBS(iJIT_IsProfilingActive, jitprofiling, [], [
echo "Error! Cannot find libjitprofiling.a. Please check path specified in flag --with-intel-jitevents"
exit -1
])
AC_CHECK_HEADER([jitprofiling.h], [], [
echo "Error! Cannot find jitprofiling.h. Please check path specified in flag --with-intel-jitevents"
exit -1
])
],
[
AC_SUBST(USE_INTEL_JITEVENTS, [0])
])
AC_DEFINE_UNQUOTED([LLVM_USE_INTEL_JITEVENTS],$USE_INTEL_JITEVENTS,
[Define if we have the Intel JIT API runtime support library])

dnl===-----------------------------------------------------------------------===
dnl===
dnl=== SECTION 6: Check for header files
Expand Down
Loading

0 comments on commit 61b1851

Please sign in to comment.