Skip to content

Commit

Permalink
Remove preload of all drivers given zeInitDrivers and update unit tes…
Browse files Browse the repository at this point in the history
…ts (#218)

Signed-off-by: Neil R. Spruit <[email protected]>
  • Loading branch information
nrspruit authored Oct 15, 2024
1 parent 8065e6f commit 0f25fdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 2 additions & 6 deletions source/lib/ze_libapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,8 @@ zeInitDrivers(
)
{
static ze_result_t result = ZE_RESULT_SUCCESS;
std::call_once(ze_lib::context->initOnceDrivers, []() {
ze_init_flags_t all_enabled = UINT32_MAX;
ze_init_driver_type_desc_t all_enabled_desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC};
all_enabled_desc.pNext = nullptr;
all_enabled_desc.flags = UINT32_MAX;
result = ze_lib::context->Init(all_enabled, false, &all_enabled_desc);
std::call_once(ze_lib::context->initOnceDrivers, [desc]() {
result = ze_lib::context->Init(0, false, desc);
return result;
});

Expand Down
7 changes: 7 additions & 0 deletions test/loader_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ TEST(
putenv_safe( const_cast<char *>( "ZEL_TEST_NULL_DRIVER_TYPE=GPU" ) );
EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc));
EXPECT_GT(pCount, 0);
pCount = 0;
desc.flags = UINT32_MAX;
EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc));
EXPECT_GT(pCount, 0);
pCount = 0;
desc.flags = ZE_INIT_DRIVER_TYPE_FLAG_GPU | ZE_INIT_DRIVER_TYPE_FLAG_NPU;
EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc));
EXPECT_GT(pCount, 0);
Expand All @@ -78,9 +80,11 @@ TEST(
putenv_safe( const_cast<char *>( "ZEL_TEST_NULL_DRIVER_TYPE=NPU" ) );
EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc));
EXPECT_GT(pCount, 0);
pCount = 0;
desc.flags = UINT32_MAX;
EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc));
EXPECT_GT(pCount, 0);
pCount = 0;
desc.flags = ZE_INIT_DRIVER_TYPE_FLAG_GPU | ZE_INIT_DRIVER_TYPE_FLAG_NPU;
EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc));
EXPECT_GT(pCount, 0);
Expand All @@ -97,12 +101,15 @@ TEST(
putenv_safe( const_cast<char *>( "ZEL_TEST_NULL_DRIVER_TYPE=ALL" ) );
EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc));
EXPECT_GT(pCount, 0);
pCount = 0;
desc.flags = UINT32_MAX;
EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc));
EXPECT_GT(pCount, 0);
pCount = 0;
desc.flags = ZE_INIT_DRIVER_TYPE_FLAG_GPU;
EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc));
EXPECT_GT(pCount, 0);
pCount = 0;
desc.flags = ZE_INIT_DRIVER_TYPE_FLAG_GPU | ZE_INIT_DRIVER_TYPE_FLAG_NPU;
EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc));
EXPECT_GT(pCount, 0);
Expand Down

0 comments on commit 0f25fdc

Please sign in to comment.