2020-03-06 18:09:57 +08:00
/*
2021-05-17 02:51:16 +08:00
* Copyright ( C ) 2020 - 2021 Intel Corporation
2020-03-06 18:09:57 +08:00
*
* SPDX - License - Identifier : MIT
*
*/
# include "pin.h"
2020-05-12 06:02:56 +08:00
# include "shared/source/debug_settings/debug_settings_manager.h"
# include "shared/source/helpers/debug_helpers.h"
2020-03-06 18:09:57 +08:00
# include "level_zero/source/inc/ze_intel_gpu.h"
2020-05-12 06:02:56 +08:00
# include "os_pin.h"
const std : : string gtPinOpenFunctionName = " OpenGTPin " ;
2020-03-06 18:09:57 +08:00
namespace L0 {
2020-07-17 01:41:28 +08:00
ze_result_t PinContext : : init ( ) {
2020-05-27 04:22:30 +08:00
std : : unique_ptr < NEO : : OsLibrary > hGtPinLibrary = nullptr ;
2020-05-12 06:02:56 +08:00
2020-05-27 04:22:30 +08:00
hGtPinLibrary . reset ( NEO : : OsLibrary : : load ( gtPinLibraryFilename . c_str ( ) ) ) ;
if ( hGtPinLibrary . get ( ) = = nullptr ) {
2020-09-25 17:24:15 +08:00
PRINT_DEBUG_STRING ( NEO : : DebugManager . flags . PrintDebugMessages . get ( ) , stderr , " Unable to find gtpin library %s \n " , gtPinLibraryFilename . c_str ( ) ) ;
2020-07-17 01:41:28 +08:00
return ZE_RESULT_ERROR_UNKNOWN ;
2020-05-12 06:02:56 +08:00
}
2020-05-27 04:22:30 +08:00
OpenGTPin_fn openGTPin = reinterpret_cast < OpenGTPin_fn > ( hGtPinLibrary . get ( ) - > getProcAddress ( gtPinOpenFunctionName . c_str ( ) ) ) ;
2020-05-12 06:02:56 +08:00
if ( openGTPin = = nullptr ) {
2020-05-27 04:22:30 +08:00
hGtPinLibrary . reset ( nullptr ) ;
2020-09-25 17:24:15 +08:00
PRINT_DEBUG_STRING ( NEO : : DebugManager . flags . PrintDebugMessages . get ( ) , stderr , " Unable to find gtpin library open function symbol %s \n " , gtPinOpenFunctionName . c_str ( ) ) ;
2020-07-17 01:41:28 +08:00
return ZE_RESULT_ERROR_UNKNOWN ;
2020-05-12 06:02:56 +08:00
}
uint32_t openResult = openGTPin ( nullptr ) ;
if ( openResult ! = 0 ) {
2020-05-27 04:22:30 +08:00
hGtPinLibrary . reset ( nullptr ) ;
2020-09-25 17:24:15 +08:00
PRINT_DEBUG_STRING ( NEO : : DebugManager . flags . PrintDebugMessages . get ( ) , stderr , " gtpin library open %s failed with status %u \n " , gtPinOpenFunctionName . c_str ( ) , openResult ) ;
2020-07-17 01:41:28 +08:00
return ZE_RESULT_ERROR_UNKNOWN ;
2020-03-06 18:09:57 +08:00
}
2020-07-17 01:41:28 +08:00
return ZE_RESULT_SUCCESS ;
2020-03-06 18:09:57 +08:00
}
} // namespace L0