1 /* See LICENSE file in the root OpenCV directory */ 2 3 #ifndef __OPENCV_CORE_OCL_RUNTIME_OPENCL_SVM_HSA_EXTENSION_HPP__ 4 #define __OPENCV_CORE_OCL_RUNTIME_OPENCL_SVM_HSA_EXTENSION_HPP__ 5 6 #if defined(HAVE_OPENCL_SVM) 7 #include "opencl_core.hpp" 8 9 #ifndef CL_DEVICE_SVM_CAPABILITIES_AMD 10 // 11 // Part of the file is an extract from the cl_ext.h file from AMD APP SDK package. 12 // Below is the original copyright. 13 // 14 /******************************************************************************* 15 * Copyright (c) 2008-2013 The Khronos Group Inc. 16 * 17 * Permission is hereby granted, free of charge, to any person obtaining a 18 * copy of this software and/or associated documentation files (the 19 * "Materials"), to deal in the Materials without restriction, including 20 * without limitation the rights to use, copy, modify, merge, publish, 21 * distribute, sublicense, and/or sell copies of the Materials, and to 22 * permit persons to whom the Materials are furnished to do so, subject to 23 * the following conditions: 24 * 25 * The above copyright notice and this permission notice shall be included 26 * in all copies or substantial portions of the Materials. 27 * 28 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 29 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 31 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 32 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 33 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 34 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 35 ******************************************************************************/ 36 37 /******************************************* 38 * Shared Virtual Memory (SVM) extension 39 *******************************************/ 40 typedef cl_bitfield cl_device_svm_capabilities_amd; 41 typedef cl_bitfield cl_svm_mem_flags_amd; 42 typedef cl_uint cl_kernel_exec_info_amd; 43 44 /* cl_device_info */ 45 #define CL_DEVICE_SVM_CAPABILITIES_AMD 0x1053 46 #define CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT_AMD 0x1054 47 48 /* cl_device_svm_capabilities_amd */ 49 #define CL_DEVICE_SVM_COARSE_GRAIN_BUFFER_AMD (1 << 0) 50 #define CL_DEVICE_SVM_FINE_GRAIN_BUFFER_AMD (1 << 1) 51 #define CL_DEVICE_SVM_FINE_GRAIN_SYSTEM_AMD (1 << 2) 52 #define CL_DEVICE_SVM_ATOMICS_AMD (1 << 3) 53 54 /* cl_svm_mem_flags_amd */ 55 #define CL_MEM_SVM_FINE_GRAIN_BUFFER_AMD (1 << 10) 56 #define CL_MEM_SVM_ATOMICS_AMD (1 << 11) 57 58 /* cl_mem_info */ 59 #define CL_MEM_USES_SVM_POINTER_AMD 0x1109 60 61 /* cl_kernel_exec_info_amd */ 62 #define CL_KERNEL_EXEC_INFO_SVM_PTRS_AMD 0x11B6 63 #define CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM_AMD 0x11B7 64 65 /* cl_command_type */ 66 #define CL_COMMAND_SVM_FREE_AMD 0x1209 67 #define CL_COMMAND_SVM_MEMCPY_AMD 0x120A 68 #define CL_COMMAND_SVM_MEMFILL_AMD 0x120B 69 #define CL_COMMAND_SVM_MAP_AMD 0x120C 70 #define CL_COMMAND_SVM_UNMAP_AMD 0x120D 71 72 typedef CL_API_ENTRY void* 73 (CL_API_CALL * clSVMAllocAMD_fn)( 74 cl_context /* context */, 75 cl_svm_mem_flags_amd /* flags */, 76 size_t /* size */, 77 unsigned int /* alignment */ 78 ) CL_EXT_SUFFIX__VERSION_1_2; 79 80 typedef CL_API_ENTRY void 81 (CL_API_CALL * clSVMFreeAMD_fn)( 82 cl_context /* context */, 83 void* /* svm_pointer */ 84 ) CL_EXT_SUFFIX__VERSION_1_2; 85 86 typedef CL_API_ENTRY cl_int 87 (CL_API_CALL * clEnqueueSVMFreeAMD_fn)( 88 cl_command_queue /* command_queue */, 89 cl_uint /* num_svm_pointers */, 90 void** /* svm_pointers */, 91 void (CL_CALLBACK *)( /*pfn_free_func*/ 92 cl_command_queue /* queue */, 93 cl_uint /* num_svm_pointers */, 94 void** /* svm_pointers */, 95 void* /* user_data */), 96 void* /* user_data */, 97 cl_uint /* num_events_in_wait_list */, 98 const cl_event* /* event_wait_list */, 99 cl_event* /* event */ 100 ) CL_EXT_SUFFIX__VERSION_1_2; 101 102 typedef CL_API_ENTRY cl_int 103 (CL_API_CALL * clEnqueueSVMMemcpyAMD_fn)( 104 cl_command_queue /* command_queue */, 105 cl_bool /* blocking_copy */, 106 void* /* dst_ptr */, 107 const void* /* src_ptr */, 108 size_t /* size */, 109 cl_uint /* num_events_in_wait_list */, 110 const cl_event* /* event_wait_list */, 111 cl_event* /* event */ 112 ) CL_EXT_SUFFIX__VERSION_1_2; 113 114 typedef CL_API_ENTRY cl_int 115 (CL_API_CALL * clEnqueueSVMMemFillAMD_fn)( 116 cl_command_queue /* command_queue */, 117 void* /* svm_ptr */, 118 const void* /* pattern */, 119 size_t /* pattern_size */, 120 size_t /* size */, 121 cl_uint /* num_events_in_wait_list */, 122 const cl_event* /* event_wait_list */, 123 cl_event* /* event */ 124 ) CL_EXT_SUFFIX__VERSION_1_2; 125 126 typedef CL_API_ENTRY cl_int 127 (CL_API_CALL * clEnqueueSVMMapAMD_fn)( 128 cl_command_queue /* command_queue */, 129 cl_bool /* blocking_map */, 130 cl_map_flags /* map_flags */, 131 void* /* svm_ptr */, 132 size_t /* size */, 133 cl_uint /* num_events_in_wait_list */, 134 const cl_event* /* event_wait_list */, 135 cl_event* /* event */ 136 ) CL_EXT_SUFFIX__VERSION_1_2; 137 138 typedef CL_API_ENTRY cl_int 139 (CL_API_CALL * clEnqueueSVMUnmapAMD_fn)( 140 cl_command_queue /* command_queue */, 141 void* /* svm_ptr */, 142 cl_uint /* num_events_in_wait_list */, 143 const cl_event* /* event_wait_list */, 144 cl_event* /* event */ 145 ) CL_EXT_SUFFIX__VERSION_1_2; 146 147 typedef CL_API_ENTRY cl_int 148 (CL_API_CALL * clSetKernelArgSVMPointerAMD_fn)( 149 cl_kernel /* kernel */, 150 cl_uint /* arg_index */, 151 const void * /* arg_value */ 152 ) CL_EXT_SUFFIX__VERSION_1_2; 153 154 typedef CL_API_ENTRY cl_int 155 (CL_API_CALL * clSetKernelExecInfoAMD_fn)( 156 cl_kernel /* kernel */, 157 cl_kernel_exec_info_amd /* param_name */, 158 size_t /* param_value_size */, 159 const void * /* param_value */ 160 ) CL_EXT_SUFFIX__VERSION_1_2; 161 162 #endif 163 164 #endif // HAVE_OPENCL_SVM 165 166 #endif // __OPENCV_CORE_OCL_RUNTIME_OPENCL_SVM_HSA_EXTENSION_HPP__ 167