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