cl_boinc.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. // a stripped-down subset of cl.h and cl_platform.h, for BOINC
  2. #ifndef BOINC_CL_BOINC_H
  3. #define BOINC_CL_BOINC_H
  4. #include <cstddef>
  5. #if defined(_WIN32)
  6. #define CL_API_ENTRY
  7. #define CL_API_CALL __stdcall
  8. #define CL_CALLBACK __stdcall
  9. #else
  10. #define CL_API_ENTRY
  11. #define CL_API_CALL
  12. #define CL_CALLBACK
  13. #endif
  14. #if (defined (_WIN32) && defined(_MSC_VER))
  15. /* scalar types */
  16. typedef signed __int8 cl_char;
  17. typedef unsigned __int8 cl_uchar;
  18. typedef signed __int16 cl_short;
  19. typedef unsigned __int16 cl_ushort;
  20. typedef signed __int32 cl_int;
  21. typedef unsigned __int32 cl_uint;
  22. typedef signed __int64 cl_long;
  23. typedef unsigned __int64 cl_ulong;
  24. typedef unsigned __int16 cl_half;
  25. #else /* !_WIN32 */
  26. #include <stdint.h>
  27. typedef int8_t cl_char;
  28. typedef uint8_t cl_uchar;
  29. typedef int16_t cl_short;
  30. typedef uint16_t cl_ushort;
  31. typedef int32_t cl_int;
  32. typedef uint32_t cl_uint;
  33. typedef int64_t cl_long;
  34. typedef uint64_t cl_ulong;
  35. typedef uint16_t cl_half;
  36. #endif /* !_WIN32 */
  37. typedef float cl_float;
  38. typedef double cl_double;
  39. typedef struct _cl_platform_id * cl_platform_id;
  40. typedef struct _cl_device_id * cl_device_id;
  41. typedef struct _cl_context * cl_context;
  42. typedef struct _cl_command_queue * cl_command_queue;
  43. typedef struct _cl_mem * cl_mem;
  44. typedef struct _cl_program * cl_program;
  45. typedef struct _cl_kernel * cl_kernel;
  46. typedef struct _cl_event * cl_event;
  47. typedef struct _cl_sampler * cl_sampler;
  48. typedef cl_uint cl_bool;
  49. typedef cl_ulong cl_bitfield;
  50. typedef cl_bitfield cl_device_type;
  51. typedef cl_uint cl_platform_info;
  52. typedef cl_uint cl_device_info;
  53. typedef cl_bitfield cl_device_fp_config;
  54. typedef cl_uint cl_device_mem_cache_type;
  55. typedef cl_uint cl_device_local_mem_type;
  56. typedef cl_bitfield cl_device_exec_capabilities;
  57. typedef cl_bitfield cl_command_queue_properties;
  58. /* Error Codes */
  59. #define CL_SUCCESS 0
  60. #define CL_DEVICE_NOT_FOUND -1
  61. #define CL_DEVICE_NOT_AVAILABLE -2
  62. #define CL_COMPILER_NOT_AVAILABLE -3
  63. #define CL_MEM_OBJECT_ALLOCATION_FAILURE -4
  64. #define CL_OUT_OF_RESOURCES -5
  65. #define CL_OUT_OF_HOST_MEMORY -6
  66. #define CL_PROFILING_INFO_NOT_AVAILABLE -7
  67. #define CL_MEM_COPY_OVERLAP -8
  68. #define CL_IMAGE_FORMAT_MISMATCH -9
  69. #define CL_IMAGE_FORMAT_NOT_SUPPORTED -10
  70. #define CL_BUILD_PROGRAM_FAILURE -11
  71. #define CL_MAP_FAILURE -12
  72. #define CL_MISALIGNED_SUB_BUFFER_OFFSET -13
  73. #define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14
  74. #define CL_INVALID_VALUE -30
  75. #define CL_INVALID_DEVICE_TYPE -31
  76. #define CL_INVALID_PLATFORM -32
  77. #define CL_INVALID_DEVICE -33
  78. #define CL_INVALID_CONTEXT -34
  79. #define CL_INVALID_QUEUE_PROPERTIES -35
  80. #define CL_INVALID_COMMAND_QUEUE -36
  81. #define CL_INVALID_HOST_PTR -37
  82. #define CL_INVALID_MEM_OBJECT -38
  83. #define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39
  84. #define CL_INVALID_IMAGE_SIZE -40
  85. #define CL_INVALID_SAMPLER -41
  86. #define CL_INVALID_BINARY -42
  87. #define CL_INVALID_BUILD_OPTIONS -43
  88. #define CL_INVALID_PROGRAM -44
  89. #define CL_INVALID_PROGRAM_EXECUTABLE -45
  90. #define CL_INVALID_KERNEL_NAME -46
  91. #define CL_INVALID_KERNEL_DEFINITION -47
  92. #define CL_INVALID_KERNEL -48
  93. #define CL_INVALID_ARG_INDEX -49
  94. #define CL_INVALID_ARG_VALUE -50
  95. #define CL_INVALID_ARG_SIZE -51
  96. #define CL_INVALID_KERNEL_ARGS -52
  97. #define CL_INVALID_WORK_DIMENSION -53
  98. #define CL_INVALID_WORK_GROUP_SIZE -54
  99. #define CL_INVALID_WORK_ITEM_SIZE -55
  100. #define CL_INVALID_GLOBAL_OFFSET -56
  101. #define CL_INVALID_EVENT_WAIT_LIST -57
  102. #define CL_INVALID_EVENT -58
  103. #define CL_INVALID_OPERATION -59
  104. #define CL_INVALID_GL_OBJECT -60
  105. #define CL_INVALID_BUFFER_SIZE -61
  106. #define CL_INVALID_MIP_LEVEL -62
  107. #define CL_INVALID_GLOBAL_WORK_SIZE -63
  108. #define CL_INVALID_PROPERTY -64
  109. // cl_platform_info
  110. #define CL_PLATFORM_PROFILE 0x0900
  111. #define CL_PLATFORM_VERSION 0x0901
  112. #define CL_PLATFORM_NAME 0x0902
  113. #define CL_PLATFORM_VENDOR 0x0903
  114. #define CL_PLATFORM_EXTENSIONS 0x0904
  115. /* cl_device_type - bitfield */
  116. #define CL_DEVICE_TYPE_DEFAULT (1 << 0)
  117. #define CL_DEVICE_TYPE_CPU (1 << 1)
  118. #define CL_DEVICE_TYPE_GPU (1 << 2)
  119. #define CL_DEVICE_TYPE_ACCELERATOR (1 << 3)
  120. #define CL_DEVICE_TYPE_ALL 0xFFFFFFFF
  121. /* cl_device_info */
  122. #define CL_DEVICE_TYPE 0x1000
  123. #define CL_DEVICE_VENDOR_ID 0x1001
  124. #define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002
  125. #define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003
  126. #define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004
  127. #define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005
  128. #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006
  129. #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007
  130. #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008
  131. #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009
  132. #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A
  133. #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B
  134. #define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C
  135. #define CL_DEVICE_ADDRESS_BITS 0x100D
  136. #define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E
  137. #define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F
  138. #define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010
  139. #define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011
  140. #define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012
  141. #define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013
  142. #define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014
  143. #define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015
  144. #define CL_DEVICE_IMAGE_SUPPORT 0x1016
  145. #define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017
  146. #define CL_DEVICE_MAX_SAMPLERS 0x1018
  147. #define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019
  148. #define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A
  149. #define CL_DEVICE_SINGLE_FP_CONFIG 0x101B
  150. #define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C
  151. #define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D
  152. #define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E
  153. #define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F
  154. #define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020
  155. #define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021
  156. #define CL_DEVICE_LOCAL_MEM_TYPE 0x1022
  157. #define CL_DEVICE_LOCAL_MEM_SIZE 0x1023
  158. #define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024
  159. #define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025
  160. #define CL_DEVICE_ENDIAN_LITTLE 0x1026
  161. #define CL_DEVICE_AVAILABLE 0x1027
  162. #define CL_DEVICE_COMPILER_AVAILABLE 0x1028
  163. #define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029
  164. #define CL_DEVICE_QUEUE_PROPERTIES 0x102A
  165. #define CL_DEVICE_NAME 0x102B
  166. #define CL_DEVICE_VENDOR 0x102C
  167. #define CL_DRIVER_VERSION 0x102D
  168. #define CL_DEVICE_PROFILE 0x102E
  169. #define CL_DEVICE_VERSION 0x102F
  170. #define CL_DEVICE_EXTENSIONS 0x1030
  171. #define CL_DEVICE_PLATFORM 0x1031
  172. #define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032
  173. #define CL_DEVICE_HALF_FP_CONFIG 0x1033
  174. #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF 0x1034
  175. #define CL_DEVICE_HOST_UNIFIED_MEMORY 0x1035
  176. #define CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR 0x1036
  177. #define CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT 0x1037
  178. #define CL_DEVICE_NATIVE_VECTOR_WIDTH_INT 0x1038
  179. #define CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG 0x1039
  180. #define CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT 0x103A
  181. #define CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 0x103B
  182. #define CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF 0x103C
  183. #define CL_DEVICE_OPENCL_C_VERSION 0x103D
  184. // Nvidia Specific Extensions
  185. //
  186. //
  187. // cl_nv_device_attribute_query
  188. // See: https://www.khronos.org/registry/cl/extensions/nv/cl_nv_device_attribute_query.txt
  189. //
  190. #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
  191. #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
  192. #define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002
  193. #define CL_DEVICE_WARP_SIZE_NV 0x4003
  194. #define CL_DEVICE_GPU_OVERLAP_NV 0x4004
  195. #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
  196. #define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006
  197. // AMD Specific Extensions
  198. //
  199. //
  200. // cl_amd_device_attribute_query
  201. // See: https://www.khronos.org/registry/cl/extensions/amd/cl_amd_device_attribute_query.txt
  202. //
  203. #define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036
  204. #define CL_DEVICE_TOPOLOGY_AMD 0x4037
  205. #define CL_DEVICE_BOARD_NAME_AMD 0x4038
  206. #define CL_DEVICE_GLOBAL_FREE_MEMORY_AMD 0x4039
  207. #define CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD 0x4040
  208. #define CL_DEVICE_SIMD_WIDTH_AMD 0x4041
  209. #define CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD 0x4042
  210. #define CL_DEVICE_WAVEFRONT_WIDTH_AMD 0x4043
  211. #define CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD 0x4044
  212. #define CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD 0x4045
  213. #define CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD 0x4046
  214. #define CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD 0x4047
  215. #define CL_DEVICE_LOCAL_MEM_BANKS_AMD 0x4048
  216. #define CL_DEVICE_THREAD_TRACE_SUPPORTED_AMD 0x4049
  217. #define CL_DEVICE_GFXIP_MAJOR_AMD 0x404A
  218. #define CL_DEVICE_GFXIP_MINOR_AMD 0x404B
  219. #define CL_DEVICE_AVAILABLE_ASYNC_QUEUES_AMD 0x404C
  220. #ifdef __cplusplus
  221. extern "C" {
  222. #endif
  223. /* Platform API */
  224. extern CL_API_ENTRY cl_int CL_API_CALL
  225. clGetPlatformIDs(cl_uint /* num_entries */,
  226. cl_platform_id * /* platforms */,
  227. cl_uint * /* num_platforms */);
  228. extern CL_API_ENTRY cl_int CL_API_CALL
  229. clGetPlatformInfo(cl_platform_id /* platform */,
  230. cl_platform_info /* param_name */,
  231. size_t /* param_value_size */,
  232. void * /* param_value */,
  233. size_t * /* param_value_size_ret */);
  234. /* Device APIs */
  235. extern CL_API_ENTRY cl_int CL_API_CALL
  236. clGetDeviceIDs(cl_platform_id /* platform */,
  237. cl_device_type /* device_type */,
  238. cl_uint /* num_entries */,
  239. cl_device_id * /* devices */,
  240. cl_uint * /* num_devices */);
  241. extern CL_API_ENTRY cl_int CL_API_CALL
  242. clGetDeviceInfo(cl_device_id /* device */,
  243. cl_device_info /* param_name */,
  244. size_t /* param_value_size */,
  245. void * /* param_value */,
  246. size_t * /* param_value_size_ret */);
  247. #ifdef __cplusplus
  248. }
  249. #endif
  250. #endif // BOINC_CL_BOINC_H