test_event_free: check for image support
Don't run image-related tests if images are not supported.
@@ -33,16 +33,25 @@ int main(int argc, char **argv)
cl_context ctx;
cl_command_queue queue;
cl_device_id did;
+ cl_bool has_img = CL_FALSE;
+
+ const size_t buf_size = sizeof(cl_int);
+
+ cl_mem buf, img;
+
+
poclu_get_any_device(&ctx, &did, &queue);
TEST_ASSERT(ctx);
TEST_ASSERT(did);
TEST_ASSERT(queue);
- const size_t buf_size = sizeof(cl_int);
- cl_mem buf = clCreateBuffer(ctx, CL_MEM_READ_WRITE, buf_size, NULL, &err);
+ CHECK_CL_ERROR (clGetDeviceInfo (did, CL_DEVICE_IMAGE_SUPPORT, sizeof(has_img), &has_img, NULL));
+
+ buf = clCreateBuffer(ctx, CL_MEM_READ_WRITE, buf_size, NULL, &err);
CHECK_OPENCL_ERROR_IN("clCreateBuffer");
+ if (has_img) {
cl_image_format img_fmt = {
.image_channel_order = CL_RGBA,
.image_channel_data_type = CL_UNSIGNED_INT32 };
@@ -59,9 +68,10 @@ int main(int argc, char **argv)
.buffer = NULL,
};
- cl_mem img = clCreateImage(ctx, CL_MEM_READ_WRITE,
+ img = clCreateImage(ctx, CL_MEM_READ_WRITE,
&img_fmt, &img_dsc, NULL, &err);
CHECK_OPENCL_ERROR_IN("clCreateImage");
+ }
/* An invalid waiting list (e.g. a null event in it) should make
* associated commands fail without segfaults and without touching any associated
@@ -133,6 +143,7 @@ int main(int argc, char **argv)
* Test image commands
*/
+ if (has_img) {
cl_int color = 0;
const size_t origin[] = {0, 0, 0};
const size_t region[] = {1, 1, 1};
@@ -197,6 +208,7 @@ int main(int argc, char **argv)
TEST_ASSERT(map_event == initial_value);
}
+ }
err = clEnqueueMarkerWithWaitList(queue, 1, &no_event, NULL);
TEST_ASSERT(err == CL_INVALID_EVENT_WAIT_LIST);
@@ -209,6 +221,7 @@ int main(int argc, char **argv)
}
clFinish (queue);
+ if (has_img)
clReleaseMemObject (img);
clReleaseMemObject (buf);
