JitRegister: fix VTune integration

This commit is contained in:
Tillmann Karras 2015-02-12 01:36:29 +01:00
parent 0e0a196a1c
commit 0ec48e0ec9
5 changed files with 48 additions and 11 deletions

View File

@ -2,6 +2,7 @@
# General setup # General setup
# #
cmake_minimum_required(VERSION 2.8.8) cmake_minimum_required(VERSION 2.8.8)
project(dolphin-emu)
option(USE_EGL "Enables EGL OpenGL Interface" OFF) option(USE_EGL "Enables EGL OpenGL Interface" OFF)
option(TRY_X11 "Enables X11 Support" ON) option(TRY_X11 "Enables X11 Support" ON)
@ -20,6 +21,9 @@ option(ENCODE_FRAMEDUMPS "Encode framedumps in AVI format" ON)
option(FASTLOG "Enable all logs" OFF) option(FASTLOG "Enable all logs" OFF)
option(OPROFILING "Enable profiling" OFF) option(OPROFILING "Enable profiling" OFF)
option(GDBSTUB "Enable gdb stub for remote debugging." OFF) option(GDBSTUB "Enable gdb stub for remote debugging." OFF)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
option(VTUNE "Enable Intel VTune integration for JIT symbols." OFF)
endif()
if(APPLE) if(APPLE)
option(SKIP_POSTPROCESS_BUNDLE "Skip postprocessing bundle for redistributability" OFF) option(SKIP_POSTPROCESS_BUNDLE "Skip postprocessing bundle for redistributability" OFF)
@ -45,7 +49,6 @@ if (APPLE)
endif() endif()
endif() endif()
endif() endif()
project(dolphin-emu)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests)
set(DOLPHIN_IS_STABLE FALSE) set(DOLPHIN_IS_STABLE FALSE)
# Libraries to link # Libraries to link
@ -335,6 +338,20 @@ if(GDBSTUB)
add_definitions(-DUSE_GDBSTUB) add_definitions(-DUSE_GDBSTUB)
endif(GDBSTUB) endif(GDBSTUB)
if(VTUNE)
if(EXISTS "$ENV{VTUNE_AMPLIFIER_XE_2015_DIR}")
set(VTUNE_DIR "$ENV{VTUNE_AMPLIFIER_XE_2015_DIR}")
elseif(EXISTS "$ENV{VTUNE_AMPLIFIER_XE_2013_DIR}")
set(VTUNE_DIR "$ENV{VTUNE_AMPLIFIER_XE_2013_DIR}")
else()
message(ERROR "Could find neither VTUNE_AMPLIFIER_XE_2015_DIR nor VTUNE_AMPLIFIER_XE_2013_DIR.")
endif()
add_definitions(-DUSE_VTUNE)
include_directories("${VTUNE_DIR}/include")
list(APPEND LIBS "${VTUNE_DIR}/lib64/libjitprofiling.a")
list(APPEND LIBS "${VTUNE_DIR}/lib64/libittnotify.a")
endif(VTUNE)
if(ANDROID) if(ANDROID)
message("Building for Android") message("Building for Android")
add_definitions(-DANDROID) add_definitions(-DANDROID)

View File

@ -26,7 +26,6 @@
#if defined USE_VTUNE #if defined USE_VTUNE
#include <jitprofiling.h> #include <jitprofiling.h>
#pragma comment(lib, "libittnotify.lib")
#pragma comment(lib, "jitprofiling.lib") #pragma comment(lib, "jitprofiling.lib")
#endif #endif
@ -89,12 +88,9 @@ void RegisterV(const void* base_address, u32 code_size,
#ifdef USE_VTUNE #ifdef USE_VTUNE
iJIT_Method_Load jmethod = {0}; iJIT_Method_Load jmethod = {0};
jmethod.method_id = iJIT_GetNewMethodID(); jmethod.method_id = iJIT_GetNewMethodID();
jmethod.class_file_name = ""; jmethod.method_load_address = const_cast<void*>(base_address);
jmethod.source_file_name = __FILE__;
jmethod.method_load_address = base_address;
jmethod.method_size = code_size; jmethod.method_size = code_size;
jmethod.line_number_size = 0; jmethod.method_name = const_cast<char*>(symbol_name.data());
jmethod.method_name = symbol_name.data();
iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&jmethod); iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&jmethod);
#endif #endif

View File

@ -12,6 +12,11 @@
#include <pthread_np.h> #include <pthread_np.h>
#endif #endif
#ifdef USE_VTUNE
#include <ittnotify.h>
#pragma comment(lib, "libittnotify.lib")
#endif
namespace Common namespace Common
{ {
@ -123,6 +128,10 @@ void SetCurrentThreadName(const char* szThreadName)
#else #else
pthread_setname_np(pthread_self(), szThreadName); pthread_setname_np(pthread_self(), szThreadName);
#endif #endif
#ifdef USE_VTUNE
// VTune uses OS thread names by default but probably supports longer names when set via its own API.
__itt_thread_set_name(szThreadName);
#endif
} }
#endif #endif

View File

@ -13,10 +13,6 @@
#include "Core/PowerPC/Gekko.h" #include "Core/PowerPC/Gekko.h"
#include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PPCAnalyst.h"
// Define this in order to get VTune profile support for the Jit generated code.
// Add the VTune include/lib directories to the project directories to get this to build.
// #define USE_VTUNE
// emulate CPU with unlimited instruction cache // emulate CPU with unlimited instruction cache
// the only way to invalidate a region is the "icbi" instruction // the only way to invalidate a region is the "icbi" instruction
#define JIT_UNLIMITED_ICACHE #define JIT_UNLIMITED_ICACHE

View File

@ -129,6 +129,25 @@
<TreatLibWarningAsErrors>true</TreatLibWarningAsErrors> <TreatLibWarningAsErrors>true</TreatLibWarningAsErrors>
<LinkTimeCodeGeneration Condition="'$(DolphinRelease)'=='true'">true</LinkTimeCodeGeneration> <LinkTimeCodeGeneration Condition="'$(DolphinRelease)'=='true'">true</LinkTimeCodeGeneration>
</Lib> </Lib>
<!--
Prefer VTune 2015 over 2013 but support both since there is no non-commercial license for 2015 :(
-->
<ItemDefinitionGroup Condition="Exists('$(VTUNE_AMPLIFIER_XE_2015_DIR)')">
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);"$(VTUNE_AMPLIFIER_XE_2015_DIR)\include"</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);"$(VTUNE_AMPLIFIER_XE_2015_DIR)\lib64"</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="Exists('$(VTUNE_AMPLIFIER_XE_2013_DIR)') And !Exists('$(VTUNE_AMPLIFIER_XE_2015_DIR)')">
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);"$(VTUNE_AMPLIFIER_XE_2013_DIR)\include"</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);"$(VTUNE_AMPLIFIER_XE_2013_DIR)\lib64"</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup /> <ItemGroup />
</Project> </Project>