Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions samples/zello_world/zello_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,14 @@ int main( int argc, char *argv[] )
zeEventHostSynchronize(event, UINT64_MAX );
std::cout << "Congratulations, the device completed execution!\n";

zeContextDestroy(context);
zeCommandListDestroy(command_list);
zeEventDestroy(event);
zeEventPoolDestroy(event_pool);
if (!zelCheckIsLoaderInTearDown())
zeContextDestroy(context);
if (!zelCheckIsLoaderInTearDown())
zeCommandListDestroy(command_list);
if (!zelCheckIsLoaderInTearDown())
zeEventDestroy(event);
if (!zelCheckIsLoaderInTearDown())
zeEventPoolDestroy(event_pool);

if (tracing_enabled) {
status = zelTracerDestroy(tracer);
Expand Down
6 changes: 1 addition & 5 deletions source/lib/ze_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,18 +489,14 @@ zelCheckIsLoaderInTearDown() {
if (ze_lib::destruction || ze_lib::context == nullptr) {
return true;
}
#ifdef DYNAMIC_LOAD_LOADER
#if defined(DYNAMIC_LOAD_LOADER) && defined(_WIN32)
std::promise<int> stabilityPromise;
std::future<int> resultFuture = stabilityPromise.get_future();
int result = -1;
try {
// Launch the stability checker thread
std::thread stabilityThread(stabilityCheck, std::move(stabilityPromise));
result = resultFuture.get(); // Blocks until the result is available
if (ze_lib::context->debugTraceEnabled) {
std::string message = "Stability checker thread completed with result: " + std::to_string(result);
ze_lib::context->debug_trace_message(message, "");
}
stabilityThread.join();
} catch (const std::exception& e) {
if (ze_lib::context->debugTraceEnabled) {
Expand Down
21 changes: 21 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,27 @@ endif()
add_test(NAME tests_loader_teardown_check COMMAND tests --gtest_filter=*GivenLoaderNotInDestructionStateWhenCallingzelCheckIsLoaderInTearDownThenFalseIsReturned)
set_property(TEST tests_loader_teardown_check PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1")

add_test(NAME test_zello_world_legacy COMMAND zello_world --enable_legacy_init --enable_null_driver --force_loader_intercepts --enable_validation_layer --enable_tracing_layer --enable_tracing_layer_runtime)
set_property(TEST test_zello_world_legacy PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1")

add_test(NAME test_zello_world_legacy_intercept COMMAND zello_world --enable_legacy_init --enable_null_driver --force_loader_intercepts)
set_property(TEST test_zello_world_legacy_intercept PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1")

add_test(NAME test_zello_world_legacy_validation_layer COMMAND zello_world --enable_legacy_init --enable_null_driver --enable_validation_layer)
set_property(TEST test_zello_world_legacy_validation_layer PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1")

add_test(NAME test_zello_world_legacy_tracing COMMAND zello_world --enable_legacy_init --enable_null_driver --enable_tracing_layer)
set_property(TEST test_zello_world_legacy_tracing PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1")

add_test(NAME test_zello_world_legacy_dynamic_tracing COMMAND zello_world --enable_legacy_init --enable_null_driver --enable_tracing_layer_runtime)
set_property(TEST test_zello_world_legacy_dynamic_tracing PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1")

add_test(NAME test_zello_world_legacy_all_tracing COMMAND zello_world --enable_legacy_init --enable_null_driver --force_loader_intercepts --enable_validation_layer --enable_tracing_layer)
set_property(TEST test_zello_world_legacy_all_tracing PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1")

add_test(NAME test_zello_world_legacy_all_tracing_dynamic COMMAND zello_world --enable_legacy_init --enable_null_driver --force_loader_intercepts --enable_validation_layer --enable_tracing_layer_runtime)
set_property(TEST test_zello_world_legacy_all_tracing_dynamic PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1")

# These tests are currently not supported on Windows. The reason is that the std::cerr is not being redirected to a pipe in Windows to be then checked against the expected output.
if(NOT MSVC)
add_test(NAME tests_event_deadlock COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingzeCommandListAppendMemoryCopyWithCircularDependencyOnEventsThenValidationLayerPrintsWarningOfDeadlock*)
Expand Down
3 changes: 3 additions & 0 deletions test/loader_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ TEST(

EXPECT_EQ(ZE_RESULT_SUCCESS, zeInit(0));
EXPECT_FALSE(zelCheckIsLoaderInTearDown());
EXPECT_FALSE(zelCheckIsLoaderInTearDown());
EXPECT_FALSE(zelCheckIsLoaderInTearDown());
EXPECT_FALSE(zelCheckIsLoaderInTearDown());
}

class CaptureOutput {
Expand Down
Loading