diff --git a/unified-runtime/examples/codegen/codegen.cpp b/unified-runtime/examples/codegen/codegen.cpp index cd6af53e70649..0527e2be67a45 100644 --- a/unified-runtime/examples/codegen/codegen.cpp +++ b/unified-runtime/examples/codegen/codegen.cpp @@ -69,7 +69,7 @@ get_platforms(std::vector &adapters) { uint32_t adapterPlatformCount = 0; urPlatformGet(adapter, 0, nullptr, &adapterPlatformCount); - platforms.reserve(platformCount + adapterPlatformCount); + platforms.resize(platformCount + adapterPlatformCount); urPlatformGet(adapter, adapterPlatformCount, &platforms[platformCount], &adapterPlatformCount); platformCount += adapterPlatformCount; @@ -77,7 +77,6 @@ get_platforms(std::vector &adapters) { if (!platformCount) { throw std::runtime_error("No platforms available."); } - platforms.resize(platformCount); return platforms; } diff --git a/unified-runtime/examples/hello_world/hello_world.cpp b/unified-runtime/examples/hello_world/hello_world.cpp index f5aec12d25d43..ea403f53c2f62 100644 --- a/unified-runtime/examples/hello_world/hello_world.cpp +++ b/unified-runtime/examples/hello_world/hello_world.cpp @@ -56,7 +56,7 @@ int main(int, char *[]) { goto out; } - platforms.reserve(platformCount + adapterPlatformCount); + platforms.resize(platformCount + adapterPlatformCount); status = urPlatformGet(adapter, adapterPlatformCount, &platforms[platformCount], &adapterPlatformCount); if (status != UR_RESULT_SUCCESS) { @@ -66,7 +66,6 @@ int main(int, char *[]) { } platformCount += adapterPlatformCount; } - platforms.resize(platformCount); for (auto p : platforms) { ur_api_version_t api_version = {}; diff --git a/unified-runtime/test/loader/platforms/no_platforms.test b/unified-runtime/test/loader/platforms/no_platforms.test index a169805bfaae0..d30aa1240cacd 100644 --- a/unified-runtime/test/loader/platforms/no_platforms.test +++ b/unified-runtime/test/loader/platforms/no_platforms.test @@ -1,4 +1,4 @@ -RUN: UR_ADAPTERS_FORCE_LOAD="" UR_LOG_TEST="level:info;output:stdout;flush:debug" platforms-test +RUN: UR_ADAPTERS_FORCE_LOAD="invalid.so" UR_LOG_TEST="level:info;output:stdout;flush:debug" platforms-test REQUIRES: linux diff --git a/unified-runtime/test/loader/platforms/platforms.cpp b/unified-runtime/test/loader/platforms/platforms.cpp index c80e671c96747..e4b980441d1a1 100644 --- a/unified-runtime/test/loader/platforms/platforms.cpp +++ b/unified-runtime/test/loader/platforms/platforms.cpp @@ -56,9 +56,9 @@ int main(int, char *[]) { out.error("urPlatformGet failed with return code: {}", status); goto out; } - out.info("urPlatformGet found {} platforms", platformCount); + out.info("urPlatformGet found {} platforms", adapterPlatformCount); - platforms.reserve(platformCount + adapterPlatformCount); + platforms.resize(platformCount + adapterPlatformCount); status = urPlatformGet(adapter, adapterPlatformCount, &platforms[platformCount], &adapterPlatformCount); if (status != UR_RESULT_SUCCESS) { @@ -67,7 +67,6 @@ int main(int, char *[]) { } platformCount += adapterPlatformCount; } - platforms.resize(platformCount); for (auto p : platforms) { size_t name_len; diff --git a/unified-runtime/test/unit/print.h b/unified-runtime/test/unit/print.h index 721756e2ed221..ec474c9673ccf 100644 --- a/unified-runtime/test/unit/print.h +++ b/unified-runtime/test/unit/print.h @@ -69,7 +69,7 @@ struct UrPlatformGet { struct UrPlatformGetEmptyArray : UrPlatformGet { UrPlatformGetEmptyArray() : UrPlatformGet() {} const char *get_expected() { - return ".phAdapters = nullptr, .NumAdapters = 0, .NumEntries = 0, " + return ".hAdapter = nullptr, .NumEntries = 0, " ".phPlatforms = nullptr, .pNumPlatforms = " "nullptr"; }; @@ -86,7 +86,7 @@ struct UrPlatformGetTwoPlatforms : UrPlatformGet { pNumPlatforms = &num_platforms; } const char *get_expected() { - return ".phAdapters = nullptr, .NumAdapters = 0, .NumEntries = 2, " + return ".hAdapter = nullptr, .NumEntries = 2, " ".phPlatforms = .+ \\{.+, .+\\}, " ".pNumPlatforms = .+ \\(2\\)"; };