Skip to content

Commit

Permalink
[ur] Remove null adapter default load
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Vesely committed Feb 14, 2023
1 parent 61cb864 commit af59031
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure -L "python|uma|loader|validation"
run: UR_ADAPTERS_FORCE_LOAD={{github.workspace}}/build/lib/libur_null.so ctest UR_ENABLE_VALIDATION_LAYER=1 UR_ENABLE_PARAMETER_VALIDATION=1 -C ${{env.BUILD_TYPE}} --output-on-failure -L "python|uma|loader|validation"

windows-build:
name: Build - Windows
Expand All @@ -59,4 +59,4 @@ jobs:

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure -L "python|uma|loader|validation"
run: UR_ADAPTERS_FORCE_LOAD={{github.workspace}}/build/lib/libur_null.dll UR_ENABLE_VALIDATION_LAYER=1 UR_ENABLE_PARAMETER_VALIDATION=1 ctest -C ${{env.BUILD_TYPE}} --output-on-failure -L "python|uma|loader|validation"
4 changes: 1 addition & 3 deletions source/loader/linux/platform_discovery_lin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

namespace loader {

static const char *knownPlatformNames[] = {
MAKE_LIBRARY_NAME("ur_null", UR_VERSION),
};
static const char *knownPlatformNames[] = {};

std::vector<PlatformLibraryPath> discoverEnabledPlatforms() {
std::vector<PlatformLibraryPath> enabledPlatforms;
Expand Down
4 changes: 1 addition & 3 deletions source/loader/windows/platform_discovery_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@

namespace loader {

static const char *knownAdaptersNames[] = {
MAKE_LIBRARY_NAME("ur_null", UR_VERSION),
};
static const char *knownAdaptersNames[] = {};

std::vector<PlatformLibraryPath> discoverEnabledPlatforms() {
std::vector<PlatformLibraryPath> enabledPlatforms;
Expand Down
30 changes: 28 additions & 2 deletions test/conformance/source/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv)
: platform_options{parsePlatformOptions(argc, argv)} {
instance = this;
ur_device_init_flags_t device_flags = 0;
if (urInit(device_flags)) {
switch (urInit(device_flags)) {
case UR_RESULT_SUCCESS:
break;
case UR_RESULT_ERROR_UNINITIALIZED:
error = "Could not load adapter";
return;
default:
error = "urInit() failed";
return;
}
Expand Down Expand Up @@ -100,11 +106,18 @@ uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv)

void uur::PlatformEnvironment::SetUp() {
if (!error.empty()) {
FAIL() << error;
if (error == "Could not load adapter") {
GTEST_SKIP() << error;
} else {
FAIL() << error;
}
}
}

void uur::PlatformEnvironment::TearDown() {
if (error == "Could not load adapter") {
return;
}
ur_tear_down_params_t tear_down_params{};
if (urTearDown(&tear_down_params)) {
FAIL() << "urTearDown() failed";
Expand Down Expand Up @@ -155,8 +168,21 @@ DevicesEnvironment::DevicesEnvironment(int argc, char **argv)

void DevicesEnvironment::SetUp() {
PlatformEnvironment::SetUp();
if (error == "Could not load adapter") {
return;
}
if (devices.empty() || !error.empty()) {
FAIL() << error;
}
}

void DevicesEnvironment::TearDown() {
PlatformEnvironment::TearDown();
for (auto device : devices) {
if (urDeviceRelease(device)) {
error = "urDeviceRelease() failed";
return;
}
}
}
} // namespace uur
2 changes: 1 addition & 1 deletion test/conformance/testing/uur/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct DevicesEnvironment : PlatformEnvironment {
virtual ~DevicesEnvironment() override = default;

virtual void SetUp() override;
inline virtual void TearDown() override { PlatformEnvironment::TearDown(); }
virtual void TearDown() override;

inline const std::vector<ur_device_handle_t> &GetDevices() const {
return devices;
Expand Down

0 comments on commit af59031

Please sign in to comment.