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
7 changes: 7 additions & 0 deletions .github/workflows/ur-build-hw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ jobs:
build_dir: build
artifact_name: 'ur-${{matrix.adapter.name}}-${{steps.artifact_suffix.outputs.suffix}}-conformance'

- name: Test loader
uses: ./devops/actions/run-tests/ur
with:
test_type: 'loader'
build_dir: build
artifact_name: 'ur-${{matrix.adapter.name}}-${{steps.artifact_suffix.outputs.suffix}}-loader'

- name: Debug CI platform information
if: ${{ always() }}
run: ./devops/scripts/get_system_info.sh
2 changes: 1 addition & 1 deletion devops/actions/run-tests/ur/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Run UR Tests'

inputs:
test_type:
description: 'Type of tests to run (adapter-specific or conformance)'
description: 'Type of tests to run (adapter-specific, conformance or loader)'
required: true
build_dir:
required: false
Expand Down
1 change: 1 addition & 0 deletions devops/scripts/ur_test_tools/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

TEST_TYPE_ADAPTER_SPECIFIC = "adapter-specific"
TEST_TYPE_CONFORMANCE = "conformance"
TEST_TYPE_LOADER = "loader"

# These tests cause timeouts on CI and are excluded from adapter-specific runs
LIT_FILTER_OUT_ADAPTER_SPECIFIC = (
Expand Down
6 changes: 6 additions & 0 deletions devops/scripts/ur_test_tools/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
LIT_CI_OPTIONS,
TEST_TYPE_ADAPTER_SPECIFIC,
TEST_TYPE_CONFORMANCE,
TEST_TYPE_LOADER,
LIT_FILTER_OUT_ADAPTER_SPECIFIC,
MAX_LINES_TO_SCAN,
)
Expand All @@ -33,6 +34,11 @@ def get_test_config(test_type: str) -> TestConfig:
target="check-unified-runtime-conformance",
log_file="conformance_tests.log",
)
elif test_type == TEST_TYPE_LOADER:
return TestConfig(
target="check-unified-runtime-loader",
log_file="loader_tests.log",
)
else:
raise ValueError(f"Invalid test_type: {test_type}")

Expand Down
11 changes: 7 additions & 4 deletions unified-runtime/source/loader/ur_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ __urdlllocal ur_result_t context_t::Init(

#if defined(UR_STATIC_UMF)
if (UR_RESULT_SUCCESS == result) {
umfInit();
holdsUmfRef = umfInit() == UMF_RESULT_SUCCESS;
}
#endif

Expand Down Expand Up @@ -220,15 +220,18 @@ ur_result_t UR_APICALL urLoaderInit(ur_device_init_flags_t device_flags,
}

ur_result_t urLoaderTearDown() {
int ret = ur_lib::context_t::release([](context_t *context) {
bool releaseUmf = false;
int ret = ur_lib::context_t::release([&releaseUmf](context_t *context) {
context->tearDownLayers();
ur_loader::context_t::forceDelete();
releaseUmf = context->holdsUmfRef;
delete context;
});

#if defined(UR_STATIC_UMF)
// Release the Init reference only after the layers are torn down above.
if (ret == 0) {
// Release the Init reference only after the layers are torn down above, and
// only when the last urLoaderTearDown deleted the context that took it.
if (releaseUmf) {
umfTearDown();
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions unified-runtime/source/loader/ur_lib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ class __urdlllocal context_t : public AtomicSingleton<context_t> {

codeloc_data codelocData;

// Set when Init took a umfInit reference that teardown must release.
bool holdsUmfRef = false;

void parseEnvEnabledLayers();
ur_result_t initLayers();
void tearDownLayers() const;
Expand Down
10 changes: 5 additions & 5 deletions unified-runtime/test/loader/adapter_registry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

function(add_adapter_reg_search_test name)
set(TEST_TARGET_NAME ${name}-test)
add_gtest_test(${name} ${TEST_SOURCES})
add_gtest_test(${name} ${ARGN})

if(WIN32)
target_sources(${TEST_TARGET_NAME} PRIVATE
Expand All @@ -18,7 +18,7 @@ function(add_adapter_reg_search_test name)
${PROJECT_SOURCE_DIR}/source/loader)
endfunction()

add_adapter_reg_search_test(search-with-env)
add_adapter_reg_search_test(search-no-env)
add_adapter_reg_search_test(search-order)
add_adapter_reg_search_test(prefilter)
add_adapter_reg_search_test(search-with-env search_with_env.cpp)
add_adapter_reg_search_test(search-no-env search_no_env.cpp)
add_adapter_reg_search_test(search-order search_order.cpp)
add_adapter_reg_search_test(prefilter prefilter.cpp)
Loading