cl_ext.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. /******************************************
  132. * cl_nv_device_attribute_query extension *
  133. ******************************************/
  134. /* cl_nv_device_attribute_query extension - no extension #define since it has no functions */
  135. #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
  136. #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
  137. #define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002
  138. #define CL_DEVICE_WARP_SIZE_NV 0x4003
  139. #define CL_DEVICE_GPU_OVERLAP_NV 0x4004
  140. #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
  141. #define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006
  142. /*********************************
  143. * cl_amd_device_attribute_query *
  144. *********************************/
  145. #define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036
  146. #ifdef CL_VERSION_1_1
  147. /***********************************
  148. * cl_ext_device_fission extension *
  149. ***********************************/
  150. #define cl_ext_device_fission 1
  151. extern CL_API_ENTRY cl_int CL_API_CALL
  152. clReleaseDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
  153. typedef CL_API_ENTRY cl_int
  154. (CL_API_CALL *clReleaseDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
  155. extern CL_API_ENTRY cl_int CL_API_CALL
  156. clRetainDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
  157. typedef CL_API_ENTRY cl_int
  158. (CL_API_CALL *clRetainDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
  159. typedef cl_ulong cl_device_partition_property_ext;
  160. extern CL_API_ENTRY cl_int CL_API_CALL
  161. clCreateSubDevicesEXT( cl_device_id /*in_device*/,
  162. const cl_device_partition_property_ext * /* properties */,
  163. cl_uint /*num_entries*/,
  164. cl_device_id * /*out_devices*/,
  165. cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
  166. typedef CL_API_ENTRY cl_int
  167. ( CL_API_CALL * clCreateSubDevicesEXT_fn)( cl_device_id /*in_device*/,
  168. const cl_device_partition_property_ext * /* properties */,
  169. cl_uint /*num_entries*/,
  170. cl_device_id * /*out_devices*/,
  171. cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
  172. /* cl_device_partition_property_ext */
  173. #define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050
  174. #define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051
  175. #define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052
  176. #define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053
  177. /* clDeviceGetInfo selectors */
  178. #define CL_DEVICE_PARENT_DEVICE_EXT 0x4054
  179. #define CL_DEVICE_PARTITION_TYPES_EXT 0x4055
  180. #define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056
  181. #define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057
  182. #define CL_DEVICE_PARTITION_STYLE_EXT 0x4058
  183. /* error codes */
  184. #define CL_DEVICE_PARTITION_FAILED_EXT -1057
  185. #define CL_INVALID_PARTITION_COUNT_EXT -1058
  186. #define CL_INVALID_PARTITION_NAME_EXT -1059
  187. /* CL_AFFINITY_DOMAINs */
  188. #define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1
  189. #define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2
  190. #define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3
  191. #define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4
  192. #define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10
  193. #define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100
  194. /* cl_device_partition_property_ext list terminators */
  195. #define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0)
  196. #define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0)
  197. #define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1)
  198. /*********************************
  199. * cl_qcom_ext_host_ptr extension
  200. *********************************/
  201. #define CL_MEM_EXT_HOST_PTR_QCOM (1 << 29)
  202. #define CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM 0x40A0
  203. #define CL_DEVICE_PAGE_SIZE_QCOM 0x40A1
  204. #define CL_IMAGE_ROW_ALIGNMENT_QCOM 0x40A2
  205. #define CL_IMAGE_SLICE_ALIGNMENT_QCOM 0x40A3
  206. #define CL_MEM_HOST_UNCACHED_QCOM 0x40A4
  207. #define CL_MEM_HOST_WRITEBACK_QCOM 0x40A5
  208. #define CL_MEM_HOST_WRITETHROUGH_QCOM 0x40A6
  209. #define CL_MEM_HOST_WRITE_COMBINING_QCOM 0x40A7
  210. typedef cl_uint cl_image_pitch_info_qcom;
  211. extern CL_API_ENTRY cl_int CL_API_CALL
  212. clGetDeviceImageInfoQCOM(cl_device_id device,
  213. size_t image_width,
  214. size_t image_height,
  215. const cl_image_format *image_format,
  216. cl_image_pitch_info_qcom param_name,
  217. size_t param_value_size,
  218. void *param_value,
  219. size_t *param_value_size_ret);
  220. typedef struct _cl_mem_ext_host_ptr
  221. {
  222. // Type of external memory allocation.
  223. // Legal values will be defined in layered extensions.
  224. cl_uint allocation_type;
  225. // Host cache policy for this external memory allocation.
  226. cl_uint host_cache_policy;
  227. } cl_mem_ext_host_ptr;
  228. /*********************************
  229. * cl_qcom_ion_host_ptr extension
  230. *********************************/
  231. #define CL_MEM_ION_HOST_PTR_QCOM 0x40A8
  232. typedef struct _cl_mem_ion_host_ptr
  233. {
  234. // Type of external memory allocation.
  235. // Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations.
  236. cl_mem_ext_host_ptr ext_host_ptr;
  237. // ION file descriptor
  238. int ion_filedesc;
  239. // Host pointer to the ION allocated memory
  240. void* ion_hostptr;
  241. } cl_mem_ion_host_ptr;
  242. #endif /* CL_VERSION_1_1 */
  243. #ifdef __cplusplus
  244. }
  245. #endif
  246. #endif /* __CL_EXT_H */