summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2012-03-13 11:03:34 -0400
committerTom Stellard <thomas.stellard@amd.com>2012-03-13 11:03:34 -0400
commita493703303f953fa31703b36d112c7d595efa4c7 (patch)
treedeab3e352d287be5dd2e513255ba9cb877a20ff5
parent35162ce669bd02d07c7d1e708c2932dab7248690 (diff)
Add cluCreateContext()
-rw-r--r--util.c18
-rw-r--r--util.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/util.c b/util.c
index 3a95c99..3c0339d 100644
--- a/util.c
+++ b/util.c
@@ -88,6 +88,24 @@ unsigned cluInitGpuDevice(cl_device_id * device_id)
return 1;
}
+unsigned cluCreateContext(cl_context * context, cl_device_id device_id)
+{
+ cl_int error;
+ *context = clCreateContext(NULL, /* Properties */
+ 1, /* Number of devices */
+ &device_id, /* Device pointer */
+ NULL, /* Callback for reporting errors */
+ NULL, /* User data to pass to error callback */
+ &error); /* Error code */
+
+ if (error != CL_SUCCESS) {
+ fprintf(stderr, "clCreateContext() failed: %s\n",
+ cluErrorString(error));
+ return 0;
+ }
+ return 1;
+}
+
#define CODE_CHUNK 64
unsigned cluCreateKernel(cl_context context, cl_device_id device_id,
diff --git a/util.h b/util.h
index 922ac8d..4fa074f 100644
--- a/util.h
+++ b/util.h
@@ -1,6 +1,7 @@
const char * cluErrorString(cl_int error);
unsigned cluInitGpuDevice(cl_device_id * device_id);
+unsigned cluCreateContext(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 cluKernelSetArg(cl_kernel kernel, cl_uint index, size_t size,