2
0

CL_Ext.pas 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. (*******************************************************************************
  2. * Copyright (c) 2008-2010 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. (************************************************)
  24. (* *)
  25. (* OpenCL1.2 and Delphi and Windows *)
  26. (* *)
  27. (* created by : Maksym Tymkovych *)
  28. (* (niello) *)
  29. (* *)
  30. (* headers versions: 0.07 *)
  31. (* file name : CL_ext.pas *)
  32. (* last modify : 10.12.11 *)
  33. (* license : BSD *)
  34. (* *)
  35. (* Site : www.niello.org.ua *)
  36. (* e-mail : [email protected] *)
  37. (* ICQ : 446-769-253 *)
  38. (* *)
  39. (* updated by : Alexander Kiselev *)
  40. (* (Igroman) *)
  41. (* Site : http://Igroman14.livejournal.com *)
  42. (* e-mail : [email protected] *)
  43. (* ICQ : 207-381-695 *)
  44. (* (c) 2010 *)
  45. (* *)
  46. (***********Copyright (c) niello 2008-2011*******)
  47. (* cl_ext.h contains OpenCL extensions which don't have external *)
  48. (* (OpenGL, D3D) dependencies. *)
  49. unit CL_Ext;
  50. interface
  51. {$INCLUDE OpenCL.inc}
  52. uses
  53. CL,
  54. CL_Platform;
  55. const
  56. (* cl_khr_fp64 extension - no extension #define since it has no functions *)
  57. CL_DEVICE_DOUBLE_FP_CONFIG = $1032;
  58. (* cl_khr_fp16 extension - no extension #define since it has no functions *)
  59. CL_DEVICE_HALF_FP_CONFIG = $1033;
  60. (* Memory object destruction
  61. *
  62. * Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR
  63. *
  64. * Registers a user callback function that will be called when the memory object is deleted and its resources
  65. * freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback
  66. * stack associated with memobj. The registered user callback functions are called in the reverse order in
  67. * which they were registered. The user callback functions are called and then the memory object is deleted
  68. * and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be
  69. * notified when the memory referenced by host_ptr, specified when the memory object is created and used as
  70. * the storage bits for the memory object, can be reused or freed.
  71. *
  72. * The application may not call CL api's with the cl_mem object passed to the pfn_notify.
  73. *
  74. * Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
  75. * before using.
  76. *)
  77. const
  78. cl_APPLE_SetMemObjectDestructor = 1;
  79. {$IFDEF CL_VERSION_1_0}
  80. type
  81. TclSetMemObjectDestructorAPPLE = function(
  82. memobj: Tcl_mem; (* memobj *)
  83. pfn_notify: Pointer;(* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/*)
  84. user_data: Pointer(*user_data *)
  85. ): TCL_int;{$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
  86. var
  87. clSetMemObjectDestructorAPPLE: TclSetMemObjectDestructorAPPLE;
  88. {$ENDIF}
  89. (* Context Logging Functions
  90. *
  91. * The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext().
  92. * Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
  93. * before using.
  94. *
  95. * clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger
  96. *)
  97. const
  98. cl_APPLE_ContextLoggingFunctions = 1;
  99. {$IFDEF CL_VERSION_1_0}
  100. type
  101. TclLogMessagesToSystemLogAPPLE = function(
  102. const errstr: PAnsiChar; (* errstr *)
  103. const private_info: Pointer; (* private_info *)
  104. cb: TSize_t; (* cb *)
  105. user_data: Pointer (* user_data *)
  106. ): TCL_int;
  107. {$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
  108. (* clLogMessagesToStdout sends all log messages to the file descriptor stdout *)
  109. TclLogMessagesToStdoutAPPLE = function(
  110. const errstr: PAnsiChar; (* errstr *)
  111. const private_info: Pointer; (* private_info *)
  112. cb: TSize_t; (* cb *)
  113. user_data: Pointer (* user_data *)
  114. ): TCL_int;
  115. {$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
  116. (* clLogMessagesToStderr sends all log messages to the file descriptor stderr *)
  117. TclLogMessagesToStderrAPPLE = function(
  118. const errstr: PAnsiChar; (* errstr *)
  119. const private_info: Pointer; (* private_info *)
  120. cb: TSize_t; (* cb *)
  121. user_data: Pointer (* user_data *)
  122. ): TCL_int;
  123. {$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
  124. var
  125. clLogMessagesToSystemLogAPPLE: TclLogMessagesToSystemLogAPPLE;
  126. clLogMessagesToStdoutAPPLE: TclLogMessagesToStdoutAPPLE;
  127. clLogMessagesToStderrAPPLE: TclLogMessagesToStderrAPPLE;
  128. {$ENDIF}
  129. const
  130. (* cl_khr_icd extension *)
  131. cl_khr_icd = 1;
  132. (* cl_platform_info *)
  133. (*
  134. Accepted as <param_name> to the function clGetPlatformInfo
  135. *)
  136. CL_PLATFORM_ICD_SUFFIX_KHR = $0920;
  137. (* Additional Error Codes *)
  138. (*
  139. Returned by clGetPlatformIDs when no platforms are found
  140. *)
  141. CL_PLATFORM_NOT_FOUND_KHR = -1001;
  142. type
  143. TclIcdGetPlatformIDsKHR = function (
  144. num_entries: Tcl_uint; (* num_entries *)
  145. platforms: Pcl_platform_id; (* platforms *)
  146. num_platforms: Pcl_uint (* num_platforms *)
  147. ): TCL_int;{$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};// external OpenCL;
  148. var
  149. clIcdGetPlatformIDsKHR: TclIcdGetPlatformIDsKHR;
  150. (******************************************
  151. * cl_nv_device_attribute_query extension *
  152. ******************************************)
  153. (* cl_nv_device_attribute_query extension - no extension #define since it has no functions *)
  154. const
  155. CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV = $4000;
  156. CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV = $4001;
  157. CL_DEVICE_REGISTERS_PER_BLOCK_NV = $4002;
  158. CL_DEVICE_WARP_SIZE_NV = $4003;
  159. CL_DEVICE_GPU_OVERLAP_NV = $4004;
  160. CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV = $4005;
  161. CL_DEVICE_INTEGRATED_MEMORY_NV = $4006;
  162. (*********************************
  163. * cl_amd_device_attribute_query *
  164. *********************************)
  165. const
  166. (*
  167. Accepted as the <param_name> parameter of clGetDeviceInfo. Return the
  168. offset in nano-seconds between an event timestamp and Epoch.
  169. *)
  170. CL_DEVICE_PROFILING_TIMER_OFFSET_AMD = $4036;
  171. {$IFDEF CL_VERSION_1_1}
  172. (***********************************
  173. * cl_ext_device_fission extension *
  174. ***********************************)
  175. const
  176. cl_ext_device_fission = 1;
  177. type
  178. (*
  179. clReleaseDeviceEXT decrements the <device> reference count. After the
  180. reference count reaches zero, the object shall be destroyed and associated
  181. resources released for reuse by the system.
  182. clReleaseDeviceEXT returns CL_SUCCESS if the function is executed
  183. successfully or the device is a root level device. It returns
  184. CL_INVALID_DEVICE if the <device> is not a valid device.
  185. *)
  186. TclReleaseDeviceEXT = function( device: TCL_device_id (*device*) ): TCL_int;{$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
  187. var
  188. clReleaseDeviceEXT: TclReleaseDeviceEXT;
  189. (*
  190. clReleaseDeviceEXT returns CL_SUCCESS if the function is executed
  191. successfully or the device is a root level device. It returns
  192. CL_INVALID_DEVICE if the <device> is not a valid device.
  193. CAUTION: Since root level devices are generally returned by a clGet call
  194. (clGetDeviceIDs) and not a clCreate call, the user generally does not own a
  195. reference count for root level devices. The reference count attached to a
  196. device retured from clGetDeviceIDs is owned by the implementation.
  197. Developers need to be careful when releasing cl_device_ids to always balance
  198. clCreateSubDevicesEXT or clRetainDeviceEXT with each call to
  199. clReleaseDeviceEXT for the device. By convention, software layers that own
  200. a reference count should be themselves responsible for releasing it.
  201. *)
  202. type
  203. TclRetainDeviceEXT = function( device: TCL_device_id (*device*) ): TCL_int;{$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
  204. var
  205. clRetainDeviceEXT: TclRetainDeviceEXT;
  206. type
  207. Pcl_device_partition_property_ext = ^Tcl_device_partition_property_ext;
  208. Tcl_device_partition_property_ext = Tcl_ulong; //?typedef cl_bitfield cl_device_partition_property_ext;
  209. (*
  210. lCreateSubDevicesEXT creates an array of sub-devices that each reference a
  211. nonintersecting set of compute units within <in_device>, according to a
  212. partition scheme given by the <cl_device_partition_property_ext> list. The
  213. output sub-devices may be used in every way that the root device can be
  214. used, including building programs, further calls to clCreateSubDevicesEXT
  215. and creating command queues. They may also be used within any context
  216. created using the in_device or parent/ancestor thereof. When a command
  217. queue is created against a sub-device, the commands enqueued on that queue
  218. are executed only on the sub-device.
  219. in_device - The device to be partitioned
  220. num_entries - The number of cl_device_ids that will fit in the array pointed
  221. to by <out_devices>. If <out_devices> is not NULL, <num_entries> must be
  222. greater than zero.
  223. out_devices - On output, the array pointed to by <out_devices> will contain
  224. up to <num_entries> sub-devices. If the <out_devices> argument is NULL,
  225. it is ignored. The number of cl_device_ids returned is the minimum of
  226. <num_entries> and the number of devices created by the partition scheme.
  227. num_devices - On output, the number of devices that the <in_device> may be
  228. partitioned in to according to the partitioning scheme given by
  229. <properties>. If num_devices is NULL, it is ignored.
  230. properties - A zero terminated list of device fission {property-value,
  231. cl_int[]} pairs that describe how to partition the device into
  232. sub-devices. <properties> may not be NULL. Only one of
  233. CL_DEVICE_PARTITION_EQUALLY_EXT, CL_DEVICE_PARTITION_BY_COUNTS_EXT,
  234. CL_DEVICE_PARTITION_BY_NAMES_EXT or
  235. CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT may be used in the same
  236. properties list. Available properties are:
  237. CL_DEVICE_PARTITION_EQUALLY_EXT - Split the aggregate device into as
  238. many smaller aggregate devices as can be created, each containing N
  239. compute units. The value N is passed as the value accompanying this
  240. property. If N does not divide evenly into
  241. CL_DEVICE_MAX_COMPUTE_UNITS then the remaining compute units are
  242. not used.
  243. Example: To divide a device containing 16 compute units into two
  244. sub-devices, each containing 8 compute units, pass:
  245. { CL_DEVICE_PARTITION_EQUALLY_EXT, 8,
  246. CL_PROPERTIES_LIST_END_EXT }
  247. CL_DEVICE_PARTITION_BY COUNTS_EXT - This property is followed by a
  248. CL_PARTITION_BY_COUNTS_LIST_END_EXT terminated list of compute unit
  249. counts. For each non-zero count M in the list, a sub-device is
  250. created with M compute units in it.
  251. CL_PARTITION_BY_COUNTS_LIST_END_EXT is defined to be 0.
  252. Example: to split a four compute unit device into two sub-devices,
  253. each containing two compute units, pass:
  254. { CL_DEVICE_PARTITION_BY_COUNTS_EXT,
  255. 2, 2, CL_PARTITION_BY_COUNTS_LIST_END_EXT,
  256. CL_PROPERTIES_LIST_END_EXT }
  257. The first 2 means put two compute units in the first sub-device. The
  258. second 2 means put two compute units in the second sub-device.
  259. CL_PARTITION_BY_COUNTS_LIST_END_EXT terminates the list of
  260. sub-devices. CL_PROPERTIES_LIST_END_EXT terminates the list of
  261. properties. The total number of compute units specified may not
  262. exceed the number of compute units in the device.
  263. CL_DEVICE_PARTITION_BY NAMES_EXT - This property is followed by a list
  264. of compute unit names. Each list starts with a
  265. CL_PARTITION_BY_NAMES_LIST_END_EXT terminated list of compute unit
  266. names. Compute unit names are integers that count up from zero to
  267. the number of compute units less one.
  268. CL_PARTITION_BY_NAMES_LIST_END_EXT is defined to be -1. Only
  269. one sub-device may be created at a time with this selector. An
  270. individual compute unit name may not appear more than once in the
  271. sub-device description.
  272. Example: To create a three compute unit sub-device using compute
  273. units, { 0, 1, 3 }, pass:
  274. { CL_DEVICE_PARTITION_BY NAMES_EXT,
  275. 0, 1, 3, CL_PARTITION_BY_NAMES_LIST_END_EXT,
  276. CL_PROPERTIES_LIST_END_EXT }
  277. The meaning of these numbers are, in order:
  278. 0 the name of the first compute unit in the sub-device
  279. 1 the name of the second compute unit in the sub-device
  280. 3 the name of the third compute unit in the sub-device
  281. CL_PROPERTIES_LIST_END_EXT list terminator for the list of
  282. properties
  283. CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT - Split the device into
  284. smaller aggregate devices containing one or more compute units
  285. that all share part of a cache hierarchy. The value accompanying
  286. this property may be drawn from the following CL_AFFINITY_DOMAIN
  287. list:
  288. CL_AFFINITY_DOMAIN_NUMA_EXT - Split the device into sub-devices
  289. comprised of compute units that share a NUMA band.
  290. CL_AFFINITY_DOMAIN_L4_CACHE_EXT - Split the device into sub-devices
  291. comprised of compute units that share a level 4 data cache.
  292. CL_AFFINITY_DOMAIN_L3_CACHE_EXT - Split the device into sub-devices
  293. comprised of compute units that share a level 3 data cache.
  294. CL_AFFINITY_DOMAIN_L2_CACHE_EXT - Split the device into sub-devices
  295. comprised of compute units that share a level 2 data cache.
  296. CL_AFFINITY_DOMAIN_L1_CACHE_EXT - Split the device into sub-devices
  297. comprised of compute units that share a level 1 data cache.
  298. CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT - Split the device along the
  299. next fissionable CL_AFFINITY_DOMAIN. The implementation shall
  300. find the first level along which the device or sub-device may be
  301. further subdivided in the order NUMA, L4, L3, L2, L1, and
  302. fission the device into sub-devices comprised of compute units
  303. that share memory sub-systems at this level. The user may
  304. determine what happened by calling
  305. clGetDeviceInfo(CL_DEVICE_PARTITION_STYLE_EXT) on the
  306. sub-devices.
  307. Example: To split a non-NUMA device along the outermost cache level
  308. (if any), pass:
  309. { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT,
  310. CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT,
  311. CL_PROPERTIES_LIST_END_EXT }
  312. CL_PROPERTIES_LIST_END_EXT - A list terminator for a properties list.
  313. The following values may be returned by clCreateSubDevicesEXT:
  314. CL_SUCCESS - The command succeeded.
  315. CL_INVALID_VALUE - The properties key is unknown, or the indicated partition
  316. style (CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT,
  317. CL_DEVICE_PARTITION_EQUALLY_EXT, CL_DEVICE_PARTITION_BY NAMES_EXT or
  318. CL_DEVICE_PARTITION_BY COUNTS_EXT) is not supported for this device by
  319. the implementation. On an OpenCL 1.1 implementation, these cases return
  320. CL_INVALID_PROPERTY instead, to be consistent with clCreateContext
  321. behavior.
  322. CL_INVALID_VALUE - num_entries is zero and out_devices is not NULL, or both
  323. out_devices and num_devices are NULL.
  324. CL_DEVICE_PARTITION_FAILED_EXT - The indicated partition scheme is supported
  325. by the implementation, but the implementation can not further partition
  326. the device in this way. For example,
  327. CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT was requested, but all
  328. compute units in in_device share the same cache at the level requested.
  329. CL_INVALID_PARTITION_COUNT_EXT - The total number of compute units requested
  330. exceeds CL_DEVICE_MAX_COMPUTE_UNITS, or the number of compute units for
  331. any one sub-device is less than 1, or the number of sub-devices
  332. requested exceeds CL_DEVICE_MAX_COMPUTE_UNITS.
  333. CL_INVALID_PARTITION_NAME_EXT - A compute unit name appearing in a name list
  334. following CL_DEVICE_PARTITION_BY NAMES_EXT is not in the range
  335. [-1, number of compute units - 1].
  336. CL_INVALID_DEVICE - The in_device is not a valid device. The in_device is
  337. not a device in context.
  338. *)
  339. TclCreateSubDevicesEXT = function(
  340. in_device: TCL_device_id; (*in_device*)
  341. const properties: Pcl_device_partition_property_ext; (* properties *)
  342. num_entries: TCL_uint; (*num_entries*)
  343. out_devices: PCL_device_id; (*out_devices*)
  344. num_devices: TCL_uint(*num_devices*)
  345. ): TCL_int;{$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
  346. var
  347. clCreateSubDevicesEXT: TclCreateSubDevicesEXT;
  348. const
  349. (*
  350. Accepted as a property name in the <properties> parameter of
  351. clCreateSubDeviceEXT:
  352. *)
  353. (* cl_device_partition_property_ext *)
  354. CL_DEVICE_PARTITION_EQUALLY_EXT = $4050;
  355. CL_DEVICE_PARTITION_BY_COUNTS_EXT = $4051;
  356. CL_DEVICE_PARTITION_BY_NAMES_EXT = $4052;
  357. CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT = $4053;
  358. (* clDeviceGetInfo selectors *)
  359. (*
  360. Accepted as a property being queried in the <param_name> argument of
  361. clGetDeviceInfo:
  362. clGetDeviceInfo - If the device is a sub-device created by
  363. clCreateSubDevicesEXT, then the value returned for
  364. CL_DEVICE_MAX_COMPUTE_UNITS is the number of compute units in the
  365. sub-device. The CL_DEVICE_VENDOR_ID may be different from the parent
  366. device CL_DEVICE_VENDOR_ID, but should be the same for all devices and
  367. sub-devices that can share a binary executable, such as that returned
  368. from clGetProgramInfo(CL_PROGRAM_BINARIES). Other selectors such as
  369. CL_DEVICE_GLOBAL_MEM_CACHE_SIZE may optionally change value to better
  370. reflect the behavior of the sub-device in an implementation defined
  371. manner.
  372. The following selectors are added for clGetDeviceInfo:
  373. *)
  374. (*
  375. CL_DEVICE_PARENT_DEVICE_EXT - a selector to get the cl_device_id for
  376. the parent cl_device_id to which the sub-device belongs.
  377. (Sub-division can be multi-level.) If the device is a root level
  378. device, then it will return NULL.
  379. *)
  380. CL_DEVICE_PARENT_DEVICE_EXT = $4054;
  381. (*
  382. CL_DEVICE_PARTITION_TYPES_EXT - a selector to get a list of supported
  383. partition types for partitioning a device. The return type is an
  384. array of cl_device partition property ext values drawn from the
  385. following list:
  386. CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT
  387. CL_DEVICE_PARTITION_BY COUNTS_EXT
  388. CL_DEVICE_PARTITION_BY NAMES_EXT
  389. CL_DEVICE_PARTITION_EQUALLY_EXT
  390. The implementation shall return at least one property from the above
  391. list. However, when a partition style is found within this list,
  392. the partition style is not required to work in every case. For
  393. example, a device might support partitioning by affinity domain, but
  394. not along NUMA domains.
  395. *)
  396. CL_DEVICE_PARTITION_TYPES_EXT = $4055;
  397. (*
  398. CL_DEVICE_AFFINITY_DOMAINS_EXT - a selector to get a list of supported
  399. affinity domains for partitioning the device using the
  400. CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT partition style. The
  401. return type is an array of cl_device_partition_property_ext values.
  402. The values shall come from the list:
  403. CL_AFFINITY_DOMAIN_L1_CACHE_EXT
  404. CL_AFFINITY_DOMAIN_L2_CACHE_EXT
  405. CL_AFFINITY_DOMAIN_L3_CACHE_EXT
  406. CL_AFFINITY_DOMAIN_L4_CACHE_EXT
  407. CL_AFFINITY_DOMAIN_NUMA_EXT
  408. If no partition style is supported then the size of the returned
  409. array is zero. Even though a device has a NUMA, or particular
  410. cache level, an implementation may elect not to provide fissioning
  411. at that level.
  412. *)
  413. CL_DEVICE_AFFINITY_DOMAINS_EXT = $4056;
  414. (*
  415. CL_DEVICE_REFERENCE_COUNT_EXT Return the device
  416. reference count. The return type is cl_uint. If the device is a
  417. root level device, a reference count of 1 is returned.
  418. *)
  419. CL_DEVICE_REFERENCE_COUNT_EXT = $4057;
  420. (*
  421. CL_DEVICE_PARTITION_STYLE_EXT - a selector to get the
  422. cl_device_partition_property_ext list used to create the sub-device.
  423. If the device is a root level device then a list consisting of
  424. { CL_PROPERTIES_LIST_END_EXT} is returned. If the property on device
  425. creation was (CL_DEVICE_PARTITION BY_AFFINITY_DOMAIN_EXT,
  426. CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE) then
  427. CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE will be replaced by the symbol
  428. representing the actual CL_AFFINITY DOMAIN used
  429. (e.g. CL_AFFINITY_DOMAIN_NUMA). The returned value is an array of
  430. cl_device_partition_property_ext. The length of the array is
  431. obtained from the size returned by the param size value ret
  432. parameter to the function.
  433. *)
  434. CL_DEVICE_PARTITION_STYLE_EXT = $4058;
  435. (* error codes *)
  436. (*
  437. Returned by clCreateSubDevicesEXT when the indicated partition scheme is
  438. supported by the implementation, but the implementation can not further
  439. partition the device in this way.
  440. *)
  441. CL_DEVICE_PARTITION_FAILED_EXT =-1057;
  442. (*
  443. Returned by clCreateSubDevicesEXT when the total number of compute units
  444. requested exceeds CL_DEVICE_MAX_COMPUTE_UNITS, or the number of compute
  445. units for any one sub-device is less than 1.
  446. *)
  447. CL_INVALID_PARTITION_COUNT_EXT =-1058;
  448. (*
  449. Returned by clCreateSubDevicesEXT when a compute unit name appearing in a
  450. name list following CL_DEVICE_PARTITION_BY_NAMES_EXT is not in range.
  451. *)
  452. CL_INVALID_PARTITION_NAME_EXT =-1059;
  453. (*
  454. Accepted as a property name, when accompanying the
  455. CL_DEVICE_PARITION_BY_AFFINITY_DOMAIN_EXT property, in the <properties>
  456. parameter of clCreateSubDeviceEXT:
  457. *)
  458. (* CL_AFFINITY_DOMAINs *)
  459. CL_AFFINITY_DOMAIN_L1_CACHE_EXT = $1;
  460. CL_AFFINITY_DOMAIN_L2_CACHE_EXT = $2;
  461. CL_AFFINITY_DOMAIN_L3_CACHE_EXT = $3;
  462. CL_AFFINITY_DOMAIN_L4_CACHE_EXT = $4;
  463. CL_AFFINITY_DOMAIN_NUMA_EXT = $10;
  464. CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT = $100;
  465. (* cl_device_partition_property_ext list terminators *)
  466. (*
  467. Accepted as the property list terminator in the <properties> parameter of
  468. clCreateSubDeviceEXT:
  469. *)
  470. CL_PROPERTIES_LIST_END_EXT : Tcl_device_partition_property_ext = (0);
  471. (*
  472. Accepted as the partition counts list terminator in the <properties>
  473. parameter of clCreateSubDeviceEXT:
  474. *)
  475. CL_PARTITION_BY_COUNTS_LIST_END_EXT : Tcl_device_partition_property_ext = (0);
  476. (*
  477. Accepted as the partition names list terminator in the <properties>
  478. parameter of clCreateSubDeviceEXT:
  479. *)
  480. CL_PARTITION_BY_NAMES_LIST_END_EXT : Tcl_device_partition_property_ext = Tcl_device_partition_property_ext(-1);
  481. (* cl_ext_atomic_counters_32 and cl_ext_atomic_counters_64 extensions
  482. * no extension #define since they have no functions
  483. *)
  484. CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT = $4032;
  485. {$ENDIF} (*CL_VERSION_1_1*)
  486. {$IFDEF CL_VERSION_1_0}
  487. (***********************************
  488. * cl_ext_migrate_memobject extension definitions
  489. ***********************************)
  490. cl_ext_migrate_memobject = 1;
  491. type
  492. Pcl_mem_migration_flags_ext = ^Tcl_mem_migration_flags_ext;
  493. Tcl_mem_migration_flags_ext = TCL_bitfield;
  494. const
  495. (*
  496. Besides a value of zero, the following cl_mem_migration_flags_ext values are
  497. allowed:
  498. *)
  499. CL_MIGRATE_MEM_OBJECT_HOST_EXT = $1;
  500. (*
  501. Returned in the <param_value> parameter of the clGetEventInfo when
  502. <param_name> is CL_EVENT_COMMAND_TYPE:
  503. *)
  504. CL_COMMAND_MIGRATE_MEM_OBJECT_EXT = $4040;
  505. type
  506. TclEnqueueMigrateMemObjectEXT = function(
  507. command_queue: Tcl_command_queue; (* command_queue *)
  508. num_mem_objects: Tcl_uint; (* num_mem_objects *)
  509. const mem_objects: Pcl_mem; (* mem_objects *)
  510. flags: Tcl_mem_migration_flags_ext; (* flags *)
  511. num_events_in_wait_list: Tcl_uint; (* num_events_in_wait_list *)
  512. const event_wait_list: Pcl_event; (* event_wait_list *)
  513. event: Pcl_event (* event *)
  514. ): TCL_int;{$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
  515. var
  516. clEnqueueMigrateMemObjectEXT: TclEnqueueMigrateMemObjectEXT;
  517. {$ENDIF}
  518. {$IFDEF CL_VERSION_1_1}
  519. (*********************************
  520. * cl_qcom_ext_host_ptr extension
  521. *********************************)
  522. const
  523. CL_MEM_EXT_HOST_PTR_QCOM = (1 shl 29);
  524. CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM = $40A0;
  525. CL_DEVICE_PAGE_SIZE_QCOM = $40A1;
  526. CL_IMAGE_ROW_ALIGNMENT_QCOM = $40A2;
  527. CL_IMAGE_SLICE_ALIGNMENT_QCOM = $40A3;
  528. CL_MEM_HOST_UNCACHED_QCOM = $40A4;
  529. CL_MEM_HOST_WRITEBACK_QCOM = $40A5;
  530. CL_MEM_HOST_WRITETHROUGH_QCOM = $40A6;
  531. CL_MEM_HOST_WRITE_COMBINING_QCOM = $40A7;
  532. type
  533. TCL_image_pitch_info_qcom = TCL_uint;
  534. PCL_image_pitch_info_qcom = ^TCL_image_pitch_info_qcom;
  535. TclGetDeviceImageInfoQCOM = function(
  536. device: PCL_device_id;
  537. image_width: TSize_t;
  538. image_height: TSize_t;
  539. const image_format: PCL_image_format;
  540. param_name: PCL_image_pitch_info_qcom;
  541. param_value_size: TSize_t;
  542. param_value: Pointer;
  543. param_value_size_ret: PSize_t
  544. ): TCL_int;
  545. {$IFDEF CDECL}cdecl{$ELSE}stdcall{$ENDIF};
  546. var
  547. clGetDeviceImageInfoQCOM: TclGetDeviceImageInfoQCOM;
  548. type
  549. TCL_mem_ext_host_ptr = packed record
  550. (* Type of external memory allocation. *)
  551. (* Legal values will be defined in layered extensions. *)
  552. allocation_type: TCL_uint;
  553. (* Host cache policy for this external memory allocation. *)
  554. host_cache_policy: TCL_uint;
  555. end;
  556. PCL_mem_ext_host_ptr = ^TCL_mem_ext_host_ptr;
  557. (*********************************
  558. * cl_qcom_ion_host_ptr extension
  559. *********************************)
  560. const
  561. CL_MEM_ION_HOST_PTR_QCOM = $40A8;
  562. type
  563. TCL_mem_ion_host_ptr = packed record
  564. (* Type of external memory allocation. *)
  565. (* Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations. *)
  566. ext_host_ptr: PCL_mem_ext_host_ptr;
  567. (* ION file descriptor *)
  568. ion_filedesc: Integer;
  569. (* Host pointer to the ION allocated memory *)
  570. ion_hostptr: Pointer;
  571. end;
  572. PCL_mem_ion_host_ptr = ^TCL_mem_ion_host_ptr;
  573. {$ENDIF}
  574. function InitCL_EXT: Boolean;
  575. implementation
  576. function InitCL_EXT: Boolean;
  577. begin
  578. Result := False;
  579. if OCL_LibHandle <> nil then
  580. begin
  581. //clIcdGetPlatformIDsKHR := oclGetProcAddress('clIcdGetPlatformIDsKHR', OCL_LibHandle));
  582. clIcdGetPlatformIDsKHR := TclIcdGetPlatformIDsKHR(oclGetProcAddress('clIcdGetPlatformIDsKHR', OCL_LibHandle));
  583. {$IFDEF CL_VERSION_1_0}
  584. clSetMemObjectDestructorAPPLE := TclSetMemObjectDestructorAPPLE(oclGetProcAddress('clSetMemObjectDestructorAPPLE', OCL_LibHandle));
  585. clLogMessagesToSystemLogAPPLE := TclLogMessagesToSystemLogAPPLE(oclGetProcAddress('clLogMessagesToSystemLogAPPLE', OCL_LibHandle));
  586. clLogMessagesToStdoutAPPLE := TclLogMessagesToStdoutAPPLE(oclGetProcAddress('clLogMessagesToStdoutAPPLE', OCL_LibHandle));
  587. clLogMessagesToStderrAPPLE := TclLogMessagesToStderrAPPLE(oclGetProcAddress('clLogMessagesToStderrAPPLE', OCL_LibHandle));
  588. {$ENDIF}
  589. {$IFDEF CL_VERSION_1_1}
  590. clReleaseDeviceEXT := TclReleaseDeviceEXT(oclGetProcAddress('clReleaseDeviceEXT', OCL_LibHandle));
  591. clRetainDeviceEXT := TclRetainDeviceEXT(oclGetProcAddress('clRetainDeviceEXT', OCL_LibHandle));
  592. clCreateSubDevicesEXT := TclCreateSubDevicesEXT(oclGetProcAddress('clCreateSubDevicesEXT', OCL_LibHandle));
  593. {$ENDIF}
  594. {$IFDEF CL_VERSION_1_0}
  595. clEnqueueMigrateMemObjectEXT := TclEnqueueMigrateMemObjectEXT(oclGetProcAddress('clEnqueueMigrateMemObjectEXT', OCL_LibHandle));
  596. {$ENDIF}
  597. {$IFDEF CL_VERSION_1_1}
  598. clGetDeviceImageInfoQCOM := TclGetDeviceImageInfoQCOM(oclGetProcAddress('clGetDeviceImageInfoQCOM', OCL_LibHandle));
  599. {$ENDIF}
  600. Result := True;
  601. end;
  602. end;
  603. end.