diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2012-03-16 13:57:59 -0400 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2012-03-16 13:57:59 -0400 |
commit | 061ffcad78e9dd6bf9efccdeb3ce27bcd7606c00 (patch) | |
tree | c6d4983dc796e75ea435e41f781712d26acd2e17 | |
parent | 2327d7372e8583f3349a50a78811d77b41c0037c (diff) |
Add clSimpleCreateBuffer
-rw-r--r-- | cl_simple.c | 29 | ||||
-rw-r--r-- | cl_simple.h | 2 |
2 files changed, 23 insertions, 8 deletions
diff --git a/cl_simple.c b/cl_simple.c index 2752027..eddfe21 100644 --- a/cl_simple.c +++ b/cl_simple.c @@ -63,6 +63,25 @@ unsigned clSimpleKernelSetArg(cl_kernel kernel, cl_uint index, size_t size, return 1; } +unsigned clSimpleCreateBuffer(cl_mem * buffer, cl_context context, + cl_mem_flags flags, size_t size) +{ + cl_int error; + + *buffer = clCreateBuffer(context, + flags, /* Flags */ + size, /* Size of buffer */ + NULL, /* Pointer to the data */ + &error); /* error code */ + + if (error != CL_SUCCESS) { + fprintf(stderr, "clCreateBuffer() failed: %s\n", clUtilErrorString(error)); + return 0; + } + + return 1; +} + unsigned clSimpleEnqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t * global_work_size, const size_t * local_work_size) @@ -264,14 +283,8 @@ unsigned clSimpleSetOutputBuffer(struct cl_simple_context * context, { cl_int error; - context->out_buffer = clCreateBuffer(context->cl_ctx, - CL_MEM_WRITE_ONLY, /* Flags */ - buffer_size, /* Size of buffer */ - NULL, /* Pointer to the data */ - &error); /* error code */ - - if (error != CL_SUCCESS) { - fprintf(stderr, "clCreateBuffer() failed: %s\n", clUtilErrorString(error)); + if (!clSimpleCreateBuffer(&context->out_buffer, context->cl_ctx, + CL_MEM_WRITE_ONLY, buffer_size)) { return 0; } diff --git a/cl_simple.h b/cl_simple.h index 44a8b16..6bde48e 100644 --- a/cl_simple.h +++ b/cl_simple.h @@ -12,6 +12,8 @@ unsigned clSimpleCreateCommandQueue(cl_command_queue * command_queue, cl_context context, cl_device_id device_id); unsigned clSimpleKernelSetArg(cl_kernel kernel, cl_uint index, size_t size, const void * value); +unsigned clSimpleCreateBuffer(cl_mem * buffer, cl_context context, + cl_mem_flags flags, size_t size); unsigned clSimpleEnqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t * global_work_size, const size_t * local_work_size); |