Skip to content

Additional tests when CUDA or Level Zero providers are disabled #938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 27, 2024
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
14 changes: 14 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -400,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
Expand Down
31 changes: 31 additions & 0 deletions test/providers/provider_cuda_not_impl.cpp
Original file line number Diff line number Diff line change
@@ -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 <umf/providers/provider_cuda.h>

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);
}
36 changes: 36 additions & 0 deletions test/providers/provider_level_zero_not_impl.cpp
Original file line number Diff line number Diff line change
@@ -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 <umf/providers/provider_level_zero.h>

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);
}
Loading