// OTHER DEALINGS IN THE SOFTWARE.
//
+#include <unordered_map>
+
+#include "api/dispatch.hpp"
#include "api/util.hpp"
#include "core/platform.hpp"
#include "git_sha1.h"
return NULL;
}
-void *
-clover::GetExtensionFunctionAddress(const char *p_name) {
- std::string name { p_name };
+namespace {
+
+cl_int
+enqueueSVMFreeARM(cl_command_queue command_queue,
+ 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) {
+
+ return EnqueueSVMFree(command_queue, num_svm_pointers, svm_pointers,
+ pfn_free_func, user_data, num_events_in_wait_list,
+ event_wait_list, event, CL_COMMAND_SVM_FREE_ARM);
+}
+
+cl_int
+enqueueSVMMapARM(cl_command_queue command_queue,
+ 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) {
+
+ return EnqueueSVMMap(command_queue, blocking_map, map_flags, svm_ptr, size,
+ num_events_in_wait_list, event_wait_list, event,
+ CL_COMMAND_SVM_MAP_ARM);
+}
+
+cl_int
+enqueueSVMMemcpyARM(cl_command_queue command_queue,
+ 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) {
+
+ return EnqueueSVMMemcpy(command_queue, blocking_copy, dst_ptr, src_ptr,
+ size, num_events_in_wait_list, event_wait_list,
+ event, CL_COMMAND_SVM_MEMCPY_ARM);
+}
+
+cl_int
+enqueueSVMMemFillARM(cl_command_queue command_queue,
+ 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) {
+
+ return EnqueueSVMMemFill(command_queue, svm_ptr, pattern, pattern_size,
+ size, num_events_in_wait_list, event_wait_list,
+ event, CL_COMMAND_SVM_MEMFILL_ARM);
+}
- if (name == "clIcdGetPlatformIDsKHR")
- return reinterpret_cast<void *>(IcdGetPlatformIDsKHR);
- else
- return NULL;
+cl_int
+enqueueSVMUnmapARM(cl_command_queue command_queue,
+ void *svm_ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event *event_wait_list,
+ cl_event *event) {
+
+ return EnqueueSVMUnmap(command_queue, svm_ptr, num_events_in_wait_list,
+ event_wait_list, event, CL_COMMAND_SVM_UNMAP_ARM);
+}
+
+const std::unordered_map<std::string, void *>
+ext_funcs = {
+ // cl_arm_shared_virtual_memory
+ { "clEnqueueSVMFreeARM", reinterpret_cast<void *>(enqueueSVMFreeARM) },
+ { "clEnqueueSVMMapARM", reinterpret_cast<void *>(enqueueSVMMapARM) },
+ { "clEnqueueSVMMemcpyARM", reinterpret_cast<void *>(enqueueSVMMemcpyARM) },
+ { "clEnqueueSVMMemFillARM", reinterpret_cast<void *>(enqueueSVMMemFillARM) },
+ { "clEnqueueSVMUnmapARM", reinterpret_cast<void *>(enqueueSVMUnmapARM) },
+ { "clSetKernelArgSVMPointerARM", reinterpret_cast<void *>(clSetKernelArgSVMPointer) },
+ { "clSetKernelExecInfoARM", reinterpret_cast<void *>(clSetKernelExecInfo) },
+ { "clSVMAllocARM", reinterpret_cast<void *>(clSVMAlloc) },
+ { "clSVMFreeARM", reinterpret_cast<void *>(clSVMFree) },
+
+ // cl_khr_icd
+ { "clIcdGetPlatformIDsKHR", reinterpret_cast<void *>(IcdGetPlatformIDsKHR) },
+};
+
+} // anonymous namespace
+
+void *
+clover::GetExtensionFunctionAddress(const char *p_name) try {
+ return ext_funcs.at(p_name);
+} catch (...) {
+ return nullptr;
}
cl_int
#include "util/bitscan.h"
+#include "api/dispatch.hpp"
#include "api/util.hpp"
#include "core/event.hpp"
#include "core/memory.hpp"
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) try {
+cl_int
+clover::EnqueueSVMFree(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,
+ cl_int cmd) try {
+
if (bool(num_svm_pointers) != bool(svm_pointers))
return CL_INVALID_VALUE;
};
}
- auto hev = create<hard_event>(q, CL_COMMAND_SVM_FREE, deps,
+ auto hev = create<hard_event>(q, cmd, deps,
[=](clover::event &) mutable {
pfn_free_func(d_q, num_svm_pointers, svm_pointers_cpy.data(),
user_data);
}
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) try {
+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) {
+
+ return EnqueueSVMFree(d_q, num_svm_pointers, svm_pointers,
+ pfn_free_func, user_data, num_events_in_wait_list,
+ event_wait_list, event, CL_COMMAND_SVM_FREE);
+}
+
+cl_int
+clover::EnqueueSVMMemcpy(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,
+ cl_int cmd) try {
if (dst_ptr == nullptr || src_ptr == nullptr)
return CL_INVALID_VALUE;
validate_common(q, deps);
if (can_emulate) {
- auto hev = create<hard_event>(q, CL_COMMAND_SVM_MEMCPY, deps,
+ auto hev = create<hard_event>(q, cmd, deps,
[=](clover::event &) {
memcpy(dst_ptr, src_ptr, size);
});
}
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) try {
+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) {
+
+ return EnqueueSVMMemcpy(d_q, blocking_copy, dst_ptr, src_ptr,
+ size, num_events_in_wait_list, event_wait_list,
+ event, CL_COMMAND_SVM_MEMCPY);
+}
+
+cl_int
+clover::EnqueueSVMMemFill(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,
+ cl_int cmd) try {
+
if (svm_ptr == nullptr || pattern == nullptr ||
!util_is_power_of_two_nonzero(pattern_size) ||
pattern_size > 128 ||
validate_common(q, deps);
if (can_emulate) {
- auto hev = create<hard_event>(q, CL_COMMAND_SVM_MEMFILL, deps,
+ auto hev = create<hard_event>(q, cmd, deps,
[=](clover::event &) {
void *ptr = svm_ptr;
for (size_t s = size; s; s -= pattern_size) {
}
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) try {
+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) {
+
+ return EnqueueSVMMemFill(d_q, svm_ptr, pattern, pattern_size,
+ size, num_events_in_wait_list, event_wait_list,
+ event, CL_COMMAND_SVM_MEMFILL);
+}
+
+cl_int
+clover::EnqueueSVMMap(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,
+ cl_int cmd) try {
if (svm_ptr == nullptr || size == 0)
return CL_INVALID_VALUE;
validate_common(q, deps);
if (can_emulate) {
- auto hev = create<hard_event>(q, CL_COMMAND_SVM_MAP, deps,
+ auto hev = create<hard_event>(q, cmd, deps,
[](clover::event &) { });
ret_object(event, hev);
}
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) try {
+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) {
+
+ return EnqueueSVMMap(d_q, blocking_map, map_flags, svm_ptr, size,
+ num_events_in_wait_list, event_wait_list, event,
+ CL_COMMAND_SVM_MAP);
+}
+
+cl_int
+clover::EnqueueSVMUnmap(cl_command_queue d_q,
+ void *svm_ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event *event_wait_list,
+ cl_event *event,
+ cl_int cmd) try {
if (svm_ptr == nullptr)
return CL_INVALID_VALUE;
validate_common(q, deps);
if (can_emulate) {
- auto hev = create<hard_event>(q, CL_COMMAND_SVM_UNMAP, deps,
+ auto hev = create<hard_event>(q, cmd, deps,
[](clover::event &) { });
ret_object(event, hev);
return e.get();
}
+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) {
+
+ return EnqueueSVMUnmap(d_q, svm_ptr, num_events_in_wait_list,
+ event_wait_list, event, CL_COMMAND_SVM_UNMAP);
+}
+
CLOVER_API cl_int
clEnqueueSVMMigrateMem(cl_command_queue d_q,
cl_uint num_svm_pointers,