diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2012-03-13 11:25:41 -0400 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2012-03-13 11:25:41 -0400 |
commit | 5534a6e31678de2aa37d6ff4f8c9b9b8229100c9 (patch) | |
tree | 6130448573e53d1b6e2a5118beb39c05795f9163 | |
parent | d2b31e6b570e2cc3b4fd0237037d93129e9422bc (diff) |
Add cluSimpleInit
-rw-r--r-- | get_global_id.c | 18 | ||||
-rw-r--r-- | util.c | 23 | ||||
-rw-r--r-- | util.h | 1 |
3 files changed, 25 insertions, 17 deletions
diff --git a/get_global_id.c b/get_global_id.c index 2f6f266..1b41809 100644 --- a/get_global_id.c +++ b/get_global_id.c @@ -17,23 +17,7 @@ int main(int argc, char ** argv) int out_data[10]; size_t global_work_size = 10; - if (!cluInitGpuDevice(&context.device_id)) { - return EXIT_FAILURE; - } - - if (!cluCreateContext(&context.cl_ctx, context.device_id)) { - return EXIT_FAILURE; - } - - if (!cluCreateCommandQueue(&context.command_queue, context.cl_ctx, - context.device_id)) { - return EXIT_FAILURE; - } - - if (!cluCreateKernel(context.cl_ctx, context.device_id, &context.kernel, - "global_id")) { - return EXIT_FAILURE; - } + cluSimpleInit(&context, "global_id"); out_buffer = clCreateBuffer(context.cl_ctx, CL_MEM_WRITE_ONLY, /* Flags */ @@ -232,6 +232,29 @@ unsigned cluCreateKernel(cl_context context, cl_device_id device_id, return 1; } +unsigned cluSimpleInit(struct clu_context * context, const char * kernel_name) +{ + if (!cluInitGpuDevice(&context->device_id)) { + return 0; + } + + if (!cluCreateContext(&context->cl_ctx, context->device_id)) { + return 0; + } + + if (!cluCreateCommandQueue(&context->command_queue, context->cl_ctx, + context->device_id)) { + return 0; + } + + if (!cluCreateKernel(context->cl_ctx, context->device_id, &context->kernel, + kernel_name)) { + return 0; + } + + return 1; +} + unsigned cluKernelSetArg(cl_kernel kernel, cl_uint index, size_t size, const void * value) { @@ -13,5 +13,6 @@ unsigned cluCreateCommandQueue(cl_command_queue * command_queue, cl_context context, cl_device_id device_id); unsigned cluCreateKernel(cl_context context, cl_device_id device_id, cl_kernel * kernel, const char * kernel_name); +unsigned cluSimpleInit(struct clu_context * context, const char * kernel_name); unsigned cluKernelSetArg(cl_kernel kernel, cl_uint index, size_t size, const void * value); |