From dcf04528d00b82b674fdd874b8632c5e54bf683e Mon Sep 17 00:00:00 2001 From: "Vinogradov, Sergei" Date: Tue, 26 Nov 2024 16:08:37 +0100 Subject: [PATCH 1/2] Add test for not implemented Level Zero provider --- test/CMakeLists.txt | 7 ++++ .../provider_level_zero_not_impl.cpp | 36 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test/providers/provider_level_zero_not_impl.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 051e759493..adf967f1de 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -368,6 +368,13 @@ if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_LEVEL_ZERO_PROVIDER) PRIVATE ${LEVEL_ZERO_INCLUDE_DIRS}) endif() +if(NOT UMF_BUILD_LEVEL_ZERO_PROVIDER) + add_umf_test( + NAME provider_level_zero_not_impl + SRCS providers/provider_level_zero_not_impl.cpp + LIBS ${UMF_UTILS_FOR_TEST}) +endif() + if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_CUDA_PROVIDER) if(UMF_CUDA_ENABLED) # we have two test binaries here that use the same sources, but differ diff --git a/test/providers/provider_level_zero_not_impl.cpp b/test/providers/provider_level_zero_not_impl.cpp new file mode 100644 index 0000000000..bea1acbe79 --- /dev/null +++ b/test/providers/provider_level_zero_not_impl.cpp @@ -0,0 +1,36 @@ +// Copyright (C) 2024 Intel Corporation +// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "base.hpp" + +#include + +using umf_test::test; + +TEST_F(test, level_zero_provider_not_implemented) { + umf_level_zero_memory_provider_params_handle_t hParams = nullptr; + umf_result_t result = umfLevelZeroMemoryProviderParamsCreate(&hParams); + ASSERT_EQ(result, UMF_RESULT_ERROR_NOT_SUPPORTED); + + result = umfLevelZeroMemoryProviderParamsDestroy(hParams); + ASSERT_EQ(result, UMF_RESULT_ERROR_NOT_SUPPORTED); + + result = umfLevelZeroMemoryProviderParamsSetContext(hParams, nullptr); + ASSERT_EQ(result, UMF_RESULT_ERROR_NOT_SUPPORTED); + + result = umfLevelZeroMemoryProviderParamsSetDevice(hParams, nullptr); + ASSERT_EQ(result, UMF_RESULT_ERROR_NOT_SUPPORTED); + + result = umfLevelZeroMemoryProviderParamsSetMemoryType( + hParams, UMF_MEMORY_TYPE_DEVICE); + ASSERT_EQ(result, UMF_RESULT_ERROR_NOT_SUPPORTED); + + ze_device_handle_t hDevices[1]; + result = umfLevelZeroMemoryProviderParamsSetResidentDevices(hParams, + hDevices, 1); + ASSERT_EQ(result, UMF_RESULT_ERROR_NOT_SUPPORTED); + + umf_memory_provider_ops_t *ops = umfLevelZeroMemoryProviderOps(); + ASSERT_EQ(ops, nullptr); +} From 4de4ebfab1df629cf2b94c829baa8e0974e4e3a3 Mon Sep 17 00:00:00 2001 From: "Vinogradov, Sergei" Date: Tue, 26 Nov 2024 16:16:59 +0100 Subject: [PATCH 2/2] Add test for not implemented CUDA provider --- test/CMakeLists.txt | 7 +++++ test/providers/provider_cuda_not_impl.cpp | 31 +++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/providers/provider_cuda_not_impl.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index adf967f1de..68d6018f90 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -407,6 +407,13 @@ if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_CUDA_PROVIDER) endif() endif() +if(NOT UMF_BUILD_CUDA_PROVIDER) + add_umf_test( + NAME provider_cuda_not_impl + SRCS providers/provider_cuda_not_impl.cpp + LIBS ${UMF_UTILS_FOR_TEST}) +endif() + add_umf_test( NAME base_alloc SRCS ${BA_SOURCES_FOR_TEST} test_base_alloc.cpp diff --git a/test/providers/provider_cuda_not_impl.cpp b/test/providers/provider_cuda_not_impl.cpp new file mode 100644 index 0000000000..30fc373ca3 --- /dev/null +++ b/test/providers/provider_cuda_not_impl.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2024 Intel Corporation +// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "base.hpp" + +#include + +using umf_test::test; + +TEST_F(test, cuda_provider_not_implemented) { + umf_cuda_memory_provider_params_handle_t hParams = nullptr; + umf_result_t result = umfCUDAMemoryProviderParamsCreate(&hParams); + ASSERT_EQ(result, UMF_RESULT_ERROR_NOT_SUPPORTED); + + result = umfCUDAMemoryProviderParamsDestroy(hParams); + ASSERT_EQ(result, UMF_RESULT_ERROR_NOT_SUPPORTED); + + result = umfCUDAMemoryProviderParamsSetContext(hParams, nullptr); + ASSERT_EQ(result, UMF_RESULT_ERROR_NOT_SUPPORTED); + + result = umfCUDAMemoryProviderParamsSetDevice(hParams, 0); + ASSERT_EQ(result, UMF_RESULT_ERROR_NOT_SUPPORTED); + + result = umfCUDAMemoryProviderParamsSetMemoryType(hParams, + UMF_MEMORY_TYPE_DEVICE); + ASSERT_EQ(result, UMF_RESULT_ERROR_NOT_SUPPORTED); + + umf_memory_provider_ops_t *ops = umfCUDAMemoryProviderOps(); + ASSERT_EQ(ops, nullptr); +}