From c170c0cfe4bd3c08385953e6e03f4403f5cfb5b9 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Wed, 22 May 2019 13:46:40 +0200 Subject: [PATCH] clover: add stubs for SVM although most of those are 2.0 core functions, there is cl_arm_shared_virtual_memory to expose those in a 1.2 context. But we should be able to expose this extension with 1.1 as well as there is no technicaly reason why this shouldn't work. v2: move svm functions into existing files v3: rename func args to match convention Signed-off-by: Karol Herbst Reviewed-by: Francisco Jerez Reviewed-by: Pierre Moreau Part-of: --- .../state_trackers/clover/api/dispatch.cpp | 20 ++--- .../state_trackers/clover/api/kernel.cpp | 17 +++++ .../state_trackers/clover/api/memory.cpp | 15 ++++ .../state_trackers/clover/api/transfer.cpp | 75 +++++++++++++++++++ 4 files changed, 117 insertions(+), 10 deletions(-) diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp b/src/gallium/state_trackers/clover/api/dispatch.cpp index a2d270ea05b..6e1b0351afa 100644 --- a/src/gallium/state_trackers/clover/api/dispatch.cpp +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp @@ -150,20 +150,20 @@ namespace clover { clCreateCommandQueueWithProperties, NULL, // clCreatePipe NULL, // clGetPipeInfo - NULL, // clSVMAlloc - NULL, // clSVMFree - NULL, // clEnqueueSVMFree - NULL, // clEnqueueSVMMemcpy - NULL, // clEnqueueSVMMemFill - NULL, // clEnqueueSVMMap - NULL, // clEnqueueSVMUnmap + clSVMAlloc, + clSVMFree, + clEnqueueSVMFree, + clEnqueueSVMMemcpy, + clEnqueueSVMMemFill, + clEnqueueSVMMap, + clEnqueueSVMUnmap, NULL, // clCreateSamplerWithProperties - NULL, // clSetKernelArgSVMPointer - NULL, // clSetKernelExecInfo + clSetKernelArgSVMPointer, + clSetKernelExecInfo, NULL, // clGetKernelSubGroupInfoKHR NULL, // clCloneKernel NULL, // clCreateProgramWithIL - NULL, // clEnqueueSVMMigrateMem + clEnqueueSVMMigrateMem, NULL, // clGetDeviceAndHostTimer NULL, // clGetHostTimer NULL, // clGetKernelSubGroupInfo diff --git a/src/gallium/state_trackers/clover/api/kernel.cpp b/src/gallium/state_trackers/clover/api/kernel.cpp index b665773d9ec..35b2f5450f7 100644 --- a/src/gallium/state_trackers/clover/api/kernel.cpp +++ b/src/gallium/state_trackers/clover/api/kernel.cpp @@ -333,3 +333,20 @@ clEnqueueNativeKernel(cl_command_queue d_q, void (*func)(void *), const cl_event *d_deps, cl_event *rd_ev) { return CL_INVALID_OPERATION; } + +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; +} + +CLOVER_API cl_int +clSetKernelExecInfo(cl_kernel d_kern, + cl_kernel_exec_info param_name, + size_t param_value_size, + const void *param_value) { + CLOVER_NOT_SUPPORTED_UNTIL("2.0"); + return CL_INVALID_VALUE; +} diff --git a/src/gallium/state_trackers/clover/api/memory.cpp b/src/gallium/state_trackers/clover/api/memory.cpp index df4b9baa1d9..6a0717680cf 100644 --- a/src/gallium/state_trackers/clover/api/memory.cpp +++ b/src/gallium/state_trackers/clover/api/memory.cpp @@ -426,3 +426,18 @@ clEnqueueFillImage(cl_command_queue command_queue, cl_mem image, CLOVER_NOT_SUPPORTED_UNTIL("1.2"); return CL_INVALID_VALUE; } + +CLOVER_API void * +clSVMAlloc(cl_context d_ctx, + cl_svm_mem_flags flags, + size_t size, + unsigned int alignment) { + CLOVER_NOT_SUPPORTED_UNTIL("2.0"); + return nullptr; +} + +CLOVER_API void +clSVMFree(cl_context d_ctx, + void *svm_pointer) { + CLOVER_NOT_SUPPORTED_UNTIL("2.0"); +} diff --git a/src/gallium/state_trackers/clover/api/transfer.cpp b/src/gallium/state_trackers/clover/api/transfer.cpp index 34559042aec..879b8a9d762 100644 --- a/src/gallium/state_trackers/clover/api/transfer.cpp +++ b/src/gallium/state_trackers/clover/api/transfer.cpp @@ -764,3 +764,78 @@ clEnqueueMigrateMemObjects(cl_command_queue command_queue, CLOVER_NOT_SUPPORTED_UNTIL("1.2"); return CL_INVALID_VALUE; } + +CLOVER_API cl_int +clEnqueueSVMFree(cl_command_queue d_q, + cl_uint num_svm_pointers, + void *svm_pointers[], + void (CL_CALLBACK *pfn_free_func) (cl_command_queue queue, cl_uint num_svm_pointers, void *svm_pointers[], void *user_data), + void *user_data, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) { + CLOVER_NOT_SUPPORTED_UNTIL("2.0"); + return CL_INVALID_VALUE; +} + +CLOVER_API cl_int +clEnqueueSVMMemcpy(cl_command_queue d_q, + cl_bool blocking_copy, + void *dst_ptr, + const void *src_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) { + CLOVER_NOT_SUPPORTED_UNTIL("2.0"); + return CL_INVALID_VALUE; +} + +CLOVER_API cl_int +clEnqueueSVMMemFill(cl_command_queue d_q, + void *svm_ptr, + const void *pattern, + size_t pattern_size, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) { + CLOVER_NOT_SUPPORTED_UNTIL("2.0"); + return CL_INVALID_VALUE; +} + +CLOVER_API cl_int +clEnqueueSVMMap(cl_command_queue d_q, + cl_bool blocking_map, + cl_map_flags map_flags, + void *svm_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) { + CLOVER_NOT_SUPPORTED_UNTIL("2.0"); + return CL_INVALID_VALUE; +} + +CLOVER_API cl_int +clEnqueueSVMUnmap(cl_command_queue d_q, + void *svm_ptr, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) { + CLOVER_NOT_SUPPORTED_UNTIL("2.0"); + return CL_INVALID_VALUE; +} + +CLOVER_API cl_int +clEnqueueSVMMigrateMem(cl_command_queue d_q, + cl_uint num_svm_pointers, + const void **svm_pointers, + const size_t *sizes, + const cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) { + CLOVER_NOT_SUPPORTED_UNTIL("2.1"); + return CL_INVALID_VALUE; +} -- 2.30.2