[Mesa-dev] [RFC PATCH 16/17] clover: Add a pointer property to return ILs
Pierre Moreau
pierre.morrow at free.fr
Wed May 3 21:57:04 UTC 2017
OpenCL 2.1 gives the ability to query for a program’s IL, which is
returned as a pointer.
Signed-off-by: Pierre Moreau <pierre.morrow at free.fr>
---
.../state_trackers/clover/core/property.hpp | 39 ++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/src/gallium/state_trackers/clover/core/property.hpp b/src/gallium/state_trackers/clover/core/property.hpp
index 7f8e17684d..5beac372e7 100644
--- a/src/gallium/state_trackers/clover/core/property.hpp
+++ b/src/gallium/state_trackers/clover/core/property.hpp
@@ -23,6 +23,7 @@
#ifndef CLOVER_CORE_PROPERTY_HPP
#define CLOVER_CORE_PROPERTY_HPP
+#include <cstring>
#include <map>
#include "util/range.hpp"
@@ -84,6 +85,19 @@ namespace clover {
private:
property_buffer &buf;
};
+
+ template<typename T>
+ class property_pointer {
+ public:
+ property_pointer(property_buffer &buf) : buf(buf) {
+ }
+
+ inline property_pointer &
+ operator=(const std::pair<const T *, size_t> &v);
+
+ private:
+ property_buffer &buf;
+ };
};
///
@@ -119,6 +133,12 @@ namespace clover {
}
template<typename T>
+ detail::property_pointer<T>
+ as_pointer() {
+ return { *this };
+ }
+
+ template<typename T>
iterator_range<T *>
allocate(size_t n) {
if (r_buf && size < n * sizeof(T))
@@ -133,6 +153,17 @@ namespace clover {
return { };
}
+ void
+ allocate_raw(const void *v, size_t n) {
+ if (r_buf && size < n)
+ throw error(CL_INVALID_VALUE);
+
+ if (r_size)
+ *r_size = n;
+
+ std::memcpy(r_buf, v, n);
+ }
+
private:
void *const r_buf;
const size_t size;
@@ -178,6 +209,14 @@ namespace clover {
return *this;
}
+ template<typename T>
+ inline property_pointer<T> &
+ property_pointer<T>::operator=(const std::pair<const T *, size_t> &v) {
+ buf.allocate_raw(v.first, v.second);
+
+ return *this;
+ }
+
inline property_string &
property_string::operator=(const std::string &v) {
auto r = buf.allocate<char>(v.size() + 1);
--
2.12.2
More information about the mesa-dev
mailing list