summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/clover/api/context.cpp4
-rw-r--r--src/gallium/state_trackers/clover/api/program.cpp12
-rw-r--r--src/gallium/state_trackers/clover/api/queue.cpp2
-rw-r--r--src/gallium/state_trackers/clover/core/context.cpp14
-rw-r--r--src/gallium/state_trackers/clover/core/context.hpp7
-rw-r--r--src/gallium/state_trackers/clover/core/format.cpp11
6 files changed, 23 insertions, 27 deletions
diff --git a/src/gallium/state_trackers/clover/api/context.cpp b/src/gallium/state_trackers/clover/api/context.cpp
index 98bc2141e11..c6c71ceb92f 100644
--- a/src/gallium/state_trackers/clover/api/context.cpp
+++ b/src/gallium/state_trackers/clover/api/context.cpp
@@ -111,11 +111,11 @@ clGetContextInfo(cl_context d_ctx, cl_context_info param,
break;
case CL_CONTEXT_NUM_DEVICES:
- buf.as_scalar<cl_uint>() = ctx.devs.size();
+ buf.as_scalar<cl_uint>() = ctx.devs().size();
break;
case CL_CONTEXT_DEVICES:
- buf.as_vector<cl_device_id>() = descs(map(derefs(), ctx.devs));
+ buf.as_vector<cl_device_id>() = descs(ctx.devs());
break;
case CL_CONTEXT_PROPERTIES:
diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp
index 84260472953..45640424a0d 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -63,8 +63,8 @@ clCreateProgramWithBinary(cl_context d_ctx, cl_uint n,
if (!lengths || !binaries)
throw error(CL_INVALID_VALUE);
- if (any_of([&](device &dev) {
- return !ctx.has_device(dev);
+ if (any_of([&](const device &dev) {
+ return !count(dev, ctx.devs());
}, devs))
throw error(CL_INVALID_DEVICE);
@@ -133,15 +133,15 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs,
void *user_data) try {
auto &prog = obj(d_prog);
auto devs = (d_devs ? objs(d_devs, num_devs) :
- ref_vector<device>(map(derefs(), prog.ctx.devs)));
+ ref_vector<device>(prog.ctx.devs()));
auto opts = (p_opts ? p_opts : "");
if (bool(num_devs) != bool(d_devs) ||
(!pfn_notify && user_data))
throw error(CL_INVALID_VALUE);
- if (any_of([&](device &dev) {
- return !prog.ctx.has_device(dev);
+ if (any_of([&](const device &dev) {
+ return !count(dev, prog.ctx.devs());
}, devs))
throw error(CL_INVALID_DEVICE);
@@ -224,7 +224,7 @@ clGetProgramBuildInfo(cl_program d_prog, cl_device_id d_dev,
auto &prog = obj(d_prog);
auto &dev = obj(d_dev);
- if (!prog.ctx.has_device(dev))
+ if (!count(dev, prog.ctx.devs()))
return CL_INVALID_DEVICE;
switch (param) {
diff --git a/src/gallium/state_trackers/clover/api/queue.cpp b/src/gallium/state_trackers/clover/api/queue.cpp
index b68dfa1f62a..0fdb7356b35 100644
--- a/src/gallium/state_trackers/clover/api/queue.cpp
+++ b/src/gallium/state_trackers/clover/api/queue.cpp
@@ -32,7 +32,7 @@ clCreateCommandQueue(cl_context d_ctx, cl_device_id d_dev,
auto &ctx = obj(d_ctx);
auto &dev = obj(d_dev);
- if (!ctx.has_device(dev))
+ if (!count(dev, ctx.devs()))
throw error(CL_INVALID_DEVICE);
if (props & ~(CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE |
diff --git a/src/gallium/state_trackers/clover/core/context.cpp b/src/gallium/state_trackers/clover/core/context.cpp
index f4f98004790..e2658f28cb4 100644
--- a/src/gallium/state_trackers/clover/core/context.cpp
+++ b/src/gallium/state_trackers/clover/core/context.cpp
@@ -20,20 +20,13 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-#include <algorithm>
-
#include "core/context.hpp"
using namespace clover;
context::context(const property_list &props,
const ref_vector<device> &devs) :
- devs(map(addresses(), devs)), _props(props) {
-}
-
-bool
-context::has_device(device &dev) const {
- return std::count(devs.begin(), devs.end(), &dev);
+ _props(props), _devs(map(addresses(), devs)) {
}
bool
@@ -50,3 +43,8 @@ const context::property_list &
context::props() const {
return _props;
}
+
+context::device_range
+context::devs() const {
+ return map(derefs(), _devs);
+}
diff --git a/src/gallium/state_trackers/clover/core/context.hpp b/src/gallium/state_trackers/clover/core/context.hpp
index e739f5e2ec2..0b5cf8aede6 100644
--- a/src/gallium/state_trackers/clover/core/context.hpp
+++ b/src/gallium/state_trackers/clover/core/context.hpp
@@ -30,6 +30,7 @@
namespace clover {
class context : public ref_counter, public _cl_context {
private:
+ typedef adaptor_range<derefs, const std::vector<device *> &> device_range;
typedef clover::property_list<cl_context_properties> property_list;
public:
@@ -39,8 +40,6 @@ namespace clover {
context &
operator=(const context &ctx) = delete;
- bool has_device(device &dev) const;
-
bool
operator==(const context &ctx) const;
bool
@@ -49,10 +48,12 @@ namespace clover {
const property_list &
props() const;
- const std::vector<device *> devs;
+ device_range
+ devs() const;
private:
property_list _props;
+ const std::vector<clover::device *> _devs;
};
}
diff --git a/src/gallium/state_trackers/clover/core/format.cpp b/src/gallium/state_trackers/clover/core/format.cpp
index 40d5ded1d76..79582306a60 100644
--- a/src/gallium/state_trackers/clover/core/format.cpp
+++ b/src/gallium/state_trackers/clover/core/format.cpp
@@ -20,8 +20,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-#include <algorithm>
-
#include "core/format.hpp"
#include "core/memory.hpp"
#include "pipe/p_screen.h"
@@ -154,11 +152,10 @@ namespace clover {
PIPE_BIND_TRANSFER_WRITE);
for (auto f : formats) {
- if (std::all_of(ctx.devs.begin(), ctx.devs.end(),
- [=](const device *dev) {
- return dev->pipe->is_format_supported(
- dev->pipe, f.second, target, 1, bindings);
- }))
+ if (all_of([=](const device &dev) {
+ return dev.pipe->is_format_supported(
+ dev.pipe, f.second, target, 1, bindings);
+ }, ctx.devs()))
s.insert(f.first);
}