Skip to content

Commit 83a04c6

Browse files
omarahmed1111kbenzie
authored andcommitted
Add more output checks for getInfo tests with relevant adapter fixes
1 parent 31d0fe1 commit 83a04c6

File tree

11 files changed

+186
-6
lines changed

11 files changed

+186
-6
lines changed

source/adapters/hip/program.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName,
368368
case UR_PROGRAM_INFO_NUM_DEVICES:
369369
return ReturnValue(1u);
370370
case UR_PROGRAM_INFO_DEVICES:
371-
return ReturnValue(hProgram->getDevice(), 1);
371+
return ReturnValue(hProgram->getContext()->getDevices()[0], 1);
372372
case UR_PROGRAM_INFO_SOURCE:
373373
return ReturnValue(hProgram->Binary);
374374
case UR_PROGRAM_INFO_BINARY_SIZES:

source/adapters/native_cpu/context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ urContextGetInfo(ur_context_handle_t hContext, ur_context_info_t propName,
5353
case UR_CONTEXT_INFO_DEVICES:
5454
return returnValue(hContext->_device);
5555
case UR_CONTEXT_INFO_REFERENCE_COUNT:
56-
return returnValue(nullptr);
56+
return returnValue(uint32_t{hContext->getReferenceCount()});
5757
case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT:
5858
return returnValue(true);
5959
case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT:
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
urContextReleaseTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU_
2-
urContextRetainTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU_
31
urContextSetExtendedDeleterTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU_

test/conformance/context/urContextGetInfo.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ UUR_TEST_SUITE_P(urContextGetInfoTestWithInfoParam,
3737
UR_CONTEXT_INFO_NUM_DEVICES, //
3838
UR_CONTEXT_INFO_DEVICES, //
3939
UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT, //
40-
UR_CONTEXT_INFO_USM_FILL2D_SUPPORT //
40+
UR_CONTEXT_INFO_USM_FILL2D_SUPPORT, //
41+
UR_CONTEXT_INFO_REFERENCE_COUNT //
4142

4243
),
4344
uur::deviceTestWithParamPrinter<ur_context_info_t>);
@@ -56,6 +57,38 @@ TEST_P(urContextGetInfoTestWithInfoParam, Success) {
5657
std::vector<uint8_t> info_data(info_size);
5758
ASSERT_SUCCESS(
5859
urContextGetInfo(context, info, info_size, info_data.data(), nullptr));
60+
61+
switch (info) {
62+
case UR_CONTEXT_INFO_NUM_DEVICES: {
63+
auto returned_num_of_devices =
64+
reinterpret_cast<uint32_t *>(info_data.data());
65+
ASSERT_GE(uur::DevicesEnvironment::instance->devices.size(),
66+
*returned_num_of_devices);
67+
break;
68+
}
69+
case UR_CONTEXT_INFO_DEVICES: {
70+
auto returned_devices =
71+
reinterpret_cast<ur_device_handle_t *>(info_data.data());
72+
size_t devices_count = info_size / sizeof(ur_device_handle_t);
73+
ASSERT_GT(devices_count, 0);
74+
for (uint32_t i = 0; i < devices_count; i++) {
75+
auto &devices = uur::DevicesEnvironment::instance->devices;
76+
auto queried_device =
77+
std::find(devices.begin(), devices.end(), returned_devices[i]);
78+
EXPECT_TRUE(queried_device != devices.end())
79+
<< "device associated with the context is not valid";
80+
}
81+
break;
82+
}
83+
case UR_CONTEXT_INFO_REFERENCE_COUNT: {
84+
auto returned_reference_count =
85+
reinterpret_cast<uint32_t *>(info_data.data());
86+
ASSERT_GT(*returned_reference_count, 0U);
87+
break;
88+
}
89+
default:
90+
break;
91+
}
5992
}
6093

6194
using urContextGetInfoTest = uur::urContextTest;

test/conformance/device/urDeviceGetInfo.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,13 @@ TEST_P(urDeviceGetInfoTest, Success) {
271271
std::vector<char> info_data(size);
272272
ASSERT_SUCCESS(urDeviceGetInfo(device, info_type, size,
273273
info_data.data(), nullptr));
274+
275+
if (info_type == UR_DEVICE_INFO_PLATFORM) {
276+
auto returned_platform =
277+
reinterpret_cast<ur_platform_handle_t *>(info_data.data());
278+
ASSERT_EQ(*returned_platform, platform);
279+
}
280+
274281
} else {
275282
ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION);
276283
}

test/conformance/kernel/urKernelGetInfo.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,28 @@ TEST_P(urKernelGetInfoTest, Success) {
2424
property_value.resize(property_size);
2525
ASSERT_SUCCESS(urKernelGetInfo(kernel, property_name, property_size,
2626
property_value.data(), nullptr));
27+
switch (property_name) {
28+
case UR_KERNEL_INFO_CONTEXT: {
29+
auto returned_context =
30+
reinterpret_cast<ur_context_handle_t *>(property_value.data());
31+
ASSERT_EQ(context, *returned_context);
32+
break;
33+
}
34+
case UR_KERNEL_INFO_PROGRAM: {
35+
auto returned_program =
36+
reinterpret_cast<ur_program_handle_t *>(property_value.data());
37+
ASSERT_EQ(program, *returned_program);
38+
break;
39+
}
40+
case UR_KERNEL_INFO_REFERENCE_COUNT: {
41+
auto returned_reference_count =
42+
reinterpret_cast<uint32_t *>(property_value.data());
43+
ASSERT_GT(*returned_reference_count, 0U);
44+
break;
45+
}
46+
default:
47+
break;
48+
}
2749
}
2850

2951
TEST_P(urKernelGetInfoTest, InvalidNullHandleKernel) {

test/conformance/memory/urMemGetInfo.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ TEST_P(urMemGetInfoTest, Success) {
3131

3232
std::vector<uint8_t> info_data(size);
3333
ASSERT_SUCCESS(urMemGetInfo(buffer, info, size, info_data.data(), nullptr));
34+
35+
switch (info) {
36+
case UR_MEM_INFO_CONTEXT: {
37+
auto returned_context =
38+
reinterpret_cast<ur_context_handle_t *>(info_data.data());
39+
ASSERT_EQ(context, *returned_context);
40+
break;
41+
}
42+
case UR_MEM_INFO_SIZE: {
43+
auto returned_size = reinterpret_cast<size_t *>(info_data.data());
44+
ASSERT_GE(*returned_size, allocation_size);
45+
break;
46+
}
47+
default:
48+
break;
49+
}
3450
}
3551

3652
TEST_P(urMemGetInfoTest, InvalidNullHandleMemory) {

test/conformance/program/urProgramGetInfo.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,54 @@ TEST_P(urProgramGetInfoTest, Success) {
3232
property_value.resize(property_size);
3333
ASSERT_SUCCESS(urProgramGetInfo(program, property_name, property_size,
3434
property_value.data(), nullptr));
35+
switch (property_name) {
36+
case UR_PROGRAM_INFO_REFERENCE_COUNT: {
37+
auto returned_reference_count =
38+
reinterpret_cast<uint32_t *>(property_value.data());
39+
ASSERT_GT(*returned_reference_count, 0U);
40+
break;
41+
}
42+
case UR_PROGRAM_INFO_CONTEXT: {
43+
auto returned_context =
44+
reinterpret_cast<ur_context_handle_t *>(property_value.data());
45+
ASSERT_EQ(context, *returned_context);
46+
break;
47+
}
48+
case UR_PROGRAM_INFO_NUM_DEVICES: {
49+
auto returned_num_of_devices =
50+
reinterpret_cast<uint32_t *>(property_value.data());
51+
ASSERT_GE(uur::DevicesEnvironment::instance->devices.size(),
52+
*returned_num_of_devices);
53+
break;
54+
}
55+
case UR_PROGRAM_INFO_DEVICES: {
56+
auto returned_devices =
57+
reinterpret_cast<ur_device_handle_t *>(property_value.data());
58+
size_t devices_count = property_size / sizeof(ur_device_handle_t);
59+
ASSERT_GT(devices_count, 0);
60+
for (uint32_t i = 0; i < devices_count; i++) {
61+
auto &devices = uur::DevicesEnvironment::instance->devices;
62+
auto queried_device =
63+
std::find(devices.begin(), devices.end(), returned_devices[i]);
64+
EXPECT_TRUE(queried_device != devices.end());
65+
}
66+
break;
67+
}
68+
case UR_PROGRAM_INFO_NUM_KERNELS: {
69+
auto returned_num_of_kernels =
70+
reinterpret_cast<uint32_t *>(property_value.data());
71+
ASSERT_GT(*returned_num_of_kernels, 0U);
72+
break;
73+
}
74+
case UR_PROGRAM_INFO_KERNEL_NAMES: {
75+
auto returned_kernel_names =
76+
reinterpret_cast<char *>(property_value.data());
77+
ASSERT_STRNE(returned_kernel_names, "");
78+
break;
79+
}
80+
default:
81+
break;
82+
}
3583
}
3684

3785
TEST_P(urProgramGetInfoTest, InvalidNullHandleProgram) {

test/conformance/queue/urQueueGetInfo.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,29 @@ TEST_P(urQueueGetInfoTestWithInfoParam, Success) {
4242
std::vector<uint8_t> data(size);
4343
ASSERT_SUCCESS(
4444
urQueueGetInfo(queue, info_type, size, data.data(), nullptr));
45+
46+
switch (info_type) {
47+
case UR_QUEUE_INFO_CONTEXT: {
48+
auto returned_context =
49+
reinterpret_cast<ur_context_handle_t *>(data.data());
50+
ASSERT_EQ(context, *returned_context);
51+
break;
52+
}
53+
case UR_QUEUE_INFO_DEVICE: {
54+
auto returned_device =
55+
reinterpret_cast<ur_device_handle_t *>(data.data());
56+
ASSERT_EQ(*returned_device, device);
57+
break;
58+
}
59+
case UR_QUEUE_INFO_REFERENCE_COUNT: {
60+
auto returned_reference_count =
61+
reinterpret_cast<uint32_t *>(data.data());
62+
ASSERT_GT(*returned_reference_count, 0U);
63+
break;
64+
}
65+
default:
66+
break;
67+
}
4568
} else {
4669
ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION);
4770
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ template <class T> struct urMemBufferTestWithParam : urContextTestWithParam<T> {
260260
void SetUp() override {
261261
UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam<T>::SetUp());
262262
ASSERT_SUCCESS(urMemBufferCreate(this->context, UR_MEM_FLAG_READ_WRITE,
263-
4096, nullptr, &buffer));
263+
allocation_size, nullptr, &buffer));
264264
ASSERT_NE(nullptr, buffer);
265265
}
266266

@@ -271,6 +271,7 @@ template <class T> struct urMemBufferTestWithParam : urContextTestWithParam<T> {
271271
UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam<T>::TearDown());
272272
}
273273
ur_mem_handle_t buffer = nullptr;
274+
size_t allocation_size = 4096;
274275
};
275276

276277
template <class T> struct urMemImageTestWithParam : urContextTestWithParam<T> {

0 commit comments

Comments
 (0)