diff options
Diffstat (limited to 'src/compute/skc/platforms/cl_12/cq_pool_cl.c')
-rw-r--r-- | src/compute/skc/platforms/cl_12/cq_pool_cl.c | 96 |
1 files changed, 77 insertions, 19 deletions
diff --git a/src/compute/skc/platforms/cl_12/cq_pool_cl.c b/src/compute/skc/platforms/cl_12/cq_pool_cl.c index 80cfe34cf8..8d1537dc40 100644 --- a/src/compute/skc/platforms/cl_12/cq_pool_cl.c +++ b/src/compute/skc/platforms/cl_12/cq_pool_cl.c @@ -7,17 +7,18 @@ */ // -// +// squelch OpenCL 1.2 deprecation warning // -#ifndef NDEBUG -#include <stdio.h> +#ifndef CL_USE_DEPRECATED_OPENCL_1_2_APIS +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS #endif // // // +#include <stdio.h> #include <string.h> // @@ -25,6 +26,7 @@ // #include "runtime_cl_12.h" +#include "common/cl/assert_cl.h" // // This implementation is probably excessive. @@ -40,21 +42,77 @@ // // +static +cl_command_queue +skc_runtime_cl_12_create_cq(struct skc_runtime * const runtime, + struct skc_cq_pool * const pool) + +{ + cl_command_queue cq; + +#if 1 + // + // <= OpenCL 1.2 + // + cl_int cl_err; + + cq = clCreateCommandQueue(runtime->cl.context, + runtime->cl.device_id, + pool->cq_props, + &cl_err); cl_ok(cl_err); +#else + if (runtime_cl->version.major < 2) + { + // + // <= OpenCL 1.2 + // + cl_int cl_err; + + cq = clCreateCommandQueue(runtime_cl->context, + runtime_cl->device_id, + (cl_command_queue_properties)type, + &cl_err); cl_ok(cl_err); + } + else + { + // + // >= OpenCL 2.0 + // + cl_int cl_err; + cl_queue_properties const queue_properties[] = { + CL_QUEUE_PROPERTIES,(cl_queue_properties)type,0 + }; + + cq = clCreateCommandQueueWithProperties(runtime_cl->context, + runtime_cl->device_id, + queue_properties, + &cl_err); cl_ok(cl_err); + } +#endif + + return cq; +} + +// +// +// + void -skc_cq_pool_create(struct skc_runtime * const runtime, - struct skc_cq_pool * const pool, - skc_uint const type, - skc_uint const size) +skc_cq_pool_create(struct skc_runtime * const runtime, + struct skc_cq_pool * const pool, + cl_command_queue_properties const cq_props, + skc_uint const size) { - pool->type = type; - pool->size = size + 1; // an empty spot - pool->reads = 0; - pool->writes = size; - pool->cq = skc_runtime_host_perm_alloc(runtime,SKC_MEM_FLAGS_READ_WRITE,pool->size * sizeof(*pool->cq)); + pool->size = size + 1; // an empty spot + pool->reads = 0; + pool->writes = size; + + pool->cq_props = cq_props; + pool->cq = skc_runtime_host_perm_alloc(runtime,SKC_MEM_FLAGS_READ_WRITE, + pool->size * sizeof(*pool->cq)); + for (skc_uint ii=0; ii<size; ii++) + pool->cq[ii] = skc_runtime_cl_12_create_cq(runtime,pool); - for (skc_uint ii=0; ii<size; ii++) { - pool->cq[ii] = skc_runtime_cl_create_cq(&runtime->cl,pool->type); - } pool->cq[size] = NULL; } @@ -77,7 +135,7 @@ skc_cq_pool_dispose(struct skc_runtime * const runtime, // // -static +static void skc_cq_pool_write(struct skc_cq_pool * const pool, cl_command_queue cq) @@ -109,14 +167,14 @@ skc_cq_pool_expand(struct skc_runtime * const runtime, pool->writes = expand; for (skc_uint ii=0; ii<expand; ii++) - pool->cq[ii] = skc_runtime_cl_create_cq(&runtime->cl,pool->type); + pool->cq[ii] = skc_runtime_cl_12_create_cq(runtime,pool); } // // // -static +static cl_command_queue skc_cq_pool_read(struct skc_runtime * const runtime, struct skc_cq_pool * const pool) @@ -141,7 +199,7 @@ skc_runtime_acquire_cq_in_order(struct skc_runtime * const runtime) } void -skc_runtime_release_cq_in_order(struct skc_runtime * const runtime, +skc_runtime_release_cq_in_order(struct skc_runtime * const runtime, cl_command_queue cq) { skc_cq_pool_write(&runtime->cq_pool,cq); |