1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include <stdio.h>
#include <stdlib.h>
#include "poclu.h"
#define MAX_DEVICES 2
int
main(void)
{
cl_int err;
cl_image_format *img_formats;
cl_uint num_entries;
cl_platform_id pid = NULL;
cl_context ctx = NULL;
cl_device_id dev = NULL;
cl_command_queue cq = NULL;
err = poclu_get_any_device2 (&ctx, &dev, &cq, &pid);
CHECK_OPENCL_ERROR_IN("poclu_get_any_device");
TEST_ASSERT(dev != NULL);
cl_bool img_support = 0;
err = clGetDeviceInfo(dev, CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool), &img_support, 0);
CHECK_OPENCL_ERROR_IN ("clGetDeviceInfo");
if (img_support != CL_TRUE)
return 77;
err = clGetSupportedImageFormats (ctx, 0, CL_MEM_OBJECT_IMAGE2D, 0,
NULL, &num_entries);
CHECK_OPENCL_ERROR_IN("clGetSupportedImageFormats");
if (num_entries == 0)
return EXIT_SUCCESS;
img_formats = (cl_image_format*)malloc (sizeof(cl_image_format)*num_entries);
err = clGetSupportedImageFormats (ctx, 0, CL_MEM_OBJECT_IMAGE2D,
num_entries, img_formats, NULL);
CHECK_OPENCL_ERROR_IN("clGetSupportedImageFormats");
TEST_ASSERT(num_entries != 0);
CHECK_CL_ERROR (clReleaseCommandQueue (cq));
CHECK_CL_ERROR (clReleaseContext (ctx));
free (img_formats);
CHECK_CL_ERROR (clUnloadPlatformCompiler (pid));
printf ("OK\n");
return EXIT_SUCCESS;
}
|