aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGil Pitney <gil.pitney@linaro.org>2015-09-30 22:12:35 +0000
committerGil Pitney <gil.pitney@linaro.org>2015-09-30 22:12:35 +0000
commit96d3c23a965296d620a85c090fdecdaac557d52e (patch)
tree837ab4a63cb2dfab580387a0141dafa2be7357f5
parent5037fc5b9a8aea560db9d287fa96a413609359b7 (diff)
downloadshamrock-96d3c23a965296d620a85c090fdecdaac557d52e.tar.gz
ICD: Update Program objects to be ICD compatible.
Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
-rw-r--r--src/api/api_kernel.cpp14
-rw-r--r--src/api/api_program.cpp52
-rw-r--r--src/core/kernel.cpp2
-rw-r--r--src/core/program.cpp8
-rw-r--r--src/core/program.h13
5 files changed, 53 insertions, 36 deletions
diff --git a/src/api/api_kernel.cpp b/src/api/api_kernel.cpp
index 89f8b01..b1447b5 100644
--- a/src/api/api_kernel.cpp
+++ b/src/api/api_kernel.cpp
@@ -38,11 +38,12 @@
// Kernel Object APIs
cl_kernel
-clCreateKernel(cl_program program,
+clCreateKernel(cl_program d_program,
const char * kernel_name,
cl_int * errcode_ret)
{
cl_int dummy_errcode;
+ auto program = pobj(d_program);
if (!errcode_ret)
errcode_ret = &dummy_errcode;
@@ -78,12 +79,13 @@ clCreateKernel(cl_program program,
}
cl_int
-clCreateKernelsInProgram(cl_program program,
+clCreateKernelsInProgram(cl_program d_program,
cl_uint num_kernels,
cl_kernel * kernels,
cl_uint * num_kernels_ret)
{
cl_int rs = CL_SUCCESS;
+ auto program = pobj(d_program);
if (!program->isA(Coal::Object::T_Program))
return CL_INVALID_PROGRAM;
@@ -159,17 +161,17 @@ clReleaseKernel(cl_kernel kernel)
if (kernel->dereference())
{
- Coal::Program *p =(Coal::Program *) kernel->parent();
+ Coal::Program *p =(Coal::Program *)kernel->parent();
for (size_t i=0; i < p->kernelList.size(); i++)
{
if (p->kernelList[i]->p_name.compare(kernel->p_name) == 0)
{
- p->kernelReleasedList.push_back(p->kernelList[i]);
+ p->kernelReleasedList.push_back(p->kernelList[i]);
p->kernelList.erase(p->kernelList.begin() + i);
// BUG: TAG
- // For some odd reason when we delete this, we're corrupting then inside of some kernel objects
- //delete kernel;
+ // For some odd reason when we delete this, we're corrupting then inside of some kernel objects
+ //delete kernel;
}
}
}
diff --git a/src/api/api_program.cpp b/src/api/api_program.cpp
index 49df322..7a17156 100644
--- a/src/api/api_program.cpp
+++ b/src/api/api_program.cpp
@@ -75,7 +75,7 @@ clCreateProgramWithSource(cl_context d_context,
return 0;
}
- return (cl_program)program;
+ return desc(program);
}
cl_program
@@ -178,12 +178,13 @@ clCreateProgramWithBinary(cl_context d_context,
std::free(context_devices);
std::free(devices);
- return (cl_program)program;
+ return desc(program);
}
cl_int
-clRetainProgram(cl_program program)
+clRetainProgram(cl_program d_program)
{
+ auto program = pobj(d_program);
if (!program->isA(Coal::Object::T_Program))
return CL_INVALID_PROGRAM;
@@ -193,8 +194,9 @@ clRetainProgram(cl_program program)
}
cl_int
-clReleaseProgram(cl_program program)
+clReleaseProgram(cl_program d_program)
{
+ auto program = pobj(d_program);
if (!program->isA(Coal::Object::T_Program))
return CL_INVALID_PROGRAM;
@@ -258,12 +260,13 @@ validateContext(Coal::Context * context,
static cl_int
-validateBuildArgs(cl_program program,
+validateBuildArgs(cl_program d_program,
cl_uint &num_devices,
const cl_device_id * &device_list,
void (*pfn_notify)(cl_program program, void * user_data),
void * user_data)
{
+ auto program = pobj(d_program);
if (!program->isA(Coal::Object::T_Program))
return CL_INVALID_PROGRAM;
@@ -292,7 +295,7 @@ validateBuildArgs(cl_program program,
cl_int
-clBuildProgram(cl_program program,
+clBuildProgram(cl_program d_program,
cl_uint num_devices,
const cl_device_id * device_list,
const char * options,
@@ -300,8 +303,9 @@ clBuildProgram(cl_program program,
void * user_data)
{
cl_int result;
+ auto program = pobj(d_program);
- result = validateBuildArgs(program, num_devices, device_list,
+ result = validateBuildArgs(d_program, num_devices, device_list,
pfn_notify, user_data);
if (result == CL_SUCCESS) {
@@ -314,14 +318,14 @@ clBuildProgram(cl_program program,
}
if (pfn_notify)
- pfn_notify(program, user_data);
+ pfn_notify(d_program, user_data);
return result;
}
cl_int
-clCompileProgram(cl_program program,
+clCompileProgram(cl_program d_program,
cl_uint num_devices,
const cl_device_id * device_list,
const char * options,
@@ -332,8 +336,9 @@ clCompileProgram(cl_program program,
void * user_data)
{
cl_int result = CL_SUCCESS;
+ auto program = pobj(d_program);
- result = validateBuildArgs(program, num_devices, device_list,
+ result = validateBuildArgs(d_program, num_devices, device_list,
pfn_notify,user_data);
if ((result == CL_SUCCESS) &&
@@ -351,7 +356,7 @@ clCompileProgram(cl_program program,
}
if (pfn_notify)
- pfn_notify(program, user_data);
+ pfn_notify(d_program, user_data);
return (result);
}
@@ -388,13 +393,14 @@ clLinkProgram(cl_context d_context,
if (retcode == CL_SUCCESS) {
// Check that each program is either loaded with a binary, or compiled
for (int i = 0; i < num_input_programs; i++) {
- if (!input_programs[i]->isA(Coal::Object::T_Program)) {
+ auto input_prog = pobj(input_programs[i]);
+ if (!input_prog->isA(Coal::Object::T_Program)) {
retcode = CL_INVALID_PROGRAM;
break;
}
- if (!((input_programs[i]->state() == Coal::Program::Loaded &&
- input_programs[i]->type() == Coal::Program::Binary) ||
- input_programs[i]->state() == Coal::Program::Compiled)) {
+ if (!((input_prog->state() == Coal::Program::Loaded &&
+ input_prog->type() == Coal::Program::Binary) ||
+ input_prog->state() == Coal::Program::Compiled)) {
retcode = CL_INVALID_OPERATION;
break;
}
@@ -417,7 +423,7 @@ clLinkProgram(cl_context d_context,
// must trigger the callback whether the build succeeds or not, here we must have a
// program object to pass to the pfn_notify() callback.
if (pfn_notify)
- pfn_notify((cl_program)program, user_data);
+ pfn_notify(desc(program), user_data);
if (retcode != CL_SUCCESS)
{
@@ -428,7 +434,7 @@ clLinkProgram(cl_context d_context,
if (errcode_ret) *errcode_ret = retcode;
- return (cl_program)program;
+ return desc(program);
}
cl_int
@@ -447,12 +453,13 @@ clUnloadPlatformCompiler(cl_platform_id platform)
cl_int
-clGetProgramInfo(cl_program program,
+clGetProgramInfo(cl_program d_program,
cl_program_info param_name,
size_t param_value_size,
void * param_value,
size_t * param_value_size_ret)
{
+ auto program = pobj(d_program);
if (!program->isA(Coal::Object::T_Program))
return CL_INVALID_PROGRAM;
@@ -461,20 +468,23 @@ clGetProgramInfo(cl_program program,
}
cl_int
-clGetProgramBuildInfo(cl_program program,
- cl_device_id device,
+clGetProgramBuildInfo(cl_program d_program,
+ cl_device_id d_device,
cl_program_build_info param_name,
size_t param_value_size,
void * param_value,
size_t * param_value_size_ret)
{
+ auto program = pobj(d_program);
+ auto device = pobj(d_device);
+
if (!program->isA(Coal::Object::T_Program))
return CL_INVALID_PROGRAM;
if (!device)
return CL_INVALID_DEVICE;
- return program->buildInfo(pobj(device), param_name,
+ return program->buildInfo(device, param_name,
param_value_size, param_value,
param_value_size_ret);
}
diff --git a/src/core/kernel.cpp b/src/core/kernel.cpp
index 073d726..4f1b7b1 100644
--- a/src/core/kernel.cpp
+++ b/src/core/kernel.cpp
@@ -460,7 +460,7 @@ cl_int Kernel::info(cl_kernel_info param_name,
break;
case CL_KERNEL_PROGRAM:
- SIMPLE_ASSIGN(cl_program, parent());
+ SIMPLE_ASSIGN(cl_program, desc((Program *)parent()));
break;
default:
diff --git a/src/core/program.cpp b/src/core/program.cpp
index 30f5637..310d012 100644
--- a/src/core/program.cpp
+++ b/src/core/program.cpp
@@ -596,7 +596,7 @@ static int storeInputHeaders(cl_uint num_input_headers,
// Make tmp header file...
// and copy header file contents there (previously stored in the program object)
- Coal::Program *prog = (Coal::Program *)input_headers[i];
+ auto prog = pobj(input_headers[i]);
assert (prog->type() == Coal::Program::Source);
std::string fullpath = tmp_headers_path + pathname;
try
@@ -779,7 +779,7 @@ cl_int Program::link(const char *options,
// If no module, initialize with the first input program:
if (!dep.linked_module) {
dep.linked_module = CloneModule(
- ((Coal::Program *)input_programs[0])->deviceDependent(device_list[i]).linked_module);
+ (pobj(input_programs[0]))->deviceDependent(device_list[i]).linked_module);
start = 1;
if (stdlib) num_input_programs++;
}
@@ -794,7 +794,7 @@ cl_int Program::link(const char *options,
}
else {
DeviceDependent &other_dep =
- ((Coal::Program *)input_programs[j])->deviceDependent(device_list[i]);
+ (pobj(input_programs[j]))->deviceDependent(device_list[i]);
other = other_dep.linked_module;
}
@@ -899,7 +899,7 @@ cl_int Program::build(const char *options,
if (result == CL_SUCCESS) {
cl_uint num_input_programs = 1;
- const cl_program input_programs[] = { (cl_program)this };
+ const cl_program input_programs[] = { desc(this) };
result = link(options, pfn_notify, user_data, num_devices,
device_list, num_input_programs, input_programs);
diff --git a/src/core/program.h b/src/core/program.h
index 3e4d641..7b8e4fc 100644
--- a/src/core/program.h
+++ b/src/core/program.h
@@ -35,11 +35,19 @@
#define __PROGRAM_H__
#include "object.h"
+#include "icd.h"
#include <CL/cl.h>
#include <string>
#include <vector>
+namespace Coal
+{
+ class Program;
+}
+struct _cl_program: public Coal::descriptor<Coal::Program, _cl_program> {};
+
+
namespace llvm
{
class MemoryBuffer;
@@ -65,7 +73,7 @@ class Kernel;
* It then contains functions to get the list of kernels available in the
* program, using \c Coal::Kernel objects.
*/
-class Program : public Object
+class Program : public _cl_program, public Object
{
public:
/**
@@ -307,7 +315,4 @@ class Program : public Object
}
-struct _cl_program : public Coal::Program
-{};
-
#endif