Skip to content

Commit

Permalink
Fix layer init with multiple drivers, perform driver check before init (
Browse files Browse the repository at this point in the history
#163)

-Fix potential race condition when initializing the layers
 with multiple drivers by verifying the usable drivers and layers
 before init of the final ddi tables.

Signed-off-by: Neil R. Spruit <[email protected]>
  • Loading branch information
nrspruit authored Jun 27, 2024
1 parent 2b75038 commit fcb536a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions source/lib/ze_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ namespace ze_lib
ze_lib::context->zesDdiTable.exchange(&ze_lib::context->initialzesDdiTable);
}


// Check which drivers and layers are functional by checking which can be loaded.
// This check needs to be done before all inits to avoid overwriting the layer ddi table pointers.
if( ZE_RESULT_SUCCESS == result && !sysmanOnly)
{
//Check which drivers support the ze_driver_flag_t specified
//No need to check if only initializing sysman
result = zelLoaderDriverCheck(flags);
}

if( ZE_RESULT_SUCCESS == result )
{
result = zeInit();
Expand All @@ -99,13 +109,6 @@ namespace ze_lib
result = zelLoaderTracingLayerInit(this->pTracingZeDdiTable, this->pTracingZetDdiTable, this->pTracingZesDdiTable);
}

if( ZE_RESULT_SUCCESS == result && !sysmanOnly)
{
//Check which drivers support the ze_driver_flag_t specified
//No need to check if only initializing sysman
result = zelLoaderDriverCheck(flags);
}

if( ZE_RESULT_SUCCESS == result )
{
isInitialized = true;
Expand Down

0 comments on commit fcb536a

Please sign in to comment.