Mesa (master): clover: implement CL_DEVICE_SVM_CAPABILITIES
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Apr 15 11:34:45 UTC 2020
Module: Mesa
Branch: master
Commit: 035e882819bcb853fff7a59c638a0ecbf89cb762
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=035e882819bcb853fff7a59c638a0ecbf89cb762
Author: Karol Herbst <kherbst at redhat.com>
Date: Mon May 21 12:19:42 2018 +0200
clover: implement CL_DEVICE_SVM_CAPABILITIES
v2: without supporting userptrs SVM can't be implemented as it's impossible
to ensure memory consistency with HOST_PTR buffers
v3: fix comment style
v4: fixes typo in comment
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/device.cpp | 4 ++++
src/gallium/state_trackers/clover/core/device.cpp | 23 +++++++++++++++++++++++
src/gallium/state_trackers/clover/core/device.hpp | 1 +
3 files changed, 28 insertions(+)
diff --git a/src/gallium/state_trackers/clover/api/device.cpp b/src/gallium/state_trackers/clover/api/device.cpp
index ca6b90ba271..d1c37b96aeb 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -405,6 +405,10 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
buf.as_scalar<cl_uint>() = 1;
break;
+ case CL_DEVICE_SVM_CAPABILITIES:
+ buf.as_scalar<cl_device_svm_capabilities>() = dev.svm_support();
+ break;
+
default:
throw error(CL_INVALID_VALUE);
}
diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp
index 298cde278b4..e05dc562189 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -220,6 +220,29 @@ device::mem_base_addr_align() const {
return sysconf(_SC_PAGESIZE);
}
+cl_device_svm_capabilities
+device::svm_support() const {
+ // Without CAP_RESOURCE_FROM_USER_MEMORY SVM and CL_MEM_USE_HOST_PTR
+ // interactions won't work according to spec as clover manages a GPU side
+ // copy of the host data.
+ //
+ // The biggest problem are memory buffers created with CL_MEM_USE_HOST_PTR,
+ // but the application and/or the kernel updates the memory via SVM and not
+ // the cl_mem buffer.
+ // We can't even do proper tracking on what memory might have been accessed
+ // as the host ptr to the buffer could be within a SVM region, where through
+ // the CL API there is no reliable way of knowing if a certain cl_mem buffer
+ // was accessed by a kernel or not and the runtime can't reliably know from
+ // which side the GPU buffer content needs to be updated.
+ //
+ // Another unsolvable scenario is a cl_mem object passed by cl_mem reference
+ // and SVM pointer into the same kernel at the same time.
+ if (pipe->get_param(pipe, PIPE_CAP_RESOURCE_FROM_USER_MEMORY) &&
+ pipe->get_param(pipe, PIPE_CAP_SYSTEM_SVM))
+ return CL_DEVICE_SVM_FINE_GRAIN_SYSTEM;
+ return 0;
+}
+
std::vector<size_t>
device::max_block_size() const {
auto v = get_compute_param<uint64_t>(pipe, ir_format(),
diff --git a/src/gallium/state_trackers/clover/core/device.hpp b/src/gallium/state_trackers/clover/core/device.hpp
index 828dfaa65e6..dc9064bb638 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -71,6 +71,7 @@ namespace clover {
bool has_int64_atomics() const;
bool has_unified_memory() const;
cl_uint mem_base_addr_align() const;
+ cl_device_svm_capabilities svm_support() const;
std::vector<size_t> max_block_size() const;
cl_uint subgroup_size() const;
More information about the mesa-commit
mailing list