aboutsummaryrefslogtreecommitdiff
path: root/trampoline.c
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-02-12 21:04:58 +1300
committerDavid Phillips <david@sighup.nz>2017-02-12 21:12:05 +1300
commit6605c05adf8775eddb1d4045b408895e0183f931 (patch)
treeedb9333d528d8fa22b900bbf7cccc57966cbe945 /trampoline.c
parentc83eacc524ffd0cc3e93a2b88ea69e98c04859ec (diff)
downloadfractal-gen-opencl-6605c05adf8775eddb1d4045b408895e0183f931.tar.xz
Add stringy CL error messages
Diffstat (limited to 'trampoline.c')
-rw-r--r--trampoline.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/trampoline.c b/trampoline.c
index 2dbccc9..fcc3402 100644
--- a/trampoline.c
+++ b/trampoline.c
@@ -2,6 +2,7 @@
#include <string.h>
#include <opencl.h>
+#include "cl_error.h"
#include "slurp.h"
static cl_platform_id platform;
@@ -92,8 +93,10 @@ int tramp_load_kernel(const char *filename)
program = clCreateProgramWithSource(context, 1, (const char **)&source, &length, &res);
- if (res != CL_SUCCESS)
+ if (res != CL_SUCCESS) {
+ fprintf(stderr, "Failed to create program from source code: %s ", get_cl_error_string(res));
return 1;
+ }
free(source);
source = NULL;
@@ -156,21 +159,30 @@ int tramp_set_kernel_args(unsigned int s, unsigned int it)
size = s;
iterations = it;
-
device_buffer = clCreateBuffer(context, CL_MEM_WRITE_ONLY, size*size, NULL, &ret);
if (ret != CL_SUCCESS)
return 1;
ret = clSetKernelArg(kernel, 0, sizeof(cl_mem), &device_buffer);
- fprintf(stderr, "first: %d\n", ret);
+ if (ret != CL_SUCCESS) {
+ fprintf(stderr, "Error on buffer argument: %s ", get_cl_error_string(ret));
+ return 1;
+ }
+
ret = clSetKernelArg(kernel, 1, sizeof(unsigned int), &size);
- fprintf(stderr, "first: %d\n", ret);
+ if (ret != CL_SUCCESS) {
+ fprintf(stderr, "Error on size argument: %s ", get_cl_error_string(ret));
+ return 1;
+ }
+
ret = clSetKernelArg(kernel, 2, sizeof(unsigned int), &iterations);
- fprintf(stderr, "first: %d\n", ret);
+ if (ret != CL_SUCCESS) {
+ fprintf(stderr, "Error on iteration argument: %s ", get_cl_error_string(ret));
+ return 1;
+ }
- /* FIXME check all clSetKernelArg */
- return ret != CL_SUCCESS;
+ return 0;
}
int tramp_run_kernel()