Skip to content

Commit

Permalink
cl_fill_image: Use CL_DEVICE_VERSION for version check
Browse files Browse the repository at this point in the history
CL_DEVICE_NUMERIC_VERSION is only available from OpenCL 3.0
Use CL_DEVICE_VERSION instead.
  • Loading branch information
lakshmih committed Aug 12, 2024
1 parent a406b34 commit 510fb34
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions test_conformance/images/clFillImage/test_fill_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
//
#include "../testBase.h"

extern void read_image_pixel_float( void *imageData, image_descriptor *imageInfo, int x, int y, int z, float *outData );

struct pitch_buffer_data
Expand Down Expand Up @@ -55,9 +54,8 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr
imageDesc.image_array_size = imageInfo->arraySize;
imageDesc.image_row_pitch = gEnablePitch ? imageInfo->rowPitch : 0;
imageDesc.image_slice_pitch = gEnablePitch ? imageInfo->slicePitch : 0;

cl_version version;
cl_device_id device;
Version version;
{
cl_int err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE,
sizeof(device), &device, nullptr);
Expand All @@ -66,14 +64,7 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr
log_error("Error: Could not get CL_QUEUE_DEVICE from queue");
return NULL;
}
err = clGetDeviceInfo(device, CL_DEVICE_NUMERIC_VERSION,
sizeof(version), &version, nullptr);
if (err != CL_SUCCESS)
{
log_error("Error: Could not get CL_DEVICE_NUMERIC_VERSION from "
"device");
return NULL;
}
version = get_device_cl_version(device);
}

switch (imageInfo->type)
Expand Down Expand Up @@ -117,7 +108,8 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr
cl_mem_flags buffer_flags = CL_MEM_READ_WRITE;
if (gEnablePitch)
{
if (CL_VERSION_MAJOR(version) == 1)
int major = (version.to_int()) / 10;
if (major == 1)
{
host_ptr = malloc(imageInfo->rowPitch);
}
Expand Down Expand Up @@ -183,8 +175,9 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr
struct pitch_buffer_data *data = (struct pitch_buffer_data *)malloc(
sizeof(struct pitch_buffer_data));
data->buf = host_ptr;
data->is_aligned = (CL_VERSION_MAJOR(version) != 1)
&& (imageInfo->type == CL_MEM_OBJECT_IMAGE1D_BUFFER);
int major = (version.to_int()) / 10;
data->is_aligned =
(major != 1) && (imageInfo->type == CL_MEM_OBJECT_IMAGE1D_BUFFER);
if (*error == CL_SUCCESS)
{
int callbackError =
Expand Down

0 comments on commit 510fb34

Please sign in to comment.