Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions test_conformance/api/test_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "testBase.h"
#include "harness/typeWrappers.h"
#include "harness/conversions.h"
#include "harness/featureHelpers.h"
#include <vector>

const char *sample_single_test_kernel[] = {
Expand Down Expand Up @@ -87,6 +88,17 @@ const char *sample_two_kernel_program[] = {
"\n"
"}\n" };

const char *sample_queue_test_kernel = R"(
__kernel void enqueue_call_func() {
}
__kernel void queue_test(queue_t queue)
{
ndrange_t ndrange = ndrange_1D(1);
enqueue_kernel(queue, CLK_ENQUEUE_FLAGS_WAIT_KERNEL, ndrange,
^{enqueue_call_func();});
}
)";

const char *sample_read_only_image_test_kernel = R"(
__kernel void read_only_image_test(__write_only image2d_t img, __global uint4 *src)
{
Expand Down Expand Up @@ -718,6 +730,44 @@ REGISTER_TEST(negative_set_immutable_memory_to_writeable_kernel_arg)
return TEST_PASS;
}

REGISTER_TEST(negative_invalid_arg_queue)
{
OpenCLCFeatures features;
get_device_cl_c_features(device, features);

const Version clc_version = get_device_latest_cl_c_version(device);
if ((clc_version < Version(2, 0))
|| !features.supports__opencl_c_device_enqueue)
return TEST_SKIPPED_ITSELF;

std::string build_opts = "-cl-std=CL" + clc_version.to_string();

cl_int error = CL_SUCCESS;
clProgramWrapper program;
clKernelWrapper queue_arg_kernel;
clCommandQueueWrapper queue_arg;

// Setup the test
error = create_single_kernel_helper(context, &program, nullptr, 1,
&sample_queue_test_kernel, "queue_test",
build_opts.c_str());
test_error(error, "Unable to build test program");

queue_arg_kernel = clCreateKernel(program, "queue_test", &error);
test_error(error, "Unable to get queue_test kernel for built program");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work - we either need the kernel name to be nullptr, or the kernel handle must not be nullptr.

Since I can't think of a reason not to do so, I'd recommend just using the harness to create the kernel also, and pass a non-nullptr kernel handle.

Suggested change
// Setup the test
error = create_single_kernel_helper(context, &program, nullptr, 1,
&sample_queue_test_kernel, "queue_test",
build_opts.c_str());
test_error(error, "Unable to build test program");
queue_arg_kernel = clCreateKernel(program, "queue_test", &error);
test_error(error, "Unable to get queue_test kernel for built program");
// Setup the test
error = create_single_kernel_helper(context, &program, &queue_arg_kernel, 1,
&sample_queue_test_kernel, "queue_test",
build_opts.c_str());
test_error(error, "Unable to create test kernel");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected


// Run the test - CL_INVALID_DEVICE_QUEUE
error = clSetKernelArg(queue_arg_kernel, 0, sizeof(cl_command_queue),
queue_arg);
test_failure_error_ret(
error, CL_INVALID_DEVICE_QUEUE,
"clSetKernelArg is supposed to fail with CL_INVALID_DEVICE_QUEUE when "
"the specified arg_value is not a valid device queue object",
TEST_FAIL);

return TEST_PASS;
}

REGISTER_TEST(negative_set_read_write_image_arg)
{
cl_int error = CL_SUCCESS;
Expand Down
Loading