Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command buffer testing fixes #2081

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct CommandBufferCopyBaseTest : BasicCommandBufferTest

if (check_image_support)
{
image = create_image_2d(context, CL_MEM_READ_WRITE, &formats,
image = create_image_2d(context, CL_MEM_READ_WRITE, &format,
img_width, img_height, 0, NULL, &error);
test_error(error, "create_image_2d failed");

Expand Down Expand Up @@ -72,19 +72,31 @@ struct CommandBufferCopyBaseTest : BasicCommandBufferTest
return BasicCommandBufferTest::Skip() || command_buffer_multi_device;
}

private:
static constexpr size_t num_channels = 4;

protected:
const size_t img_width = 512;
const size_t img_height = 512;
const size_t origin[3] = { 0, 0, 0 };
const size_t region[3] = { img_width, img_height, 1 };
const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 };
static constexpr size_t img_width = 512;
static constexpr size_t img_height = 512;
static constexpr size_t origin[3] = { 0, 0, 0 };
static constexpr size_t region[3] = { img_width, img_height, 1 };
static constexpr cl_image_format format = { CL_RGBA, CL_UNSIGNED_INT8 };
static constexpr size_t data_size =
img_width * img_height * num_channels * sizeof(uint8_t);
clMemWrapper image;
clMemWrapper buffer;
const size_t data_size = img_width * img_height * sizeof(cl_char);
clMemWrapper in_mem;
clMemWrapper out_mem;
};

template <bool check_image_support>
constexpr size_t CommandBufferCopyBaseTest<check_image_support>::origin[3];
template <bool check_image_support>
constexpr size_t CommandBufferCopyBaseTest<check_image_support>::region[3];
template <bool check_image_support>
constexpr cl_image_format
CommandBufferCopyBaseTest<check_image_support>::format;

namespace {

// CL_INVALID_COMMAND_QUEUE if command_queue is not NULL.
Expand Down Expand Up @@ -226,7 +238,7 @@ struct CommandBufferCopyImageDifferentContexts
context1 = clCreateContext(0, 1, &device, nullptr, nullptr, &error);
test_error(error, "Failed to create context");

image_ctx = create_image_2d(context1, CL_MEM_READ_WRITE, &formats,
image_ctx = create_image_2d(context1, CL_MEM_READ_WRITE, &format,
img_width, img_height, 0, NULL, &error);
test_error(error, "create_image_2d failed");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest
TEST_FAIL);

error = clCommandCopyImageToBufferKHR(
command_buffer, nullptr, nullptr, src_image, dst_image_ctx, origin,
command_buffer, nullptr, nullptr, src_image, out_mem_ctx, origin,
region, 0, 0, nullptr, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_CONTEXT,
Expand Down Expand Up @@ -192,6 +192,12 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest
elements / 64, 64, 0, NULL, &error);
test_error(error, "create_image_2d failed");

out_mem_ctx = clCreateBuffer(context1, CL_MEM_WRITE_ONLY,
sizeof(cl_int) * num_elements
* buffer_size_multiplier,
nullptr, &error);
test_error(error, "clCreateBuffer failed");

queue1 = clCreateCommandQueue(context1, device, 0, &error);
test_error(error, "clCreateCommandQueue failed");

Expand All @@ -202,6 +208,7 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest
clCommandQueueWrapper queue1;
clMemWrapper src_image_ctx;
clMemWrapper dst_image_ctx;
clMemWrapper out_mem_ctx;
};

// CL_INVALID_SYNC_POINT_WAIT_LIST_KHR if sync_point_wait_list is NULL and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,22 @@ struct GetCommandBufferInfo : public BasicCommandBufferTest

cl_int RunPropArrayInfoTest()
{
std::vector<cl_command_buffer_properties_khr> properties;
properties.resize(number_of_properties);

cl_int error = clGetCommandBufferInfoKHR(
command_buffer, CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR,
number_of_properties * sizeof(cl_command_buffer_properties_khr) - 1,
properties.data(), nullptr);

test_failure_error_ret(error, CL_INVALID_VALUE,
"clGetCommandBufferInfoKHR should return "
"CL_INVALID_VALUE",
TEST_FAIL);
if (0 != number_of_properties)
{
std::vector<cl_command_buffer_properties_khr> properties;
properties.resize(number_of_properties);

cl_int error = clGetCommandBufferInfoKHR(
command_buffer, CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR,
number_of_properties * sizeof(cl_command_buffer_properties_khr)
- 1,
properties.data(), nullptr);

test_failure_error_ret(error, CL_INVALID_VALUE,
"clGetCommandBufferInfoKHR should return "
"CL_INVALID_VALUE",
TEST_FAIL);
}

return TEST_PASS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ __kernel void printf_kernel() {
}
)";

error = build_program_create_kernel_helper(context, &program, &kernel,
1, &kernel_str,
"printf_kernel", nullptr);
test_error(error, "build_program_create_kernel_helper failed");
error =
create_single_kernel_helper(context, &program, &kernel, 1,
&kernel_str, "printf_kernel", nullptr);
test_error(error, "create_single_kernel_helper failed");

return CL_SUCCESS;
}
Expand Down Expand Up @@ -407,10 +407,10 @@ enqueue_kernel(def_q, CLK_ENQUEUE_FLAGS_WAIT_KERNEL, ndrange,
)";
std::string build_options = std::string(" ") + cl_std;

error = build_program_create_kernel_helper(
context, &program, &kernel, 1, &kernel_str, "enqueue_call_kernel",
build_options.c_str());
test_error(error, "build_program_create_kernel_helper failed");
error = create_single_kernel_helper(context, &program, &kernel, 1,
&kernel_str, "enqueue_call_kernel",
build_options.c_str());
test_error(error, "create_single_kernel_helper failed");

return CL_SUCCESS;
}
Expand Down
Loading