[Mesa-dev] [PATCH v2 14/22] clover: Add a pointer property to return ILs
Francisco Jerez
currojerez at riseup.net
Tue Jan 23 22:08:36 UTC 2018
Pierre Moreau <pierre.morrow at free.fr> writes:
> OpenCL 2.1, and cl_khr_il_program, 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>
I'm not convinced this is correct, but... It seems fully unnecessary, I
think you should be using a property_vector<unsigned char> instead.
> ---
> .../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;
> + };
> };
>
> ///
> @@ -118,6 +132,12 @@ namespace clover {
> return { *this };
> }
>
> + template<typename T>
> + detail::property_pointer<T>
> + as_pointer() {
> + return { *this };
> + }
> +
> template<typename T>
> iterator_range<T *>
> allocate(size_t n) {
> @@ -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.16.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 227 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180123/edac1b9f/attachment.sig>
More information about the mesa-dev
mailing list