#include #include #include #include "util.h" int main (int argc, char ** argv) { int i,j; struct cltest_context context; cl_int error; cl_mem out_buffer; int out_data[100]; size_t global_work_size = 10; if (!clTestSimpleInit(&context, "loop")) { return EXIT_FAILURE; } out_buffer = clCreateBuffer(context.cl_ctx, CL_MEM_WRITE_ONLY, sizeof(out_data), NULL, &error); assert(error == CL_SUCCESS); if (!clTestKernelSetArg(context.kernel, 0, sizeof(cl_mem), &out_buffer)) { return EXIT_FAILURE; } error = clEnqueueNDRangeKernel(context.command_queue, context.kernel, 1, NULL, &global_work_size, &global_work_size, 0, NULL, NULL); assert(error == CL_SUCCESS); error = clEnqueueReadBuffer(context.command_queue, out_buffer, CL_TRUE, 0, sizeof(out_data), out_data, 0, NULL, NULL); assert(error == CL_SUCCESS); for (i = 0; i < global_work_size; i++) { for (j = 0; j < 10; j++) { fprintf(stderr, "%2u ", out_data[i * global_work_size + j]); } fprintf(stderr, "\n"); } }