Mesa (master): clover: implement clSetKernelArgSVMPointer
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Apr 15 11:34:45 UTC 2020
Module: Mesa
Branch: master
Commit: d6754eb92072332fc6e7d22dd98628d22ce76531
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d6754eb92072332fc6e7d22dd98628d22ce76531
Author: Karol Herbst <kherbst at redhat.com>
Date: Mon Mar 12 11:04:53 2018 +0100
clover: implement clSetKernelArgSVMPointer
it is pretty much identical to a clSetKernelArg for a scalar field, except
it is only valid for global and constant memory pointers.
Also the type equals void* on the Host, so we can just check the size of it.
v2: prefer using target_size to extend the pointer value
v3: handle more corner cases in combiation to clSetKernelArg
Signed-off-by: Karol Herbst <kherbst at redhat.com>
Reviewed-by: Pierre Moreau <dev at pmoreau.org>
Reviewed-by: Francisco Jerez <currojerez at riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2076>
---
src/gallium/state_trackers/clover/api/kernel.cpp | 12 +++++++++---
src/gallium/state_trackers/clover/core/kernel.cpp | 13 +++++++++++++
src/gallium/state_trackers/clover/core/kernel.hpp | 7 +++++++
3 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/src/gallium/state_trackers/clover/api/kernel.cpp b/src/gallium/state_trackers/clover/api/kernel.cpp
index 35b2f5450f7..38a5cc10454 100644
--- a/src/gallium/state_trackers/clover/api/kernel.cpp
+++ b/src/gallium/state_trackers/clover/api/kernel.cpp
@@ -337,9 +337,15 @@ clEnqueueNativeKernel(cl_command_queue d_q, void (*func)(void *),
CLOVER_API cl_int
clSetKernelArgSVMPointer(cl_kernel d_kern,
cl_uint arg_index,
- const void *arg_value) {
- CLOVER_NOT_SUPPORTED_UNTIL("2.0");
- return CL_INVALID_VALUE;
+ const void *arg_value) try {
+ obj(d_kern).args().at(arg_index).set_svm(arg_value);
+ return CL_SUCCESS;
+
+} catch (std::out_of_range &e) {
+ return CL_INVALID_ARG_INDEX;
+
+} catch (error &e) {
+ return e.get();
}
CLOVER_API cl_int
diff --git a/src/gallium/state_trackers/clover/core/kernel.cpp b/src/gallium/state_trackers/clover/core/kernel.cpp
index 3cffec320e1..7d839767aa0 100644
--- a/src/gallium/state_trackers/clover/core/kernel.cpp
+++ b/src/gallium/state_trackers/clover/core/kernel.cpp
@@ -410,6 +410,14 @@ kernel::global_argument::set(size_t size, const void *value) {
throw error(CL_INVALID_ARG_SIZE);
buf = pobj<buffer>(value ? *(cl_mem *)value : NULL);
+ svm = nullptr;
+ _set = true;
+}
+
+void
+kernel::global_argument::set_svm(const void *value) {
+ svm = value;
+ buf = nullptr;
_set = true;
}
@@ -430,6 +438,11 @@ kernel::global_argument::bind(exec_context &ctx,
extend(v, marg.ext_type, marg.target_size);
byteswap(v, ctx.q->device().endianness());
insert(ctx.input, v);
+ } else if (svm) {
+ auto v = bytes(svm);
+ extend(v, marg.ext_type, marg.target_size);
+ byteswap(v, ctx.q->device().endianness());
+ insert(ctx.input, v);
} else {
// Null pointer.
allocate(ctx.input, marg.target_size);
diff --git a/src/gallium/state_trackers/clover/core/kernel.hpp b/src/gallium/state_trackers/clover/core/kernel.hpp
index 5d46854d679..4441091f300 100644
--- a/src/gallium/state_trackers/clover/core/kernel.hpp
+++ b/src/gallium/state_trackers/clover/core/kernel.hpp
@@ -85,6 +85,11 @@ namespace clover {
/// Set this argument to some object.
virtual void set(size_t size, const void *value) = 0;
+ /// Set this argument to an SVM pointer.
+ virtual void set_svm(const void *value) {
+ throw error(CL_INVALID_ARG_INDEX);
+ };
+
/// Allocate the necessary resources to bind the specified
/// object to this argument, and update \a ctx accordingly.
virtual void bind(exec_context &ctx,
@@ -158,12 +163,14 @@ namespace clover {
class global_argument : public argument {
public:
virtual void set(size_t size, const void *value);
+ virtual void set_svm(const void *value);
virtual void bind(exec_context &ctx,
const module::argument &marg);
virtual void unbind(exec_context &ctx);
private:
buffer *buf;
+ const void *svm;
};
class local_argument : public argument {
More information about the mesa-commit
mailing list