cl.pp 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224
  1. (*******************************************************************************
  2. * Copyright (c) 2008-2009 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. // ported to FPC by Dmitry 'skalogryz' Boyarintsev: 28th apr 2009
  24. // due to name conflict with type names, some constants have been renamed
  25. // Original C name Ported_name
  26. // CL_DEVICE_TYPE CL_DEVICE_TYPE_INFO
  27. // CL_DEVICE_LOCAL_MEM_TYPE CL_DEVICE_LOCAL_MEM_TYPE_INFO
  28. // CL_CONTEXT_PROPERTIES CL_CONTEXT_PROPERTIES_INFO
  29. // CL_CONTEXT_PLATFORM CL_CONTEXT_PLATFORM_INFO
  30. // CL_FLOAT CL_FLOAT_TYPE
  31. // CL_MEM_FLAGS CL_MEM_FLAGS_INFO
  32. // CL_IMAGE_FORMAT CL_IMAGE_FORMAT_INFO
  33. unit cl;
  34. interface
  35. uses
  36. ctypes;
  37. {$MACRO ON}
  38. {$IFDEF WINDOWS}
  39. {$DEFINE DYNLINK}
  40. const
  41. OpenCLlib = 'OpenCL.dll';
  42. {$DEFINE extdecl := stdcall}
  43. {$ELSE}
  44. {$IFDEF LINUX}
  45. {$DEFINE DYNLINK}
  46. const
  47. OpenCLlib = 'libOpenCL.so';
  48. {$DEFINE extdecl := cdecl}
  49. {$ENDIF}
  50. {$IFDEF DARWIN}
  51. {$linkframework OpenCL}
  52. {$DEFINE extdecl := cdecl}
  53. {$ENDIF}
  54. {$ENDIF}
  55. {cl_platform.h}
  56. const
  57. CL_PLATFORM_NVIDIA = $3001; // NVidia specific platform value
  58. {* scalar types *}
  59. type
  60. intptr_t = PtrInt;
  61. cl_char = cint8;
  62. cl_uchar = cuint8;
  63. cl_short = cint16;
  64. cl_ushort = cuint16;
  65. cl_int = cint32;
  66. cl_uint = cuint32;
  67. cl_long = cint64;
  68. cl_ulong = cuint64;
  69. cl_half = cuint16;
  70. cl_float = cfloat;
  71. cl_double = cdouble;
  72. Pcl_char = ^cl_char;
  73. Pcl_uchar = ^cl_uchar;
  74. Pcl_short = ^cl_short;
  75. Pcl_ushort = ^cl_ushort;
  76. Pcl_int = ^cl_int;
  77. Pcl_uint = ^cl_uint;
  78. Pcl_long = ^cl_long;
  79. Pcl_ulong = ^cl_ulong;
  80. Pcl_half = ^cl_half;
  81. Pcl_float = ^cl_float;
  82. Pcl_double = ^cl_double;
  83. const
  84. CL_CHAR_BIT = 8;
  85. CL_SCHAR_MAX = 127;
  86. CL_SCHAR_MIN = (-127-1);
  87. CL_CHAR_MAX = CL_SCHAR_MAX;
  88. CL_CHAR_MIN = CL_SCHAR_MIN;
  89. CL_UCHAR_MAX = 255;
  90. CL_SHRT_MAX = 32767;
  91. CL_SHRT_MIN = (-32767-1);
  92. CL_USHRT_MAX = 65535;
  93. CL_INT_MAX = 2147483647;
  94. CL_INT_MIN = (-2147483647-1);
  95. CL_UINT_MAX = $ffffffff;
  96. CL_LONG_MAX = $7FFFFFFFFFFFFFFF;
  97. CL_LONG_MIN = -$7FFFFFFFFFFFFFFF - 1;
  98. CL_ULONG_MAX = $FFFFFFFFFFFFFFFF;
  99. CL_FLT_DIG = 6;
  100. CL_FLT_MANT_DIG = 24;
  101. CL_FLT_MAX_10_EXP = +38;
  102. CL_FLT_MAX_EXP = +128;
  103. CL_FLT_MIN_10_EXP = -37;
  104. CL_FLT_MIN_EXP = -125;
  105. CL_FLT_RADIX = 2;
  106. // CL_FLT_MAX = 0x1.fffffep127f;
  107. // CL_FLT_MIN = 0x1.0p-126f;
  108. // CL_FLT_EPSILON = 0x1.0p-23f;
  109. CL_DBL_DIG = 15;
  110. CL_DBL_MANT_DIG = 53;
  111. CL_DBL_MAX_10_EXP = +308;
  112. CL_DBL_MAX_EXP = +1024;
  113. CL_DBL_MIN_10_EXP = -307;
  114. CL_DBL_MIN_EXP = -1021;
  115. CL_DBL_RADIX = 2;
  116. // CL_DBL_MAX 0x1.fffffffffffffp1023
  117. // CL_DBL_MIN 0x1.0p-1022
  118. // CL_DBL_EPSILON 0x1.0p-52
  119. {*
  120. * Vector types
  121. *
  122. * Note: OpenCL requires that all types be naturally aligned.
  123. * This means that vector types must be naturally aligned.
  124. * For example, a vector of four floats must be aligned to
  125. * a 16 byte boundary (calculated as 4 * the natural 4-byte
  126. * alignment of the float). The alignment qualifiers here
  127. * will only function properly if your compiler supports them
  128. * and if you don't actively work to defeat them. For example,
  129. * in order for a cl_float4 to be 16 byte aligned in a struct,
  130. * the start of the struct must itself be 16-byte aligned.
  131. *
  132. * Maintaining proper alignment is the user's responsibility.
  133. *}
  134. type
  135. cl_char2 = array [0..1] of cint8;
  136. cl_char4 = array [0..3] of cint8;
  137. cl_char8 = array [0..7] of cint8;
  138. cl_char16 = array [0..15] of cint8;
  139. cl_uchar2 = array [0..1] of cuint8;
  140. cl_uchar4 = array [0..3] of cuint8;
  141. cl_uchar8 = array [0..7] of cuint8;
  142. cl_uchar16 = array [0..15] of cuint8;
  143. cl_short2 = array [0..1] of cint16;
  144. cl_short4 = array [0..3] of cint16;
  145. cl_short8 = array [0..7] of cint16;
  146. cl_short16 = array [0..15] of cint16;
  147. cl_ushort2 = array [0..1] of cuint16;
  148. cl_ushort4 = array [0..3] of cuint16;
  149. cl_ushort8 = array [0..7] of cuint16;
  150. cl_ushort16 = array [0..15] of cuint16;
  151. cl_int2 = array [0..1] of cint32;
  152. cl_int4 = array [0..3] of cint32;
  153. cl_int8 = array [0..7] of cint32;
  154. cl_int16 = array [0..15] of cint32;
  155. cl_uint2 = array [0..1] of cuint32;
  156. cl_uint4 = array [0..3] of cuint32;
  157. cl_uint8 = array [0..7] of cuint32;
  158. cl_uint16 = array [0..15] of cuint32;
  159. cl_long2 = array [0..1] of cint64;
  160. cl_long4 = array [0..3] of cint64;
  161. cl_long8 = array [0..7] of cint64;
  162. cl_long16 = array [0..15] of cint64;
  163. cl_ulong2 = array [0..1] of cuint64;
  164. cl_ulong4 = array [0..3] of cuint64;
  165. cl_ulong8 = array [0..7] of cuint64;
  166. cl_ulong16 = array [0..15] of cuint64;
  167. cl_float2 = array [0..1] of cfloat;
  168. cl_float4 = array [0..3] of cfloat;
  169. cl_float8 = array [0..7] of cfloat;
  170. cl_float16 = array [0..15] of cfloat;
  171. cl_double2 = array [0..1] of cdouble;
  172. cl_double4 = array [0..3] of cdouble;
  173. cl_double8 = array [0..7] of cdouble;
  174. cl_double16 = array [0..15] of cdouble;
  175. {* There are no vector types for half *}
  176. // ****************************************************************************
  177. {cl.h}
  178. type
  179. _cl_platform_id = record end;
  180. _cl_device_id = record end;
  181. _cl_context = record end;
  182. _cl_command_queue = record end;
  183. _cl_mem = record end;
  184. _cl_program = record end;
  185. _cl_kernel = record end;
  186. _cl_event = record end;
  187. _cl_sampler = record end;
  188. cl_platform_id = ^_cl_platform_id;
  189. cl_device_id = ^_cl_device_id;
  190. cl_context = ^_cl_context;
  191. cl_command_queue = ^_cl_command_queue;
  192. cl_mem = ^_cl_mem;
  193. cl_program = ^_cl_program;
  194. cl_kernel = ^_cl_kernel;
  195. cl_event = ^_cl_event;
  196. cl_sampler = ^_cl_sampler;
  197. Pcl_platform_id = ^cl_platform_id;
  198. Pcl_device_id = ^cl_device_id;
  199. Pcl_context = ^cl_context;
  200. Pcl_command_queue = ^cl_command_queue;
  201. Pcl_mem = ^cl_mem;
  202. Pcl_program = ^cl_program;
  203. Pcl_kernel = ^cl_kernel;
  204. Pcl_event = ^cl_event;
  205. Pcl_sampler = ^cl_sampler;
  206. cl_bool = cl_uint; // WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels.
  207. cl_bitfield = cl_ulong;
  208. cl_device_type = cl_bitfield;
  209. cl_platform_info = cl_uint;
  210. cl_device_info = cl_uint;
  211. cl_device_address_info = cl_bitfield;
  212. cl_device_fp_config = cl_bitfield;
  213. cl_device_mem_cache_type = cl_uint;
  214. cl_device_local_mem_type = cl_uint;
  215. cl_device_exec_capabilities = cl_bitfield;
  216. cl_command_queue_properties = cl_bitfield;
  217. cl_context_properties = intptr_t;
  218. cl_context_info = cl_uint;
  219. cl_command_queue_info = cl_uint;
  220. cl_channel_order = cl_uint;
  221. cl_channel_type = cl_uint;
  222. cl_mem_flags = cl_bitfield;
  223. cl_mem_object_type = cl_uint;
  224. cl_mem_info = cl_uint;
  225. cl_image_info = cl_uint;
  226. cl_addressing_mode = cl_uint;
  227. cl_filter_mode = cl_uint;
  228. cl_sampler_info = cl_uint;
  229. cl_map_flags = cl_bitfield;
  230. cl_program_info = cl_uint;
  231. cl_program_build_info = cl_uint;
  232. cl_build_status = cl_int;
  233. cl_kernel_info = cl_uint;
  234. cl_kernel_work_group_info = cl_uint;
  235. cl_event_info = cl_uint;
  236. cl_command_type = cl_uint;
  237. cl_profiling_info = cl_uint;
  238. _cl_image_format = packed record
  239. image_channel_order : cl_channel_order;
  240. image_channel_data_type : cl_channel_type;
  241. end;
  242. cl_image_format = _cl_image_format;
  243. Pcl_context_properties = ^cl_context_properties;
  244. Pcl_image_format = ^cl_image_format;
  245. const
  246. // Error Codes
  247. CL_SUCCESS = 0;
  248. CL_DEVICE_NOT_FOUND = -1;
  249. CL_DEVICE_NOT_AVAILABLE = -2;
  250. CL_DEVICE_COMPILER_NOT_AVAILABLE = -3;
  251. CL_MEM_OBJECT_ALLOCATION_FAILURE = -4;
  252. CL_OUT_OF_RESOURCES = -5;
  253. CL_OUT_OF_HOST_MEMORY = -6;
  254. CL_PROFILING_INFO_NOT_AVAILABLE = -7;
  255. CL_MEM_COPY_OVERLAP = -8;
  256. CL_IMAGE_FORMAT_MISMATCH = -9;
  257. CL_IMAGE_FORMAT_NOT_SUPPORTED = -10;
  258. CL_BUILD_PROGRAM_FAILURE = -11;
  259. CL_MAP_FAILURE = -12;
  260. CL_INVALID_VALUE = -30;
  261. CL_INVALID_DEVICE_TYPE = -31;
  262. CL_INVALID_PLATFORM = -32;
  263. CL_INVALID_DEVICE = -33;
  264. CL_INVALID_CONTEXT = -34;
  265. CL_INVALID_QUEUE_PROPERTIES = -35;
  266. CL_INVALID_COMMAND_QUEUE = -36;
  267. CL_INVALID_HOST_PTR = -37;
  268. CL_INVALID_MEM_OBJECT = -38;
  269. CL_INVALID_IMAGE_FORMAT_DESCRIPTOR = -39;
  270. CL_INVALID_IMAGE_SIZE = -40;
  271. CL_INVALID_SAMPLER = -41;
  272. CL_INVALID_BINARY = -42;
  273. CL_INVALID_BUILD_OPTIONS = -43;
  274. CL_INVALID_PROGRAM = -44;
  275. CL_INVALID_PROGRAM_EXECUTABLE = -45;
  276. CL_INVALID_KERNEL_NAME = -46;
  277. CL_INVALID_KERNEL_DEFINITION = -47;
  278. CL_INVALID_KERNEL = -48;
  279. CL_INVALID_ARG_INDEX = -49;
  280. CL_INVALID_ARG_VALUE = -50;
  281. CL_INVALID_ARG_SIZE = -51;
  282. CL_INVALID_KERNEL_ARGS = -52;
  283. CL_INVALID_WORK_DIMENSION = -53;
  284. CL_INVALID_WORK_GROUP_SIZE = -54;
  285. CL_INVALID_WORK_ITEM_SIZE = -55;
  286. CL_INVALID_GLOBAL_OFFSET = -56;
  287. CL_INVALID_EVENT_WAIT_LIST = -57;
  288. CL_INVALID_EVENT = -58;
  289. CL_INVALID_OPERATION = -59;
  290. CL_INVALID_GL_OBJECT = -60;
  291. CL_INVALID_BUFFER_SIZE = -61;
  292. CL_INVALID_MIP_LEVEL = -62;
  293. // OpenCL Version
  294. CL_VERSION_1_0 = 1;
  295. // cl_bool
  296. CL_FALSE = 0;
  297. CL_TRUE = 1;
  298. // cl_platform_info
  299. CL_PLATFORM_PROFILE = $0900;
  300. CL_PLATFORM_VERSION = $0901;
  301. CL_PLATFORM_NAME = $0902;
  302. CL_PLATFORM_VENDOR = $0903;
  303. CL_PLATFORM_EXTENSIONS = $0904;
  304. // cl_device_type - bitfield
  305. CL_DEVICE_TYPE_DEFAULT = (1 shl 0);
  306. CL_DEVICE_TYPE_CPU = (1 shl 1);
  307. CL_DEVICE_TYPE_GPU = (1 shl 2);
  308. CL_DEVICE_TYPE_ACCELERATOR = (1 shl 3);
  309. CL_DEVICE_TYPE_ALL = $FFFFFFFF;
  310. // cl_device_info
  311. CL_DEVICE_TYPE_INFO = $1000; // CL_DEVICE_TYPE
  312. CL_DEVICE_VENDOR_ID = $1001;
  313. CL_DEVICE_MAX_COMPUTE_UNITS = $1002;
  314. CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = $1003;
  315. CL_DEVICE_MAX_WORK_GROUP_SIZE = $1004;
  316. CL_DEVICE_MAX_WORK_ITEM_SIZES = $1005;
  317. CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR = $1006;
  318. CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT = $1007;
  319. CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT = $1008;
  320. CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG = $1009;
  321. CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT = $100A;
  322. CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE = $100B;
  323. CL_DEVICE_MAX_CLOCK_FREQUENCY = $100C;
  324. CL_DEVICE_ADDRESS_BITS = $100D;
  325. CL_DEVICE_MAX_READ_IMAGE_ARGS = $100E;
  326. CL_DEVICE_MAX_WRITE_IMAGE_ARGS = $100F;
  327. CL_DEVICE_MAX_MEM_ALLOC_SIZE = $1010;
  328. CL_DEVICE_IMAGE2D_MAX_WIDTH = $1011;
  329. CL_DEVICE_IMAGE2D_MAX_HEIGHT = $1012;
  330. CL_DEVICE_IMAGE3D_MAX_WIDTH = $1013;
  331. CL_DEVICE_IMAGE3D_MAX_HEIGHT = $1014;
  332. CL_DEVICE_IMAGE3D_MAX_DEPTH = $1015;
  333. CL_DEVICE_IMAGE_SUPPORT = $1016;
  334. CL_DEVICE_MAX_PARAMETER_SIZE = $1017;
  335. CL_DEVICE_MAX_SAMPLERS = $1018;
  336. CL_DEVICE_MEM_BASE_ADDR_ALIGN = $1019;
  337. CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE = $101A;
  338. CL_DEVICE_SINGLE_FP_CONFIG = $101B;
  339. CL_DEVICE_DOUBLE_FP_CONFIG = $1032;
  340. CL_DEVICE_GLOBAL_MEM_CACHE_TYPE = $101C;
  341. CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE = $101D;
  342. CL_DEVICE_GLOBAL_MEM_CACHE_SIZE = $101E;
  343. CL_DEVICE_GLOBAL_MEM_SIZE = $101F;
  344. CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE = $1020;
  345. CL_DEVICE_MAX_CONSTANT_ARGS = $1021;
  346. CL_DEVICE_LOCAL_MEM_TYPE_INFO = $1022; // CL_DEVICE_LOCAL_MEM_TYPE
  347. CL_DEVICE_LOCAL_MEM_SIZE = $1023;
  348. CL_DEVICE_ERROR_CORRECTION_SUPPORT = $1024;
  349. CL_DEVICE_PROFILING_TIMER_RESOLUTION = $1025;
  350. CL_DEVICE_ENDIAN_LITTLE = $1026;
  351. CL_DEVICE_AVAILABLE = $1027;
  352. CL_DEVICE_COMPILER_AVAILABLE = $1028;
  353. CL_DEVICE_EXECUTION_CAPABILITIES = $1029;
  354. CL_DEVICE_QUEUE_PROPERTIES = $102A;
  355. CL_DEVICE_NAME = $102B;
  356. CL_DEVICE_VENDOR = $102C;
  357. CL_DRIVER_VERSION = $102D;
  358. CL_DEVICE_PROFILE = $102E;
  359. CL_DEVICE_VERSION = $102F;
  360. CL_DEVICE_EXTENSIONS = $1030;
  361. CL_DEVICE_PLATFORM = $1031;
  362. CL_DEVICE_OPENCL_C_VERSION = $103D;
  363. // cl_device_address_info - bitfield
  364. CL_DEVICE_ADDRESS_32_BITS = (1 shl 0);
  365. CL_DEVICE_ADDRESS_64_BITS = (1 shl 1);
  366. // cl_device_fp_config - bitfield
  367. CL_FP_DENORM = (1 shl 0);
  368. CL_FP_INF_NAN = (1 shl 1);
  369. CL_FP_ROUND_TO_NEAREST = (1 shl 2);
  370. CL_FP_ROUND_TO_ZERO = (1 shl 3);
  371. CL_FP_ROUND_TO_INF = (1 shl 4);
  372. CL_FP_FMA = (1 shl 5);
  373. // cl_device_mem_cache_type
  374. CL_NONE = $0;
  375. CL_READ_ONLY_CACHE = $1;
  376. CL_READ_WRITE_CACHE = $2;
  377. // cl_device_local_mem_type
  378. CL_LOCAL = $1;
  379. CL_GLOBAL = $2;
  380. // cl_device_exec_capabilities - bitfield
  381. CL_EXEC_KERNEL = (1 shl 0);
  382. CL_EXEC_NATIVE_KERNEL = (1 shl 1);
  383. // cl_command_queue_properties - bitfield
  384. CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 shl 0);
  385. CL_QUEUE_PROFILING_ENABLE = (1 shl 1);
  386. // cl_context_info
  387. CL_CONTEXT_REFERENCE_COUNT = $1080;
  388. CL_CONTEXT_DEVICES = $1081;
  389. CL_CONTEXT_PROPERTIES_INFO = $1082; // CL_CONTEXT_PROPERTIES
  390. CL_CONTEXT_NUM_DEVICES = $1083;
  391. CL_CONTEXT_PLATFORM_INFO = $1084; // CL_CONTEXT_PLATFORM
  392. // cl_command_queue_info
  393. CL_QUEUE_CONTEXT = $1090;
  394. CL_QUEUE_DEVICE = $1091;
  395. CL_QUEUE_REFERENCE_COUNT = $1092;
  396. CL_QUEUE_PROPERTIES = $1093;
  397. // cl_mem_flags - bitfield
  398. CL_MEM_READ_WRITE = (1 shl 0);
  399. CL_MEM_WRITE_ONLY = (1 shl 1);
  400. CL_MEM_READ_ONLY = (1 shl 2);
  401. CL_MEM_USE_HOST_PTR = (1 shl 3);
  402. CL_MEM_ALLOC_HOST_PTR = (1 shl 4);
  403. CL_MEM_COPY_HOST_PTR = (1 shl 5);
  404. // cl_channel_order
  405. CL_R = $10B0;
  406. CL_A = $10B1;
  407. CL_RG = $10B2;
  408. CL_RA = $10B3;
  409. CL_RGB = $10B4;
  410. CL_RGBA = $10B5;
  411. CL_BGRA = $10B6;
  412. CL_ARGB = $10B7;
  413. CL_INTENSITY = $10B8;
  414. CL_LUMINANCE = $10B9;
  415. // cl_channel_type
  416. CL_SNORM_INT8 = $10D0;
  417. CL_SNORM_INT16 = $10D1;
  418. CL_UNORM_INT8 = $10D2;
  419. CL_UNORM_INT16 = $10D3;
  420. CL_UNORM_SHORT_565 = $10D4;
  421. CL_UNORM_SHORT_555 = $10D5;
  422. CL_UNORM_INT_101010 = $10D6;
  423. CL_SIGNED_INT8 = $10D7;
  424. CL_SIGNED_INT16 = $10D8;
  425. CL_SIGNED_INT32 = $10D9;
  426. CL_UNSIGNED_INT8 = $10DA;
  427. CL_UNSIGNED_INT16 = $10DB;
  428. CL_UNSIGNED_INT32 = $10DC;
  429. CL_HALF_FLOAT = $10DD;
  430. CL_FLOAT_TYPE = $10DE; // CL_FLOAT
  431. // cl_mem_object_type
  432. CL_MEM_OBJECT_BUFFER = $10F0;
  433. CL_MEM_OBJECT_IMAGE2D = $10F1;
  434. CL_MEM_OBJECT_IMAGE3D = $10F2;
  435. // cl_mem_info
  436. CL_MEM_TYPE = $1100;
  437. CL_MEM_FLAGS_INFO = $1101; // CL_MEM_FLAGS
  438. CL_MEM_SIZE = $1102;
  439. CL_MEM_HOST_PTR = $1103;
  440. CL_MEM_MAP_COUNT = $1104;
  441. CL_MEM_REFERENCE_COUNT = $1105;
  442. CL_MEM_CONTEXT = $1106;
  443. // cl_image_info
  444. CL_IMAGE_FORMAT_INFO = $1110; // CL_IMAGE_FORMAT
  445. CL_IMAGE_ELEMENT_SIZE = $1111;
  446. CL_IMAGE_ROW_PITCH = $1112;
  447. CL_IMAGE_SLICE_PITCH = $1113;
  448. CL_IMAGE_WIDTH = $1114;
  449. CL_IMAGE_HEIGHT = $1115;
  450. CL_IMAGE_DEPTH = $1116;
  451. // cl_addressing_mode
  452. CL_ADDRESS_NONE = $1130;
  453. CL_ADDRESS_CLAMP_TO_EDGE = $1131;
  454. CL_ADDRESS_CLAMP = $1132;
  455. CL_ADDRESS_REPEAT = $1133;
  456. // cl_filter_mode
  457. CL_FILTER_NEAREST = $1140;
  458. CL_FILTER_LINEAR = $1141;
  459. // cl_sampler_info
  460. CL_SAMPLER_REFERENCE_COUNT = $1150;
  461. CL_SAMPLER_CONTEXT = $1151;
  462. CL_SAMPLER_NORMALIZED_COORDS = $1152;
  463. CL_SAMPLER_ADDRESSING_MODE = $1153;
  464. CL_SAMPLER_FILTER_MODE = $1154;
  465. // cl_map_flags - bitfield
  466. CL_MAP_READ = (1 shl 0);
  467. CL_MAP_WRITE = (1 shl 1);
  468. // cl_program_info
  469. CL_PROGRAM_REFERENCE_COUNT = $1160;
  470. CL_PROGRAM_CONTEXT = $1161;
  471. CL_PROGRAM_NUM_DEVICES = $1162;
  472. CL_PROGRAM_DEVICES = $1163;
  473. CL_PROGRAM_SOURCE = $1164;
  474. CL_PROGRAM_BINARY_SIZES = $1165;
  475. CL_PROGRAM_BINARIES = $1166;
  476. // cl_program_build_info
  477. CL_PROGRAM_BUILD_STATUS = $1181;
  478. CL_PROGRAM_BUILD_OPTIONS = $1182;
  479. CL_PROGRAM_BUILD_LOG = $1183;
  480. // cl_build_status
  481. CL_BUILD_SUCCESS = 0;
  482. CL_BUILD_NONE = -1;
  483. CL_BUILD_ERROR = -2;
  484. CL_BUILD_IN_PROGRESS = -3;
  485. // cl_kernel_info
  486. CL_KERNEL_FUNCTION_NAME = $1190;
  487. CL_KERNEL_NUM_ARGS = $1191;
  488. CL_KERNEL_REFERENCE_COUNT = $1192;
  489. CL_KERNEL_CONTEXT = $1193;
  490. CL_KERNEL_PROGRAM = $1194;
  491. // cl_kernel_work_group_info
  492. CL_KERNEL_WORK_GROUP_SIZE = $11B0;
  493. CL_KERNEL_COMPILE_WORK_GROUP_SIZE = $11B1;
  494. CL_KERNEL_LOCAL_MEM_SIZE = $11B2;
  495. // cl_event_info
  496. CL_EVENT_COMMAND_QUEUE = $11D0;
  497. CL_EVENT_COMMAND_TYPE = $11D1;
  498. CL_EVENT_REFERENCE_COUNT = $11D2;
  499. CL_EVENT_COMMAND_EXECUTION_STATUS = $11D3;
  500. // cl_command_type
  501. CL_COMMAND_NDRANGE_KERNEL = $11F0;
  502. CL_COMMAND_TASK = $11F1;
  503. CL_COMMAND_NATIVE_KERNEL = $11F2;
  504. CL_COMMAND_READ_BUFFER = $11F3;
  505. CL_COMMAND_WRITE_BUFFER = $11F4;
  506. CL_COMMAND_COPY_BUFFER = $11F5;
  507. CL_COMMAND_READ_IMAGE = $11F6;
  508. CL_COMMAND_WRITE_IMAGE = $11F7;
  509. CL_COMMAND_COPY_IMAGE = $11F8;
  510. CL_COMMAND_COPY_IMAGE_TO_BUFFER = $11F9;
  511. CL_COMMAND_COPY_BUFFER_TO_IMAGE = $11FA;
  512. CL_COMMAND_MAP_BUFFER = $11FB;
  513. CL_COMMAND_MAP_IMAGE = $11FC;
  514. CL_COMMAND_UNMAP_MEM_OBJECT = $11FD;
  515. CL_COMMAND_MARKER = $11FE;
  516. CL_COMMAND_WAIT_FOR_EVENTS = $11FF;
  517. CL_COMMAND_BARRIER = $1200;
  518. CL_COMMAND_ACQUIRE_GL_OBJECTS = $1201;
  519. CL_COMMAND_RELEASE_GL_OBJECTS = $1202;
  520. // command execution status
  521. CL_COMPLETE = $0;
  522. CL_RUNNING = $1;
  523. CL_SUBMITTED = $2;
  524. CL_QUEUED = $3;
  525. // cl_profiling_info
  526. CL_PROFILING_COMMAND_QUEUED = $1280;
  527. CL_PROFILING_COMMAND_SUBMIT = $1281;
  528. CL_PROFILING_COMMAND_START = $1282;
  529. CL_PROFILING_COMMAND_END = $1283;
  530. // ****************************************************************************
  531. // Platform APIs
  532. function clGetPlatformIDs(
  533. num_entries : cl_uint;
  534. platforms : Pcl_platform_id;
  535. num_platforms : Pcl_uint
  536. ): cl_int; extdecl;
  537. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetPlatformIDs';
  538. function clGetPlatformInfo(
  539. _platform : cl_platform_id;
  540. param_name : cl_platform_info;
  541. value_size : csize_t;
  542. value : Pointer;
  543. var size_ret : csize_t
  544. ): cl_int; extdecl;
  545. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetPlatformInfo';
  546. // Device APIs
  547. function clGetDeviceIDs(
  548. _platform : cl_platform_id;
  549. device_type : cl_device_type;
  550. num_entries : cl_uint;
  551. devices : Pcl_device_id;
  552. num_devices : pcl_uint
  553. ): cl_int; extdecl;
  554. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetDeviceIDs';
  555. function clGetDeviceInfo(
  556. device : cl_device_id;
  557. param_name : cl_device_info;
  558. value_size : csize_t;
  559. value : Pointer;
  560. var size_ret : csize_t
  561. ): cl_int; extdecl;
  562. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetDeviceInfo';
  563. // Context APIs
  564. type
  565. TContextNotify = procedure (name: Pchar; data: Pointer; size: csize_t; data2: Pointer); extdecl;
  566. function clCreateContext(
  567. properties : Pcl_context_properties;
  568. num_devices : cl_uint;
  569. devices : Pcl_device_id;
  570. notify : TContextNotify;
  571. user_data : Pointer;
  572. var errcode_ret : cl_int
  573. ): cl_context; extdecl;
  574. external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateContext';
  575. function clCreateContextFromType(
  576. properties : Pcl_context_properties;
  577. device_type : cl_device_type;
  578. notify : TContextNotify;
  579. user_data : Pointer;
  580. var errcode_ret : cl_int
  581. ): cl_context; extdecl;
  582. external name 'clCreateContextFromType';
  583. function clRetainContext(context: cl_context): cl_int; extdecl;
  584. external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainContext';
  585. function clReleaseContext(context: cl_context): cl_int; extdecl;
  586. external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseContext';
  587. function clGetContextInfo(
  588. context : cl_context;
  589. param_name : cl_context_info;
  590. value_size : csize_t;
  591. value : Pointer;
  592. var size_ret : csize_t
  593. ): cl_int; extdecl;
  594. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetContextInfo';
  595. // Command Queue APIs
  596. function clCreateCommandQueue(
  597. context : cl_context;
  598. device : cl_device_id;
  599. properties : cl_command_queue_properties;
  600. errcode_ret: cl_int
  601. ): cl_command_queue; extdecl;
  602. external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateCommandQueue';
  603. function clRetainCommandQueue(command_queue : cl_command_queue): cl_int; extdecl;
  604. external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainCommandQueue';
  605. function clReleaseCommandQueue(command_queue : cl_command_queue): cl_int; extdecl;
  606. external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseCommandQueue';
  607. function clGetCommandQueueInfo(
  608. command_queue: cl_command_queue;
  609. param_name : cl_command_queue_info;
  610. value_size : csize_t;
  611. value : Pointer;
  612. var size_ret : csize_t
  613. ): cl_int; extdecl;
  614. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetCommandQueueInfo';
  615. function clSetCommandQueueProperty(
  616. command_queue : cl_command_queue;
  617. properties : cl_command_queue_properties;
  618. enable : cl_bool;
  619. var old_properties : cl_command_queue_properties
  620. ): cl_int; extdecl;
  621. external {$ifdef DYNLINK}opencllib{$endif} name 'clSetCommandQueueProperty';
  622. // Memory Object APIs
  623. function clCreateBuffer(
  624. context : cl_context;
  625. flags : cl_mem_flags;
  626. size : csize_t;
  627. host_ptr : Pointer;
  628. var errcode_ret : cl_int
  629. ): cl_mem; extdecl;
  630. external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateBuffer';
  631. function clCreateImage2D(
  632. context : cl_context;
  633. flags : cl_mem_flags;
  634. image_format : Pcl_image_format;
  635. image_width : csize_t;
  636. image_height : csize_t;
  637. image_row_pitch : csize_t;
  638. host_ptr : Pointer;
  639. var errcode_ret : cl_int
  640. ): cl_mem; extdecl;
  641. external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateImage2D';
  642. function clCreateImage3D(
  643. context : cl_context;
  644. flags : cl_mem_flags;
  645. image_format : Pcl_image_format;
  646. image_width : csize_t;
  647. image_height : csize_t;
  648. image_depth : csize_t;
  649. image_row_pitch : csize_t;
  650. image_slice_pitch : csize_t;
  651. host_ptr : Pointer;
  652. var errcode_ret : cl_int
  653. ): cl_mem; extdecl;
  654. external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateImage3D';
  655. function clRetainMemObject(memobj: cl_mem): cl_int; extdecl;
  656. external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainMemObject';
  657. function clReleaseMemObject(memobj: cl_mem): cl_int; extdecl;
  658. external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseMemObject';
  659. function clGetSupportedImageFormats(
  660. context : cl_context;
  661. flags : cl_mem_flags;
  662. image_type : cl_mem_object_type;
  663. num_entries : cl_uint;
  664. image_formats : Pcl_image_format;
  665. var num_formats : cl_uint
  666. ): cl_int; extdecl;
  667. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetSupportedImageFormats';
  668. function clGetMemObjectInfo(
  669. memobj : cl_mem;
  670. param_name : cl_mem_info;
  671. value_size : csize_t;
  672. value : Pointer;
  673. var size_ret : csize_t
  674. ): cl_int; extdecl;
  675. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetMemObjectInfo';
  676. function clGetImageInfo(
  677. image : cl_mem;
  678. param_name : cl_image_info;
  679. value_size : csize_t;
  680. value : Pointer;
  681. var size_ret : csize_t
  682. ): cl_int; extdecl;
  683. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetImageInfo';
  684. // Sampler APIs
  685. function clCreateSampler(
  686. context : cl_context;
  687. is_norm_coords : cl_bool;
  688. addr_mode : cl_addressing_mode;
  689. filter_mode : cl_filter_mode;
  690. var errcode_ret : cl_int
  691. ): cl_sampler; extdecl;
  692. external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateSampler';
  693. function clRetainSampler(sampler: cl_sampler): cl_int; extdecl;
  694. external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainSampler';
  695. function clReleaseSampler(sampler: cl_sampler): cl_int; extdecl;
  696. external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseSampler';
  697. function clGetSamplerInfo(
  698. sampler : cl_sampler;
  699. param_name : cl_sampler_info;
  700. value_size : csize_t;
  701. value : Pointer;
  702. var size_ret : csize_t
  703. ): cl_int; extdecl;
  704. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetSamplerInfo';
  705. // Program Object APIs
  706. function clCreateProgramWithSource(
  707. context : cl_context;
  708. count : cl_uint;
  709. strings : PPChar;
  710. lengths : Pcsize_t;
  711. var errcode_ret : cl_int
  712. ): cl_program; extdecl;
  713. external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateProgramWithSource';
  714. type
  715. PPByte = ^PByte;
  716. function clCreateProgramWithBinary(
  717. context : cl_context;
  718. num_devices : cl_uint;
  719. device_list : Pcl_device_id;
  720. lengths : Pcsize_t;
  721. binaries : PPByte;
  722. var binary_status: cl_int;
  723. var errcode_ret: cl_int
  724. ): cl_program; extdecl;
  725. external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateProgramWithBinary';
  726. function clRetainProgram(_program: cl_program): cl_int; extdecl;
  727. external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainProgram';
  728. function clReleaseProgram(_program: cl_program): cl_int; extdecl;
  729. external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseProgram';
  730. type
  731. TProgramNotify = procedure (_program: cl_program; user_data: Pointer); extdecl;
  732. //extern cl_int
  733. function clBuildProgram(
  734. _program : cl_program;
  735. num_devices : cl_uint;
  736. device_list : Pcl_device_id;
  737. options : PChar;
  738. notify : TProgramNotify;
  739. user_data : Pointer
  740. ): cl_int; extdecl;
  741. external {$ifdef DYNLINK}opencllib{$endif} name 'clBuildProgram';
  742. function clUnloadCompiler: cl_int; extdecl;
  743. external {$ifdef DYNLINK}opencllib{$endif} name 'clUnloadCompiler';
  744. function clGetProgramInfo(
  745. _program : cl_program;
  746. param_name : cl_program_info;
  747. value_size : csize_t;
  748. value : Pointer;
  749. var size_ret : csize_t
  750. ): cl_int; extdecl;
  751. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetProgramInfo';
  752. function clGetProgramBuildInfo(
  753. _program : cl_program;
  754. device : cl_device_id;
  755. param_name : cl_program_build_info;
  756. value_size : csize_t;
  757. value : Pointer;
  758. var size_ret : csize_t
  759. ): cl_int; extdecl;
  760. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetProgramBuildInfo';
  761. // Kernel Object APIs
  762. function clCreateKernel(
  763. _program : cl_program;
  764. kernel_name : PChar;
  765. var errcode_ret : cl_int
  766. ): cl_kernel; extdecl;
  767. external {$ifdef DYNLINK}opencllib{$endif} name 'clCreateKernel';
  768. function clCreateKernelsInProgram(
  769. _program : cl_program;
  770. num_kernels : cl_uint;
  771. kernels : Pcl_kernel;
  772. var num_ret : cl_uint
  773. ): cl_int; extdecl; external name 'clCreateKernelsInProgram';
  774. function clRetainKernel(kernel: cl_kernel): cl_int; extdecl;
  775. external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainKernel';
  776. function clReleaseKernel(kernel: cl_kernel): cl_int; extdecl;
  777. external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseKernel';
  778. function clSetKernelArg(
  779. kernel : cl_kernel;
  780. arg_index : cl_uint;
  781. arg_size : csize_t;
  782. arg_value : Pointer
  783. ): cl_int; extdecl;
  784. external {$ifdef DYNLINK}opencllib{$endif} name 'clSetKernelArg';
  785. function clGetKernelInfo(
  786. kernel : cl_kernel;
  787. param_name : cl_kernel_info;
  788. value_size : csize_t;
  789. value : Pointer;
  790. var size_ret : csize_t
  791. ): cl_int; extdecl;
  792. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetKernelInfo';
  793. function clGetKernelWorkGroupInfo(
  794. kernel : cl_kernel;
  795. device : cl_device_id;
  796. param_name : cl_kernel_work_group_info;
  797. value_size : csize_t;
  798. value : Pointer;
  799. size_ret : pcsize_t
  800. ): cl_int; extdecl;
  801. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetKernelWorkGroupInfo';
  802. // Event Object APIs
  803. function clWaitForEvents(
  804. num_events : cl_uint;
  805. event_list : cl_event
  806. ): cl_int; extdecl;
  807. external {$ifdef DYNLINK}opencllib{$endif} name 'clWaitForEvents';
  808. function clGetEventInfo(
  809. event : cl_event;
  810. param_name : cl_event_info;
  811. value_size : csize_t;
  812. value : Pointer;
  813. var size_ret : csize_t
  814. ): cl_int; extdecl;
  815. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetEventInfo';
  816. function clRetainEvent(event: cl_event): cl_int; extdecl;
  817. external {$ifdef DYNLINK}opencllib{$endif} name 'clRetainEvent';
  818. function clReleaseEvent(event: cl_event): cl_int; extdecl;
  819. external {$ifdef DYNLINK}opencllib{$endif} name 'clReleaseEvent';
  820. // Profiling APIs
  821. function clGetEventProfilingInfo(
  822. event : cl_event;
  823. param_name : cl_profiling_info;
  824. value_size : csize_t;
  825. value : Pointer;
  826. var size_ret : csize_t
  827. ): cl_int; extdecl;
  828. external {$ifdef DYNLINK}opencllib{$endif} name 'clGetEventProfilingInfo';
  829. // Flush and Finish APIs
  830. function clFlush(command_queue: cl_command_queue): cl_int; extdecl;
  831. external {$ifdef DYNLINK}opencllib{$endif} name 'clFlush';
  832. function clFinish(command_queue: cl_command_queue): cl_int; extdecl;
  833. external {$ifdef DYNLINK}opencllib{$endif} name 'clFinish';
  834. // Enqueued Commands APIs
  835. function clEnqueueReadBuffer(
  836. command_queue : cl_command_queue;
  837. buffer : cl_mem;
  838. blocking_read : cl_bool;
  839. offset : csize_t;
  840. cb : csize_t;
  841. ptr : Pointer;
  842. num_events : cl_uint;
  843. events_list : Pcl_event;
  844. event : Pcl_event
  845. ): cl_int; extdecl;
  846. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueReadBuffer';
  847. function clEnqueueWriteBuffer(
  848. command_queue : cl_command_queue;
  849. buffer : cl_mem;
  850. blocking_write : cl_bool;
  851. offset : csize_t;
  852. cb : csize_t;
  853. ptr : Pointer;
  854. num_events : cl_uint;
  855. events_list : Pcl_event;
  856. event : Pcl_event
  857. ): cl_int; extdecl;
  858. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueWriteBuffer';
  859. function clEnqueueCopyBuffer(
  860. command_queue : cl_command_queue;
  861. src_buffer : cl_mem;
  862. dst_buffer : cl_mem;
  863. src_offset : csize_t;
  864. dst_offset : csize_t;
  865. cb : csize_t;
  866. num_events : cl_uint;
  867. events_list : Pcl_event;
  868. event : Pcl_event
  869. ): cl_int; extdecl;
  870. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueCopyBuffer';
  871. function clEnqueueReadImage(
  872. command_queue : cl_command_queue;
  873. image : cl_mem;
  874. blocking_read : cl_bool;
  875. origin : Pcsize_t;
  876. region : Pcsize_t;
  877. row_pitch : csize_t;
  878. slice_pitch : csize_t;
  879. ptr : Pointer;
  880. num_events : cl_uint;
  881. events_list : Pcl_event;
  882. event : Pcl_event
  883. ): cl_int; extdecl;
  884. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueReadImage';
  885. function clEnqueueWriteImage(
  886. command_queue : cl_command_queue;
  887. image : cl_mem;
  888. blocking_write : cl_bool;
  889. origin : Pcsize_t;
  890. region : Pcsize_t;
  891. row_pitch : csize_t;
  892. slice_pitch : csize_t;
  893. ptr : Pointer;
  894. num_events : cl_uint;
  895. events_list : Pcl_event;
  896. event : Pcl_event
  897. ): cl_int; extdecl;
  898. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueWriteImage';
  899. function clEnqueueCopyImage(
  900. command_queue : cl_command_queue;
  901. src_image : cl_mem;
  902. dst_image : cl_mem;
  903. src_origin : Pcsize_t;
  904. dst_origin : Pcsize_t;
  905. region : Pcsize_t;
  906. num_events : cl_uint;
  907. events_list : Pcl_event;
  908. event : Pcl_event
  909. ): cl_int; extdecl;
  910. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueCopyImage';
  911. function clEnqueueCopyImageToBuffer(
  912. command_queue : cl_command_queue;
  913. src_image : cl_mem;
  914. dst_buffre : cl_mem;
  915. src_origin : Pcsize_t;
  916. region : Pcsize_t;
  917. dst_offset : csize_t;
  918. num_events : cl_uint;
  919. events_list : Pcl_event;
  920. event : Pcl_event
  921. ): cl_int; extdecl;
  922. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueCopyImageToBuffer';
  923. function clEnqueueCopyBufferToImage(
  924. command_queue : cl_command_queue;
  925. src_buffer : cl_mem;
  926. dst_image : cl_mem;
  927. src_offset : csize_t;
  928. dst_origin : Pcsize_t;
  929. region : Pcsize_t;
  930. num_events : cl_uint;
  931. events_list : Pcl_event;
  932. event : Pcl_event
  933. ): cl_int; extdecl;
  934. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueCopyBufferToImage';
  935. function clEnqueueMapBuffer(
  936. command_queue : cl_command_queue;
  937. buffer : cl_mem;
  938. blocking_map : cl_bool;
  939. map_flags : cl_map_flags;
  940. offset : csize_t;
  941. cb : csize_t;
  942. num_events : cl_uint;
  943. events_list : Pcl_event;
  944. event : Pcl_event;
  945. var errcode_ret : cl_int
  946. ): Pointer; extdecl;
  947. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueMapBuffer';
  948. function clEnqueueMapImage(
  949. command_queue : cl_command_queue;
  950. image : cl_mem;
  951. blocking_map : cl_bool;
  952. map_flags : cl_map_flags;
  953. origin : Pcsize_t;
  954. region : Pcsize_t;
  955. row_pitch : csize_t;
  956. slice_pitch : csize_t;
  957. num_events : cl_uint;
  958. events_list : Pcl_event;
  959. event : Pcl_event;
  960. var errcode_ret : cl_int
  961. ): Pointer; extdecl;
  962. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueMapImage';
  963. function clEnqueueUnmapMemObject(
  964. command_queue : cl_command_queue;
  965. memobj : cl_mem;
  966. mapped_ptr : Pointer;
  967. num_events : cl_uint;
  968. events_list : Pcl_event;
  969. event : Pcl_event
  970. ): cl_int; extdecl;
  971. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueUnmapMemObject';
  972. function clEnqueueNDRangeKernel(
  973. command_queue : cl_command_queue;
  974. kernel : cl_kernel;
  975. work_dim : cl_uint;
  976. global_offset,
  977. global_size,
  978. local_size : Pcsize_t;
  979. num_events : cl_uint;
  980. events_list : Pcl_event;
  981. event : Pcl_event
  982. ): cl_int; extdecl;
  983. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueNDRangeKernel';
  984. function clEnqueueTask(
  985. command_queue : cl_command_queue;
  986. kernel : cl_kernel;
  987. num_events : cl_uint;
  988. events_list : Pcl_event;
  989. event : Pcl_event
  990. ): cl_int; extdecl;
  991. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueTask';
  992. type
  993. TEnqueueUserProc = procedure (userdata: Pointer); extdecl;
  994. function clEnqueueNativeKernel(
  995. command_queue : cl_command_queue;
  996. user_func : TEnqueueUserProc;
  997. args : Pointer;
  998. cb_args : csize_t;
  999. num_mem_objects : cl_uint;
  1000. mem_list : Pcl_mem;
  1001. args_mem_loc : PPointer;
  1002. num_events : cl_uint;
  1003. event_wait_list : Pcl_event;
  1004. event : Pcl_event
  1005. ): cl_int; extdecl;
  1006. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueNativeKernel';
  1007. function clEnqueueMarker(command_queue: cl_command_queue; event: Pcl_event
  1008. ): cl_int; extdecl;
  1009. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueMarker';
  1010. function clEnqueueWaitForEvents(command_queue: cl_command_queue;
  1011. num_events: cl_uint; event_list: Pcl_event
  1012. ): cl_int; extdecl;
  1013. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueWaitForEvents';
  1014. function clEnqueueBarrier(command_queue: cl_command_queue
  1015. ): cl_int; extdecl;
  1016. external {$ifdef DYNLINK}opencllib{$endif} name 'clEnqueueBarrier';
  1017. function clErrorText(err:cl_int):string;
  1018. implementation
  1019. function clErrorText(err:cl_int):string;
  1020. begin
  1021. case err of
  1022. CL_DEVICE_NOT_FOUND : clErrorText:='CL_DEVICE_NOT_FOUND';
  1023. CL_DEVICE_NOT_AVAILABLE : clErrorText:='CL_DEVICE_NOT_AVAILABLE';
  1024. CL_DEVICE_COMPILER_NOT_AVAILABLE : clErrorText:='CL_DEVICE_COMPILER_NOT_AVAILABLE';
  1025. CL_MEM_OBJECT_ALLOCATION_FAILURE : clErrorText:='CL_MEM_OBJECT_ALLOCATION_FAILURE';
  1026. CL_OUT_OF_RESOURCES : clErrorText:='CL_OUT_OF_RESOURCES';
  1027. CL_OUT_OF_HOST_MEMORY : clErrorText:='CL_OUT_OF_HOST_MEMORY';
  1028. CL_PROFILING_INFO_NOT_AVAILABLE : clErrorText:='CL_PROFILING_INFO_NOT_AVAILABLE';
  1029. CL_MEM_COPY_OVERLAP : clErrorText:='CL_MEM_COPY_OVERLAP';
  1030. CL_IMAGE_FORMAT_MISMATCH : clErrorText:='CL_IMAGE_FORMAT_MISMATCH';
  1031. CL_IMAGE_FORMAT_NOT_SUPPORTED : clErrorText:='CL_IMAGE_FORMAT_NOT_SUPPORTED';
  1032. CL_BUILD_PROGRAM_FAILURE : clErrorText:='CL_BUILD_PROGRAM_FAILURE';
  1033. CL_MAP_FAILURE : clErrorText:='CL_MAP_FAILURE';
  1034. CL_INVALID_VALUE : clErrorText:='CL_INVALID_VALUE';
  1035. CL_INVALID_DEVICE_TYPE : clErrorText:='CL_INVALID_DEVICE_TYPE';
  1036. CL_INVALID_PLATFORM : clErrorText:='CL_INVALID_PLATFORM';
  1037. CL_INVALID_DEVICE : clErrorText:='CL_INVALID_DEVICE';
  1038. CL_INVALID_CONTEXT : clErrorText:='CL_INVALID_CONTEXT';
  1039. CL_INVALID_QUEUE_PROPERTIES : clErrorText:='CL_INVALID_QUEUE_PROPERTIES';
  1040. CL_INVALID_COMMAND_QUEUE : clErrorText:='CL_INVALID_COMMAND_QUEUE';
  1041. CL_INVALID_HOST_PTR : clErrorText:='CL_INVALID_HOST_PTR';
  1042. CL_INVALID_MEM_OBJECT : clErrorText:='CL_INVALID_MEM_OBJECT';
  1043. CL_INVALID_IMAGE_FORMAT_DESCRIPTOR : clErrorText:='CL_INVALID_IMAGE_FORMAT_DESCRIPTOR';
  1044. CL_INVALID_IMAGE_SIZE : clErrorText:='CL_INVALID_IMAGE_SIZE';
  1045. CL_INVALID_SAMPLER : clErrorText:='CL_INVALID_SAMPLER';
  1046. CL_INVALID_BINARY : clErrorText:='CL_INVALID_BINARY';
  1047. CL_INVALID_BUILD_OPTIONS : clErrorText:='CL_INVALID_BUILD_OPTIONS';
  1048. CL_INVALID_PROGRAM : clErrorText:='CL_INVALID_PROGRAM';
  1049. CL_INVALID_PROGRAM_EXECUTABLE : clErrorText:='CL_INVALID_PROGRAM_EXECUTABLE';
  1050. CL_INVALID_KERNEL_NAME : clErrorText:='CL_INVALID_KERNEL_NAME';
  1051. CL_INVALID_KERNEL_DEFINITION : clErrorText:='CL_INVALID_KERNEL_DEFINITION';
  1052. CL_INVALID_KERNEL : clErrorText:='CL_INVALID_KERNEL';
  1053. CL_INVALID_ARG_INDEX : clErrorText:='CL_INVALID_ARG_INDEX';
  1054. CL_INVALID_ARG_VALUE : clErrorText:='CL_INVALID_ARG_VALUE';
  1055. CL_INVALID_ARG_SIZE : clErrorText:='CL_INVALID_ARG_SIZE';
  1056. CL_INVALID_KERNEL_ARGS : clErrorText:='CL_INVALID_KERNEL_ARGS';
  1057. CL_INVALID_WORK_DIMENSION : clErrorText:='CL_INVALID_WORK_DIMENSION';
  1058. CL_INVALID_WORK_GROUP_SIZE : clErrorText:='CL_INVALID_WORK_GROUP_SIZE';
  1059. CL_INVALID_WORK_ITEM_SIZE : clErrorText:='CL_INVALID_WORK_ITEM_SIZE';
  1060. CL_INVALID_GLOBAL_OFFSET : clErrorText:='CL_INVALID_GLOBAL_OFFSET';
  1061. CL_INVALID_EVENT_WAIT_LIST : clErrorText:='CL_INVALID_EVENT_WAIT_LIST';
  1062. CL_INVALID_EVENT : clErrorText:='CL_INVALID_EVENT';
  1063. CL_INVALID_OPERATION : clErrorText:='CL_INVALID_OPERATION';
  1064. CL_INVALID_GL_OBJECT : clErrorText:='CL_INVALID_GL_OBJECT';
  1065. CL_INVALID_BUFFER_SIZE : clErrorText:='CL_INVALID_BUFFER_SIZE';
  1066. CL_INVALID_MIP_LEVEL : clErrorText:='CL_INVALID_MIP_LEVEL';
  1067. else
  1068. clErrorText:='Unknown OpenCL error';
  1069. end;
  1070. end;
  1071. end.