cl_ext.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /*******************************************************************************
  2. * Copyright (c) 2008-2013 The Khronos Group Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and/or associated documentation files (the
  6. * "Materials"), to deal in the Materials without restriction, including
  7. * without limitation the rights to use, copy, modify, merge, publish,
  8. * distribute, sublicense, and/or sell copies of the Materials, and to
  9. * permit persons to whom the Materials are furnished to do so, subject to
  10. * the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included
  13. * in all copies or substantial portions of the Materials.
  14. *
  15. * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  19. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  20. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  21. * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
  22. ******************************************************************************/
  23. /* $Revision: 11928 $ on $Date: 2010-07-13 09:04:56 -0700 (Tue, 13 Jul 2010) $ */
  24. /* cl_ext.h contains OpenCL extensions which don't have external */
  25. /* (OpenGL, D3D) dependencies. */
  26. #ifndef __CL_EXT_H
  27. #define __CL_EXT_H
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #ifdef __APPLE__
  32. #include <OpenCL/cl.h>
  33. #include <AvailabilityMacros.h>
  34. #else
  35. #include <CL/cl.h>
  36. #endif
  37. /* cl_khr_fp16 extension - no extension #define since it has no functions */
  38. #define CL_DEVICE_HALF_FP_CONFIG 0x1033
  39. /* Memory object destruction
  40. *
  41. * Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR
  42. *
  43. * Registers a user callback function that will be called when the memory object is deleted and its resources
  44. * freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback
  45. * stack associated with memobj. The registered user callback functions are called in the reverse order in
  46. * which they were registered. The user callback functions are called and then the memory object is deleted
  47. * and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be
  48. * notified when the memory referenced by host_ptr, specified when the memory object is created and used as
  49. * the storage bits for the memory object, can be reused or freed.
  50. *
  51. * The application may not call CL api's with the cl_mem object passed to the pfn_notify.
  52. *
  53. * Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
  54. * before using.
  55. */
  56. #define cl_APPLE_SetMemObjectDestructor 1
  57. cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem /* memobj */,
  58. void (* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
  59. void * /*user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
  60. /* Context Logging Functions
  61. *
  62. * The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext().
  63. * Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
  64. * before using.
  65. *
  66. * clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger
  67. */
  68. #define cl_APPLE_ContextLoggingFunctions 1
  69. extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * /* errstr */,
  70. const void * /* private_info */,
  71. size_t /* cb */,
  72. void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
  73. /* clLogMessagesToStdout sends all log messages to the file descriptor stdout */
  74. extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * /* errstr */,
  75. const void * /* private_info */,
  76. size_t /* cb */,
  77. void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
  78. /* clLogMessagesToStderr sends all log messages to the file descriptor stderr */
  79. extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * /* errstr */,
  80. const void * /* private_info */,
  81. size_t /* cb */,
  82. void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
  83. /************************
  84. * cl_khr_icd extension *
  85. ************************/
  86. #define cl_khr_icd 1
  87. /* cl_platform_info */
  88. #define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920
  89. /* Additional Error Codes */
  90. #define CL_PLATFORM_NOT_FOUND_KHR -1001
  91. extern CL_API_ENTRY cl_int CL_API_CALL
  92. clIcdGetPlatformIDsKHR(cl_uint /* num_entries */,
  93. cl_platform_id * /* platforms */,
  94. cl_uint * /* num_platforms */);
  95. typedef CL_API_ENTRY cl_int (CL_API_CALL *clIcdGetPlatformIDsKHR_fn)(
  96. cl_uint /* num_entries */,
  97. cl_platform_id * /* platforms */,
  98. cl_uint * /* num_platforms */);
  99. /* Extension: cl_khr_image2D_buffer
  100. *
  101. * This extension allows a 2D image to be created from a cl_mem buffer without a copy.
  102. * The type associated with a 2D image created from a buffer in an OpenCL program is image2d_t.
  103. * Both the sampler and sampler-less read_image built-in functions are supported for 2D images
  104. * and 2D images created from a buffer. Similarly, the write_image built-ins are also supported
  105. * for 2D images created from a buffer.
  106. *
  107. * When the 2D image from buffer is created, the client must specify the width,
  108. * height, image format (i.e. channel order and channel data type) and optionally the row pitch
  109. *
  110. * The pitch specified must be a multiple of CL_DEVICE_IMAGE_PITCH_ALIGNMENT pixels.
  111. * The base address of the buffer must be aligned to CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT pixels.
  112. */
  113. /*************************************
  114. * cl_khr_initalize_memory extension *
  115. *************************************/
  116. #define CL_CONTEXT_MEMORY_INITIALIZE_KHR 0x200E
  117. /**************************************
  118. * cl_khr_terminate_context extension *
  119. **************************************/
  120. #define CL_DEVICE_TERMINATE_CAPABILITY_KHR 0x200F
  121. #define CL_CONTEXT_TERMINATE_KHR 0x2010
  122. #define cl_khr_terminate_context 1
  123. extern CL_API_ENTRY cl_int CL_API_CALL clTerminateContextKHR(cl_context /* context */) CL_EXT_SUFFIX__VERSION_1_2;
  124. typedef CL_API_ENTRY cl_int (CL_API_CALL *clTerminateContextKHR_fn)(cl_context /* context */) CL_EXT_SUFFIX__VERSION_1_2;
  125. /*
  126. * Extension: cl_khr_spir
  127. *
  128. * This extension adds support to create an OpenCL program object from a
  129. * Standard Portable Intermediate Representation (SPIR) instance
  130. */
  131. #define CL_DEVICE_SPIR_VERSIONS 0x40E0
  132. #define CL_PROGRAM_BINARY_TYPE_INTERMEDIATE 0x40E1
  133. /******************************************
  134. * cl_nv_device_attribute_query extension *
  135. ******************************************/
  136. /* cl_nv_device_attribute_query extension - no extension #define since it has no functions */
  137. #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
  138. #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
  139. #define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002
  140. #define CL_DEVICE_WARP_SIZE_NV 0x4003
  141. #define CL_DEVICE_GPU_OVERLAP_NV 0x4004
  142. #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
  143. #define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006
  144. /*********************************
  145. * cl_amd_device_attribute_query *
  146. *********************************/
  147. #define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036
  148. /*********************************
  149. * cl_arm_printf extension
  150. *********************************/
  151. #define CL_PRINTF_CALLBACK_ARM 0x40B0
  152. #define CL_PRINTF_BUFFERSIZE_ARM 0x40B1
  153. #ifdef CL_VERSION_1_1
  154. /***********************************
  155. * cl_ext_device_fission extension *
  156. ***********************************/
  157. #define cl_ext_device_fission 1
  158. extern CL_API_ENTRY cl_int CL_API_CALL
  159. clReleaseDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
  160. typedef CL_API_ENTRY cl_int
  161. (CL_API_CALL *clReleaseDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
  162. extern CL_API_ENTRY cl_int CL_API_CALL
  163. clRetainDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
  164. typedef CL_API_ENTRY cl_int
  165. (CL_API_CALL *clRetainDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
  166. typedef cl_ulong cl_device_partition_property_ext;
  167. extern CL_API_ENTRY cl_int CL_API_CALL
  168. clCreateSubDevicesEXT( cl_device_id /*in_device*/,
  169. const cl_device_partition_property_ext * /* properties */,
  170. cl_uint /*num_entries*/,
  171. cl_device_id * /*out_devices*/,
  172. cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
  173. typedef CL_API_ENTRY cl_int
  174. ( CL_API_CALL * clCreateSubDevicesEXT_fn)( cl_device_id /*in_device*/,
  175. const cl_device_partition_property_ext * /* properties */,
  176. cl_uint /*num_entries*/,
  177. cl_device_id * /*out_devices*/,
  178. cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
  179. /* cl_device_partition_property_ext */
  180. #define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050
  181. #define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051
  182. #define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052
  183. #define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053
  184. /* clDeviceGetInfo selectors */
  185. #define CL_DEVICE_PARENT_DEVICE_EXT 0x4054
  186. #define CL_DEVICE_PARTITION_TYPES_EXT 0x4055
  187. #define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056
  188. #define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057
  189. #define CL_DEVICE_PARTITION_STYLE_EXT 0x4058
  190. /* error codes */
  191. #define CL_DEVICE_PARTITION_FAILED_EXT -1057
  192. #define CL_INVALID_PARTITION_COUNT_EXT -1058
  193. #define CL_INVALID_PARTITION_NAME_EXT -1059
  194. /* CL_AFFINITY_DOMAINs */
  195. #define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1
  196. #define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2
  197. #define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3
  198. #define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4
  199. #define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10
  200. #define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100
  201. /* cl_device_partition_property_ext list terminators */
  202. #define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0)
  203. #define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0)
  204. #define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1)
  205. /*********************************
  206. * cl_qcom_ext_host_ptr extension
  207. *********************************/
  208. #define CL_MEM_EXT_HOST_PTR_QCOM (1 << 29)
  209. #define CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM 0x40A0
  210. #define CL_DEVICE_PAGE_SIZE_QCOM 0x40A1
  211. #define CL_IMAGE_ROW_ALIGNMENT_QCOM 0x40A2
  212. #define CL_IMAGE_SLICE_ALIGNMENT_QCOM 0x40A3
  213. #define CL_MEM_HOST_UNCACHED_QCOM 0x40A4
  214. #define CL_MEM_HOST_WRITEBACK_QCOM 0x40A5
  215. #define CL_MEM_HOST_WRITETHROUGH_QCOM 0x40A6
  216. #define CL_MEM_HOST_WRITE_COMBINING_QCOM 0x40A7
  217. typedef cl_uint cl_image_pitch_info_qcom;
  218. extern CL_API_ENTRY cl_int CL_API_CALL
  219. clGetDeviceImageInfoQCOM(cl_device_id device,
  220. size_t image_width,
  221. size_t image_height,
  222. const cl_image_format *image_format,
  223. cl_image_pitch_info_qcom param_name,
  224. size_t param_value_size,
  225. void *param_value,
  226. size_t *param_value_size_ret);
  227. typedef struct _cl_mem_ext_host_ptr
  228. {
  229. /* Type of external memory allocation. */
  230. /* Legal values will be defined in layered extensions. */
  231. cl_uint allocation_type;
  232. /* Host cache policy for this external memory allocation. */
  233. cl_uint host_cache_policy;
  234. } cl_mem_ext_host_ptr;
  235. /*********************************
  236. * cl_qcom_ion_host_ptr extension
  237. *********************************/
  238. #define CL_MEM_ION_HOST_PTR_QCOM 0x40A8
  239. typedef struct _cl_mem_ion_host_ptr
  240. {
  241. /* Type of external memory allocation. */
  242. /* Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations. */
  243. cl_mem_ext_host_ptr ext_host_ptr;
  244. /* ION file descriptor */
  245. int ion_filedesc;
  246. /* Host pointer to the ION allocated memory */
  247. void* ion_hostptr;
  248. } cl_mem_ion_host_ptr;
  249. #endif /* CL_VERSION_1_1 */
  250. #ifdef __cplusplus
  251. }
  252. #endif
  253. #endif /* __CL_EXT_H */