Skip to content

Commit f9a5d84

Browse files
committed
Address feedback: remove some redundant checks including those in Queue and Event.
1 parent b879e1f commit f9a5d84

File tree

3 files changed

+13
-35
lines changed

3 files changed

+13
-35
lines changed

test/conformance/context/urContextGetInfo.cpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ TEST_P(urContextGetInfoTest, SuccessNumDevices) {
1212
size_t size = 0;
1313

1414
ASSERT_SUCCESS(urContextGetInfo(context, info_type, 0, nullptr, &size));
15-
ASSERT_NE(size, 0);
1615
ASSERT_EQ(size, sizeof(uint32_t));
1716

1817
uint32_t nDevices = 0;
@@ -29,23 +28,19 @@ TEST_P(urContextGetInfoTest, SuccessDevices) {
2928
ASSERT_SUCCESS(urContextGetInfo(context, info_type, 0, nullptr, &size));
3029
ASSERT_NE(size, 0);
3130

32-
if (size > 0) {
33-
ur_device_handle_t devices = 0;
34-
ASSERT_SUCCESS(
35-
urContextGetInfo(context, info_type, size, &devices, nullptr));
36-
37-
size_t devices_count = size / sizeof(ur_device_handle_t);
38-
ASSERT_GT(devices_count, 0);
39-
40-
for (uint32_t i = 0; i < devices_count; i++) {
41-
auto &devices = uur::DevicesEnvironment::instance->devices;
42-
auto queried_device =
43-
std::find(devices.begin(), devices.end(), devices[i]);
44-
EXPECT_TRUE(queried_device != devices.end())
45-
<< "device associated with the context is not valid";
46-
}
47-
} else {
48-
ASSERT_EQ(size, 0);
31+
ur_device_handle_t devices = 0;
32+
ASSERT_SUCCESS(
33+
urContextGetInfo(context, info_type, size, &devices, nullptr));
34+
35+
size_t devices_count = size / sizeof(ur_device_handle_t);
36+
ASSERT_GT(devices_count, 0);
37+
38+
for (uint32_t i = 0; i < devices_count; i++) {
39+
auto &devices = uur::DevicesEnvironment::instance->devices;
40+
auto queried_device =
41+
std::find(devices.begin(), devices.end(), devices[i]);
42+
EXPECT_TRUE(queried_device != devices.end())
43+
<< "device associated with the context is not valid";
4944
}
5045
}
5146

@@ -54,7 +49,6 @@ TEST_P(urContextGetInfoTest, SuccessUSMMemCpy2DSupport) {
5449
size_t size = 0;
5550

5651
ASSERT_SUCCESS(urContextGetInfo(context, info_type, 0, nullptr, &size));
57-
ASSERT_NE(size, 0);
5852
ASSERT_EQ(size, sizeof(ur_bool_t));
5953
}
6054

@@ -63,7 +57,6 @@ TEST_P(urContextGetInfoTest, SuccessUSMFill2DSupport) {
6357
size_t size = 0;
6458

6559
ASSERT_SUCCESS(urContextGetInfo(context, info_type, 0, nullptr, &size));
66-
ASSERT_NE(size, 0);
6760
ASSERT_EQ(size, sizeof(ur_bool_t));
6861
}
6962

@@ -72,7 +65,6 @@ TEST_P(urContextGetInfoTest, SuccessReferenceCount) {
7265
size_t size = 0;
7366

7467
ASSERT_SUCCESS(urContextGetInfo(context, info_type, 0, nullptr, &size));
75-
ASSERT_NE(size, 0);
7668
ASSERT_EQ(size, sizeof(uint32_t));
7769

7870
uint32_t reference_count = 0;
@@ -88,7 +80,6 @@ TEST_P(urContextGetInfoTest, SuccessAtomicMemoryOrderCapabilities) {
8880

8981
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
9082
urContextGetInfo(context, info_type, 0, nullptr, &size), info_type);
91-
ASSERT_NE(size, 0);
9283
ASSERT_EQ(size, sizeof(ur_memory_order_capability_flags_t));
9384

9485
ur_memory_order_capability_flags_t flags = 0;
@@ -104,7 +95,6 @@ TEST_P(urContextGetInfoTest, SuccessAtomicMemoryScopeCapabilities) {
10495

10596
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
10697
urContextGetInfo(context, info_type, 0, nullptr, &size), info_type);
107-
ASSERT_NE(size, 0);
10898
ASSERT_EQ(size, sizeof(ur_memory_scope_capability_flags_t));
10999

110100
ur_memory_scope_capability_flags_t flags = 0;
@@ -120,7 +110,6 @@ TEST_P(urContextGetInfoTest, SuccessAtomicFenceOrderCapabilities) {
120110

121111
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
122112
urContextGetInfo(context, info_type, 0, nullptr, &size), info_type);
123-
ASSERT_NE(size, 0);
124113
ASSERT_EQ(size, sizeof(ur_memory_order_capability_flags_t));
125114

126115
ur_memory_order_capability_flags_t flags = 0;
@@ -136,7 +125,6 @@ TEST_P(urContextGetInfoTest, SuccessAtomicFenceScopeCapabilities) {
136125

137126
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
138127
urContextGetInfo(context, info_type, 0, nullptr, &size), info_type);
139-
ASSERT_NE(size, 0);
140128
ASSERT_EQ(size, sizeof(ur_memory_scope_capability_flags_t));
141129

142130
ur_memory_scope_capability_flags_t flags = 0;

test/conformance/event/urEventGetInfo.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ TEST_P(urEventGetInfoTest, SuccessCommandQueue) {
1212
size_t size = 0;
1313

1414
ASSERT_SUCCESS(urEventGetInfo(event, info_type, 0, nullptr, &size));
15-
ASSERT_NE(size, 0);
1615
ASSERT_EQ(size, sizeof(ur_queue_handle_t));
1716

1817
ur_queue_handle_t returned_queue;
@@ -27,7 +26,6 @@ TEST_P(urEventGetInfoTest, SuccessContext) {
2726
size_t size = 0;
2827

2928
ASSERT_SUCCESS(urEventGetInfo(event, info_type, 0, nullptr, &size));
30-
ASSERT_NE(size, 0);
3129
ASSERT_EQ(size, sizeof(ur_context_handle_t));
3230

3331
ur_context_handle_t returned_context;
@@ -42,7 +40,6 @@ TEST_P(urEventGetInfoTest, SuccessCommandType) {
4240
size_t size = 0;
4341

4442
ASSERT_SUCCESS(urEventGetInfo(event, info_type, 0, nullptr, &size));
45-
ASSERT_NE(size, 0);
4643
ASSERT_EQ(size, sizeof(ur_command_t));
4744

4845
ur_command_t returned_command_type;
@@ -57,7 +54,6 @@ TEST_P(urEventGetInfoTest, SuccessCommandExecutionStatus) {
5754
size_t size = 0;
5855

5956
ASSERT_SUCCESS(urEventGetInfo(event, info_type, 0, nullptr, &size));
60-
ASSERT_NE(size, 0);
6157
ASSERT_EQ(size, sizeof(ur_event_status_t));
6258

6359
ur_event_status_t returned_status;
@@ -72,7 +68,6 @@ TEST_P(urEventGetInfoTest, SuccessReferenceCount) {
7268
size_t size = 0;
7369

7470
ASSERT_SUCCESS(urEventGetInfo(event, info_type, 0, nullptr, &size));
75-
ASSERT_NE(size, 0);
7671
ASSERT_EQ(size, sizeof(uint32_t));
7772

7873
uint32_t returned_reference_count;

test/conformance/queue/urQueueGetInfo.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ TEST_P(urQueueGetInfoTest, Context) {
1212
auto infoType = UR_QUEUE_INFO_CONTEXT;
1313
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
1414
urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType);
15-
ASSERT_NE(size, 0);
1615
ASSERT_EQ(sizeof(ur_context_handle_t), size);
1716

1817
std::vector<uint8_t> data(size);
@@ -28,7 +27,6 @@ TEST_P(urQueueGetInfoTest, Device) {
2827
auto infoType = UR_QUEUE_INFO_DEVICE;
2928
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
3029
urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType);
31-
ASSERT_NE(size, 0);
3230
ASSERT_EQ(sizeof(ur_device_handle_t), size);
3331

3432
std::vector<uint8_t> data(size);
@@ -43,7 +41,6 @@ TEST_P(urQueueGetInfoTest, Flags) {
4341
auto infoType = UR_QUEUE_INFO_FLAGS;
4442
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
4543
urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType);
46-
ASSERT_NE(size, 0);
4744
ASSERT_EQ(sizeof(ur_queue_flags_t), size);
4845

4946
std::vector<uint8_t> data(size);
@@ -58,7 +55,6 @@ TEST_P(urQueueGetInfoTest, ReferenceCount) {
5855
auto infoType = UR_QUEUE_INFO_REFERENCE_COUNT;
5956
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
6057
urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType);
61-
ASSERT_NE(size, 0);
6258
ASSERT_EQ(sizeof(uint32_t), size);
6359

6460
std::vector<uint8_t> data(size);
@@ -73,7 +69,6 @@ TEST_P(urQueueGetInfoTest, EmptyQueue) {
7369
auto infoType = UR_QUEUE_INFO_EMPTY;
7470
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
7571
urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType);
76-
ASSERT_NE(size, 0);
7772
ASSERT_EQ(sizeof(ur_bool_t), size);
7873

7974
std::vector<uint8_t> data(size);

0 commit comments

Comments
 (0)