Files
compute-runtime/shared/source/pin/pin.cpp
Kacper Nowak 1afaf37f78 refactor: Unify GTPin initialization logic between APIs
Add support for new GTPin loading logic in OCL path, similar to existing
in L0 - invoking exposed, dedicated API call (OpenGTPinOCL).
- Move logic to shared, including unit tests
- Check whether instrumentation is required on
  context creation and if yes,
  make a call to OpenGTPinOCL function.
  Handle potential errors gracefully without exiting.
Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
2023-08-09 17:15:24 +02:00

43 lines
1.4 KiB
C++

/*
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "pin.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "os_pin.h"
namespace NEO {
PinContext::OsLibraryLoadPtr PinContext::osLibraryLoadFunction(NEO::OsLibrary::load);
bool PinContext::init(const std::string &gtPinOpenFunctionName) {
NEO::OsLibrary *hGtPinLibrary = nullptr;
hGtPinLibrary = PinContext::osLibraryLoadFunction(PinContext::gtPinLibraryFilename.c_str());
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