summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2020-10-08 04:44:46 +1000
committerDave Airlie <airlied@redhat.com>2020-11-17 05:15:09 +1000
commit39940ee8d6a18f4b19d98ca7ffcba137d8b33a62 (patch)
treed2c86f4f7b5086086191dc3ba15e7546e9a70d1e
parenta144dd69172b0c4a5858f3025d1b82c9281661fe (diff)
clover: add cl 3.0 SVM invalid support
Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7642>
-rw-r--r--src/gallium/frontends/clover/api/kernel.cpp7
-rw-r--r--src/gallium/frontends/clover/api/memory.cpp8
-rw-r--r--src/gallium/frontends/clover/api/transfer.cpp30
3 files changed, 41 insertions, 4 deletions
diff --git a/src/gallium/frontends/clover/api/kernel.cpp b/src/gallium/frontends/clover/api/kernel.cpp
index 773d8e185bd..d172750481e 100644
--- a/src/gallium/frontends/clover/api/kernel.cpp
+++ b/src/gallium/frontends/clover/api/kernel.cpp
@@ -379,6 +379,8 @@ CLOVER_API cl_int
clSetKernelArgSVMPointer(cl_kernel d_kern,
cl_uint arg_index,
const void *arg_value) try {
+ if (!any_of(std::mem_fn(&device::svm_support), obj(d_kern).program().devices()))
+ return CL_INVALID_OPERATION;
obj(d_kern).args().at(arg_index).set_svm(arg_value);
return CL_SUCCESS;
@@ -394,7 +396,12 @@ clSetKernelExecInfo(cl_kernel d_kern,
cl_kernel_exec_info param_name,
size_t param_value_size,
const void *param_value) try {
+
+ if (!any_of(std::mem_fn(&device::svm_support), obj(d_kern).program().devices()))
+ return CL_INVALID_OPERATION;
+
auto &kern = obj(d_kern);
+
const bool has_system_svm = all_of(std::mem_fn(&device::has_system_svm),
kern.program().context().devices());
diff --git a/src/gallium/frontends/clover/api/memory.cpp b/src/gallium/frontends/clover/api/memory.cpp
index def2f800c52..cfd0aa26d7f 100644
--- a/src/gallium/frontends/clover/api/memory.cpp
+++ b/src/gallium/frontends/clover/api/memory.cpp
@@ -481,6 +481,10 @@ clSVMAlloc(cl_context d_ctx,
size_t size,
unsigned int alignment) try {
auto &ctx = obj(d_ctx);
+
+ if (!any_of(std::mem_fn(&device::svm_support), ctx.devices()))
+ return NULL;
+
validate_flags(NULL, flags, true);
if (!size ||
@@ -515,6 +519,10 @@ CLOVER_API void
clSVMFree(cl_context d_ctx,
void *svm_pointer) try {
auto &ctx = obj(d_ctx);
+
+ if (!any_of(std::mem_fn(&device::svm_support), ctx.devices()))
+ return;
+
bool can_emulate = all_of(std::mem_fn(&device::has_system_svm), ctx.devices());
if (can_emulate)
diff --git a/src/gallium/frontends/clover/api/transfer.cpp b/src/gallium/frontends/clover/api/transfer.cpp
index bb9133c8285..d1da88fae44 100644
--- a/src/gallium/frontends/clover/api/transfer.cpp
+++ b/src/gallium/frontends/clover/api/transfer.cpp
@@ -953,6 +953,10 @@ clover::EnqueueSVMFree(cl_command_queue d_q,
return CL_INVALID_VALUE;
auto &q = obj(d_q);
+
+ if (!q.device().svm_support())
+ return CL_INVALID_OPERATION;
+
bool can_emulate = q.device().has_system_svm();
auto deps = objs<wait_list_tag>(event_wait_list, num_events_in_wait_list);
@@ -1012,6 +1016,10 @@ clover::EnqueueSVMMemcpy(cl_command_queue d_q,
const cl_event *event_wait_list,
cl_event *event,
cl_int cmd) try {
+ auto &q = obj(d_q);
+
+ if (!q.device().svm_support())
+ return CL_INVALID_OPERATION;
if (dst_ptr == nullptr || src_ptr == nullptr)
return CL_INVALID_VALUE;
@@ -1020,7 +1028,7 @@ clover::EnqueueSVMMemcpy(cl_command_queue d_q,
reinterpret_cast<ptrdiff_t>(src_ptr))) < size)
return CL_MEM_COPY_OVERLAP;
- auto &q = obj(d_q);
+
bool can_emulate = q.device().has_system_svm();
auto deps = objs<wait_list_tag>(event_wait_list, num_events_in_wait_list);
@@ -1070,6 +1078,10 @@ clover::EnqueueSVMMemFill(cl_command_queue d_q,
const cl_event *event_wait_list,
cl_event *event,
cl_int cmd) try {
+ auto &q = obj(d_q);
+
+ if (!q.device().svm_support())
+ return CL_INVALID_OPERATION;
if (svm_ptr == nullptr || pattern == nullptr ||
!util_is_power_of_two_nonzero(pattern_size) ||
@@ -1078,7 +1090,6 @@ clover::EnqueueSVMMemFill(cl_command_queue d_q,
size % pattern_size)
return CL_INVALID_VALUE;
- auto &q = obj(d_q);
bool can_emulate = q.device().has_system_svm();
auto deps = objs<wait_list_tag>(event_wait_list, num_events_in_wait_list);
@@ -1130,11 +1141,14 @@ clover::EnqueueSVMMap(cl_command_queue d_q,
const cl_event *event_wait_list,
cl_event *event,
cl_int cmd) try {
+ auto &q = obj(d_q);
+
+ if (!q.device().svm_support())
+ return CL_INVALID_OPERATION;
if (svm_ptr == nullptr || size == 0)
return CL_INVALID_VALUE;
- auto &q = obj(d_q);
bool can_emulate = q.device().has_system_svm();
auto deps = objs<wait_list_tag>(event_wait_list, num_events_in_wait_list);
@@ -1177,11 +1191,14 @@ clover::EnqueueSVMUnmap(cl_command_queue d_q,
const cl_event *event_wait_list,
cl_event *event,
cl_int cmd) try {
+ auto &q = obj(d_q);
+
+ if (!q.device().svm_support())
+ return CL_INVALID_OPERATION;
if (svm_ptr == nullptr)
return CL_INVALID_VALUE;
- auto &q = obj(d_q);
bool can_emulate = q.device().has_system_svm();
auto deps = objs<wait_list_tag>(event_wait_list, num_events_in_wait_list);
@@ -1222,6 +1239,11 @@ clEnqueueSVMMigrateMem(cl_command_queue d_q,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list,
cl_event *event) {
+ auto &q = obj(d_q);
+
+ if (!q.device().svm_support())
+ return CL_INVALID_OPERATION;
+
CLOVER_NOT_SUPPORTED_UNTIL("2.1");
return CL_INVALID_VALUE;
}