summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2012-03-13 11:09:22 -0400
committerTom Stellard <thomas.stellard@amd.com>2012-03-13 11:09:53 -0400
commitd290aedf15294fc815746fe9c2931fe153c708b1 (patch)
tree08f6c1b0a5d87724dd3a2deb40bb228a26192f00
parent8cc71da413c5966ff94f016f718110057129d503 (diff)
Add cluCreateCommandQueue()
-rw-r--r--get_global_id.c11
-rw-r--r--util.c17
-rw-r--r--util.h2
3 files changed, 20 insertions, 10 deletions
diff --git a/get_global_id.c b/get_global_id.c
index 65e20d4..34fd753 100644
--- a/get_global_id.c
+++ b/get_global_id.c
@@ -29,19 +29,10 @@ int main(int argc, char ** argv)
return EXIT_FAILURE;
}
- command_queue = clCreateCommandQueue(context,
- device_id,
- 0, /* Command queue properties */
- &error); /* Error code */
-
- if (error != CL_SUCCESS) {
- fprintf(stderr, "clCreateCommandQueue() failed: %s\n",
- cluErrorString(error));
+ if (!cluCreateCommandQueue(&command_queue, context, device_id)) {
return EXIT_FAILURE;
}
- fprintf(stderr, "clCreateCommandQueue() succeeded.\n");
-
if (!cluCreateKernel(context, device_id, &kernel, "global_id")) {
return EXIT_FAILURE;
}
diff --git a/util.c b/util.c
index 3c0339d..e85bda1 100644
--- a/util.c
+++ b/util.c
@@ -106,6 +106,23 @@ unsigned cluCreateContext(cl_context * context, cl_device_id device_id)
return 1;
}
+unsigned cluCreateCommandQueue(cl_command_queue * command_queue,
+ cl_context context, cl_device_id device_id)
+{
+ cl_int error;
+ *command_queue = clCreateCommandQueue(context,
+ device_id,
+ 0, /* Command queue properties */
+ &error); /* Error code */
+
+ if (error != CL_SUCCESS) {
+ fprintf(stderr, "clCreateCommandQueue() 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 4fa074f..7589655 100644
--- a/util.h
+++ b/util.h
@@ -2,6 +2,8 @@
const char * cluErrorString(cl_int error);
unsigned cluInitGpuDevice(cl_device_id * device_id);
unsigned cluCreateContext(cl_context * context, cl_device_id device_id);
+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 cluKernelSetArg(cl_kernel kernel, cl_uint index, size_t size,