aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGil Pitney <gil.pitney@linaro.org>2015-09-30 23:23:45 +0000
committerGil Pitney <gil.pitney@linaro.org>2015-09-30 23:23:45 +0000
commit6407a0805fd933bf1d46ca09b37ca560241dcae4 (patch)
treeca7c101839705714b0f7546ed9bed2108b96ac51
parent96d3c23a965296d620a85c090fdecdaac557d52e (diff)
downloadshamrock-6407a0805fd933bf1d46ca09b37ca560241dcae4.tar.gz
ICD: Update Kernel objects to be ICD compatible.
Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
-rw-r--r--src/api/api_enqueue.cpp11
-rw-r--r--src/api/api_kernel.cpp32
-rw-r--r--src/core/events.cpp4
-rw-r--r--src/core/kernel.h12
4 files changed, 38 insertions, 21 deletions
diff --git a/src/api/api_enqueue.cpp b/src/api/api_enqueue.cpp
index 6431cb8..1225258 100644
--- a/src/api/api_enqueue.cpp
+++ b/src/api/api_enqueue.cpp
@@ -34,6 +34,7 @@
#include <core/events.h>
#include <core/memobject.h>
+#include <core/kernel.h>
#include <cstdlib>
#include <stdio.h>
@@ -679,7 +680,7 @@ clEnqueueUnmapMemObject(cl_command_queue command_queue,
cl_int
clEnqueueNDRangeKernel(cl_command_queue command_queue,
- cl_kernel kernel,
+ cl_kernel d_kernel,
cl_uint work_dim,
const size_t * global_work_offset,
const size_t * global_work_size,
@@ -689,6 +690,7 @@ clEnqueueNDRangeKernel(cl_command_queue command_queue,
cl_event * event)
{
cl_int rs = CL_SUCCESS;
+ auto kernel = pobj(d_kernel);
if (!command_queue->isA(Coal::Object::T_CommandQueue))
{
@@ -697,7 +699,7 @@ clEnqueueNDRangeKernel(cl_command_queue command_queue,
Coal::KernelEvent *command = new Coal::KernelEvent(
(Coal::CommandQueue *)command_queue,
- (Coal::Kernel *)kernel,
+ kernel,
work_dim, global_work_offset, global_work_size, local_work_size,
num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs
);
@@ -713,12 +715,13 @@ clEnqueueNDRangeKernel(cl_command_queue command_queue,
cl_int
clEnqueueTask(cl_command_queue command_queue,
- cl_kernel kernel,
+ cl_kernel d_kernel,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event)
{
cl_int rs = CL_SUCCESS;
+ auto kernel = pobj(d_kernel);
if (!command_queue->isA(Coal::Object::T_CommandQueue))
{
@@ -727,7 +730,7 @@ clEnqueueTask(cl_command_queue command_queue,
Coal::TaskEvent *command = new Coal::TaskEvent(
(Coal::CommandQueue *)command_queue,
- (Coal::Kernel *)kernel,
+ kernel,
num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs
);
diff --git a/src/api/api_kernel.cpp b/src/api/api_kernel.cpp
index b1447b5..69deddd 100644
--- a/src/api/api_kernel.cpp
+++ b/src/api/api_kernel.cpp
@@ -75,7 +75,7 @@ clCreateKernel(cl_program d_program,
return 0;
}
- return (cl_kernel)kernel;
+ return desc(kernel);
}
cl_int
@@ -124,7 +124,7 @@ clCreateKernelsInProgram(cl_program d_program,
if (!kernels)
{
// We don't need the kernels in fact
- /* while (ks.size())
+ /* while (ks.size())
{
delete ks.back();
ks.pop_back();
@@ -135,7 +135,7 @@ clCreateKernelsInProgram(cl_program d_program,
// Copy the kernels
for (size_t i=0; i<ks.size(); ++i)
{
- kernels[i] = (cl_kernel)ks[i];
+ kernels[i] = desc(ks[i]);
}
}
@@ -143,8 +143,9 @@ clCreateKernelsInProgram(cl_program d_program,
}
cl_int
-clRetainKernel(cl_kernel kernel)
+clRetainKernel(cl_kernel d_kernel)
{
+ auto kernel = pobj(d_kernel);
if (!kernel->isA(Coal::Object::T_Kernel))
return CL_INVALID_KERNEL;
@@ -154,8 +155,9 @@ clRetainKernel(cl_kernel kernel)
}
cl_int
-clReleaseKernel(cl_kernel kernel)
+clReleaseKernel(cl_kernel d_kernel)
{
+ auto kernel = pobj(d_kernel);
if (!kernel->isA(Coal::Object::T_Kernel))
return CL_INVALID_KERNEL;
@@ -180,11 +182,12 @@ clReleaseKernel(cl_kernel kernel)
}
cl_int
-clSetKernelArg(cl_kernel kernel,
+clSetKernelArg(cl_kernel d_kernel,
cl_uint arg_indx,
size_t arg_size,
const void * arg_value)
{
+ auto kernel = pobj(d_kernel);
if (!kernel->isA(Coal::Object::T_Kernel))
return CL_INVALID_KERNEL;
@@ -192,12 +195,14 @@ clSetKernelArg(cl_kernel kernel,
}
cl_int
-clGetKernelInfo(cl_kernel kernel,
+clGetKernelInfo(cl_kernel d_kernel,
cl_kernel_info param_name,
size_t param_value_size,
void * param_value,
size_t * param_value_size_ret)
{
+ auto kernel = pobj(d_kernel);
+
if (!kernel->isA(Coal::Object::T_Kernel))
return CL_INVALID_KERNEL;
@@ -206,13 +211,15 @@ clGetKernelInfo(cl_kernel kernel,
}
cl_int
-clGetKernelArgInfo(cl_kernel kernel,
+clGetKernelArgInfo(cl_kernel d_kernel,
cl_uint arg_indx,
cl_kernel_arg_info param_name,
size_t param_value_size,
void * param_value,
size_t * param_value_size_ret)
{
+ auto kernel = pobj(d_kernel);
+
if (!kernel->isA(Coal::Object::T_Kernel))
return CL_INVALID_KERNEL;
@@ -222,17 +229,20 @@ clGetKernelArgInfo(cl_kernel kernel,
cl_int
-clGetKernelWorkGroupInfo(cl_kernel kernel,
- cl_device_id device,
+clGetKernelWorkGroupInfo(cl_kernel d_kernel,
+ cl_device_id d_device,
cl_kernel_work_group_info param_name,
size_t param_value_size,
void * param_value,
size_t * param_value_size_ret)
{
+ auto device = pobj(d_device);
+ auto kernel = pobj(d_kernel);
+
if (!kernel->isA(Coal::Object::T_Kernel))
return CL_INVALID_KERNEL;
- return kernel->workGroupInfo(pobj(device), param_name,
+ return kernel->workGroupInfo(device, param_name,
param_value_size, param_value,
param_value_size_ret);
}
diff --git a/src/core/events.cpp b/src/core/events.cpp
index a968124..118cc34 100644
--- a/src/core/events.cpp
+++ b/src/core/events.cpp
@@ -719,7 +719,7 @@ KernelEvent::KernelEvent(CommandQueue *parent,
: Event(parent, CL_QUEUED, num_events_in_wait_list, event_wait_list, errcode_ret),
p_work_dim(work_dim), p_kernel(kernel)
{
- clRetainKernel((cl_kernel) p_kernel);
+ clRetainKernel(desc(p_kernel));
// Also, retain any buffers in case the client releases during execute,
// as is done in the Khronos test_api release_during_execute test!.
// Check arguments (buffer alignment, image size, ...)
@@ -958,7 +958,7 @@ KernelEvent::~KernelEvent()
clReleaseMemObject((cl_mem)buffer);
}
}
- clReleaseKernel((cl_kernel) p_kernel);
+ clReleaseKernel(desc(p_kernel));
}
cl_uint KernelEvent::work_dim() const
diff --git a/src/core/kernel.h b/src/core/kernel.h
index 47fd0a2..9c91e0c 100644
--- a/src/core/kernel.h
+++ b/src/core/kernel.h
@@ -35,6 +35,7 @@
#define __KERNEL_H__
#include "object.h"
+#include "icd.h"
#include <CL/cl.h>
@@ -42,6 +43,12 @@
#include <string>
#include <boost/tuple/tuple.hpp>
+namespace Coal
+{
+ class Kernel;
+}
+struct _cl_kernel: public Coal::descriptor<Coal::Kernel, _cl_kernel> {};
+
namespace llvm
{
class Function;
@@ -64,7 +71,7 @@ class DeviceKernel;
* but it also contains a list of LLVM functions for each device for which its
* parent \c Coal::Program has been built
*/
-class Kernel : public Object
+class Kernel : public _cl_kernel, public Object
{
public:
/**
@@ -347,7 +354,4 @@ class Kernel : public Object
}
-struct _cl_kernel : public Coal::Kernel
-{};
-
#endif