Skip to content

Commit a2dd4d4

Browse files
committed
[CTS] add UMF integration test
1 parent 95e03b4 commit a2dd4d4

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

test/conformance/usm/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,12 @@ add_conformance_test_with_kernels_environment(usm
1313
urUSMPoolRelease.cpp
1414
urUSMPoolRetain.cpp
1515
urUSMSharedAlloc.cpp)
16+
17+
if(UMF_BUILD_SHARED_LIBRARY)
18+
add_conformance_test_with_kernels_environment(usm_umf
19+
umfIntegration.cpp)
20+
21+
target_link_libraries(test-usm_umf PRIVATE umf::umf)
22+
else()
23+
message(WARNING "UMF build as static library, UMF integration tests will be disabled")
24+
endif()
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (C) 2025 Intel Corporation
2+
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM
3+
// Exceptions. See LICENSE.TXT
4+
//
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
#include "helpers.h"
7+
#include "uur/utils.h"
8+
#include <uur/fixtures.h>
9+
#include <uur/known_failure.h>
10+
11+
#include <umf.h>
12+
#include <umf/memory_pool.h>
13+
#include <umf/memory_provider.h>
14+
15+
struct umfDeviceAllocTest : uur::urUSMAllocTest {
16+
void SetUp() override {
17+
UUR_RETURN_ON_FATAL_FAILURE(uur::urUSMAllocTest::SetUp());
18+
ASSERT_SUCCESS(uur::GetDeviceUSMDeviceSupport(device, USMSupport));
19+
if (!USMSupport) {
20+
GTEST_SKIP() << "Device USM is not supported.";
21+
}
22+
}
23+
};
24+
25+
// The 0 value parameters are not relevant for umfDeviceAllocTest tests, they
26+
// are used below in urUSMDeviceAllocAlignmentTest for allocation size and
27+
// alignment values
28+
UUR_DEVICE_TEST_SUITE_WITH_PARAM(
29+
umfDeviceAllocTest,
30+
testing::Combine(
31+
testing::ValuesIn(uur::BoolTestParam::makeBoolParam("UsePool")),
32+
testing::Values(0), testing::Values(0), testing::Values(UR_USM_ADVICE_FLAG_DEFAULT)),
33+
uur::printUSMAllocTestString<umfDeviceAllocTest>);
34+
35+
TEST_P(umfDeviceAllocTest, UMFAllocSuccessfull) {
36+
UUR_KNOWN_FAILURE_ON(uur::NativeCPU{}, uur::CUDA{}, uur::HIP{},
37+
uur::OpenCL{});
38+
39+
void *ptr = nullptr;
40+
size_t allocation_size = sizeof(int);
41+
ASSERT_SUCCESS(
42+
urUSMDeviceAlloc(context, device, nullptr, pool, allocation_size, &ptr));
43+
ASSERT_NE(ptr, nullptr);
44+
45+
auto umfPool = umfPoolByPtr(ptr);
46+
ASSERT_NE(umfPool, nullptr);
47+
48+
umf_memory_provider_handle_t hProvider;
49+
ASSERT_EQ(umfPoolGetMemoryProvider(umfPool, &hProvider), UMF_RESULT_SUCCESS);
50+
ASSERT_NE(hProvider, nullptr);
51+
52+
// make sure that pool can be used for allocations
53+
void *umfPtr = umfPoolMalloc(umfPool, allocation_size);
54+
ASSERT_NE(umfPtr, nullptr);
55+
ASSERT_EQ(umfPoolFree(umfPool, umfPtr), UMF_RESULT_SUCCESS);
56+
57+
ASSERT_SUCCESS(urUSMFree(context, ptr));
58+
}

0 commit comments

Comments
 (0)