summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2013-09-16 21:44:19 -0700
committerMark Mueller <MarkKMueller@gmail.com>2013-10-28 11:06:48 -0700
commit93de69eccc7e1a6c191cbde584fe5c79f628ba10 (patch)
tree0752924fce0e7ace16772188ebef1dc93f1d7dfd
parent61101e2470322b9f80e8537cb9651edd5077ea39 (diff)
clover: Simplify the platform object by using util/range.
Tested-by: Tom Stellard <thomas.stellard@amd.com>
-rw-r--r--src/gallium/state_trackers/clover/core/device.hpp2
-rw-r--r--src/gallium/state_trackers/clover/core/platform.cpp4
-rw-r--r--src/gallium/state_trackers/clover/core/platform.hpp30
3 files changed, 8 insertions, 28 deletions
diff --git a/src/gallium/state_trackers/clover/core/device.hpp b/src/gallium/state_trackers/clover/core/device.hpp
index 95669bdeb6..42e32a1907 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -35,7 +35,7 @@ namespace clover {
class root_resource;
class hard_event;
- class device : public _cl_device_id {
+ class device : public ref_counter, public _cl_device_id {
public:
device(clover::platform &platform, pipe_loader_device *ldev);
device(device &&dev);
diff --git a/src/gallium/state_trackers/clover/core/platform.cpp b/src/gallium/state_trackers/clover/core/platform.cpp
index 31e8830760..e35b1f96da 100644
--- a/src/gallium/state_trackers/clover/core/platform.cpp
+++ b/src/gallium/state_trackers/clover/core/platform.cpp
@@ -24,7 +24,7 @@
using namespace clover;
-platform::platform() {
+platform::platform() : adaptor_range(derefs(), devs) {
int n = pipe_loader_probe(NULL, 0);
std::vector<pipe_loader_device *> ldevs(n);
@@ -32,7 +32,7 @@ platform::platform() {
for (pipe_loader_device *ldev : ldevs) {
try {
- devs.emplace_back(*this, ldev);
+ devs.push_back(transfer(new device(*this, ldev)));
} catch (error &) {}
}
}
diff --git a/src/gallium/state_trackers/clover/core/platform.hpp b/src/gallium/state_trackers/clover/core/platform.hpp
index 26c65c788b..83f0cab35e 100644
--- a/src/gallium/state_trackers/clover/core/platform.hpp
+++ b/src/gallium/state_trackers/clover/core/platform.hpp
@@ -27,37 +27,17 @@
#include "core/object.hpp"
#include "core/device.hpp"
+#include "util/range.hpp"
namespace clover {
- class platform : public _cl_platform_id {
+ class platform : public _cl_platform_id,
+ public adaptor_range<
+ derefs, std::vector<ref_ptr<device>> &> {
public:
- typedef std::vector<device>::iterator iterator;
-
platform();
- ///
- /// Container of all compute devices that are available in the platform.
- ///
- /// @{
- iterator begin() {
- return devs.begin();
- }
-
- iterator end() {
- return devs.end();
- }
-
- device &front() {
- return devs.front();
- }
-
- device &back() {
- return devs.back();
- }
- /// @}
-
protected:
- std::vector<device> devs;
+ std::vector<ref_ptr<device>> devs;
};
}