From d425853dd9111b68def72fc25c949aa9f12146a2 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 26 Mar 2012 15:55:08 -0400 Subject: Add clSimpleEnqueueReadBuffer() Also a better error mesage for clCreateBuffer() --- cl_simple.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/cl_simple.c b/cl_simple.c index eddfe21..169807a 100644 --- a/cl_simple.c +++ b/cl_simple.c @@ -75,7 +75,29 @@ unsigned clSimpleCreateBuffer(cl_mem * buffer, cl_context context, &error); /* error code */ if (error != CL_SUCCESS) { - fprintf(stderr, "clCreateBuffer() failed: %s\n", clUtilErrorString(error)); + fprintf(stderr, "clCreateBuffer(%p, %p, %u, %u) failed: %s\n", + buffer, context, flags, size, + clUtilErrorString(error)); + return 0; + } + + return 1; +} + +unsigned clSimpleEnqueueWriteBuffer(cl_command_queue command_queue, + cl_mem buffer, size_t buffer_size, void * ptr) +{ + + cl_int error = clEnqueueWriteBuffer(command_queue, + buffer, + CL_TRUE, /* Blocking write */ + 0, /* Offset into buffer */ + buffer_size, + ptr, + 0, /* Events in waiting list */ + NULL, /* Wait list */ + NULL); /* Event */ + if (error != CL_SUCCESS) { return 0; } -- cgit v1.2.3