Variadic Macros in OpenCL: Where are they supported? -
i have been trying find information on (non-standard, cf. 1.0, 1.1, 1.2, 2.0) support variadic macros in opencl implementations.
i have access following platforms, of support variadic macros:
- mac os x, intel cpu, opencl 1.2, driver: 1.1
- mac os x, intel gpu, opencl 1.2, driver: 1.2(dec 23 2014 00:18:31)
- mac os x, ati gpu, opencl 1.2, driver: 1.2 (aug 17 2014 20:27:52)
- mac os x, nvidia gpu, opencl 1.2, driver: 10.2.7 310.41.25f01
could other please check available implementations can have map of implementations supported variadic macros?
edit: here self-contained test program makes uses of variadic macro.
#include <stdlib.h> #include <stdio.h> #ifdef __apple__ #include <opencl/opencl.h> #else #include <cl/cl.h> #endif const char* source = "#define kernel(name, ...) kernel void name(__va_args__) \n" " \n" "kernel(test, global float* input, global float* output) \n" "{ \n" " int = get_global_id(0); \n" " output[i] = input[i]; \n" "} \n" " \n" ; static const int gpu = 1; int main(int argc, char** argv) { int err; cl_float input[16]; cl_float output[16]; size_t global = 16; size_t local = 16; cl_platform_id platform_id; cl_device_id device_id; cl_context context; cl_command_queue command_queue; cl_program program; cl_kernel kernel; cl_mem input_buf; cl_mem output_buf; err = clgetplatformids(1, &platform_id, null); if(err != cl_success) { printf("error: clgetplatformids\n"); return exit_failure; } err = clgetdeviceids(platform_id, gpu ? cl_device_type_gpu : cl_device_type_cpu, 1, &device_id, null); if(err != cl_success) { printf("error: clgetdeviceids\n"); return exit_failure; } context = clcreatecontext(0, 1, &device_id, null, null, &err); if(err != cl_success) { printf("error: clcreatecontext\n"); return exit_failure; } command_queue = clcreatecommandqueue(context, device_id, 0, &err); if(err != cl_success) { printf("error: clcreatecommandqueue\n"); return exit_failure; } program = clcreateprogramwithsource(context, 1, &source, null, &err); if(err != cl_success) { printf("error: clcreateprogramwithsource\n"); return exit_failure; } err = clbuildprogram(program, 0, null, null, null, null); if (err != cl_success) { size_t len; char buffer[2048]; printf("error: clbuildprogram\n"); clgetprogrambuildinfo(program, device_id, cl_program_build_log, sizeof(buffer), buffer, &len); printf("%s\n", buffer); return exit_failure; } kernel = clcreatekernel(program, "test", &err); if(err != cl_success) { printf("error: clcreatekernel\n"); return exit_failure; } input_buf = clcreatebuffer(context, cl_mem_read_only, 16*sizeof(cl_float), null, null); output_buf = clcreatebuffer(context, cl_mem_write_only, 16*sizeof(cl_float), null, null); if(!input_buf || !output_buf) { printf("error: clcreatebuffer\n"); return exit_failure; } err = clenqueuewritebuffer(command_queue, input_buf, cl_true, 0, 16*sizeof(cl_float), input, 0, null, null); if(err != cl_success) { printf("error: clenqueuewritebuffer\n"); return exit_failure; } err = 0; err |= clsetkernelarg(kernel, 0, sizeof(cl_mem), &input_buf); err |= clsetkernelarg(kernel, 1, sizeof(cl_mem), &output_buf); if(err != cl_success) { printf("error: clsetkernelarg\n"); return exit_failure; } err = clenqueuendrangekernel(command_queue, kernel, 1, null, &global, &local, 0, null, null); if(err != cl_success) { printf("error: clenqueuendrangekernel\n"); return exit_failure; } clfinish(command_queue); err = clenqueuereadbuffer(command_queue, output_buf, cl_true, 0, 16*sizeof(cl_float), output, 0, null, null ); if(err != cl_success) { printf("error: clenqueuereadbuffer\n"); return exit_failure; } clreleasememobject(input_buf); clreleasememobject(output_buf); clreleaseprogram(program); clreleasekernel(kernel); clreleasecommandqueue(command_queue); clreleasecontext(context); printf("success\n"); return exit_success; }
for posterity, answer myself list of platforms tested support of variadic macros. future visitor, please feel free add platform can test list.
supported:
- mac os x, intel cpu, opencl 1.2, driver: 1.1
- mac os x, intel gpu, opencl 1.2, driver: 1.2(dec 23 2014 00:18:31)
- mac os x, ati gpu, opencl 1.2, driver: 1.2 (aug 17 2014 20:27:52)
- debian unstable, amd gpu, opencl 2.0, driver: amdgpu-pro 16.15.2-277429
- mac os x, nvidia gpu, opencl 1.2, driver: 10.2.7 310.41.25f01
- redhat enterprise linux 5, nvidia cuda sdk 4.0, opencl 1.0 cuda, driver: 260.19.26
unsupported:
- debian unstable, intel gpu, opencl 1.2, driver: beignet 1.1.1
Comments
Post a Comment