mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-20 13:11:34 +08:00

- don't load ze_loader.dll from file system - to perform self-open on Windows use getModuleHandleA with proper module name - don't free library loaded with getModuleHandleA - as loader may be not available during runtime teardown: - load translate handle function during global setup - load setDriverTeardown function during global teardown - when loader is not available during teardown, unset translate handle function Related-To: GSD-10147 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
/*
|
|
* Copyright (C) 2020-2024 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "pin.h"
|
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
|
#include "shared/source/os_interface/os_library.h"
|
|
|
|
#include "os_pin.h"
|
|
|
|
#include <memory>
|
|
|
|
namespace NEO {
|
|
|
|
bool PinContext::init(const std::string >PinOpenFunctionName) {
|
|
auto hGtPinLibrary = std::unique_ptr<OsLibrary>(OsLibrary::loadFunc({PinContext::gtPinLibraryFilename}));
|
|
|
|
if (hGtPinLibrary == nullptr) {
|
|
PRINT_DEBUG_STRING(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find gtpin library %s\n", PinContext::gtPinLibraryFilename.c_str());
|
|
return false;
|
|
}
|
|
|
|
OpenGTPin_fn openGTPin = reinterpret_cast<OpenGTPin_fn>(hGtPinLibrary->getProcAddress(gtPinOpenFunctionName.c_str()));
|
|
if (openGTPin == nullptr) {
|
|
PRINT_DEBUG_STRING(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Unable to find gtpin library open function symbol %s\n", gtPinOpenFunctionName.c_str());
|
|
return false;
|
|
}
|
|
|
|
uint32_t openResult = openGTPin(nullptr);
|
|
if (openResult != 0) {
|
|
PRINT_DEBUG_STRING(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "gtpin library open %s failed with status %u\n", gtPinOpenFunctionName.c_str(), openResult);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
} // namespace NEO
|