mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 01:04:57 +08:00
Add code for GTPin handshake at init time.
Change-Id: I1f572d9e036d4d5b5c6999518d40c9c4ba094649 Signed-off-by: davidoli <david.olien@intel.com>
This commit is contained in:
@@ -5,14 +5,17 @@
|
||||
#
|
||||
|
||||
set(L0_SRCS_TOOLS_PIN
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pin.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pin.h
|
||||
)
|
||||
|
||||
target_sources(${L0_STATIC_LIB_NAME} PRIVATE
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${L0_SRCS_TOOLS_PIN}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
# Make our source files visible to parent
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_PIN ${L0_SRCS_TOOLS_PIN})
|
||||
|
||||
24
level_zero/tools/source/pin/linux/CMakeLists.txt
Normal file
24
level_zero/tools/source/pin/linux/CMakeLists.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_TOOLS_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_pin.h
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${L0_SRCS_TOOLS_LINUX}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
)
|
||||
target_include_directories(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
# Make our source files visible to parent
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_LINUX ${L0_SRCS_TOOLS_LINUX})
|
||||
18
level_zero/tools/source/pin/linux/os_pin.h
Normal file
18
level_zero/tools/source/pin/linux/os_pin.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/tools/source/pin/pin.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
typedef uint32_t (*OpenGTPin_fn)(void *gtPinInit);
|
||||
|
||||
const std::string PinContext::gtPinLibraryFilename = "libgtpin.so";
|
||||
|
||||
} // namespace L0
|
||||
@@ -7,19 +7,43 @@
|
||||
|
||||
#include "pin.h"
|
||||
|
||||
#include "level_zero/core/source/module/module.h"
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
|
||||
#include "level_zero/source/inc/ze_intel_gpu.h"
|
||||
|
||||
#include "os_pin.h"
|
||||
|
||||
const std::string gtPinOpenFunctionName = "OpenGTPin";
|
||||
|
||||
namespace L0 {
|
||||
|
||||
static PinContext *PinContextInstance = nullptr;
|
||||
void PinContext::init(ze_init_flag_t flag, ze_result_t &result) {
|
||||
result = ZE_RESULT_SUCCESS;
|
||||
|
||||
void PinContext::init(ze_init_flag_t flag) {
|
||||
if (!getenv_tobool("ZE_ENABLE_PROGRAM_INSTRUMENTATION")) {
|
||||
return;
|
||||
}
|
||||
if (PinContextInstance == nullptr) {
|
||||
PinContextInstance = new PinContext();
|
||||
|
||||
NEO::OsLibrary *hPin = NEO::OsLibrary::load(gtPinLibraryFilename.c_str());
|
||||
if (hPin == nullptr) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find gtpin library %s\n", gtPinLibraryFilename.c_str());
|
||||
result = ZE_RESULT_ERROR_UNKNOWN;
|
||||
return;
|
||||
}
|
||||
|
||||
OpenGTPin_fn openGTPin = reinterpret_cast<OpenGTPin_fn>(hPin->getProcAddress(gtPinOpenFunctionName.c_str()));
|
||||
if (openGTPin == nullptr) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find gtpin library open function symbol %s\n", gtPinOpenFunctionName.c_str());
|
||||
result = ZE_RESULT_ERROR_UNKNOWN;
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t openResult = openGTPin(nullptr);
|
||||
if (openResult != 0) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "gtpin library open %s failed with status %u\n", gtPinOpenFunctionName.c_str(), openResult);
|
||||
result = ZE_RESULT_ERROR_UNKNOWN;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include <level_zero/ze_api.h>
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
@@ -13,7 +15,10 @@ namespace L0 {
|
||||
|
||||
class PinContext {
|
||||
public:
|
||||
static void init(ze_init_flag_t flag);
|
||||
static void init(ze_init_flag_t flag, ze_result_t &result);
|
||||
|
||||
private:
|
||||
static const std::string gtPinLibraryFilename;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
26
level_zero/tools/source/pin/windows/CMakeLists.txt
Normal file
26
level_zero/tools/source/pin/windows/CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_TOOLS_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_pin.h
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${L0_SRCS_TOOLS_WINDOWS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
)
|
||||
target_include_directories(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# Make our source files visible to parent
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_WINDOWS ${L0_SRCS_TOOLS_WINDOWS})
|
||||
|
||||
18
level_zero/tools/source/pin/windows/os_pin.h
Normal file
18
level_zero/tools/source/pin/windows/os_pin.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/tools/source/pin/pin.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
typedef uint32_t(__fastcall *OpenGTPin_fn)(void *gtPinInit);
|
||||
|
||||
const std::string PinContext::gtPinLibraryFilename = "gtpin.dll";
|
||||
|
||||
} // namespace L0
|
||||
@@ -25,7 +25,10 @@ static void enableTools(ze_result_t &result, ze_init_flag_t flag, bool *ptoolsAr
|
||||
return;
|
||||
}
|
||||
SysmanHandleContext::init(flag);
|
||||
PinContext::init(flag);
|
||||
PinContext::init(flag, std::ref(result));
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
APITracerContextImp::apiTracingEnable(flag);
|
||||
*ptoolsAreEnabled = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user