Skip to content

Commit

Permalink
Added major and minor corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-goras-mobica committed May 20, 2024
1 parent b16b222 commit be9d2f3
Showing 1 changed file with 71 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,57 @@
#include <vector>

//--------------------------------------------------------------------------
struct CommandFillBaseTest : BasicCommandBufferTest
{
CommandFillBaseTest(cl_device_id device, cl_context context,
cl_command_queue queue)
: BasicCommandBufferTest(device, context, queue)
{}

cl_int SetUp(int elements) override
{
cl_int error = BasicCommandBufferTest::SetUp(elements);
test_error(error, "BasicCommandBufferTest::SetUp failed");

src_image = create_image_2d(context, CL_MEM_WRITE_ONLY, &formats, 512,
512, 0, NULL, &error);
test_error(error, "create_image_2d failed");

dst_image = create_image_2d(context, CL_MEM_READ_ONLY, &formats, 512,
512, 0, NULL, &error);
test_error(error, "create_image_2d failed");

return CL_SUCCESS;
}

bool Skip() override
{
cl_bool image_support;

cl_int error =
clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT,
sizeof(image_support), &image_support, nullptr);
test_error(error, "clGetDeviceInfo for CL_DEVICE_IMAGE_SUPPORT failed");

return (!image_support || BasicCommandBufferTest::Skip());
}

protected:
clMemWrapper src_image;
clMemWrapper dst_image;
const cl_uint fill_color_1[4] = { 0x05, 0x05, 0x05, 0x05 };
const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 };
const size_t origin[3] = { 0, 0, 0 };
const size_t region[3] = { 512, 512, 1 };
const cl_int pattern = 0xFF;
};

namespace {

// CL_INVALID_COMMAND_QUEUE if command_queue is not NULL.
struct CommandBufferCommandFillQueueNotNull : public BasicCommandBufferTest
struct CommandBufferCommandFillQueueNotNull : public CommandFillBaseTest
{
using BasicCommandBufferTest::BasicCommandBufferTest;
using CommandFillBaseTest::CommandFillBaseTest;

cl_int Run() override
{
Expand All @@ -48,31 +93,19 @@ struct CommandBufferCommandFillQueueNotNull : public BasicCommandBufferTest
return CL_SUCCESS;
}

cl_int SetUp(int elements) override
bool Skip() override
{
cl_int error = BasicCommandBufferTest::SetUp(elements);
test_error(error, "BasicCommandBufferTest::SetUp failed");

src_image = create_image_2d(context, CL_MEM_WRITE_ONLY, &formats, 512,
512, 0, NULL, &error);
test_error(error, "create_image_2d failed");

return CL_SUCCESS;
return CommandFillBaseTest::Skip()
|| is_extension_available(device,
"cl_khr_command_buffer_multi_device");
}

clMemWrapper src_image;
const cl_uint fill_color_1[4] = { 0x05, 0x05, 0x05, 0x05 };
const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 };
const size_t origin[3] = { 0, 0, 0 };
const size_t region[3] = { 512, 512, 1 };
const cl_int pattern = 0xFF;
};

// CL_INVALID_CONTEXT if the context associated with command_queue,
// command_buffer, and buffer are not the same.
struct CommandBufferCommandFillContextNotSame : public BasicCommandBufferTest
struct CommandBufferCommandFillContextNotSame : public CommandFillBaseTest
{
using BasicCommandBufferTest::BasicCommandBufferTest;
using CommandFillBaseTest::CommandFillBaseTest;

cl_int Run() override
{
Expand All @@ -94,34 +127,13 @@ struct CommandBufferCommandFillContextNotSame : public BasicCommandBufferTest
"CL_INVALID_CONTEXT",
TEST_FAIL);

command_buffer = clCreateCommandBufferKHR(1, &queue1, 0, &error);
test_error(error, "clCreateCommandBufferKHR failed");

error = clCommandFillBufferKHR(command_buffer, nullptr, out_mem,
&pattern, sizeof(cl_int), 0, data_size(),
0, nullptr, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_CONTEXT,
"clCommandFillBufferKHR should return "
"CL_INVALID_CONTEXT",
TEST_FAIL);

error = clCommandFillImageKHR(command_buffer, nullptr, dst_image,
fill_color_1, origin, region, 0, nullptr,
nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_CONTEXT,
"clCommandFillImageKHR should return "
"CL_INVALID_CONTEXT",
TEST_FAIL);

return CL_SUCCESS;
}

cl_int SetUp(int elements) override
{
cl_int error = BasicCommandBufferTest::SetUp(elements);
test_error(error, "BasicCommandBufferTest::SetUp failed");
cl_int error = CommandFillBaseTest::SetUp(elements);
test_error(error, "CommandFillBaseTest::SetUp failed");

context1 = clCreateContext(0, 1, &device, nullptr, nullptr, &error);
test_error(error, "Failed to create context");
Expand All @@ -135,55 +147,39 @@ struct CommandBufferCommandFillContextNotSame : public BasicCommandBufferTest
512, 512, 0, NULL, &error);
test_error(error, "create_image_2d failed");

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

dst_image = create_image_2d(context, CL_MEM_WRITE_ONLY, &formats, 512,
512, 0, NULL, &error);
test_error(error, "create_image_2d failed");

return CL_SUCCESS;
}

clContextWrapper context1;
clCommandQueueWrapper queue1;
clMemWrapper out_mem_ctx;
clMemWrapper dst_image;
clMemWrapper dst_image_ctx;
const cl_uint fill_color_1[4] = { 0x05, 0x05, 0x05, 0x05 };
const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 };
const size_t origin[3] = { 0, 0, 0 };
const size_t region[3] = { 512, 512, 1 };
const cl_int pattern = 0xFF;
};

// CL_INVALID_SYNC_POINT_WAIT_LIST_KHR if sync_point_wait_list is NULL and
// num_sync_points_in_wait_list is > 0, or sync_point_wait_list is not NULL and
// num_sync_points_in_wait_list is 0, or if synchronization-point objects in
// sync_point_wait_list are not valid synchronization-points.
struct CommandBufferCommandFillSyncPointsNullOrNumZero
: public BasicCommandBufferTest
: public CommandFillBaseTest
{
using BasicCommandBufferTest::BasicCommandBufferTest;
using CommandFillBaseTest::CommandFillBaseTest;

cl_int Run() override
{
cl_sync_point_khr invalid_point = 0;
std::vector<cl_sync_point_khr*> invalid_sync_points;
invalid_sync_points.push_back(&invalid_point);

cl_int error = clCommandFillBufferKHR(
command_buffer, nullptr, out_mem, &pattern, sizeof(cl_int), 0,
data_size(), 1, *invalid_sync_points.data(), nullptr, nullptr);
data_size(), 1, &invalid_point, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR,
"clCommandFillBufferKHR should return "
"CL_INVALID_SYNC_POINT_WAIT_LIST_KHR",
TEST_FAIL);

error = clCommandFillImageKHR(
command_buffer, nullptr, dst_image, fill_color_1, origin, region, 1,
*invalid_sync_points.data(), nullptr, nullptr);
error = clCommandFillImageKHR(command_buffer, nullptr, dst_image,
fill_color_1, origin, region, 1,
&invalid_point, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR,
"clCommandFillImageKHR should return "
Expand Down Expand Up @@ -213,21 +209,19 @@ struct CommandBufferCommandFillSyncPointsNullOrNumZero
error = clCommandBarrierWithWaitListKHR(command_buffer, nullptr, 0,
nullptr, &point, nullptr);
test_error(error, "clCommandBarrierWithWaitListKHR failed");
std::vector<cl_sync_point_khr> sync_points;
sync_points.push_back(point);

error = clCommandFillBufferKHR(command_buffer, nullptr, out_mem,
&pattern, sizeof(cl_int), 0, data_size(),
0, sync_points.data(), nullptr, nullptr);
0, &point, nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR,
"clCommandFillBufferKHR should return "
"CL_INVALID_SYNC_POINT_WAIT_LIST_KHR",
TEST_FAIL);

error = clCommandFillImageKHR(command_buffer, nullptr, dst_image,
fill_color_1, origin, region, 0,
sync_points.data(), nullptr, nullptr);
fill_color_1, origin, region, 0, &point,
nullptr, nullptr);

test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR,
"clCommandFillImageKHR should return "
Expand All @@ -237,33 +231,13 @@ struct CommandBufferCommandFillSyncPointsNullOrNumZero

return CL_SUCCESS;
}

cl_int SetUp(int elements) override
{
cl_int error = BasicCommandBufferTest::SetUp(elements);
test_error(error, "BasicCommandBufferTest::SetUp failed");

dst_image = create_image_2d(context, CL_MEM_READ_ONLY, &formats, 512,
512, 0, NULL, &error);
test_error(error, "create_image_2d failed");

return CL_SUCCESS;
}

clMemWrapper dst_image;
const cl_uint fill_color_1[4] = { 0x05, 0x05, 0x05, 0x05 };
const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 };
const size_t origin[3] = { 0, 0, 0 };
const size_t region[3] = { 512, 512, 1 };
const cl_int pattern = 0xFF;
};

// CL_INVALID_COMMAND_BUFFER_KHR if command_buffer is not a valid
// command-buffer.
struct CommandBufferCommandFillInvalidCommandBuffer
: public BasicCommandBufferTest
struct CommandBufferCommandFillInvalidCommandBuffer : public CommandFillBaseTest
{
using BasicCommandBufferTest::BasicCommandBufferTest;
using CommandFillBaseTest::CommandFillBaseTest;

cl_int Run() override
{
Expand All @@ -287,32 +261,13 @@ struct CommandBufferCommandFillInvalidCommandBuffer

return CL_SUCCESS;
}

cl_int SetUp(int elements) override
{
cl_int error = BasicCommandBufferTest::SetUp(elements);
test_error(error, "BasicCommandBufferTest::SetUp failed");

dst_image = create_image_2d(context, CL_MEM_WRITE_ONLY, &formats, 512,
512, 0, NULL, &error);
test_error(error, "create_image_2d failed");

return CL_SUCCESS;
}

clMemWrapper dst_image;
const cl_uint fill_color_1[4] = { 0x05, 0x05, 0x05, 0x05 };
const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 };
const size_t origin[3] = { 0, 0, 0 };
const size_t region[3] = { 512, 512, 1 };
const cl_int pattern = 0xFF;
};

// CL_INVALID_OPERATION if command_buffer has been finalized.
struct CommandBufferCommandFillFinalizedCommandBuffer
: public BasicCommandBufferTest
: public CommandFillBaseTest
{
using BasicCommandBufferTest::BasicCommandBufferTest;
using CommandFillBaseTest::CommandFillBaseTest;

cl_int Run() override
{
Expand All @@ -339,32 +294,12 @@ struct CommandBufferCommandFillFinalizedCommandBuffer

return CL_SUCCESS;
}

cl_int SetUp(int elements) override
{
cl_int error = BasicCommandBufferTest::SetUp(elements);
test_error(error, "BasicCommandBufferTest::SetUp failed");

dst_image = create_image_2d(context, CL_MEM_WRITE_ONLY, &formats, 512,
512, 0, NULL, &error);
test_error(error, "create_image_2d failed");

return CL_SUCCESS;
}

clMemWrapper dst_image;
const cl_uint fill_color_1[4] = { 0x05, 0x05, 0x05, 0x05 };
const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 };
const size_t origin[3] = { 0, 0, 0 };
const size_t region[3] = { 512, 512, 1 };
const cl_int pattern = 0xFF;
};

// CL_INVALID_VALUE if mutable_handle is not NULL.
struct CommandBufferCommandFillMutableHandleNotNull
: public BasicCommandBufferTest
struct CommandBufferCommandFillMutableHandleNotNull : public CommandFillBaseTest
{
using BasicCommandBufferTest::BasicCommandBufferTest;
using CommandFillBaseTest::CommandFillBaseTest;

cl_int Run() override
{
Expand All @@ -390,27 +325,8 @@ struct CommandBufferCommandFillMutableHandleNotNull

return CL_SUCCESS;
}

cl_int SetUp(int elements) override
{
cl_int error = BasicCommandBufferTest::SetUp(elements);
test_error(error, "BasicCommandBufferTest::SetUp failed");

dst_image = create_image_2d(context, CL_MEM_WRITE_ONLY, &formats, 512,
512, 0, NULL, &error);
test_error(error, "create_image_2d failed");

return CL_SUCCESS;
}

clMemWrapper dst_image;
const cl_uint fill_color_1[4] = { 0x05, 0x05, 0x05, 0x05 };
const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 };
const size_t origin[3] = { 0, 0, 0 };
const size_t region[3] = { 512, 512, 1 };
const cl_int pattern = 0xFF;
};
};
}

int test_negative_command_buffer_command_fill_queue_not_null(
cl_device_id device, cl_context context, cl_command_queue queue,
Expand Down

0 comments on commit be9d2f3

Please sign in to comment.