Skip to content

Commit 00741fa

Browse files
authored
Merge branch 'main' into command_buffer_req_group_size
2 parents 8d7241d + d1b75bd commit 00741fa

File tree

22 files changed

+760
-144
lines changed

22 files changed

+760
-144
lines changed

test_common/harness/deviceInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ std::string get_device_info_string(cl_device_id device,
5050
}
5151

5252
/* Determines if an extension is supported by a device. */
53-
int is_extension_available(cl_device_id device, const char *extensionName)
53+
bool is_extension_available(cl_device_id device, const char *extensionName)
5454
{
5555
std::string extString = get_device_extensions_string(device);
5656
std::istringstream ss(extString);

test_common/harness/deviceInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ std::string get_device_info_string(cl_device_id device,
2626
cl_device_info param_name);
2727

2828
/* Determines if an extension is supported by a device. */
29-
int is_extension_available(cl_device_id device, const char *extensionName);
29+
bool is_extension_available(cl_device_id device, const char *extensionName);
3030

3131
/* Returns the version of the extension the device supports or throws an
3232
* exception if the extension is not supported by the device. */

test_conformance/api/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set(${MODULE_NAME}_SOURCES
66
main.cpp
77
negative_platform.cpp
88
negative_queue.cpp
9+
negative_enqueue_marker.cpp
910
negative_enqueue_map_image.cpp
1011
test_api_consistency.cpp
1112
test_bool.cpp
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
//
2+
// Copyright (c) 2025 The Khronos Group Inc.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
#include "testBase.h"
17+
#include "harness/typeWrappers.h"
18+
19+
REGISTER_TEST(negative_enqueue_marker_with_wait_list)
20+
{
21+
cl_platform_id platform = getPlatformFromDevice(device);
22+
cl_context_properties props[3] = {
23+
CL_CONTEXT_PLATFORM, reinterpret_cast<cl_context_properties>(platform),
24+
0
25+
};
26+
27+
cl_int err = CL_SUCCESS;
28+
clContextWrapper ctx =
29+
clCreateContext(props, 1, &device, nullptr, nullptr, &err);
30+
test_error(err, "clCreateContext failed");
31+
32+
cl_event ret_event = nullptr;
33+
34+
err = clEnqueueMarkerWithWaitList(nullptr, 0, nullptr, &ret_event);
35+
test_failure_error_ret(err, CL_INVALID_COMMAND_QUEUE,
36+
"clEnqueueMarkerWithWaitList should return "
37+
"CL_INVALID_COMMAND_QUEUE when: \"command_queue is "
38+
"not a valid host command-queue\" using a nullptr",
39+
TEST_FAIL);
40+
test_assert_error(ret_event == nullptr,
41+
"if clEnqueueMarkerWithWaitList failed, no ret_event "
42+
"should be created");
43+
44+
clEventWrapper different_ctx_event = clCreateUserEvent(ctx, &err);
45+
test_error(err, "clCreateUserEvent failed");
46+
47+
err =
48+
clEnqueueMarkerWithWaitList(queue, 1, &different_ctx_event, &ret_event);
49+
test_failure_error_ret(
50+
err, CL_INVALID_CONTEXT,
51+
"clEnqueueMarkerWithWaitList should return CL_INVALID_CONTEXT when: "
52+
"\"The context of both the command queue and the events in ret_event "
53+
"wait list are not the same\"",
54+
TEST_FAIL);
55+
test_assert_error(ret_event == nullptr,
56+
"if clEnqueueMarkerWithWaitList failed, no ret_event "
57+
"should be created");
58+
59+
err = clEnqueueMarkerWithWaitList(queue, 1, nullptr, &ret_event);
60+
test_failure_error_ret(
61+
err, CL_INVALID_EVENT_WAIT_LIST,
62+
"clEnqueueMarkerWithWaitList should return CL_INVALID_EVENT_WAIT_LIST "
63+
"when: \"num_events_in_wait_list > 0 but event_wait_list is NULL\"",
64+
TEST_FAIL);
65+
test_assert_error(ret_event == nullptr,
66+
"if clEnqueueMarkerWithWaitList failed, no ret_event "
67+
"should be created");
68+
69+
70+
clEventWrapper event = clCreateUserEvent(context, &err);
71+
test_error(err, "clCreateUserEvent failed");
72+
73+
err = clEnqueueMarkerWithWaitList(queue, 0, &event, &ret_event);
74+
test_failure_error_ret(
75+
err, CL_INVALID_EVENT_WAIT_LIST,
76+
"clEnqueueMarkerWithWaitList should return CL_INVALID_EVENT_WAIT_LIST "
77+
"when: \"num_events_in_wait_list is 0 but event_wait_list is not "
78+
"NULL\"",
79+
TEST_FAIL);
80+
test_assert_error(ret_event == nullptr,
81+
"if clEnqueueMarkerWithWaitList failed, no ret_event "
82+
"should be created");
83+
84+
cl_event invalid_event_wait_list[] = { nullptr };
85+
err = clEnqueueMarkerWithWaitList(queue, 1, invalid_event_wait_list,
86+
&ret_event);
87+
test_failure_error_ret(
88+
err, CL_INVALID_EVENT_WAIT_LIST,
89+
"clEnqueueMarkerWithWaitList should return CL_INVALID_EVENT_WAIT_LIST "
90+
"when: \"event objects in event_wait_list are not valid events\"",
91+
TEST_FAIL);
92+
test_assert_error(ret_event == nullptr,
93+
"if clEnqueueMarkerWithWaitList failed, no ret_event "
94+
"should be created");
95+
96+
return TEST_PASS;
97+
}

test_conformance/api/test_kernel_attributes.cpp

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,14 @@ REGISTER_TEST(null_required_work_group_size)
386386

387387
struct KernelAttribInfo
388388
{
389-
std::string str;
390-
cl_uint max_dim;
389+
cl_int wgs[3];
390+
cl_uint min_dim;
391391
};
392392

393393
std::vector<KernelAttribInfo> attribs;
394-
attribs.push_back({ "__attribute__((reqd_work_group_size(2,1,1)))", 1 });
395-
attribs.push_back({ "__attribute__((reqd_work_group_size(2,3,1)))", 2 });
396-
attribs.push_back({ "__attribute__((reqd_work_group_size(2,3,4)))", 3 });
394+
attribs.push_back({ { 2, 1, 1 }, 1 });
395+
attribs.push_back({ { 2, 3, 1 }, 2 });
396+
attribs.push_back({ { 2, 3, 4 }, 3 });
397397

398398
const std::string body_str = R"(
399399
__kernel void wg_size(__global int* dst)
@@ -410,7 +410,11 @@ REGISTER_TEST(null_required_work_group_size)
410410

411411
for (auto& attrib : attribs)
412412
{
413-
const std::string source_str = attrib.str + body_str;
413+
const std::string attrib_str = "__attribute__((reqd_work_group_size("
414+
+ std::to_string(attrib.wgs[0]) + ","
415+
+ std::to_string(attrib.wgs[1]) + ","
416+
+ std::to_string(attrib.wgs[2]) + ")))";
417+
const std::string source_str = attrib_str + body_str;
414418
const char* source = source_str.c_str();
415419

416420
clProgramWrapper program;
@@ -422,21 +426,19 @@ REGISTER_TEST(null_required_work_group_size)
422426
error = clSetKernelArg(kernel, 0, sizeof(cl_mem), &dst);
423427
test_error(error, "clSetKernelArg failed");
424428

425-
for (cl_uint work_dim = 1; work_dim <= attrib.max_dim; work_dim++)
429+
for (cl_uint work_dim = attrib.min_dim; work_dim <= 3; work_dim++)
426430
{
427-
const cl_int expected[3] = { 2, work_dim >= 2 ? 3 : 1,
428-
work_dim >= 3 ? 4 : 1 };
429431
const size_t test_work_group_size =
430-
expected[0] * expected[1] * expected[2];
431-
if ((size_t)expected[0] > device_max_work_item_sizes[0]
432-
|| (size_t)expected[1] > device_max_work_item_sizes[1]
433-
|| (size_t)expected[2] > device_max_work_item_sizes[2]
432+
attrib.wgs[0] * attrib.wgs[1] * attrib.wgs[2];
433+
if ((size_t)attrib.wgs[0] > device_max_work_item_sizes[0]
434+
|| (size_t)attrib.wgs[1] > device_max_work_item_sizes[1]
435+
|| (size_t)attrib.wgs[2] > device_max_work_item_sizes[2]
434436
|| test_work_group_size > device_max_work_group_size)
435437
{
436438
log_info("Skipping test for work_dim = %u: required work group "
437439
"size (%i, %i, %i) (total %zu) exceeds device max "
438440
"work group size (%zu, %zu, %zu) (total %zu)\n",
439-
work_dim, expected[0], expected[1], expected[2],
441+
work_dim, attrib.wgs[0], attrib.wgs[1], attrib.wgs[2],
440442
test_work_group_size, device_max_work_item_sizes[0],
441443
device_max_work_item_sizes[1],
442444
device_max_work_item_sizes[2],
@@ -445,8 +447,9 @@ REGISTER_TEST(null_required_work_group_size)
445447
}
446448

447449
const cl_int zero = 0;
448-
error = clEnqueueFillBuffer(queue, dst, &zero, sizeof(zero), 0,
449-
sizeof(expected), 0, nullptr, nullptr);
450+
error =
451+
clEnqueueFillBuffer(queue, dst, &zero, sizeof(zero), 0,
452+
sizeof(attrib.wgs), 0, nullptr, nullptr);
450453
test_error(error, "clEnqueueFillBuffer failed");
451454

452455
const size_t global_work_size[3] = { 2 * 32, 3 * 32, 4 * 32 };
@@ -460,12 +463,12 @@ REGISTER_TEST(null_required_work_group_size)
460463
results, 0, nullptr, nullptr);
461464
test_error(error, "clEnqueueReadBuffer failed");
462465

463-
if (results[0] != expected[0] || results[1] != expected[1]
464-
|| results[2] != expected[2])
466+
if (results[0] != attrib.wgs[0] || results[1] != attrib.wgs[1]
467+
|| results[2] != attrib.wgs[2])
465468
{
466469
log_error("Executed local size mismatch with work_dim = %u: "
467470
"Expected (%d,%d,%d) got (%d,%d,%d)\n",
468-
work_dim, expected[0], expected[1], expected[2],
471+
work_dim, attrib.wgs[0], attrib.wgs[1], attrib.wgs[2],
469472
results[0], results[1], results[2]);
470473
return TEST_FAIL;
471474
}
@@ -479,15 +482,15 @@ REGISTER_TEST(null_required_work_group_size)
479482
test_error(error,
480483
"clGetKernelSuggestedLocalWorkSizeKHR failed");
481484

482-
if ((cl_int)suggested[0] != expected[0]
483-
|| (cl_int)suggested[1] != expected[1]
484-
|| (cl_int)suggested[2] != expected[2])
485+
if (suggested[0] != (size_t)attrib.wgs[0]
486+
|| suggested[1] != (size_t)attrib.wgs[1]
487+
|| suggested[2] != (size_t)attrib.wgs[2])
485488
{
486489
log_error("Suggested local size mismatch with work_dim = "
487-
"%u: Expected (%d,%d,%d) got (%d,%d,%d)\n",
488-
work_dim, expected[0], expected[1], expected[2],
489-
(cl_int)suggested[0], (cl_int)suggested[1],
490-
(cl_int)suggested[2]);
490+
"%u: Expected (%d,%d,%d) got (%zu,%zu,%zu)\n",
491+
work_dim, attrib.wgs[0], attrib.wgs[1],
492+
attrib.wgs[2], suggested[0], suggested[1],
493+
suggested[2]);
491494
return TEST_FAIL;
492495
}
493496
}

test_conformance/api/test_kernels.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,12 @@ REGISTER_TEST(negative_invalid_arg_index)
982982

983983
REGISTER_TEST(negative_invalid_arg_size_local)
984984
{
985+
if (true)
986+
{
987+
log_info("Disabling this test temporarily, see internal issue 374.\n");
988+
return TEST_SKIPPED_ITSELF;
989+
}
990+
985991
cl_int error = CL_SUCCESS;
986992
clProgramWrapper program;
987993
clKernelWrapper local_arg_kernel;

test_conformance/c11_atomics/common.h

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,28 @@ class CBasicTestMemOrder2Scope
702702
cl_context context,
703703
cl_command_queue queue)
704704
{
705+
// Comparator for orders and scopes.
706+
const auto checkValidity = [](TExplicitMemoryOrderType success,
707+
TExplicitMemoryOrderType failure,
708+
TExplicitMemoryScopeType scope) {
709+
// Both memory order arguments must be set (or neither).
710+
if ((success == MEMORY_ORDER_EMPTY || failure == MEMORY_ORDER_EMPTY)
711+
&& success != failure)
712+
return false;
713+
714+
// Memory scope without memory order is disallowed.
715+
if (success == MEMORY_ORDER_EMPTY && scope != MEMORY_SCOPE_EMPTY)
716+
return false;
717+
718+
// Failure must not be release or acq_rel.
719+
if (failure == MEMORY_ORDER_RELEASE
720+
|| failure == MEMORY_ORDER_ACQ_REL)
721+
return false;
722+
723+
// Failure must not be stronger than success.
724+
return failure <= success;
725+
};
726+
705727
// repeat test for each reasonable memory order/scope combination
706728
std::vector<TExplicitMemoryOrderType> memoryOrder;
707729
std::vector<TExplicitMemoryScopeType> memoryScope;
@@ -719,16 +741,10 @@ class CBasicTestMemOrder2Scope
719741
{
720742
for (unsigned si = 0; si < memoryScope.size(); si++)
721743
{
722-
if ((memoryOrder[oi] == MEMORY_ORDER_EMPTY
723-
|| memoryOrder[o2i] == MEMORY_ORDER_EMPTY)
724-
&& memoryOrder[oi] != memoryOrder[o2i])
725-
continue; // both memory order arguments must be set (or
726-
// none)
727-
if ((memoryOrder[oi] == MEMORY_ORDER_EMPTY
728-
|| memoryOrder[o2i] == MEMORY_ORDER_EMPTY)
729-
&& memoryScope[si] != MEMORY_SCOPE_EMPTY)
730-
continue; // memory scope without memory order is not
731-
// allowed
744+
if (!checkValidity(memoryOrder[oi], memoryOrder[o2i],
745+
memoryScope[si]))
746+
continue;
747+
732748
MemoryOrder(memoryOrder[oi]);
733749
MemoryOrder2(memoryOrder[o2i]);
734750
MemoryScope(memoryScope[si]);

0 commit comments

Comments
 (0)