summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/clover/api
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2013-09-16 21:50:40 -0700
committerFrancisco Jerez <[email protected]>2013-10-21 10:47:03 -0700
commit7a9bbff7d641b82deae73e043fe1f02b7492993b (patch)
tree5c917a2777a3efc5c03c3ae9065b6a5f224baaab /src/gallium/state_trackers/clover/api
parent10284b1d2d3f59c2d54b8c975c400be29548e0cc (diff)
clover: Clean up the kernel and program object interface.
[ Tom Stellard: Make sure to bind global arguments before retrieving handles. ] Tested-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/clover/api')
-rw-r--r--src/gallium/state_trackers/clover/api/kernel.cpp34
-rw-r--r--src/gallium/state_trackers/clover/api/program.cpp36
2 files changed, 29 insertions, 41 deletions
diff --git a/src/gallium/state_trackers/clover/api/kernel.cpp b/src/gallium/state_trackers/clover/api/kernel.cpp
index dd742c3bb05..e55a55b546e 100644
--- a/src/gallium/state_trackers/clover/api/kernel.cpp
+++ b/src/gallium/state_trackers/clover/api/kernel.cpp
@@ -33,15 +33,12 @@ clCreateKernel(cl_program d_prog, const char *name, cl_int *r_errcode) try {
if (!name)
throw error(CL_INVALID_VALUE);
- if (prog.binaries().empty())
- throw error(CL_INVALID_PROGRAM_EXECUTABLE);
-
- auto sym = prog.binaries().begin()->second.sym(name);
+ auto &sym = find(name_equals(name), prog.symbols());
ret_error(r_errcode, CL_SUCCESS);
return new kernel(prog, name, range(sym.args));
-} catch (module::noent_error &e) {
+} catch (std::out_of_range &e) {
ret_error(r_errcode, CL_INVALID_KERNEL_NAME);
return NULL;
@@ -54,11 +51,7 @@ PUBLIC cl_int
clCreateKernelsInProgram(cl_program d_prog, cl_uint count,
cl_kernel *rd_kerns, cl_uint *r_count) try {
auto &prog = obj(d_prog);
-
- if (prog.binaries().empty())
- throw error(CL_INVALID_PROGRAM_EXECUTABLE);
-
- auto &syms = prog.binaries().begin()->second.syms;
+ auto &syms = prog.symbols();
if (rd_kerns && count < syms.size())
throw error(CL_INVALID_VALUE);
@@ -102,15 +95,12 @@ clReleaseKernel(cl_kernel d_kern) try {
PUBLIC cl_int
clSetKernelArg(cl_kernel d_kern, cl_uint idx, size_t size,
const void *value) try {
- auto &kern = obj(d_kern);
-
- if (idx >= kern.args.size())
- throw error(CL_INVALID_ARG_INDEX);
-
- kern.args[idx]->set(size, value);
-
+ obj(d_kern).args().at(idx).set(size, value);
return CL_SUCCESS;
+} catch (std::out_of_range &e) {
+ return CL_INVALID_ARG_INDEX;
+
} catch (error &e) {
return e.get();
}
@@ -127,7 +117,7 @@ clGetKernelInfo(cl_kernel d_kern, cl_kernel_info param,
break;
case CL_KERNEL_NUM_ARGS:
- buf.as_scalar<cl_uint>() = kern.args.size();
+ buf.as_scalar<cl_uint>() = kern.args().size();
break;
case CL_KERNEL_REFERENCE_COUNT:
@@ -160,8 +150,8 @@ clGetKernelWorkGroupInfo(cl_kernel d_kern, cl_device_id d_dev,
auto &kern = obj(d_kern);
auto pdev = pobj(d_dev);
- if ((!pdev && kern.prog.binaries().size() != 1) ||
- (pdev && !kern.prog.binaries().count(pdev)))
+ if ((!pdev && kern.prog.devices().size() != 1) ||
+ (pdev && !count(*pdev, kern.prog.devices())))
throw error(CL_INVALID_DEVICE);
switch (param) {
@@ -210,10 +200,10 @@ namespace {
if (any_of([](kernel::argument &arg) {
return !arg.set();
- }, map(derefs(), kern.args)))
+ }, kern.args()))
throw error(CL_INVALID_KERNEL_ARGS);
- if (!kern.prog.binaries().count(&q.dev))
+ if (!count(q.dev, kern.prog.devices()))
throw error(CL_INVALID_PROGRAM_EXECUTABLE);
}
diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp
index 45640424a0d..01133813f98 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -173,11 +173,11 @@ clGetProgramInfo(cl_program d_prog, cl_program_info param,
break;
case CL_PROGRAM_NUM_DEVICES:
- buf.as_scalar<cl_uint>() = prog.binaries().size();
+ buf.as_scalar<cl_uint>() = prog.devices().size();
break;
case CL_PROGRAM_DEVICES:
- buf.as_vector<cl_device_id>() = map(keys(), prog.binaries());
+ buf.as_vector<cl_device_id>() = descs(prog.devices());
break;
case CL_PROGRAM_SOURCE:
@@ -185,25 +185,23 @@ clGetProgramInfo(cl_program d_prog, cl_program_info param,
break;
case CL_PROGRAM_BINARY_SIZES:
- buf.as_vector<size_t>() =
- map([](const std::pair<device *, module> &ent) {
- compat::ostream::buffer_t bin;
- compat::ostream s(bin);
- ent.second.serialize(s);
- return bin.size();
- },
- prog.binaries());
+ buf.as_vector<size_t>() = map([&](const device &dev) {
+ compat::ostream::buffer_t bin;
+ compat::ostream s(bin);
+ prog.binary(dev).serialize(s);
+ return bin.size();
+ },
+ prog.devices());
break;
case CL_PROGRAM_BINARIES:
- buf.as_matrix<unsigned char>() =
- map([](const std::pair<device *, module> &ent) {
- compat::ostream::buffer_t bin;
- compat::ostream s(bin);
- ent.second.serialize(s);
- return bin;
- },
- prog.binaries());
+ buf.as_matrix<unsigned char>() = map([&](const device &dev) {
+ compat::ostream::buffer_t bin;
+ compat::ostream s(bin);
+ prog.binary(dev).serialize(s);
+ return bin;
+ },
+ prog.devices());
break;
default:
@@ -224,7 +222,7 @@ clGetProgramBuildInfo(cl_program d_prog, cl_device_id d_dev,
auto &prog = obj(d_prog);
auto &dev = obj(d_dev);
- if (!count(dev, prog.ctx.devs()))
+ if (!count(dev, prog.devices()))
return CL_INVALID_DEVICE;
switch (param) {