Skip to content

Commit 4aeb55e

Browse files
authored
Merge pull request #1474 from oneapi-src/martin/removeUSMKind
[CTS] Remove USMKind struct and replace usage with ur_usm_type_t in CTS tests
2 parents ff276ab + b1619cb commit 4aeb55e

File tree

4 files changed

+28
-42
lines changed

4 files changed

+28
-42
lines changed

test/conformance/enqueue/helpers.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,6 @@ struct TestParameters2D {
6666
size_t height;
6767
};
6868

69-
inline std::string USMKindToString(USMKind kind) {
70-
switch (kind) {
71-
case USMKind::Device:
72-
return "Device";
73-
case USMKind::Host:
74-
return "Host";
75-
case USMKind::Shared:
76-
default:
77-
return "Shared";
78-
}
79-
}
80-
8169
template <typename T>
8270
inline std::string
8371
print2DTestString(const testing::TestParamInfo<typename T::ParamType> &info) {
@@ -91,8 +79,7 @@ print2DTestString(const testing::TestParamInfo<typename T::ParamType> &info) {
9179
<< std::get<0>(std::get<1>(info.param)).pitch << "__width__"
9280
<< std::get<0>(std::get<1>(info.param)).width << "__height__"
9381
<< std::get<0>(std::get<1>(info.param)).height << "__src__"
94-
<< USMKindToString(src_kind) << "__dst__"
95-
<< USMKindToString(dst_kind);
82+
<< src_kind << "__dst__" << dst_kind;
9683
return test_name.str();
9784
}
9885

test/conformance/enqueue/urEnqueueUSMMemcpy2D.cpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <uur/fixtures.h>
88

99
using TestParametersMemcpy2D =
10-
std::tuple<uur::TestParameters2D, uur::USMKind, uur::USMKind>;
10+
std::tuple<uur::TestParameters2D, ur_usm_type_t, ur_usm_type_t>;
1111

1212
struct urEnqueueUSMMemcpy2DTestWithParam
1313
: uur::urQueueTestWithParam<TestParametersMemcpy2D> {
@@ -22,8 +22,8 @@ struct urEnqueueUSMMemcpy2DTestWithParam
2222

2323
ur_device_usm_access_capability_flags_t device_usm = 0;
2424
ASSERT_SUCCESS(uur::GetDeviceUSMDeviceSupport(device, device_usm));
25-
if (!device_usm && (src_kind == uur::USMKind::Device ||
26-
dst_kind == uur::USMKind::Device)) {
25+
if (!device_usm && (src_kind == ur_usm_type_t::UR_USM_TYPE_DEVICE ||
26+
dst_kind == ur_usm_type_t::UR_USM_TYPE_DEVICE)) {
2727
GTEST_SKIP() << "Device USM is not supported";
2828
}
2929

@@ -66,7 +66,7 @@ struct urEnqueueUSMMemcpy2DTestWithParam
6666
void verifyMemcpySucceeded() {
6767
std::vector<uint8_t> host_mem(pitch * height);
6868
const uint8_t *host_ptr = nullptr;
69-
if (dst_kind == uur::USMKind::Device) {
69+
if (dst_kind == ur_usm_type_t::UR_USM_TYPE_DEVICE) {
7070
ASSERT_SUCCESS(urEnqueueUSMMemcpy2D(queue, true, host_mem.data(),
7171
pitch, pDst, pitch, width,
7272
height, 0, nullptr, nullptr));
@@ -88,8 +88,8 @@ struct urEnqueueUSMMemcpy2DTestWithParam
8888
size_t pitch = 0;
8989
size_t width = 0;
9090
size_t height = 0;
91-
uur::USMKind src_kind;
92-
uur::USMKind dst_kind;
91+
ur_usm_type_t src_kind;
92+
ur_usm_type_t dst_kind;
9393
};
9494

9595
static std::vector<uur::TestParameters2D> test_sizes{
@@ -106,15 +106,16 @@ static std::vector<uur::TestParameters2D> test_sizes{
106106
/* Height == 1 && Pitch == width + 1 */
107107
{234, 233, 1}};
108108

109-
UUR_TEST_SUITE_P(urEnqueueUSMMemcpy2DTestWithParam,
110-
::testing::Combine(::testing::ValuesIn(test_sizes),
111-
::testing::Values(uur::USMKind::Device,
112-
uur::USMKind::Host,
113-
uur::USMKind::Shared),
114-
::testing::Values(uur::USMKind::Device,
115-
uur::USMKind::Host,
116-
uur::USMKind::Shared)),
117-
uur::print2DTestString<urEnqueueUSMMemcpy2DTestWithParam>);
109+
UUR_TEST_SUITE_P(
110+
urEnqueueUSMMemcpy2DTestWithParam,
111+
::testing::Combine(::testing::ValuesIn(test_sizes),
112+
::testing::Values(ur_usm_type_t::UR_USM_TYPE_DEVICE,
113+
ur_usm_type_t::UR_USM_TYPE_HOST,
114+
ur_usm_type_t::UR_USM_TYPE_SHARED),
115+
::testing::Values(ur_usm_type_t::UR_USM_TYPE_DEVICE,
116+
ur_usm_type_t::UR_USM_TYPE_HOST,
117+
ur_usm_type_t::UR_USM_TYPE_SHARED)),
118+
uur::print2DTestString<urEnqueueUSMMemcpy2DTestWithParam>);
118119

119120
TEST_P(urEnqueueUSMMemcpy2DTestWithParam, SuccessBlocking) {
120121
ASSERT_SUCCESS(urEnqueueUSMMemcpy2D(queue, true, pDst, pitch, pSrc, pitch,
@@ -141,7 +142,9 @@ TEST_P(urEnqueueUSMMemcpy2DTestWithParam, SuccessNonBlocking) {
141142
using urEnqueueUSMMemcpy2DNegativeTest = urEnqueueUSMMemcpy2DTestWithParam;
142143
UUR_TEST_SUITE_P(urEnqueueUSMMemcpy2DNegativeTest,
143144
::testing::Values(TestParametersMemcpy2D{
144-
{1, 1, 1}, uur::USMKind::Device, uur::USMKind::Device}),
145+
{1, 1, 1},
146+
ur_usm_type_t::UR_USM_TYPE_DEVICE,
147+
ur_usm_type_t::UR_USM_TYPE_DEVICE}),
145148
uur::print2DTestString<urEnqueueUSMMemcpy2DTestWithParam>);
146149

147150
TEST_P(urEnqueueUSMMemcpy2DNegativeTest, InvalidNullHandleQueue) {

test/conformance/testing/include/uur/utils.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,8 @@ ur_device_partition_property_t makePartitionEquallyDesc(uint32_t cu_per_device);
403403
ur_device_partition_property_t
404404
makePartitionByAffinityDomain(ur_device_affinity_domain_flags_t aff_domain);
405405

406-
enum class USMKind {
407-
Device,
408-
Host,
409-
Shared,
410-
};
411-
412-
ur_result_t MakeUSMAllocationByType(USMKind kind, ur_context_handle_t hContext,
406+
ur_result_t MakeUSMAllocationByType(ur_usm_type_t type,
407+
ur_context_handle_t hContext,
413408
ur_device_handle_t hDevice,
414409
const ur_usm_desc_t *pUSMDesc,
415410
ur_usm_pool_handle_t hPool, size_t size,

test/conformance/testing/source/utils.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -658,19 +658,20 @@ makePartitionByAffinityDomain(ur_device_affinity_domain_flags_t aff_domain) {
658658
return desc;
659659
}
660660

661-
ur_result_t MakeUSMAllocationByType(USMKind kind, ur_context_handle_t hContext,
661+
ur_result_t MakeUSMAllocationByType(ur_usm_type_t type,
662+
ur_context_handle_t hContext,
662663
ur_device_handle_t hDevice,
663664
const ur_usm_desc_t *pUSMDesc,
664665
ur_usm_pool_handle_t hPool, size_t size,
665666
void **ppMem) {
666-
switch (kind) {
667-
case USMKind::Device:
667+
switch (type) {
668+
case ur_usm_type_t::UR_USM_TYPE_DEVICE:
668669
return urUSMDeviceAlloc(hContext, hDevice, pUSMDesc, hPool, size,
669670
ppMem);
670-
case USMKind::Host:
671+
case ur_usm_type_t::UR_USM_TYPE_HOST:
671672
return urUSMHostAlloc(hContext, pUSMDesc, hPool, size, ppMem);
672673
default:
673-
case USMKind::Shared:
674+
case ur_usm_type_t::UR_USM_TYPE_SHARED:
674675
return urUSMSharedAlloc(hContext, hDevice, pUSMDesc, hPool, size,
675676
ppMem);
676677
}

0 commit comments

Comments
 (0)