diff options
author | Karol Herbst <[email protected]> | 2018-05-21 12:19:42 +0200 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-04-15 11:08:13 +0000 |
commit | 035e882819bcb853fff7a59c638a0ecbf89cb762 (patch) | |
tree | da81f869bbc65f8e00c1aa306cabecd81bc389bf /src/gallium/state_trackers | |
parent | c170c0cfe4bd3c08385953e6e03f4403f5cfb5b9 (diff) |
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 <[email protected]>
Reviewed-by: Pierre Moreau <[email protected]>
Reviewed-by: Francisco Jerez <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2076>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/clover/api/device.cpp | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/device.cpp | 23 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/device.hpp | 1 |
3 files changed, 28 insertions, 0 deletions
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; |