CUDA.Import.pas 108 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674
  1. //
  2. // The graphics platform GLScene https://github.com/glscene
  3. //
  4. unit CUDA.Import;
  5. (*
  6. * Copyright 1993-2020 NVIDIA Corporation. All rights reserved.
  7. *
  8. * NOTICE TO USER:
  9. *
  10. * This source code is subject to NVIDIA ownership rights under U.S. and
  11. * international Copyright laws. Users and possessors of this source code
  12. * are hereby granted a nonexclusive, royalty-free license to use this code
  13. * in individual and commercial software.
  14. *
  15. * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
  16. * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
  17. * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
  18. * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
  19. * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
  20. * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
  21. * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  22. * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  23. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  24. * OR PERFORMANCE OF THIS SOURCE CODE.
  25. *
  26. * U.S. Government End Users. This source code is a "commercial item" as
  27. * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
  28. * "commercial computer software" and "commercial computer software
  29. * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
  30. * and is provided to the U.S. Government only as a commercial end item.
  31. * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
  32. * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
  33. * source code with only those rights set forth herein.
  34. *
  35. * Any use of this source code in individual and commercial software must
  36. * include, in the user documentation and internal comments to the code,
  37. * the above Disclaimer and U.S. Government End Users Notice.
  38. *)
  39. interface
  40. uses
  41. Winapi.Windows;
  42. const
  43. CUDAAPIDLL = 'nvcuda.dll';
  44. type
  45. // CUDA device pointer
  46. TCUdeviceptr = Pointer;
  47. // CUDA device
  48. TCUdevice = Integer;
  49. // CUDA context
  50. PCUcontext = ^TCUcontext;
  51. TCUcontext = record
  52. end;
  53. // CUDA module
  54. PCUmodule = ^TCUmodule;
  55. TCUmodule = record
  56. end;
  57. // CUDA function
  58. PCUfunction = ^TCUfunction;
  59. TCUfunction = record
  60. end;
  61. // CUDA array
  62. PCUarray = ^TCUarray;
  63. TCUarray = record
  64. end;
  65. // CUDA texture reference
  66. PCUtexref = ^TCUtexref;
  67. TCUtexref = record
  68. end;
  69. // CUDA event
  70. PCUevent = ^TCUevent;
  71. TCUevent = record
  72. end;
  73. // CUDA stream
  74. PCUstream = ^TCUstream;
  75. TCUstream = record
  76. end;
  77. // CUDA graphics interop resource
  78. PPCUgraphicsResource = ^PCUgraphicsResource;
  79. PCUgraphicsResource = ^TCUgraphicsResource;
  80. TCUgraphicsResource = record
  81. end;
  82. // Context creation flags
  83. TCUctx_flags = (
  84. // Automatic scheduling
  85. CU_CTX_SCHED_AUTO = 0,
  86. // Set spin as default scheduling
  87. CU_CTX_SCHED_SPIN = 1,
  88. // Set yield as default scheduling
  89. CU_CTX_SCHED_YIELD = 2,
  90. CU_CTX_SCHED_MASK = 3,
  91. // Use blocking synchronization
  92. CU_CTX_BLOCKING_SYNC = 4,
  93. // Support mapped pinned allocations
  94. CU_CTX_MAP_HOST = 8,
  95. CU_CTX_FLAGS_MASK = 15);
  96. // Event creation flags
  97. TCUevent_flags = (
  98. // Default event flag
  99. CU_EVENT_DEFAULT = 0,
  100. // Event uses blocking synchronization
  101. CU_EVENT_BLOCKING_SYNC = 1
  102. );
  103. // Array formats
  104. TCUarray_format = (
  105. // Unsigned 8-bit integers
  106. CU_AD_FORMAT_UNSIGNED_INT8 = $01,
  107. // Unsigned 16-bit integers
  108. CU_AD_FORMAT_UNSIGNED_INT16 = $02,
  109. // Unsigned 32-bit integers
  110. CU_AD_FORMAT_UNSIGNED_INT32 = $03,
  111. // Signed 8-bit integers
  112. CU_AD_FORMAT_SIGNED_INT8 = $08,
  113. // Signed 16-bit integers
  114. CU_AD_FORMAT_SIGNED_INT16 = $09,
  115. // Signed 32-bit integers
  116. CU_AD_FORMAT_SIGNED_INT32 = $0A,
  117. // 16-bit floating point
  118. CU_AD_FORMAT_HALF = $10,
  119. // 32-bit floating point
  120. CU_AD_FORMAT_FLOAT = $20
  121. );
  122. // Texture reference addressing modes
  123. TCUaddress_mode = (
  124. // Wrapping address mode
  125. CU_TR_ADDRESS_MODE_WRAP = 0,
  126. // Clamp to edge address mode
  127. CU_TR_ADDRESS_MODE_CLAMP = 1,
  128. // Mirror address mode
  129. CU_TR_ADDRESS_MODE_MIRROR = 2
  130. );
  131. // Texture reference filtering modes
  132. TCUfilter_mode = (
  133. // Point filter mode
  134. CU_TR_FILTER_MODE_POINT = 0,
  135. // Linear filter mode
  136. CU_TR_FILTER_MODE_LINEAR = 1
  137. );
  138. // Device properties
  139. TCUdevice_attribute = (
  140. // Maximum number of threads per block
  141. CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 1,
  142. // Maximum block dimension X
  143. CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X = 2,
  144. // Maximum block dimension Y
  145. CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y = 3,
  146. // Maximum block dimension Z
  147. CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z = 4,
  148. // Maximum grid dimension X
  149. CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X = 5,
  150. // Maximum grid dimension Y
  151. CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y = 6,
  152. // Maximum grid dimension Z
  153. CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z = 7,
  154. // Maximum shared memory available per block in bytes
  155. CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK = 8,
  156. // Deprecated, use CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK
  157. CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK = 8,
  158. // Memory available on device for __constant__ variables in a CUDA C kernel in bytes
  159. CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY = 9,
  160. // Warp size in threads
  161. CU_DEVICE_ATTRIBUTE_WARP_SIZE = 10,
  162. // Maximum pitch in bytes allowed by memory copies
  163. CU_DEVICE_ATTRIBUTE_MAX_PITCH = 11,
  164. // Maximum number of 32-bit registers available per block
  165. CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK = 12,
  166. // Deprecated, use CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK
  167. CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK = 12,
  168. // Peak clock frequency in kilohertz
  169. CU_DEVICE_ATTRIBUTE_CLOCK_RATE = 13,
  170. // Alignment requirement for textures
  171. CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT = 14,
  172. // Device can possibly copy memory and execute a kernel concurrently
  173. CU_DEVICE_ATTRIBUTE_GPU_OVERLAP = 15,
  174. // Number of multiprocessors on device
  175. CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT = 16,
  176. // Specifies whether there is a run time limit on kernels
  177. CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT = 17,
  178. // Device is integrated with host memory
  179. CU_DEVICE_ATTRIBUTE_INTEGRATED = 18,
  180. // Device can map host memory into CUDA address space
  181. CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY = 19,
  182. // Compute mode (See ::CUcomputemode for details)
  183. CU_DEVICE_ATTRIBUTE_COMPUTE_MODE = 20
  184. );
  185. (* *
  186. * CUDA Limits
  187. *)
  188. TcudaLimit = (
  189. // GPU thread stack size
  190. cudaLimitStackSize = $00,
  191. // GPU printf FIFO size
  192. cudaLimitPrintfFifoSize = $01
  193. );
  194. // Legacy device properties
  195. TCUdevprop = record
  196. // Maximum number of threads per block
  197. maxThreadsPerBlock: Integer;
  198. // Maximum size of each dimension of a block
  199. maxThreadsDim: array [0 .. 2] of Integer;
  200. // Maximum size of each dimension of a grid
  201. maxGridSize: array [0 .. 2] of Integer;
  202. // Shared memory available per block in bytes
  203. sharedMemPerBlock: Integer;
  204. // Constant memory available on device in bytes
  205. totalConstantMemory: Integer;
  206. // Warp size in threads
  207. SIMDWidth: Integer;
  208. // Maximum pitch in bytes allowed by memory copies
  209. memPitch: Integer;
  210. // 32-bit registers available per block
  211. regsPerBlock: Integer;
  212. // Clock frequency in kilohertz
  213. clockRate: Integer;
  214. // Alignment requirement for textures
  215. textureAlign: Integer;
  216. end;
  217. // Function properties
  218. TCUfunction_attribute = (
  219. (* The number of threads beyond which a launch of the function would fail.
  220. * This number depends on both the function and the device on which the
  221. * function is currently loaded. *)
  222. CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 0,
  223. (* The size in bytes of statically-allocated shared memory required by
  224. * this function. This does not include dynamically-allocated shared
  225. * memory requested by the user at runtime. *)
  226. CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES = 1,
  227. { * The size in bytes of user-allocated constant memory required by this
  228. * function. }
  229. CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES = 2,
  230. { * The size in bytes of thread local memory used by this function. }
  231. CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES = 3,
  232. { * The number of registers used by each thread of this function. }
  233. CU_FUNC_ATTRIBUTE_NUM_REGS = 4,
  234. CU_FUNC_ATTRIBUTE_MAX);
  235. // Memory types
  236. TCUmemorytype = (
  237. // Host memory
  238. CU_MEMORYTYPE_HOST = $01,
  239. // Device memory
  240. CU_MEMORYTYPE_DEVICE = $02,
  241. // Array memory
  242. CU_MEMORYTYPE_ARRAY = $03
  243. );
  244. // Compute Modes
  245. TCUcomputemode = (
  246. // Default compute mode (Multiple contexts allowed per device)
  247. CU_COMPUTEMODE_DEFAULT = 0,
  248. // Compute-exclusive mode (Only one context can be present on this device at a time)
  249. CU_COMPUTEMODE_EXCLUSIVE = 1,
  250. // Compute-prohibited mode (No contexts can be created on this device at this time)
  251. CU_COMPUTEMODE_PROHIBITED = 2
  252. );
  253. // Online compiler options
  254. TCUjit_option = (
  255. { * Max number of registers that a thread may use. }
  256. CU_JIT_MAX_REGISTERS = 0,
  257. { * IN: Specifies minimum number of threads per block to target compilation
  258. * for\n
  259. * OUT: Returns the number of threads the compiler actually targeted.
  260. * This restricts the resource utilization fo the compiler (e.g. max
  261. * registers) such that a block with the given number of threads should be
  262. * able to launch based on register limitations. Note, this option does not
  263. * currently take into account any other resource limitations, such as
  264. * shared memory utilization. }
  265. CU_JIT_THREADS_PER_BLOCK,
  266. { * Returns a float value in the option of the wall clock time, in
  267. * milliseconds, spent creating the cubin }
  268. CU_JIT_WALL_TIME,
  269. { * Pointer to a buffer in which to print any log messsages from PTXAS
  270. * that are informational in nature }
  271. CU_JIT_INFO_LOG_BUFFER,
  272. { * IN: Log buffer size in bytes. Log messages will be capped at this size
  273. * (including null terminator)\n
  274. * OUT: Amount of log buffer filled with messages }
  275. CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES,
  276. { * Pointer to a buffer in which to print any log messages from PTXAS that
  277. * reflect errors }
  278. CU_JIT_ERROR_LOG_BUFFER,
  279. { * IN: Log buffer size in bytes. Log messages will be capped at this size
  280. * (including null terminator)\n
  281. * OUT: Amount of log buffer filled with messages }
  282. CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES,
  283. { * Level of optimizations to apply to generated code (0 - 4), with 4
  284. * being the default and highest level of optimizations. }
  285. CU_JIT_OPTIMIZATION_LEVEL,
  286. { * No option value required. Determines the target based on the current
  287. * attached context (default) }
  288. CU_JIT_TARGET_FROM_CUCONTEXT,
  289. { * Target is chosen based on supplied CUjit_target_enum. }
  290. CU_JIT_TARGET,
  291. { * Specifies choice of fallback strategy if matching cubin is not found.
  292. * Choice is based on supplied CUjit_fallback_enum. }
  293. CU_JIT_FALLBACK_STRATEGY );
  294. // Online compilation targets
  295. TCUjit_target = (
  296. // Compute device class 1.0
  297. CU_TARGET_COMPUTE_10 = 0,
  298. // Compute device class 1.1
  299. CU_TARGET_COMPUTE_11,
  300. // Compute device class 1.2
  301. CU_TARGET_COMPUTE_12,
  302. // Compute device class 1.3
  303. CU_TARGET_COMPUTE_13
  304. );
  305. // Cubin matching fallback strategies
  306. TCUjit_fallback = (
  307. // ** Prefer to compile ptx */
  308. CU_PREFER_PTX = 0,
  309. // ** Prefer to fall back to compatible binary code */
  310. CU_PREFER_BINARY);
  311. // Flags to register a graphics resource
  312. TCUgraphicsRegisterFlags = (CU_GRAPHICS_REGISTER_FLAGS_NONE = $00000000);
  313. // Flags for mapping and unmapping interop resources
  314. TCUgraphicsMapResourceFlags =
  315. (CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE = $00000000,
  316. CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY = $00000001,
  317. CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD = $00000002);
  318. // Array indices for cube faces
  319. TCUarray_cubemap_face = (
  320. // Positive X face of cubemap
  321. CU_CUBEMAP_FACE_POSITIVE_X = $00000000,
  322. // Negative X face of cubemap
  323. CU_CUBEMAP_FACE_NEGATIVE_X = $00000001,
  324. // Positive Y face of cubemap
  325. CU_CUBEMAP_FACE_POSITIVE_Y = $00000002,
  326. // Negative Y face of cubemap
  327. CU_CUBEMAP_FACE_NEGATIVE_Y = $00000003,
  328. // Positive Z face of cubemap
  329. CU_CUBEMAP_FACE_POSITIVE_Z = $00000004,
  330. // Negative Z face of cubemap
  331. CU_CUBEMAP_FACE_NEGATIVE_Z = $00000005
  332. );
  333. (*
  334. * CUDA function attributes
  335. *)
  336. TcudaFuncAttributes = record
  337. // Size of shared memory in bytes
  338. sharedSizeBytes: NativeUInt;
  339. // Size of constant memory in bytes
  340. constSizeBytes: NativeUInt;
  341. // Size of local memory in bytes
  342. localSizeBytes: NativeUInt;
  343. // Maximum number of threads per block
  344. maxThreadsPerBlock: Integer;
  345. // Number of registers used
  346. numRegs: Integer;
  347. (* \brief PTX virtual architecture version for which the function was
  348. * compiled. This value is the major PTX version * 10 + the minor PTX
  349. * version, so a PTX version 1.3 function would return the value 13.
  350. * For device emulation kernels, this is set to 9999. *)
  351. ptxVersion: Integer;
  352. (* * \brief Binary architecture version for which the function was compiled.
  353. * This value is the major binary version * 10 + the minor binary version,
  354. * so a binary version 1.3 function would return the value 13.
  355. * For device emulation kernels, this is set to 9999. *)
  356. binaryVersion: Integer;
  357. __cudaReserved: array [0 .. 5] of Integer;
  358. end;
  359. (* *
  360. * CUDA function cache configurations
  361. *)
  362. TcudaFuncCache = (
  363. // Default function cache configuration, no preference
  364. cudaFuncCachePreferNone = 0,
  365. // Prefer larger shared memory and smaller L1 cache
  366. cudaFuncCachePreferShared = 1,
  367. // Prefer larger L1 cache and smaller shared memory
  368. cudaFuncCachePreferL1 = 2
  369. );
  370. // ************************************
  371. // **
  372. // ** Error codes
  373. // **
  374. // ***********************************/
  375. // Error codes
  376. TCUresult = type Cardinal;
  377. const
  378. CUDA_SUCCESS: TCUresult = 0; /// < No errors
  379. CUDA_ERROR_INVALID_VALUE = 1; /// < Invalid value
  380. CUDA_ERROR_OUT_OF_MEMORY = 2; /// < Out of memory
  381. CUDA_ERROR_NOT_INITIALIZED = 3; /// < Driver not initialized
  382. CUDA_ERROR_DEINITIALIZED = 4; /// < Driver deinitialized
  383. CUDA_ERROR_NO_DEVICE = 100; /// < No CUDA-capable device available
  384. CUDA_ERROR_INVALID_DEVICE = 101; /// < Invalid device
  385. CUDA_ERROR_INVALID_IMAGE = 200; /// < Invalid kernel image
  386. CUDA_ERROR_INVALID_CONTEXT = 201; /// < Invalid context
  387. CUDA_ERROR_CONTEXT_ALREADY_CURRENT = 202; /// < Context already current
  388. CUDA_ERROR_MAP_FAILED = 205; /// < Map failed
  389. CUDA_ERROR_UNMAP_FAILED = 206; /// < Unmap failed
  390. CUDA_ERROR_ARRAY_IS_MAPPED = 207; /// < Array is mapped
  391. CUDA_ERROR_ALREADY_MAPPED = 208; /// < Already mapped
  392. CUDA_ERROR_NO_BINARY_FOR_GPU = 209; /// < No binary for GPU
  393. CUDA_ERROR_ALREADY_ACQUIRED = 210; /// < Already acquired
  394. CUDA_ERROR_NOT_MAPPED = 211; /// < Not mapped
  395. CUDA_ERROR_NOT_MAPPED_AS_ARRAY = 212; /// < Mapped resource not available for access as an array
  396. CUDA_ERROR_NOT_MAPPED_AS_POINTER = 213; /// < Mapped resource not available for access as a pointer
  397. CUDA_ERROR_INVALID_SOURCE = 300; /// < Invalid source
  398. CUDA_ERROR_FILE_NOT_FOUND = 301; /// < File not found
  399. CUDA_ERROR_INVALID_HANDLE = 400; /// < Invalid handle
  400. CUDA_ERROR_NOT_FOUND = 500; /// < Not found
  401. CUDA_ERROR_NOT_READY = 600; /// < CUDA not ready
  402. CUDA_ERROR_LAUNCH_FAILED = 700; /// < Launch failed
  403. CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES = 701; /// < Launch exceeded resources
  404. CUDA_ERROR_LAUNCH_TIMEOUT = 702; /// < Launch exceeded timeout
  405. CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING = 703; /// < Launch with incompatible texturing
  406. CUDA_ERROR_POINTER_IS_64BIT = 800; /// < Attempted to retrieve 64-bit pointer via 32-bit API function
  407. CUDA_ERROR_SIZE_IS_64BIT = 801; /// < Attempted to retrieve 64-bit size via 32-bit API function
  408. CUDA_ERROR_UNKNOWN = 999; /// < Unknown error
  409. const
  410. { * If set, host memory is portable between CUDA contexts.
  411. * Flag for ::cuMemHostAlloc() }
  412. CU_MEMHOSTALLOC_PORTABLE = $01;
  413. { * If set, host memory is mapped into CUDA address space and
  414. * ::cuMemHostGetDevicePointer() may be called on the host pointer.
  415. * Flag for ::cuMemHostAlloc() }
  416. CU_MEMHOSTALLOC_DEVICEMAP = $02;
  417. { * If set, host memory is allocated as write-combined - fast to write,
  418. * faster to DMA, slow to read except via SSE4 streaming load instruction
  419. * (MOVNTDQA).
  420. * Flag for ::cuMemHostAlloc() }
  421. CU_MEMHOSTALLOC_WRITECOMBINED = $04;
  422. // 2D memory copy parameters
  423. type
  424. PCUDA_MEMCPY2D = ^TCUDA_MEMCPY2D;
  425. TCUDA_MEMCPY2D = record
  426. srcXInBytes, /// < Source X in bytes
  427. srcY: Cardinal; /// < Source Y
  428. srcMemoryType: TCUmemorytype; /// < Source memory type (host, device, array)
  429. srcHost: Pointer; /// < Source host pointer
  430. srcDevice: TCUdeviceptr; /// < Source device pointer
  431. srcArray: PCUarray; /// < Source array reference
  432. srcPitch: Cardinal; /// < Source pitch (ignored when src is array)
  433. dstXInBytes, /// < Destination X in bytes
  434. dstY: Cardinal; /// < Destination Y
  435. dstMemoryType: TCUmemorytype; /// < Destination memory type (host, device, array)
  436. dstHost: Pointer; /// < Destination host pointer
  437. dstDevice: TCUdeviceptr; /// < Destination device pointer
  438. dstArray: PCUarray; /// < Destination array reference
  439. dstPitch: Cardinal; /// < Destination pitch (ignored when dst is array)
  440. WidthInBytes: Cardinal; /// < Width of 2D memory copy in bytes
  441. Height: Cardinal; /// < Height of 2D memory copy
  442. end;
  443. // 3D memory copy parameters
  444. TCUDA_MEMCPY3D = record
  445. srcXInBytes, /// < Source X in bytes
  446. srcY, /// < Source Y
  447. srcZ: Cardinal; /// < Source Z
  448. srcLOD: Cardinal; /// < Source LOD
  449. srcMemoryType: TCUmemorytype; /// < Source memory type (host, device, array)
  450. srcHost: Pointer; /// < Source host pointer
  451. srcDevice: TCUdeviceptr; /// < Source device pointer
  452. srcArray: PCUarray; /// < Source array reference
  453. reserved0: Pointer; /// < Must be NULL
  454. srcPitch: Cardinal; /// < Source pitch (ignored when src is array)
  455. srcHeight: Cardinal; /// < Source height (ignored when src is array; may be 0 if Depth==1)
  456. dstXInBytes, /// < Destination X in bytes
  457. dstY, /// < Destination Y
  458. dstZ: Cardinal; /// < Destination Z
  459. dstLOD: Cardinal; /// < Destination LOD
  460. dstMemoryType: TCUmemorytype; /// < Destination memory type (host, device, array)
  461. dstHost: Pointer; /// < Destination host pointer
  462. dstDevice: TCUdeviceptr; /// < Destination device pointer
  463. dstArray: PCUarray; /// < Destination array reference
  464. reserved1: Pointer; /// < Must be NULL
  465. dstPitch: Cardinal; /// < Destination pitch (ignored when dst is array)
  466. dstHeight: Cardinal; /// < Destination height (ignored when dst is array; may be 0 if Depth==1)
  467. WidthInBytes: Cardinal; /// < Width of 3D memory copy in bytes
  468. Height: Cardinal; /// < Height of 3D memory copy
  469. Depth: Cardinal; /// < Depth of 3D memory copy
  470. end;
  471. // Array descriptor
  472. PCUDA_ARRAY_DESCRIPTOR = ^TCUDA_ARRAY_DESCRIPTOR;
  473. TCUDA_ARRAY_DESCRIPTOR = record
  474. Width: Cardinal; /// < Width of array
  475. Height: Cardinal; /// < Height of array
  476. Format: TCUarray_format; /// < Array format
  477. NumChannels: Cardinal; /// < Channels per array element
  478. end;
  479. // 3D array descriptor
  480. TCUDA_ARRAY3D_DESCRIPTOR = record
  481. Width: Cardinal; /// < Width of 3D array
  482. Height: Cardinal; /// < Height of 3D array
  483. Depth: Cardinal; /// < Depth of 3D array
  484. Format: TCUarray_format; /// < Array format
  485. NumChannels: Cardinal; /// < Channels per array element
  486. Flags: Cardinal; /// < Flags
  487. end;
  488. // Flags to map or unmap a resource
  489. TCUGLmap_flags = (CU_GL_MAP_RESOURCE_FLAGS_NONE,
  490. CU_GL_MAP_RESOURCE_FLAGS_READ_ONLY, CU_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD);
  491. const
  492. { * Override the texref format with a format inferred from the array.
  493. * Flag for ::cuTexRefSetArray() }
  494. CU_TRSA_OVERRIDE_FORMAT = $01;
  495. { * Read the texture as integers rather than promoting the values to floats
  496. * in the range [0,1].
  497. * Flag for ::cuTexRefSetFlags() }
  498. CU_TRSF_READ_AS_INTEGER = $01;
  499. { * Use normalized texture coordinates in the range [0,1) instead of [0,dim).
  500. * Flag for ::cuTexRefSetFlags() }
  501. CU_TRSF_NORMALIZED_COORDINATES = $02;
  502. { * For texture references loaded into the module, use default texunit from
  503. * texture reference. }
  504. CU_PARAM_TR_DEFAULT = -1;
  505. type
  506. TDim3 = array [0 .. 2] of LongWord;
  507. {$IFDEF MSWINDOWS}
  508. type
  509. HGPUNV = Pointer;
  510. {$ENDIF}
  511. type
  512. TcuInit = function(Flags: Cardinal): TCUresult;stdcall;
  513. TcuDriverGetVersion = function(out driverVersion: Integer): TCUresult;stdcall;
  514. TcuDeviceGet = function(var device: TCUdevice; ordinal: Integer): TCUresult;stdcall;
  515. TcuDeviceGetCount = function(var count: Integer): TCUresult;stdcall;
  516. TcuDeviceGetName = function(name: PAnsiChar; len: Integer; dev: TCUdevice): TCUresult;stdcall;
  517. TcuDeviceComputeCapability = function(var major: Integer; var minor: Integer; dev: TCUdevice): TCUresult;stdcall;
  518. TcuDeviceTotalMem = function(bytes: PSize_t; dev: TCUdevice): TCUresult;stdcall;
  519. TcuDeviceGetProperties = function(var prop: TCUdevprop; dev: TCUdevice): TCUresult;stdcall;
  520. TcuDeviceGetAttribute = function(pi: PSize_t; attrib: TCUdevice_attribute; dev: TCUdevice): TCUresult;stdcall;
  521. TcuCtxCreate = function(var pctx: PCUcontext; Flags: Cardinal; dev: TCUdevice): TCUresult;stdcall;
  522. TcuCtxDestroy = function(ctx: PCUcontext): TCUresult;stdcall;
  523. TcuCtxAttach = function(var pctx: PCUcontext; Flags: Cardinal): TCUresult;stdcall;
  524. TcuCtxDetach = function(ctx: PCUcontext): TCUresult;stdcall;
  525. TcuCtxPushCurrent = function(ctx: PCUcontext): TCUresult;stdcall;
  526. TcuCtxPopCurrent = function(var pctx: PCUcontext): TCUresult;stdcall;
  527. TcuCtxGetDevice = function(var device: TCUdevice): TCUresult;stdcall;
  528. TcuCtxSynchronize = function: TCUresult;stdcall;
  529. TcuModuleLoad = function(var module: PCUmodule; const fname: PAnsiChar): TCUresult;stdcall;
  530. TcuModuleLoadData = function(var module: PCUmodule; const image: PAnsiChar): TCUresult;stdcall;
  531. TcuModuleLoadDataEx = function(var module: PCUmodule; var image;
  532. numOptions: Cardinal; var options: TCUjit_option; var optionValues): TCUresult;stdcall;
  533. TcuModuleLoadFatBinary = function(var module: PCUmodule; var fatCubin): TCUresult;stdcall;
  534. TcuModuleUnload = function(hmod: PCUmodule): TCUresult;stdcall;
  535. TcuModuleGetFunction = function(out hfunc: PCUfunction; hmod: PCUmodule;
  536. const name: PAnsiChar): TCUresult;stdcall;
  537. TcuModuleGetGlobal = function(out dptr: TCUdeviceptr; var bytes: Cardinal;
  538. hmod: PCUmodule; const name: PAnsiChar): TCUresult;stdcall;
  539. TcuModuleGetTexRef = function(out pTexRef: PCUtexref; hmod: PCUmodule;
  540. const name: PAnsiChar): TCUresult;stdcall;
  541. TcuMemGetInfo = function(var free: Cardinal; var total: Cardinal): TCUresult;stdcall;
  542. TcuMemAlloc = function(var dptr: TCUdeviceptr; bytesize: Cardinal): TCUresult;stdcall;
  543. TcuMemAllocPitch = function(var dptr: TCUdeviceptr; var pPitch: Cardinal;
  544. WidthInBytes: Cardinal; Height: Cardinal; ElementSizeBytes: Cardinal): TCUresult;stdcall;
  545. TcuMemFree = function(dptr: TCUdeviceptr): TCUresult;stdcall;
  546. TcuMemGetAddressRange = function(var pbase: TCUdeviceptr; var psize: Cardinal;
  547. dptr: TCUdeviceptr): TCUresult;stdcall;
  548. TcuMemAllocHost = function(var pp; bytesize: Cardinal): TCUresult;stdcall;
  549. TcuMemFreeHost = function(p: Pointer): TCUresult;stdcall;
  550. TcuMemHostAlloc = function(var pp: Pointer; bytesize: Cardinal; Flags: Cardinal): TCUresult;stdcall;
  551. TcuMemHostGetDevicePointer = function(var pdptr: TCUdeviceptr; p: Pointer; Flags: Cardinal): TCUresult;stdcall;
  552. TcuMemHostGetFlags = function(var pFlags: Cardinal; var p): TCUresult;stdcall;
  553. TcuMemcpyHtoD = function(dstDevice: TCUdeviceptr; const srcHost: Pointer;
  554. ByteCount: Cardinal): TCUresult;stdcall;
  555. TcuMemcpyDtoH = function(const dstHost: Pointer; srcDevice: TCUdeviceptr;
  556. ByteCount: Cardinal): TCUresult;stdcall;
  557. TcuMemcpyDtoD = function(dstDevice: TCUdeviceptr; srcDevice: TCUdeviceptr;
  558. ByteCount: Cardinal): TCUresult;stdcall;
  559. TcuMemcpyDtoDAsync = function(dstDevice: TCUdeviceptr;
  560. srcDevice: TCUdeviceptr; ByteCount: Cardinal; hStream: PCUstream): TCUresult;stdcall;
  561. TcuMemcpyDtoA = function(dstArray: PCUarray; dstIndex: Cardinal;
  562. srcDevice: TCUdeviceptr; ByteCount: Cardinal): TCUresult;stdcall;
  563. TcuMemcpyAtoD = function(dstDevice: TCUdeviceptr; hSrc: PCUarray;
  564. SrcIndex: Cardinal; ByteCount: Cardinal): TCUresult;stdcall;
  565. TcuMemcpyHtoA = function(dstArray: PCUarray; dstIndex: Cardinal;
  566. pSrc: Pointer; ByteCount: Cardinal): TCUresult;stdcall;
  567. TcuMemcpyAtoH = function(dstHost: Pointer; srcArray: PCUarray;
  568. SrcIndex: Cardinal; ByteCount: Cardinal): TCUresult;stdcall;
  569. TcuMemcpyAtoA = function(dstArray: PCUarray; dstIndex: Cardinal;
  570. srcArray: PCUarray; SrcIndex: Cardinal; ByteCount: Cardinal): TCUresult;stdcall;
  571. TcuMemcpy2D = function(const pCopy: PCUDA_MEMCPY2D): TCUresult;stdcall;
  572. TcuMemcpy2DUnaligned = function(var pCopy: TCUDA_MEMCPY2D): TCUresult;stdcall;
  573. TcuMemcpy3D = function(var pCopy: TCUDA_MEMCPY3D): TCUresult;stdcall;
  574. TcuMemcpyHtoDAsync = function(dstDevice: TCUdeviceptr; var srcHost;
  575. ByteCount: Cardinal; hStream: PCUstream): TCUresult;stdcall;
  576. TcuMemcpyDtoHAsync = function(var dstHost; srcDevice: TCUdeviceptr;
  577. ByteCount: Cardinal; hStream: PCUstream): TCUresult;stdcall;
  578. TcuMemcpyHtoAAsync = function(dstArray: PCUarray; dstIndex: Cardinal;
  579. var pSrc; ByteCount: Cardinal; hStream: PCUstream): TCUresult;stdcall;
  580. TcuMemcpyAtoHAsync = function(var dstHost; srcArray: PCUstream;
  581. SrcIndex: Cardinal; ByteCount: Cardinal; hStream: PCUstream): TCUresult;stdcall;
  582. TcuMemcpy2DAsync = function(var pCopy: TCUDA_MEMCPY2D; hStream: PCUstream): TCUresult;stdcall;
  583. TcuMemcpy3DAsync = function(var pCopy: TCUDA_MEMCPY3D; hStream: PCUstream): TCUresult;stdcall;
  584. TcuMemsetD8 = function(dstDevice: TCUdeviceptr; ub: Byte; N: Cardinal): TCUresult;stdcall;
  585. TcuMemsetD16 = function(dstDevice: TCUdeviceptr; uw: Word; N: Cardinal): TCUresult;stdcall;
  586. TcuMemsetD32 = function(dstDevice: TCUdeviceptr; ui: Cardinal; N: Cardinal): TCUresult;stdcall;
  587. TcuMemsetD2D8 = function(dstDevice: TCUdeviceptr; dstPitch: Cardinal;
  588. ub: Byte; Width: Cardinal; Height: Cardinal): TCUresult;stdcall;
  589. TcuMemsetD2D16 = function(dstDevice: TCUdeviceptr; dstPitch: Cardinal;
  590. uw: Word; Width: Cardinal; Height: Cardinal): TCUresult;stdcall;
  591. TcuMemsetD2D32 = function(dstDevice: TCUdeviceptr; dstPitch: Cardinal;
  592. ui: Cardinal; Width: Cardinal; Height: Cardinal): TCUresult;stdcall;
  593. TcuFuncSetBlockShape = function(hfunc: PCUfunction; x: Integer; y: Integer;
  594. z: Integer): TCUresult;stdcall;
  595. TcuFuncSetSharedSize = function(hfunc: PCUfunction; bytes: Cardinal): TCUresult;stdcall;
  596. TcuFuncGetAttribute = function(var pi: Integer; attrib: TCUfunction_attribute;
  597. hfunc: PCUfunction): TCUresult;stdcall;
  598. TcuArrayCreate = function(var pHandle: PCUarray;
  599. var pAllocateArray: TCUDA_ARRAY_DESCRIPTOR): TCUresult;stdcall;
  600. TcuArrayGetDescriptor = function(var pArrayDescriptor: TCUDA_ARRAY_DESCRIPTOR;
  601. hArray: PCUarray): TCUresult;stdcall;
  602. TcuArrayDestroy = function(hArray: PCUarray): TCUresult;stdcall;
  603. TcuArray3DCreate = function(var pHandle: PCUarray;
  604. var pAllocateArray: TCUDA_ARRAY3D_DESCRIPTOR): TCUresult;stdcall;
  605. TcuArray3DGetDescriptor = function(var pArrayDescriptor
  606. : TCUDA_ARRAY3D_DESCRIPTOR; hArray: PCUarray): TCUresult;stdcall;
  607. TcuTexRefCreate = function(var pTexRef: PCUtexref): TCUresult;stdcall;
  608. TcuTexRefDestroy = function(hTexRef: PCUtexref): TCUresult;stdcall;
  609. TcuTexRefSetArray = function(hTexRef: PCUtexref; hArray: PCUarray;
  610. Flags: Cardinal): TCUresult;stdcall;
  611. TcuTexRefSetAddress = function(var ByteOffset: Cardinal; hTexRef: PCUtexref;
  612. dptr: TCUdeviceptr; bytes: Cardinal): TCUresult;stdcall;
  613. TcuTexRefSetAddress2D = function(hTexRef: PCUtexref;
  614. var desc: TCUDA_ARRAY_DESCRIPTOR; dptr: TCUdeviceptr; Pitch: Cardinal)
  615. : TCUresult;stdcall;
  616. TcuTexRefSetFormat = function(hTexRef: PCUtexref; fmt: TCUarray_format;
  617. NumPackedComponents: Integer): TCUresult;stdcall;
  618. TcuTexRefSetAddressMode = function(hTexRef: PCUtexref; dim: Integer;
  619. am: TCUaddress_mode): TCUresult;stdcall;
  620. TcuTexRefSetFilterMode = function(hTexRef: PCUtexref; fm: TCUfilter_mode)
  621. : TCUresult;stdcall;
  622. TcuTexRefSetFlags = function(hTexRef: PCUtexref; Flags: Cardinal): TCUresult;stdcall;
  623. TcuTexRefGetAddress = function(var pdptr: TCUdeviceptr; hTexRef: PCUtexref): TCUresult;stdcall;
  624. TcuTexRefGetArray = function(var phArray: PCUarray; hTexRef: PCUtexref): TCUresult;stdcall;
  625. TcuTexRefGetAddressMode = function(var pam: TCUaddress_mode;
  626. hTexRef: PCUtexref; dim: Integer): TCUresult;stdcall;
  627. TcuTexRefGetFilterMode = function(var pfm: TCUfilter_mode; hTexRef: PCUtexref): TCUresult;stdcall;
  628. TcuTexRefGetFormat = function(var pFormat: TCUarray_format;
  629. var pNumChannels: Integer; hTexRef: PCUtexref): TCUresult;stdcall;
  630. TcuTexRefGetFlags = function(var pFlags: Cardinal; hTexRef: PCUtexref): TCUresult;stdcall;
  631. TcuParamSetSize = function(hfunc: PCUfunction; numbytes: Cardinal): TCUresult;stdcall;
  632. TcuParamSeti = function(hfunc: PCUfunction; offset: Integer; value: Cardinal)
  633. : TCUresult;stdcall;
  634. TcuParamSetf = function(hfunc: PCUfunction; offset: Integer; value: Single)
  635. : TCUresult;stdcall;
  636. TcuParamSetv = function(hfunc: PCUfunction; offset: Integer; var ptr;
  637. numbytes: Cardinal): TCUresult;stdcall;
  638. TcuParamSetTexRef = function(hfunc: PCUfunction; texunit: Integer;
  639. hTexRef: PCUtexref): TCUresult;stdcall;
  640. TcuLaunch = function(f: PCUfunction): TCUresult;stdcall;
  641. TcuLaunchGrid = function(f: PCUfunction; grid_width: Integer;
  642. grid_height: Integer): TCUresult;stdcall;
  643. TcuLaunchGridAsync = function(f: PCUfunction; grid_width: Integer;
  644. grid_height: Integer; hStream: PCUstream): TCUresult;stdcall;
  645. TcuEventCreate = function(var phEvent: PCUevent; Flags: Cardinal): TCUresult;stdcall;
  646. TcuEventRecord = function(hEvent: PCUevent; hStream: PCUstream): TCUresult;stdcall;
  647. TcuEventQuery = function(hEvent: PCUevent): TCUresult;stdcall;
  648. TcuEventSynchronize = function(hEvent: PCUevent): TCUresult;stdcall;
  649. TcuEventDestroy = function(hEvent: PCUevent): TCUresult;stdcall;
  650. TcuEventElapsedTime = function(var pMilliseconds: Single; hStart: PCUevent;
  651. hEnd: PCUevent): TCUresult;stdcall;
  652. TcuStreamCreate = function(var phStream: PCUstream; Flags: Cardinal): TCUresult;stdcall;
  653. TcuStreamQuery = function(hStream: PCUstream): TCUresult;stdcall;
  654. TcuStreamSynchronize = function(hStream: PCUstream): TCUresult;stdcall;
  655. TcuStreamDestroy = function(hStream: PCUstream): TCUresult;stdcall;
  656. TcuGLCtxCreate = function(var pctx: PCUcontext; Flags: Cardinal;
  657. device: TCUdevice): TCUresult;stdcall;
  658. TcuGraphicsGLRegisterBuffer = function(var pCudaResource: PCUgraphicsResource;
  659. buffer: Cardinal; Flags: TCUgraphicsMapResourceFlags): TCUresult;stdcall;
  660. TcuGraphicsGLRegisterImage = function(var pCudaResource: PCUgraphicsResource;
  661. image, target: Cardinal; Flags: TCUgraphicsMapResourceFlags): TCUresult;stdcall;
  662. TcuWGLGetDevice = function(var pDevice: TCUdevice; hGpu: HGPUNV): TCUresult;stdcall;
  663. TcuGraphicsUnregisterResource = function(resource: PCUgraphicsResource): TCUresult;stdcall;
  664. TcuGraphicsSubResourceGetMappedArray = function(var pArray: PCUarray;
  665. resource: PCUgraphicsResource; arrayIndex: Cardinal; mipLevel: Cardinal)
  666. : TCUresult;stdcall;
  667. TcuGraphicsResourceGetMappedPointer = function(var pDevPtr: TCUdeviceptr;
  668. out psize: Cardinal; resource: PCUgraphicsResource): TCUresult;stdcall;
  669. TcuGraphicsResourceSetMapFlags = function(resource: PCUgraphicsResource;
  670. Flags: Cardinal): TCUresult;stdcall;
  671. TcuGraphicsMapResources = function(count: Cardinal;
  672. resources: PPCUgraphicsResource; hStream: PCUstream): TCUresult;stdcall;
  673. TcuGraphicsUnmapResources = function(count: Cardinal;
  674. resources: PPCUgraphicsResource; hStream: PCUstream): TCUresult;stdcall;
  675. TcuGLInit = procedure();stdcall;
  676. TcuGLRegisterBufferObject = function(buffer: Cardinal): TCUresult;stdcall;
  677. TcuGLMapBufferObject = function(var dptr: TCUdeviceptr; var size: Cardinal;
  678. buffer: Cardinal): TCUresult;stdcall;
  679. TcuGLUnmapBufferObject = function(buffer: Cardinal): TCUresult;stdcall;
  680. TcuGLUnregisterBufferObject = function(buffer: Cardinal): TCUresult;stdcall;
  681. TcuGLSetBufferObjectMapFlags = function(buffer: Cardinal; Flags: Cardinal)
  682. : TCUresult;stdcall;
  683. TcuGLMapBufferObjectAsync = function(var dptr: TCUdeviceptr;
  684. var size: Cardinal; buffer: Cardinal; hStream: PCUstream): TCUresult;stdcall;
  685. TcuGLUnmapBufferObjectAsync = function(buffer: Cardinal; hStream: PCUstream)
  686. : TCUresult;stdcall;
  687. var
  688. cuInit: TcuInit;
  689. cuDriverGetVersion: TcuDriverGetVersion;
  690. cuDeviceGet: TcuDeviceGet;
  691. cuDeviceGetCount: TcuDeviceGetCount;
  692. cuDeviceGetName: TcuDeviceGetName;
  693. cuDeviceComputeCapability: TcuDeviceComputeCapability;
  694. cuDeviceTotalMem: TcuDeviceTotalMem;
  695. cuDeviceGetProperties: TcuDeviceGetProperties;
  696. cuDeviceGetAttribute: TcuDeviceGetAttribute;
  697. cuCtxCreate: TcuCtxCreate;
  698. cuCtxDestroy: TcuCtxDestroy;
  699. cuCtxAttach: TcuCtxAttach;
  700. cuCtxDetach: TcuCtxDetach;
  701. cuCtxPushCurrent: TcuCtxPushCurrent;
  702. cuCtxPopCurrent: TcuCtxPopCurrent;
  703. cuCtxGetDevice: TcuCtxGetDevice;
  704. cuCtxSynchronize: TcuCtxSynchronize;
  705. cuModuleLoad: TcuModuleLoad;
  706. cuModuleLoadData: TcuModuleLoadData;
  707. cuModuleLoadDataEx: TcuModuleLoadDataEx;
  708. cuModuleLoadFatBinary: TcuModuleLoadFatBinary;
  709. cuModuleUnload: TcuModuleUnload;
  710. cuModuleGetFunction: TcuModuleGetFunction;
  711. cuModuleGetGlobal: TcuModuleGetGlobal;
  712. cuModuleGetTexRef: TcuModuleGetTexRef;
  713. cuMemGetInfo: TcuMemGetInfo;
  714. cuMemAlloc: TcuMemAlloc;
  715. cuMemAllocPitch: TcuMemAllocPitch;
  716. cuMemFree: TcuMemFree;
  717. cuMemGetAddressRange: TcuMemGetAddressRange;
  718. cuMemAllocHost: TcuMemAllocHost;
  719. cuMemFreeHost: TcuMemFreeHost;
  720. cuMemHostAlloc: TcuMemHostAlloc;
  721. cuMemHostGetDevicePointer: TcuMemHostGetDevicePointer;
  722. cuMemHostGetFlags: TcuMemHostGetFlags;
  723. cuMemcpyHtoD: TcuMemcpyHtoD;
  724. cuMemcpyDtoH: TcuMemcpyDtoH;
  725. cuMemcpyDtoD: TcuMemcpyDtoD;
  726. cuMemcpyDtoDAsync: TcuMemcpyDtoDAsync;
  727. cuMemcpyDtoA: TcuMemcpyDtoA;
  728. cuMemcpyAtoD: TcuMemcpyAtoD;
  729. cuMemcpyHtoA: TcuMemcpyHtoA;
  730. cuMemcpyAtoH: TcuMemcpyAtoH;
  731. cuMemcpyAtoA: TcuMemcpyAtoA;
  732. cuMemcpy2D: TcuMemcpy2D;
  733. cuMemcpy2DUnaligned: TcuMemcpy2DUnaligned;
  734. cuMemcpy3D: TcuMemcpy3D;
  735. cuMemcpyHtoDAsync: TcuMemcpyHtoDAsync;
  736. cuMemcpyDtoHAsync: TcuMemcpyDtoHAsync;
  737. cuMemcpyHtoAAsync: TcuMemcpyHtoAAsync;
  738. cuMemcpyAtoHAsync: TcuMemcpyAtoHAsync;
  739. cuMemcpy2DAsync: TcuMemcpy2DAsync;
  740. cuMemcpy3DAsync: TcuMemcpy3DAsync;
  741. cuMemsetD8: TcuMemsetD8;
  742. cuMemsetD16: TcuMemsetD16;
  743. cuMemsetD32: TcuMemsetD32;
  744. cuMemsetD2D8: TcuMemsetD2D8;
  745. cuMemsetD2D16: TcuMemsetD2D16;
  746. cuMemsetD2D32: TcuMemsetD2D32;
  747. cuFuncSetBlockShape: TcuFuncSetBlockShape;
  748. cuFuncSetSharedSize: TcuFuncSetSharedSize;
  749. cuFuncGetAttribute: TcuFuncGetAttribute;
  750. cuArrayCreate: TcuArrayCreate;
  751. cuArrayGetDescriptor: TcuArrayGetDescriptor;
  752. cuArrayDestroy: TcuArrayDestroy;
  753. cuArray3DCreate: TcuArray3DCreate;
  754. cuArray3DGetDescriptor: TcuArray3DGetDescriptor;
  755. cuTexRefCreate: TcuTexRefCreate;
  756. cuTexRefDestroy: TcuTexRefDestroy;
  757. cuTexRefSetArray: TcuTexRefSetArray;
  758. cuTexRefSetAddress: TcuTexRefSetAddress;
  759. cuTexRefSetAddress2D: TcuTexRefSetAddress2D;
  760. cuTexRefSetFormat: TcuTexRefSetFormat;
  761. cuTexRefSetAddressMode: TcuTexRefSetAddressMode;
  762. cuTexRefSetFilterMode: TcuTexRefSetFilterMode;
  763. cuTexRefSetFlags: TcuTexRefSetFlags;
  764. cuTexRefGetAddress: TcuTexRefGetAddress;
  765. cuTexRefGetArray: TcuTexRefGetArray;
  766. cuTexRefGetAddressMode: TcuTexRefGetAddressMode;
  767. cuTexRefGetFilterMode: TcuTexRefGetFilterMode;
  768. cuTexRefGetFormat: TcuTexRefGetFormat;
  769. cuTexRefGetFlags: TcuTexRefGetFlags;
  770. cuParamSetSize: TcuParamSetSize;
  771. cuParamSeti: TcuParamSeti;
  772. cuParamSetf: TcuParamSetf;
  773. cuParamSetv: TcuParamSetv;
  774. cuParamSetTexRef: TcuParamSetTexRef;
  775. cuLaunch: TcuLaunch;
  776. cuLaunchGrid: TcuLaunchGrid;
  777. cuLaunchGridAsync: TcuLaunchGridAsync;
  778. cuEventCreate: TcuEventCreate;
  779. cuEventRecord: TcuEventRecord;
  780. cuEventQuery: TcuEventQuery;
  781. cuEventSynchronize: TcuEventSynchronize;
  782. cuEventDestroy: TcuEventDestroy;
  783. cuEventElapsedTime: TcuEventElapsedTime;
  784. cuStreamCreate: TcuStreamCreate;
  785. cuStreamQuery: TcuStreamQuery;
  786. cuStreamSynchronize: TcuStreamSynchronize;
  787. cuStreamDestroy: TcuStreamDestroy;
  788. cuGLInit: TcuGLInit;
  789. cuGLCtxCreate: TcuGLCtxCreate;
  790. cuGraphicsGLRegisterBuffer: TcuGraphicsGLRegisterBuffer;
  791. cuGraphicsGLRegisterImage: TcuGraphicsGLRegisterImage;
  792. cuWGLGetDevice: TcuWGLGetDevice;
  793. cuGraphicsUnregisterResource: TcuGraphicsUnregisterResource;
  794. cuGraphicsSubResourceGetMappedArray: TcuGraphicsSubResourceGetMappedArray;
  795. cuGraphicsResourceGetMappedPointer: TcuGraphicsResourceGetMappedPointer;
  796. cuGraphicsResourceSetMapFlags: TcuGraphicsResourceSetMapFlags;
  797. cuGraphicsMapResources: TcuGraphicsMapResources;
  798. cuGraphicsUnmapResources: TcuGraphicsUnmapResources;
  799. cuGLRegisterBufferObject: TcuGLRegisterBufferObject;
  800. cuGLMapBufferObject: TcuGLMapBufferObject;
  801. cuGLUnmapBufferObject: TcuGLUnmapBufferObject;
  802. cuGLUnregisterBufferObject: TcuGLUnregisterBufferObject;
  803. cuGLSetBufferObjectMapFlags: TcuGLSetBufferObjectMapFlags;
  804. cuGLMapBufferObjectAsync: TcuGLMapBufferObjectAsync;
  805. cuGLUnmapBufferObjectAsync: TcuGLUnmapBufferObjectAsync;
  806. function InitCUDA: Boolean;
  807. procedure CloseCUDA;
  808. function InitCUDAFromLibrary(const LibName: WideString): Boolean;
  809. function IsCUDAInitialized: Boolean;
  810. function Get_CUDA_API_Error_String(AError: TCUresult): string;
  811. //==============================================================
  812. implementation
  813. //==============================================================
  814. resourcestring
  815. cudasFuncRetErr = '%s return error: %s';
  816. const
  817. INVALID_MODULEHANDLE = 0;
  818. // ************** Windows specific ********************
  819. {$IFDEF MSWINDOWS}
  820. var
  821. CUDAHandle: HINST;
  822. {$ENDIF}
  823. // ************** UNIX specific ********************
  824. {$IFDEF UNIX}
  825. var
  826. CUDAHandle: TLibHandle;
  827. {$ENDIF}
  828. const
  829. cuInitName = 'cuInit';
  830. cuDriverGetVersionName = 'cuDriverGetVersion';
  831. cuDeviceGet_Name = 'cuDeviceGet';
  832. cuDeviceGetCountName = 'cuDeviceGetCount';
  833. cuDeviceGetNameName = 'cuDeviceGetName';
  834. cuDeviceComputeCapabilityName = 'cuDeviceComputeCapability';
  835. cuDeviceTotalMemName = 'cuDeviceTotalMem';
  836. cuDeviceGetPropertiesName = 'cuDeviceGetProperties';
  837. cuDeviceGetAttributeName = 'cuDeviceGetAttribute';
  838. cuCtxCreateName = 'cuCtxCreate';
  839. cuCtxDestroyName = 'cuCtxDestroy';
  840. cuCtxAttachName = 'cuCtxAttach';
  841. cuCtxDetachName = 'cuCtxDetach';
  842. cuCtxPushCurrentName = 'cuCtxPushCurrent';
  843. cuCtxPopCurrentName = 'cuCtxPopCurrent';
  844. cuCtxGetDeviceName = 'cuCtxGetDevice';
  845. cuCtxSynchronizeName = 'cuCtxSynchronize';
  846. cuModuleLoadName = 'cuModuleLoad';
  847. cuModuleLoadDataName = 'cuModuleLoadData';
  848. cuModuleLoadDataExName = 'cuModuleLoadDataEx';
  849. cuModuleLoadFatBinaryName = 'cuModuleLoadFatBinary';
  850. cuModuleUnloadName = 'cuModuleUnload';
  851. cuModuleGetFunctionName = 'cuModuleGetFunction';
  852. cuModuleGetGlobalName = 'cuModuleGetGlobal';
  853. cuModuleGetTexRefName = 'cuModuleGetTexRef';
  854. cuMemGetInfoName = 'cuMemGetInfo';
  855. cuMemAllocName = 'cuMemAlloc';
  856. cuMemAllocPitchName = 'cuMemAllocPitch';
  857. cuMemFreeName = 'cuMemFree';
  858. cuMemGetAddressRangeName = 'cuMemGetAddressRange';
  859. cuMemAllocHostName = 'cuMemAllocHost';
  860. cuMemFreeHostName = 'cuMemFreeHost';
  861. cuMemHostAllocName = 'cuMemHostAlloc';
  862. cuMemHostGetDevicePointerName = 'cuMemHostGetDevicePointer';
  863. cuMemHostGetFlagsName = 'cuMemHostGetFlags';
  864. cuMemcpyHtoDName = 'cuMemcpyHtoD';
  865. cuMemcpyDtoHName = 'cuMemcpyDtoH';
  866. cuMemcpyDtoDName = 'cuMemcpyDtoD';
  867. cuMemcpyDtoDAsyncName = 'cuMemcpyDtoDAsync';
  868. cuMemcpyDtoAName = 'cuMemcpyDtoA';
  869. cuMemcpyAtoDName = 'cuMemcpyAtoD';
  870. cuMemcpyHtoAName = 'cuMemcpyHtoA';
  871. cuMemcpyAtoHName = 'cuMemcpyAtoH';
  872. cuMemcpyAtoAName = 'cuMemcpyAtoA';
  873. cuMemcpy2DName = 'cuMemcpy2D';
  874. cuMemcpy2DUnalignedName = 'cuMemcpy2DUnaligned';
  875. cuMemcpy3DName = 'cuMemcpy3D';
  876. cuMemcpyHtoDAsyncName = 'cuMemcpyHtoDAsync';
  877. cuMemcpyDtoHAsyncName = 'cuMemcpyDtoHAsync';
  878. cuMemcpyHtoAAsyncName = 'cuMemcpyHtoAAsync';
  879. cuMemcpyAtoHAsyncName = 'cuMemcpyAtoHAsync';
  880. cuMemcpy2DAsyncName = 'cuMemcpy2DAsync';
  881. cuMemcpy3DAsyncName = 'cuMemcpy3DAsync';
  882. cuMemsetD8Name = 'cuMemsetD8';
  883. cuMemsetD16Name = 'cuMemsetD16';
  884. cuMemsetD32Name = 'cuMemsetD32';
  885. cuMemsetD2D8Name = 'cuMemsetD2D8';
  886. cuMemsetD2D16Name = 'cuMemsetD2D16';
  887. cuMemsetD2D32Name = 'cuMemsetD2D32';
  888. cuFuncSetBlockShapeName = 'cuFuncSetBlockShape';
  889. cuFuncSetSharedSizeName = 'cuFuncSetSharedSize';
  890. cuFuncGetAttributeName = 'cuFuncGetAttribute';
  891. cuArrayCreateName = 'cuArrayCreate';
  892. cuArrayGetDescriptorName = 'cuArrayGetDescriptor';
  893. cuArrayDestroyName = 'cuArrayDestroy';
  894. cuArray3DCreateName = 'cuArray3DCreate';
  895. cuArray3DGetDescriptorName = 'cuArray3DGetDescriptor';
  896. cuTexRefCreateName = 'cuTexRefCreate';
  897. cuTexRefDestroyName = 'cuTexRefDestroy';
  898. cuTexRefSetArrayName = 'cuTexRefSetArray';
  899. cuTexRefSetAddressName = 'cuTexRefSetAddress';
  900. cuTexRefSetAddress2DName = 'cuTexRefSetAddress2D';
  901. cuTexRefSetFormatName = 'cuTexRefSetFormat';
  902. cuTexRefSetAddressModeName = 'cuTexRefSetAddressMode';
  903. cuTexRefSetFilterModeName = 'cuTexRefSetFilterMode';
  904. cuTexRefSetFlagsName = 'cuTexRefSetFlags';
  905. cuTexRefGetAddressName = 'cuTexRefGetAddress';
  906. cuTexRefGetArrayName = 'cuTexRefGetArray';
  907. cuTexRefGetAddressModeName = 'cuTexRefGetAddressMode';
  908. cuTexRefGetFilterModeName = 'cuTexRefGetFilterMode';
  909. cuTexRefGetFormatName = 'cuTexRefGetFormat';
  910. cuTexRefGetFlagsName = 'cuTexRefGetFlags';
  911. cuParamSetSizeName = 'cuParamSetSize';
  912. cuParamSetiName = 'cuParamSeti';
  913. cuParamSetfName = 'cuParamSetf';
  914. cuParamSetvName = 'cuParamSetv';
  915. cuParamSetTexRefName = 'cuParamSetTexRef';
  916. cuLaunchName = 'cuLaunch';
  917. cuLaunchGridName = 'cuLaunchGrid';
  918. cuLaunchGridAsyncName = 'cuLaunchGridAsync';
  919. cuEventCreateName = 'cuEventCreate';
  920. cuEventRecordName = 'cuEventRecord';
  921. cuEventQueryName = 'cuEventQuery';
  922. cuEventSynchronizeName = 'cuEventSynchronize';
  923. cuEventDestroyName = 'cuEventDestroy';
  924. cuEventElapsedTimeName = 'cuEventElapsedTime';
  925. cuStreamCreateName = 'cuStreamCreate';
  926. cuStreamQueryName = 'cuStreamQuery';
  927. cuStreamSynchronizeName = 'cuStreamSynchronize';
  928. cuStreamDestroyName = 'cuStreamDestroy';
  929. cuGLCtxCreateName = 'cuGLCtxCreate';
  930. cuGraphicsGLRegisterBufferName = 'cuGraphicsGLRegisterBuffer';
  931. cuGraphicsGLRegisterImageName = 'cuGraphicsGLRegisterImage';
  932. cuWGLGetDeviceName = 'cuWGLGetDevice';
  933. cuGraphicsUnregisterResourceName = 'cuGraphicsUnregisterResource';
  934. cuGraphicsSubResourceGetMappedArrayName =
  935. 'cuGraphicsSubResourceGetMappedArray';
  936. cuGraphicsResourceGetMappedPointerName = 'cuGraphicsResourceGetMappedPointer';
  937. cuGraphicsResourceSetMapFlagsName = 'cuGraphicsResourceSetMapFlags';
  938. cuGraphicsMapResourcesName = 'cuGraphicsMapResources';
  939. cuGraphicsUnmapResourcesName = 'cuGraphicsUnmapResources';
  940. cuGLInitName = 'cuGLInit';
  941. cuGLRegisterBufferObjectName = 'cuGLRegisterBufferObject';
  942. cuGLMapBufferObjectName = 'cuGLMapBufferObject';
  943. cuGLUnmapBufferObjectName = 'cuGLUnmapBufferObject';
  944. cuGLUnregisterBufferObjectName = 'cuGLUnregisterBufferObject';
  945. cuGLSetBufferObjectMapFlagsName = 'cuGLSetBufferObjectMapFlags';
  946. cuGLMapBufferObjectAsyncName = 'cuGLMapBufferObjectAsync';
  947. cuGLUnmapBufferObjectAsyncName = 'cuGLUnmapBufferObjectAsync';
  948. {$IFDEF USE_CUDA_DEBUG_MODE}
  949. var
  950. cuInit_: TcuInit;
  951. cuDriverGetVersion_: TcuDriverGetVersion;
  952. cuDeviceGet_: TcuDeviceGet;
  953. cuDeviceGetCount_: TcuDeviceGetCount;
  954. cuDeviceGetName_: TcuDeviceGetName;
  955. cuDeviceComputeCapability_: TcuDeviceComputeCapability;
  956. cuDeviceTotalMem_: TcuDeviceTotalMem;
  957. cuDeviceGetProperties_: TcuDeviceGetProperties;
  958. cuDeviceGetAttribute_: TcuDeviceGetAttribute;
  959. cuCtxCreate_: TcuCtxCreate;
  960. cuCtxDestroy_: TcuCtxDestroy;
  961. cuCtxAttach_: TcuCtxAttach;
  962. cuCtxDetach_: TcuCtxDetach;
  963. cuCtxPushCurrent_: TcuCtxPushCurrent;
  964. cuCtxPopCurrent_: TcuCtxPopCurrent;
  965. cuCtxGetDevice_: TcuCtxGetDevice;
  966. cuCtxSynchronize_: TcuCtxSynchronize;
  967. cuModuleLoad_: TcuModuleLoad;
  968. cuModuleLoadData_: TcuModuleLoadData;
  969. cuModuleLoadDataEx_: TcuModuleLoadDataEx;
  970. cuModuleLoadFatBinary_: TcuModuleLoadFatBinary;
  971. cuModuleUnload_: TcuModuleUnload;
  972. cuModuleGetFunction_: TcuModuleGetFunction;
  973. cuModuleGetGlobal_: TcuModuleGetGlobal;
  974. cuModuleGetTexRef_: TcuModuleGetTexRef;
  975. cuMemGetInfo_: TcuMemGetInfo;
  976. cuMemAlloc_: TcuMemAlloc;
  977. cuMemAllocPitch_: TcuMemAllocPitch;
  978. cuMemFree_: TcuMemFree;
  979. cuMemGetAddressRange_: TcuMemGetAddressRange;
  980. cuMemAllocHost_: TcuMemAllocHost;
  981. cuMemFreeHost_: TcuMemFreeHost;
  982. cuMemHostAlloc_: TcuMemHostAlloc;
  983. cuMemHostGetDevicePointer_: TcuMemHostGetDevicePointer;
  984. cuMemHostGetFlags_: TcuMemHostGetFlags;
  985. cuMemcpyHtoD_: TcuMemcpyHtoD;
  986. cuMemcpyDtoH_: TcuMemcpyDtoH;
  987. cuMemcpyDtoD_: TcuMemcpyDtoD;
  988. cuMemcpyDtoDAsync_: TcuMemcpyDtoDAsync;
  989. cuMemcpyDtoA_: TcuMemcpyDtoA;
  990. cuMemcpyAtoD_: TcuMemcpyAtoD;
  991. cuMemcpyHtoA_: TcuMemcpyHtoA;
  992. cuMemcpyAtoH_: TcuMemcpyAtoH;
  993. cuMemcpyAtoA_: TcuMemcpyAtoA;
  994. cuMemcpy2D_: TcuMemcpy2D;
  995. cuMemcpy2DUnaligned_: TcuMemcpy2DUnaligned;
  996. cuMemcpy3D_: TcuMemcpy3D;
  997. cuMemcpyHtoDAsync_: TcuMemcpyHtoDAsync;
  998. cuMemcpyDtoHAsync_: TcuMemcpyDtoHAsync;
  999. cuMemcpyHtoAAsync_: TcuMemcpyHtoAAsync;
  1000. cuMemcpyAtoHAsync_: TcuMemcpyAtoHAsync;
  1001. cuMemcpy2DAsync_: TcuMemcpy2DAsync;
  1002. cuMemcpy3DAsync_: TcuMemcpy3DAsync;
  1003. cuMemsetD8_: TcuMemsetD8;
  1004. cuMemsetD16_: TcuMemsetD16;
  1005. cuMemsetD32_: TcuMemsetD32;
  1006. cuMemsetD2D8_: TcuMemsetD2D8;
  1007. cuMemsetD2D16_: TcuMemsetD2D16;
  1008. cuMemsetD2D32_: TcuMemsetD2D32;
  1009. cuFuncSetBlockShape_: TcuFuncSetBlockShape;
  1010. cuFuncSetSharedSize_: TcuFuncSetSharedSize;
  1011. cuFuncGetAttribute_: TcuFuncGetAttribute;
  1012. cuArrayCreate_: TcuArrayCreate;
  1013. cuArrayGetDescriptor_: TcuArrayGetDescriptor;
  1014. cuArrayDestroy_: TcuArrayDestroy;
  1015. cuArray3DCreate_: TcuArray3DCreate;
  1016. cuArray3DGetDescriptor_: TcuArray3DGetDescriptor;
  1017. cuTexRefCreate_: TcuTexRefCreate;
  1018. cuTexRefDestroy_: TcuTexRefDestroy;
  1019. cuTexRefSetArray_: TcuTexRefSetArray;
  1020. cuTexRefSetAddress_: TcuTexRefSetAddress;
  1021. cuTexRefSetAddress2D_: TcuTexRefSetAddress2D;
  1022. cuTexRefSetFormat_: TcuTexRefSetFormat;
  1023. cuTexRefSetAddressMode_: TcuTexRefSetAddressMode;
  1024. cuTexRefSetFilterMode_: TcuTexRefSetFilterMode;
  1025. cuTexRefSetFlags_: TcuTexRefSetFlags;
  1026. cuTexRefGetAddress_: TcuTexRefGetAddress;
  1027. cuTexRefGetArray_: TcuTexRefGetArray;
  1028. cuTexRefGetAddressMode_: TcuTexRefGetAddressMode;
  1029. cuTexRefGetFilterMode_: TcuTexRefGetFilterMode;
  1030. cuTexRefGetFormat_: TcuTexRefGetFormat;
  1031. cuTexRefGetFlags_: TcuTexRefGetFlags;
  1032. cuParamSetSize_: TcuParamSetSize;
  1033. cuParamSeti_: TcuParamSeti;
  1034. cuParamSetf_: TcuParamSetf;
  1035. cuParamSetv_: TcuParamSetv;
  1036. cuParamSetTexRef_: TcuParamSetTexRef;
  1037. cuLaunch_: TcuLaunch;
  1038. cuLaunchGrid_: TcuLaunchGrid;
  1039. cuLaunchGridAsync_: TcuLaunchGridAsync;
  1040. cuEventCreate_: TcuEventCreate;
  1041. cuEventRecord_: TcuEventRecord;
  1042. cuEventQuery_: TcuEventQuery;
  1043. cuEventSynchronize_: TcuEventSynchronize;
  1044. cuEventDestroy_: TcuEventDestroy;
  1045. cuEventElapsedTime_: TcuEventElapsedTime;
  1046. cuStreamCreate_: TcuStreamCreate;
  1047. cuStreamQuery_: TcuStreamQuery;
  1048. cuStreamSynchronize_: TcuStreamSynchronize;
  1049. cuStreamDestroy_: TcuStreamDestroy;
  1050. cuGLCtxCreate_: TcuGLCtxCreate;
  1051. cuGraphicsGLRegisterBuffer_: TcuGraphicsGLRegisterBuffer;
  1052. cuGraphicsGLRegisterImage_: TcuGraphicsGLRegisterImage;
  1053. cuWGLGetDevice_: TcuWGLGetDevice;
  1054. cuGraphicsUnregisterResource_: TcuGraphicsUnregisterResource;
  1055. cuGraphicsSubResourceGetMappedArray_: TcuGraphicsSubResourceGetMappedArray;
  1056. cuGraphicsResourceGetMappedPointer_: TcuGraphicsResourceGetMappedPointer;
  1057. cuGraphicsResourceSetMapFlags_: TcuGraphicsResourceSetMapFlags;
  1058. cuGraphicsMapResources_: TcuGraphicsMapResources;
  1059. cuGraphicsUnmapResources_: TcuGraphicsUnmapResources;
  1060. cuGLRegisterBufferObject_: TcuGLRegisterBufferObject;
  1061. cuGLMapBufferObject_: TcuGLMapBufferObject;
  1062. cuGLUnmapBufferObject_: TcuGLUnmapBufferObject;
  1063. cuGLUnregisterBufferObject_: TcuGLUnregisterBufferObject;
  1064. cuGLSetBufferObjectMapFlags_: TcuGLSetBufferObjectMapFlags;
  1065. cuGLMapBufferObjectAsync_: TcuGLMapBufferObjectAsync;
  1066. cuGLUnmapBufferObjectAsync_: TcuGLUnmapBufferObjectAsync;
  1067. function cuInitShell(Flags: Cardinal): TCUresult;stdcall;
  1068. begin
  1069. Result := cuInit_(Flags);
  1070. if Result <> CUDA_SUCCESS then
  1071. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1072. [cuInitName, Get_CUDA_API_Error_String(Result)])
  1073. end;
  1074. function cuDriverGetVersionShell(out driverVersion: Integer): TCUresult;stdcall;
  1075. begin
  1076. Result := cuDriverGetVersion_(driverVersion);
  1077. if Result <> CUDA_SUCCESS then
  1078. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuDriverGetVersionName,
  1079. Get_CUDA_API_Error_String(Result)])
  1080. end;
  1081. function cuDeviceGetShell(var device: TCUdevice; ordinal: Integer): TCUresult;stdcall;
  1082. begin
  1083. Result := cuDeviceGet_(device, ordinal);
  1084. if Result <> CUDA_SUCCESS then
  1085. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1086. [cuDeviceGet_Name, Get_CUDA_API_Error_String(Result)])
  1087. end;
  1088. function cuDeviceGetCountShell(var count: Integer): TCUresult;stdcall;
  1089. begin
  1090. Result := cuDeviceGetCount_(count);
  1091. if Result <> CUDA_SUCCESS then
  1092. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuDeviceGetCountName,
  1093. Get_CUDA_API_Error_String(Result)])
  1094. end;
  1095. function cuDeviceGetNameShell(name: PAnsiChar; len: Integer; dev: TCUdevice)
  1096. : TCUresult;stdcall;
  1097. begin
  1098. Result := cuDeviceGetName_(name, len, dev);
  1099. if Result <> CUDA_SUCCESS then
  1100. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuDeviceGetNameName,
  1101. Get_CUDA_API_Error_String(Result)])
  1102. end;
  1103. function cuDeviceComputeCapabilityShell(var major: Integer; var minor: Integer;
  1104. dev: TCUdevice): TCUresult;stdcall;
  1105. begin
  1106. Result := cuDeviceComputeCapability_(major, minor, dev);
  1107. if Result <> CUDA_SUCCESS then
  1108. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuDeviceComputeCapabilityName,
  1109. Get_CUDA_API_Error_String(Result)])
  1110. end;
  1111. function cuDeviceTotalMemShell(bytes: PSize_t; dev: TCUdevice): TCUresult;stdcall;
  1112. begin
  1113. Result := cuDeviceTotalMem_(bytes, dev);
  1114. if Result <> CUDA_SUCCESS then
  1115. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuDeviceTotalMemName,
  1116. Get_CUDA_API_Error_String(Result)])
  1117. end;
  1118. function cuDeviceGetPropertiesShell(var prop: TCUdevprop; dev: TCUdevice)
  1119. : TCUresult;
  1120. stdcall;
  1121. begin
  1122. Result := cuDeviceGetProperties_(prop, dev);
  1123. if Result <> CUDA_SUCCESS then
  1124. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuDeviceGetPropertiesName,
  1125. Get_CUDA_API_Error_String(Result)])
  1126. end;
  1127. function cuDeviceGetAttributeShell(pi: PSize_t; attrib: TCUdevice_attribute;
  1128. dev: TCUdevice): TCUresult;stdcall;
  1129. begin
  1130. Result := cuDeviceGetAttribute_(pi, attrib, dev);
  1131. if Result <> CUDA_SUCCESS then
  1132. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuDeviceGetAttributeName,
  1133. Get_CUDA_API_Error_String(Result)])
  1134. end;
  1135. function cuCtxCreateShell(var pctx: PCUcontext; Flags: Cardinal; dev: TCUdevice)
  1136. : TCUresult;stdcall;
  1137. begin
  1138. Result := cuCtxCreate_(pctx, Flags, dev);
  1139. if Result <> CUDA_SUCCESS then
  1140. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1141. [cuCtxCreateName, Get_CUDA_API_Error_String(Result)])
  1142. end;
  1143. function cuCtxDestroyShell(ctx: PCUcontext): TCUresult;stdcall;
  1144. begin
  1145. Result := cuCtxDestroy_(ctx);
  1146. if Result <> CUDA_SUCCESS then
  1147. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1148. [cuCtxDestroyName, Get_CUDA_API_Error_String(Result)])
  1149. end;
  1150. function cuCtxAttachShell(var pctx: PCUcontext; Flags: Cardinal): TCUresult;stdcall;
  1151. begin
  1152. Result := cuCtxAttach_(pctx, Flags);
  1153. if Result <> CUDA_SUCCESS then
  1154. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1155. [cuCtxAttachName, Get_CUDA_API_Error_String(Result)])
  1156. end;
  1157. function cuCtxDetachShell(ctx: PCUcontext): TCUresult;stdcall;
  1158. begin
  1159. Result := cuCtxDetach_(ctx);
  1160. if Result <> CUDA_SUCCESS then
  1161. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1162. [cuCtxDetachName, Get_CUDA_API_Error_String(Result)])
  1163. end;
  1164. function cuCtxPushCurrentShell(ctx: PCUcontext): TCUresult;stdcall;
  1165. begin
  1166. Result := cuCtxPushCurrent_(ctx);
  1167. if Result <> CUDA_SUCCESS then
  1168. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuCtxPushCurrentName,
  1169. Get_CUDA_API_Error_String(Result)])
  1170. end;
  1171. function cuCtxPopCurrentShell(var pctx: PCUcontext): TCUresult;stdcall;
  1172. begin
  1173. Result := cuCtxPopCurrent_(pctx);
  1174. if Result <> CUDA_SUCCESS then
  1175. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuCtxPopCurrentName,
  1176. Get_CUDA_API_Error_String(Result)])
  1177. end;
  1178. function cuCtxGetDeviceShell(var device: TCUdevice): TCUresult;stdcall;
  1179. begin
  1180. Result := cuCtxGetDevice_(device);
  1181. if Result <> CUDA_SUCCESS then
  1182. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1183. [cuCtxGetDeviceName, Get_CUDA_API_Error_String(Result)])
  1184. end;
  1185. function cuCtxSynchronizeShell: TCUresult;stdcall;
  1186. begin
  1187. Result := cuCtxSynchronize_;
  1188. if Result <> CUDA_SUCCESS then
  1189. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuCtxSynchronizeName,
  1190. Get_CUDA_API_Error_String(Result)])
  1191. end;
  1192. function cuModuleLoadShell(var module: PCUmodule; const fname: PAnsiChar)
  1193. : TCUresult;stdcall;
  1194. begin
  1195. Result := cuModuleLoad_(module, fname);
  1196. if Result <> CUDA_SUCCESS then
  1197. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1198. [cuModuleLoadName, Get_CUDA_API_Error_String(Result)])
  1199. end;
  1200. function cuModuleLoadDataShell(var module: PCUmodule; const image: PAnsiChar)
  1201. : TCUresult;stdcall;
  1202. begin
  1203. Result := cuModuleLoadData_(module, image);
  1204. if Result <> CUDA_SUCCESS then
  1205. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuModuleLoadDataName,
  1206. Get_CUDA_API_Error_String(Result)])
  1207. end;
  1208. function cuModuleLoadDataExShell(var module: PCUmodule; var image;
  1209. numOptions: Cardinal; var options: TCUjit_option; var optionValues)
  1210. : TCUresult;stdcall;
  1211. begin
  1212. Result := cuModuleLoadDataEx_(module, image, numOptions, options,
  1213. optionValues);
  1214. if Result <> CUDA_SUCCESS then
  1215. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuModuleLoadDataExName,
  1216. Get_CUDA_API_Error_String(Result)])
  1217. end;
  1218. function cuModuleLoadFatBinaryShell(var module: PCUmodule; var fatCubin)
  1219. : TCUresult;stdcall;
  1220. begin
  1221. Result := cuModuleLoadFatBinary_(module, fatCubin);
  1222. if Result <> CUDA_SUCCESS then
  1223. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuModuleLoadFatBinaryName,
  1224. Get_CUDA_API_Error_String(Result)])
  1225. end;
  1226. function cuModuleUnloadShell(hmod: PCUmodule): TCUresult;stdcall;
  1227. begin
  1228. Result := cuModuleUnload_(hmod);
  1229. if Result <> CUDA_SUCCESS then
  1230. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1231. [cuModuleUnloadName, Get_CUDA_API_Error_String(Result)])
  1232. end;
  1233. function cuModuleGetFunctionShell(out hfunc: PCUfunction; hmod: PCUmodule;
  1234. const name: PAnsiChar): TCUresult;stdcall;
  1235. begin
  1236. Result := cuModuleGetFunction_(hfunc, hmod, name);
  1237. if Result <> CUDA_SUCCESS then
  1238. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuModuleGetFunctionName,
  1239. Get_CUDA_API_Error_String(Result)])
  1240. end;
  1241. function cuModuleGetGlobalShell(out dptr: TCUdeviceptr; var bytes: Cardinal;
  1242. hmod: PCUmodule; const name: PAnsiChar): TCUresult;stdcall;
  1243. begin
  1244. Result := cuModuleGetGlobal_(dptr, bytes, hmod, name);
  1245. if Result <> CUDA_SUCCESS then
  1246. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuModuleGetGlobalName,
  1247. Get_CUDA_API_Error_String(Result)])
  1248. end;
  1249. function cuModuleGetTexRefShell(out pTexRef: PCUtexref; hmod: PCUmodule;
  1250. const name: PAnsiChar): TCUresult;stdcall;
  1251. begin
  1252. Result := cuModuleGetTexRef_(pTexRef, hmod, name);
  1253. if Result <> CUDA_SUCCESS then
  1254. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuModuleGetTexRefName,
  1255. Get_CUDA_API_Error_String(Result)])
  1256. end;
  1257. function cuMemGetInfoShell(var free: Cardinal; var total: Cardinal): TCUresult;stdcall;
  1258. begin
  1259. Result := cuMemGetInfo_(free, total);
  1260. if Result <> CUDA_SUCCESS then
  1261. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1262. [cuMemGetInfoName, Get_CUDA_API_Error_String(Result)])
  1263. end;
  1264. function cuMemAllocShell(var dptr: TCUdeviceptr; bytesize: Cardinal): TCUresult;stdcall;
  1265. begin
  1266. Result := cuMemAlloc_(dptr, bytesize);
  1267. if Result <> CUDA_SUCCESS then
  1268. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1269. [cuMemAllocName, Get_CUDA_API_Error_String(Result)])
  1270. end;
  1271. function cuMemAllocPitchShell(var dptr: TCUdeviceptr; var pPitch: Cardinal;
  1272. WidthInBytes: Cardinal; Height: Cardinal; ElementSizeBytes: Cardinal)
  1273. : TCUresult;stdcall;
  1274. begin
  1275. Result := cuMemAllocPitch_(dptr, pPitch, WidthInBytes, Height,
  1276. ElementSizeBytes);
  1277. if Result <> CUDA_SUCCESS then
  1278. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuMemAllocPitchName,
  1279. Get_CUDA_API_Error_String(Result)])
  1280. end;
  1281. function cuMemFreeShell(dptr: TCUdeviceptr): TCUresult;stdcall;
  1282. begin
  1283. Result := cuMemFree_(dptr);
  1284. if Result <> CUDA_SUCCESS then
  1285. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1286. [cuMemFreeName, Get_CUDA_API_Error_String(Result)])
  1287. end;
  1288. function cuMemGetAddressRangeShell(var pbase: TCUdeviceptr; var psize: Cardinal;
  1289. dptr: TCUdeviceptr): TCUresult;stdcall;
  1290. begin
  1291. Result := cuMemGetAddressRange_(pbase, psize, dptr);
  1292. if Result <> CUDA_SUCCESS then
  1293. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuMemGetAddressRangeName,
  1294. Get_CUDA_API_Error_String(Result)])
  1295. end;
  1296. function cuMemAllocHostShell(var pp; bytesize: Cardinal): TCUresult;stdcall;
  1297. begin
  1298. Result := cuMemAllocHost_(pp, bytesize);
  1299. if Result <> CUDA_SUCCESS then
  1300. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1301. [cuMemAllocHostName, Get_CUDA_API_Error_String(Result)])
  1302. end;
  1303. function cuMemFreeHostShell(p: Pointer): TCUresult;stdcall;
  1304. begin
  1305. Result := cuMemFreeHost_(p);
  1306. if Result <> CUDA_SUCCESS then
  1307. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1308. [cuMemFreeHostName, Get_CUDA_API_Error_String(Result)])
  1309. end;
  1310. function cuMemHostAllocShell(var pp: Pointer; bytesize: Cardinal; Flags: Cardinal)
  1311. : TCUresult;stdcall;
  1312. begin
  1313. Result := cuMemHostAlloc_(pp, bytesize, Flags);
  1314. if Result <> CUDA_SUCCESS then
  1315. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1316. [cuMemHostAllocName, Get_CUDA_API_Error_String(Result)])
  1317. end;
  1318. function cuMemHostGetDevicePointerShell(var pdptr: TCUdeviceptr; p: Pointer;
  1319. Flags: Cardinal): TCUresult;stdcall;
  1320. begin
  1321. Result := cuMemHostGetDevicePointer_(pdptr, p, Flags);
  1322. if Result <> CUDA_SUCCESS then
  1323. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuMemHostGetDevicePointerName,
  1324. Get_CUDA_API_Error_String(Result)])
  1325. end;
  1326. function cuMemHostGetFlagsShell(var pFlags: Cardinal; var p): TCUresult;stdcall;
  1327. begin
  1328. Result := cuMemHostGetFlags_(pFlags, p);
  1329. if Result <> CUDA_SUCCESS then
  1330. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuMemHostGetFlagsName,
  1331. Get_CUDA_API_Error_String(Result)])
  1332. end;
  1333. function cuMemcpyHtoDShell(dstDevice: TCUdeviceptr; const srcHost: Pointer;
  1334. ByteCount: Cardinal): TCUresult;stdcall;
  1335. begin
  1336. Result := cuMemcpyHtoD_(dstDevice, srcHost, ByteCount);
  1337. if Result <> CUDA_SUCCESS then
  1338. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1339. [cuMemcpyHtoDName, Get_CUDA_API_Error_String(Result)])
  1340. end;
  1341. function cuMemcpyDtoHShell(const dstHost: Pointer; srcDevice: TCUdeviceptr;
  1342. ByteCount: Cardinal): TCUresult;stdcall;
  1343. begin
  1344. Result := cuMemcpyDtoH_(dstHost, srcDevice, ByteCount);
  1345. if Result <> CUDA_SUCCESS then
  1346. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1347. [cuMemcpyDtoHName, Get_CUDA_API_Error_String(Result)])
  1348. end;
  1349. function cuMemcpyDtoDShell(dstDevice: TCUdeviceptr; srcDevice: TCUdeviceptr;
  1350. ByteCount: Cardinal): TCUresult;stdcall;
  1351. begin
  1352. Result := cuMemcpyDtoD_(dstDevice, srcDevice, ByteCount);
  1353. if Result <> CUDA_SUCCESS then
  1354. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1355. [cuMemcpyDtoDName, Get_CUDA_API_Error_String(Result)])
  1356. end;
  1357. function cuMemcpyDtoDAsyncShell(dstDevice: TCUdeviceptr;
  1358. srcDevice: TCUdeviceptr; ByteCount: Cardinal; hStream: PCUstream): TCUresult;stdcall;
  1359. begin
  1360. Result := cuMemcpyDtoDAsync_(dstDevice, srcDevice, ByteCount, hStream);
  1361. if Result <> CUDA_SUCCESS then
  1362. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuMemcpyDtoDAsyncName,
  1363. Get_CUDA_API_Error_String(Result)])
  1364. end;
  1365. function cuMemcpyDtoAShell(dstArray: PCUarray; dstIndex: Cardinal;
  1366. srcDevice: TCUdeviceptr; ByteCount: Cardinal): TCUresult;stdcall;
  1367. begin
  1368. Result := cuMemcpyDtoA_(dstArray, dstIndex, srcDevice, ByteCount);
  1369. if Result <> CUDA_SUCCESS then
  1370. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1371. [cuMemcpyDtoAName, Get_CUDA_API_Error_String(Result)])
  1372. end;
  1373. function cuMemcpyAtoDShell(dstDevice: TCUdeviceptr; hSrc: PCUarray;
  1374. SrcIndex: Cardinal; ByteCount: Cardinal): TCUresult;stdcall;
  1375. begin
  1376. Result := cuMemcpyAtoD_(dstDevice, hSrc, SrcIndex, ByteCount);
  1377. if Result <> CUDA_SUCCESS then
  1378. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1379. [cuMemcpyAtoDName, Get_CUDA_API_Error_String(Result)])
  1380. end;
  1381. function cuMemcpyHtoAShell(dstArray: PCUarray; dstIndex: Cardinal;
  1382. pSrc: Pointer; ByteCount: Cardinal): TCUresult;stdcall;
  1383. begin
  1384. Result := cuMemcpyHtoA_(dstArray, dstIndex, pSrc, ByteCount);
  1385. if Result <> CUDA_SUCCESS then
  1386. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1387. [cuMemcpyHtoAName, Get_CUDA_API_Error_String(Result)])
  1388. end;
  1389. function cuMemcpyAtoHShell(dstHost: Pointer; srcArray: PCUarray;
  1390. SrcIndex: Cardinal; ByteCount: Cardinal): TCUresult;stdcall;
  1391. begin
  1392. Result := cuMemcpyAtoH_(dstHost, srcArray, SrcIndex, ByteCount);
  1393. if Result <> CUDA_SUCCESS then
  1394. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1395. [cuMemcpyAtoHName, Get_CUDA_API_Error_String(Result)])
  1396. end;
  1397. function cuMemcpyAtoAShell(dstArray: PCUarray; dstIndex: Cardinal;
  1398. srcArray: PCUarray; SrcIndex: Cardinal; ByteCount: Cardinal): TCUresult;stdcall;
  1399. begin
  1400. Result := cuMemcpyAtoA_(dstArray, dstIndex, srcArray, SrcIndex, ByteCount);
  1401. if Result <> CUDA_SUCCESS then
  1402. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1403. [cuMemcpyAtoAName, Get_CUDA_API_Error_String(Result)])
  1404. end;
  1405. function cuMemcpy2DShell(const pCopy: PCUDA_MEMCPY2D): TCUresult;stdcall;
  1406. begin
  1407. Result := cuMemcpy2D_(pCopy);
  1408. if Result <> CUDA_SUCCESS then
  1409. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1410. [cuMemcpy2DName, Get_CUDA_API_Error_String(Result)])
  1411. end;
  1412. function cuMemcpy2DUnalignedShell(var pCopy: TCUDA_MEMCPY2D): TCUresult;stdcall;
  1413. begin
  1414. Result := cuMemcpy2DUnaligned_(pCopy);
  1415. if Result <> CUDA_SUCCESS then
  1416. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuMemcpy2DUnalignedName,
  1417. Get_CUDA_API_Error_String(Result)])
  1418. end;
  1419. function cuMemcpy3DShell(var pCopy: TCUDA_MEMCPY3D): TCUresult;stdcall;
  1420. begin
  1421. Result := cuMemcpy3D_(pCopy);
  1422. if Result <> CUDA_SUCCESS then
  1423. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1424. [cuMemcpy3DName, Get_CUDA_API_Error_String(Result)])
  1425. end;
  1426. function cuMemcpyHtoDAsyncShell(dstDevice: TCUdeviceptr; var srcHost;
  1427. ByteCount: Cardinal; hStream: PCUstream): TCUresult;stdcall;
  1428. begin
  1429. Result := cuMemcpyHtoDAsync_(dstDevice, srcHost, ByteCount, hStream);
  1430. if Result <> CUDA_SUCCESS then
  1431. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuMemcpyHtoDAsyncName,
  1432. Get_CUDA_API_Error_String(Result)])
  1433. end;
  1434. function cuMemcpyDtoHAsyncShell(var dstHost; srcDevice: TCUdeviceptr;
  1435. ByteCount: Cardinal; hStream: PCUstream): TCUresult;stdcall;
  1436. begin
  1437. Result := cuMemcpyDtoHAsync_(dstHost, srcDevice, ByteCount, hStream);
  1438. if Result <> CUDA_SUCCESS then
  1439. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuMemcpyDtoHAsyncName,
  1440. Get_CUDA_API_Error_String(Result)])
  1441. end;
  1442. function cuMemcpyHtoAAsyncShell(dstArray: PCUarray; dstIndex: Cardinal;
  1443. var pSrc; ByteCount: Cardinal; hStream: PCUstream): TCUresult;stdcall;
  1444. begin
  1445. Result := cuMemcpyHtoAAsync_(dstArray, dstIndex, pSrc, ByteCount, hStream);
  1446. if Result <> CUDA_SUCCESS then
  1447. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuMemcpyHtoAAsyncName,
  1448. Get_CUDA_API_Error_String(Result)])
  1449. end;
  1450. function cuMemcpyAtoHAsyncShell(var dstHost; srcArray: PCUstream;
  1451. SrcIndex: Cardinal; ByteCount: Cardinal; hStream: PCUstream): TCUresult;stdcall;
  1452. begin
  1453. Result := cuMemcpyAtoHAsync_(dstHost, srcArray, SrcIndex, ByteCount, hStream);
  1454. if Result <> CUDA_SUCCESS then
  1455. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuMemcpyAtoHAsyncName,
  1456. Get_CUDA_API_Error_String(Result)])
  1457. end;
  1458. function cuMemcpy2DAsyncShell(var pCopy: TCUDA_MEMCPY2D; hStream: PCUstream)
  1459. : TCUresult;stdcall;
  1460. begin
  1461. Result := cuMemcpy2DAsync_(pCopy, hStream);
  1462. if Result <> CUDA_SUCCESS then
  1463. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuMemcpy2DAsyncName,
  1464. Get_CUDA_API_Error_String(Result)])
  1465. end;
  1466. function cuMemcpy3DAsyncShell(var pCopy: TCUDA_MEMCPY3D; hStream: PCUstream)
  1467. : TCUresult;stdcall;
  1468. begin
  1469. Result := cuMemcpy3DAsync_(pCopy, hStream);
  1470. if Result <> CUDA_SUCCESS then
  1471. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuMemcpy3DAsyncName,
  1472. Get_CUDA_API_Error_String(Result)])
  1473. end;
  1474. function cuMemsetD8Shell(dstDevice: TCUdeviceptr; ub: Byte; N: Cardinal)
  1475. : TCUresult;stdcall;
  1476. begin
  1477. Result := cuMemsetD8_(dstDevice, ub, N);
  1478. if Result <> CUDA_SUCCESS then
  1479. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1480. [cuMemsetD8Name, Get_CUDA_API_Error_String(Result)])
  1481. end;
  1482. function cuMemsetD16Shell(dstDevice: TCUdeviceptr; uw: Word; N: Cardinal)
  1483. : TCUresult;stdcall;
  1484. begin
  1485. Result := cuMemsetD16_(dstDevice, uw, N);
  1486. if Result <> CUDA_SUCCESS then
  1487. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1488. [cuMemsetD16Name, Get_CUDA_API_Error_String(Result)])
  1489. end;
  1490. function cuMemsetD32Shell(dstDevice: TCUdeviceptr; ui: Cardinal; N: Cardinal)
  1491. : TCUresult;stdcall;
  1492. begin
  1493. Result := cuMemsetD32_(dstDevice, ui, N);
  1494. if Result <> CUDA_SUCCESS then
  1495. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1496. [cuMemsetD32Name, Get_CUDA_API_Error_String(Result)])
  1497. end;
  1498. function cuMemsetD2D8Shell(dstDevice: TCUdeviceptr; dstPitch: Cardinal;
  1499. ub: Byte; Width: Cardinal; Height: Cardinal): TCUresult;stdcall;
  1500. begin
  1501. Result := cuMemsetD2D8_(dstDevice, dstPitch, ub, Width, Height);
  1502. if Result <> CUDA_SUCCESS then
  1503. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1504. [cuMemsetD2D8Name, Get_CUDA_API_Error_String(Result)])
  1505. end;
  1506. function cuMemsetD2D16Shell(dstDevice: TCUdeviceptr; dstPitch: Cardinal;
  1507. uw: Word; Width: Cardinal; Height: Cardinal): TCUresult;stdcall;
  1508. begin
  1509. Result := cuMemsetD2D16_(dstDevice, dstPitch, uw, Width, Height);
  1510. if Result <> CUDA_SUCCESS then
  1511. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1512. [cuMemsetD2D16Name, Get_CUDA_API_Error_String(Result)])
  1513. end;
  1514. function cuMemsetD2D32Shell(dstDevice: TCUdeviceptr; dstPitch: Cardinal;
  1515. ui: Cardinal; Width: Cardinal; Height: Cardinal): TCUresult;stdcall;
  1516. begin
  1517. Result := cuMemsetD2D32_(dstDevice, dstPitch, ui, Width, Height);
  1518. if Result <> CUDA_SUCCESS then
  1519. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1520. [cuMemsetD2D32Name, Get_CUDA_API_Error_String(Result)])
  1521. end;
  1522. function cuFuncSetBlockShapeShell(hfunc: PCUfunction; x: Integer; y: Integer;
  1523. z: Integer): TCUresult;stdcall;
  1524. begin
  1525. Result := cuFuncSetBlockShape_(hfunc, x, y, z);
  1526. if Result <> CUDA_SUCCESS then
  1527. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuFuncSetBlockShapeName,
  1528. Get_CUDA_API_Error_String(Result)])
  1529. end;
  1530. function cuFuncSetSharedSizeShell(hfunc: PCUfunction; bytes: Cardinal)
  1531. : TCUresult;
  1532. stdcall;
  1533. begin
  1534. Result := cuFuncSetSharedSize_(hfunc, bytes);
  1535. if Result <> CUDA_SUCCESS then
  1536. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuFuncSetSharedSizeName,
  1537. Get_CUDA_API_Error_String(Result)])
  1538. end;
  1539. function cuFuncGetAttributeShell(var pi: Integer; attrib: TCUfunction_attribute;
  1540. hfunc: PCUfunction): TCUresult;stdcall;
  1541. begin
  1542. Result := cuFuncGetAttribute_(pi, attrib, hfunc);
  1543. if Result <> CUDA_SUCCESS then
  1544. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuFuncGetAttributeName,
  1545. Get_CUDA_API_Error_String(Result)])
  1546. end;
  1547. function cuArrayCreateShell(var pHandle: PCUarray;
  1548. var pAllocateArray: TCUDA_ARRAY_DESCRIPTOR): TCUresult;stdcall;
  1549. begin
  1550. Result := cuArrayCreate_(pHandle, pAllocateArray);
  1551. if Result <> CUDA_SUCCESS then
  1552. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1553. [cuArrayCreateName, Get_CUDA_API_Error_String(Result)])
  1554. end;
  1555. function cuArrayGetDescriptorShell(var pArrayDescriptor: TCUDA_ARRAY_DESCRIPTOR;
  1556. hArray: PCUarray): TCUresult;stdcall;
  1557. begin
  1558. Result := cuArrayGetDescriptor_(pArrayDescriptor, hArray);
  1559. if Result <> CUDA_SUCCESS then
  1560. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuArrayGetDescriptorName,
  1561. Get_CUDA_API_Error_String(Result)])
  1562. end;
  1563. function cuArrayDestroyShell(hArray: PCUarray): TCUresult;stdcall;
  1564. begin
  1565. Result := cuArrayDestroy_(hArray);
  1566. if Result <> CUDA_SUCCESS then
  1567. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1568. [cuArrayDestroyName, Get_CUDA_API_Error_String(Result)])
  1569. end;
  1570. function cuArray3DCreateShell(var pHandle: PCUarray;
  1571. var pAllocateArray: TCUDA_ARRAY3D_DESCRIPTOR): TCUresult;stdcall;
  1572. begin
  1573. Result := cuArray3DCreate_(pHandle, pAllocateArray);
  1574. if Result <> CUDA_SUCCESS then
  1575. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuArray3DCreateName,
  1576. Get_CUDA_API_Error_String(Result)])
  1577. end;
  1578. function cuArray3DGetDescriptorShell(var pArrayDescriptor
  1579. : TCUDA_ARRAY3D_DESCRIPTOR; hArray: PCUarray): TCUresult;stdcall;
  1580. begin
  1581. Result := cuArray3DGetDescriptor_(pArrayDescriptor, hArray);
  1582. if Result <> CUDA_SUCCESS then
  1583. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuArray3DGetDescriptorName,
  1584. Get_CUDA_API_Error_String(Result)])
  1585. end;
  1586. function cuTexRefCreateShell(var pTexRef: PCUtexref): TCUresult;stdcall;
  1587. begin
  1588. Result := cuTexRefCreate_(pTexRef);
  1589. if Result <> CUDA_SUCCESS then
  1590. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1591. [cuTexRefCreateName, Get_CUDA_API_Error_String(Result)])
  1592. end;
  1593. function cuTexRefDestroyShell(hTexRef: PCUtexref): TCUresult;stdcall;
  1594. begin
  1595. Result := cuTexRefDestroy_(hTexRef);
  1596. if Result <> CUDA_SUCCESS then
  1597. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefDestroyName,
  1598. Get_CUDA_API_Error_String(Result)])
  1599. end;
  1600. function cuTexRefSetArrayShell(hTexRef: PCUtexref; hArray: PCUarray;
  1601. Flags: Cardinal): TCUresult;stdcall;
  1602. begin
  1603. Result := cuTexRefSetArray_(hTexRef, hArray, Flags);
  1604. if Result <> CUDA_SUCCESS then
  1605. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefSetArrayName,
  1606. Get_CUDA_API_Error_String(Result)])
  1607. end;
  1608. function cuTexRefSetAddressShell(var ByteOffset: Cardinal; hTexRef: PCUtexref;
  1609. dptr: TCUdeviceptr; bytes: Cardinal): TCUresult;stdcall;
  1610. begin
  1611. Result := cuTexRefSetAddress_(ByteOffset, hTexRef, dptr, bytes);
  1612. if Result <> CUDA_SUCCESS then
  1613. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefSetAddressName,
  1614. Get_CUDA_API_Error_String(Result)])
  1615. end;
  1616. function cuTexRefSetAddress2DShell(hTexRef: PCUtexref;
  1617. var desc: TCUDA_ARRAY_DESCRIPTOR; dptr: TCUdeviceptr; Pitch: Cardinal)
  1618. : TCUresult;
  1619. stdcall;
  1620. begin
  1621. Result := cuTexRefSetAddress2D_(hTexRef, desc, dptr, Pitch);
  1622. if Result <> CUDA_SUCCESS then
  1623. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefSetAddress2DName,
  1624. Get_CUDA_API_Error_String(Result)])
  1625. end;
  1626. function cuTexRefSetFormatShell(hTexRef: PCUtexref; fmt: TCUarray_format;
  1627. NumPackedComponents: Integer): TCUresult;stdcall;
  1628. begin
  1629. Result := cuTexRefSetFormat_(hTexRef, fmt, NumPackedComponents);
  1630. if Result <> CUDA_SUCCESS then
  1631. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefSetFormatName,
  1632. Get_CUDA_API_Error_String(Result)])
  1633. end;
  1634. function cuTexRefSetAddressModeShell(hTexRef: PCUtexref; dim: Integer;
  1635. am: TCUaddress_mode): TCUresult;stdcall;
  1636. begin
  1637. Result := cuTexRefSetAddressMode_(hTexRef, dim, am);
  1638. if Result <> CUDA_SUCCESS then
  1639. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefSetAddressModeName,
  1640. Get_CUDA_API_Error_String(Result)])
  1641. end;
  1642. function cuTexRefSetFilterModeShell(hTexRef: PCUtexref; fm: TCUfilter_mode)
  1643. : TCUresult;stdcall;
  1644. begin
  1645. Result := cuTexRefSetFilterMode_(hTexRef, fm);
  1646. if Result <> CUDA_SUCCESS then
  1647. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefSetFilterModeName,
  1648. Get_CUDA_API_Error_String(Result)])
  1649. end;
  1650. function cuTexRefSetFlagsShell(hTexRef: PCUtexref; Flags: Cardinal): TCUresult;stdcall;
  1651. begin
  1652. Result := cuTexRefSetFlags_(hTexRef, Flags);
  1653. if Result <> CUDA_SUCCESS then
  1654. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefSetFlagsName,
  1655. Get_CUDA_API_Error_String(Result)])
  1656. end;
  1657. function cuTexRefGetAddressShell(var pdptr: TCUdeviceptr; hTexRef: PCUtexref)
  1658. : TCUresult;stdcall;
  1659. begin
  1660. Result := cuTexRefGetAddress_(pdptr, hTexRef);
  1661. if Result <> CUDA_SUCCESS then
  1662. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefGetAddressName,
  1663. Get_CUDA_API_Error_String(Result)])
  1664. end;
  1665. function cuTexRefGetArrayShell(var phArray: PCUarray; hTexRef: PCUtexref)
  1666. : TCUresult;stdcall;
  1667. begin
  1668. Result := cuTexRefGetArray_(phArray, hTexRef);
  1669. if Result <> CUDA_SUCCESS then
  1670. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefGetArrayName,
  1671. Get_CUDA_API_Error_String(Result)])
  1672. end;
  1673. function cuTexRefGetAddressModeShell(var pam: TCUaddress_mode;
  1674. hTexRef: PCUtexref; dim: Integer): TCUresult;stdcall;
  1675. begin
  1676. Result := cuTexRefGetAddressMode_(pam, hTexRef, dim);
  1677. if Result <> CUDA_SUCCESS then
  1678. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefGetAddressModeName,
  1679. Get_CUDA_API_Error_String(Result)])
  1680. end;
  1681. function cuTexRefGetFilterModeShell(var pfm: TCUfilter_mode; hTexRef: PCUtexref)
  1682. : TCUresult;stdcall;
  1683. begin
  1684. Result := cuTexRefGetFilterMode_(pfm, hTexRef);
  1685. if Result <> CUDA_SUCCESS then
  1686. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefGetFilterModeName,
  1687. Get_CUDA_API_Error_String(Result)])
  1688. end;
  1689. function cuTexRefGetFormatShell(var pFormat: TCUarray_format;
  1690. var pNumChannels: Integer; hTexRef: PCUtexref): TCUresult;stdcall;
  1691. begin
  1692. Result := cuTexRefGetFormat_(pFormat, pNumChannels, hTexRef);
  1693. if Result <> CUDA_SUCCESS then
  1694. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefGetFormatName,
  1695. Get_CUDA_API_Error_String(Result)])
  1696. end;
  1697. function cuTexRefGetFlagsShell(var pFlags: Cardinal; hTexRef: PCUtexref)
  1698. : TCUresult;stdcall;
  1699. begin
  1700. Result := cuTexRefGetFlags_(pFlags, hTexRef);
  1701. if Result <> CUDA_SUCCESS then
  1702. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuTexRefGetFlagsName,
  1703. Get_CUDA_API_Error_String(Result)])
  1704. end;
  1705. function cuParamSetSizeShell(hfunc: PCUfunction; numbytes: Cardinal): TCUresult;stdcall;
  1706. begin
  1707. Result := cuParamSetSize_(hfunc, numbytes);
  1708. if Result <> CUDA_SUCCESS then
  1709. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1710. [cuParamSetSizeName, Get_CUDA_API_Error_String(Result)])
  1711. end;
  1712. function cuParamSetiShell(hfunc: PCUfunction; offset: Integer; value: Cardinal)
  1713. : TCUresult;stdcall;
  1714. begin
  1715. Result := cuParamSeti_(hfunc, offset, value);
  1716. if Result <> CUDA_SUCCESS then
  1717. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1718. [cuParamSetiName, Get_CUDA_API_Error_String(Result)])
  1719. end;
  1720. function cuParamSetfShell(hfunc: PCUfunction; offset: Integer; value: Single)
  1721. : TCUresult;stdcall;
  1722. begin
  1723. Result := cuParamSetf_(hfunc, offset, value);
  1724. if Result <> CUDA_SUCCESS then
  1725. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1726. [cuParamSetfName, Get_CUDA_API_Error_String(Result)])
  1727. end;
  1728. function cuParamSetvShell(hfunc: PCUfunction; offset: Integer; var ptr;
  1729. numbytes: Cardinal): TCUresult;stdcall;
  1730. begin
  1731. Result := cuParamSetv_(hfunc, offset, ptr, numbytes);
  1732. if Result <> CUDA_SUCCESS then
  1733. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1734. [cuParamSetvName, Get_CUDA_API_Error_String(Result)])
  1735. end;
  1736. function cuParamSetTexRefShell(hfunc: PCUfunction; texunit: Integer;
  1737. hTexRef: PCUtexref): TCUresult;stdcall;
  1738. begin
  1739. Result := cuParamSetTexRef_(hfunc, texunit, hTexRef);
  1740. if Result <> CUDA_SUCCESS then
  1741. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuParamSetTexRefName,
  1742. Get_CUDA_API_Error_String(Result)])
  1743. end;
  1744. function cuLaunchShell(f: PCUfunction): TCUresult;stdcall;
  1745. begin
  1746. Result := cuLaunch_(f);
  1747. if Result <> CUDA_SUCCESS then
  1748. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1749. [cuLaunchName, Get_CUDA_API_Error_String(Result)])
  1750. end;
  1751. function cuLaunchGridShell(f: PCUfunction; grid_width: Integer;
  1752. grid_height: Integer): TCUresult;stdcall;
  1753. begin
  1754. Result := cuLaunchGrid_(f, grid_width, grid_height);
  1755. if Result <> CUDA_SUCCESS then
  1756. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1757. [cuLaunchGridName, Get_CUDA_API_Error_String(Result)])
  1758. end;
  1759. function cuLaunchGridAsyncShell(f: PCUfunction; grid_width: Integer;
  1760. grid_height: Integer; hStream: PCUstream): TCUresult;stdcall;
  1761. begin
  1762. Result := cuLaunchGridAsync_(f, grid_width, grid_height, hStream);
  1763. if Result <> CUDA_SUCCESS then
  1764. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuLaunchGridAsyncName,
  1765. Get_CUDA_API_Error_String(Result)])
  1766. end;
  1767. function cuEventCreateShell(var phEvent: PCUevent; Flags: Cardinal): TCUresult;stdcall;
  1768. begin
  1769. Result := cuEventCreate_(phEvent, Flags);
  1770. if Result <> CUDA_SUCCESS then
  1771. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1772. [cuEventCreateName, Get_CUDA_API_Error_String(Result)])
  1773. end;
  1774. function cuEventRecordShell(hEvent: PCUevent; hStream: PCUstream): TCUresult;stdcall;
  1775. begin
  1776. Result := cuEventRecord_(hEvent, hStream);
  1777. if Result <> CUDA_SUCCESS then
  1778. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1779. [cuEventRecordName, Get_CUDA_API_Error_String(Result)])
  1780. end;
  1781. function cuEventQueryShell(hEvent: PCUevent): TCUresult;stdcall;
  1782. begin
  1783. Result := cuEventQuery_(hEvent);
  1784. if Result <> CUDA_SUCCESS then
  1785. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1786. [cuEventQueryName, Get_CUDA_API_Error_String(Result)])
  1787. end;
  1788. function cuEventSynchronizeShell(hEvent: PCUevent): TCUresult;stdcall;
  1789. begin
  1790. Result := cuEventSynchronize_(hEvent);
  1791. if Result <> CUDA_SUCCESS then
  1792. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuEventSynchronizeName,
  1793. Get_CUDA_API_Error_String(Result)])
  1794. end;
  1795. function cuEventDestroyShell(hEvent: PCUevent): TCUresult;stdcall;
  1796. begin
  1797. Result := cuEventDestroy_(hEvent);
  1798. if Result <> CUDA_SUCCESS then
  1799. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1800. [cuEventDestroyName, Get_CUDA_API_Error_String(Result)])
  1801. end;
  1802. function cuEventElapsedTimeShell(var pMilliseconds: Single; hStart: PCUevent;
  1803. hEnd: PCUevent): TCUresult;stdcall;
  1804. begin
  1805. Result := cuEventElapsedTime_(pMilliseconds, hStart, hEnd);
  1806. if Result <> CUDA_SUCCESS then
  1807. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuEventElapsedTimeName,
  1808. Get_CUDA_API_Error_String(Result)])
  1809. end;
  1810. function cuStreamCreateShell(var phStream: PCUstream; Flags: Cardinal)
  1811. : TCUresult;stdcall;
  1812. begin
  1813. Result := cuStreamCreate_(phStream, Flags);
  1814. if Result <> CUDA_SUCCESS then
  1815. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1816. [cuStreamCreateName, Get_CUDA_API_Error_String(Result)])
  1817. end;
  1818. function cuStreamQueryShell(hStream: PCUstream): TCUresult;stdcall;
  1819. begin
  1820. Result := cuStreamQuery_(hStream);
  1821. if Result <> CUDA_SUCCESS then
  1822. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1823. [cuStreamQueryName, Get_CUDA_API_Error_String(Result)])
  1824. end;
  1825. function cuStreamSynchronizeShell(hStream: PCUstream): TCUresult;stdcall;
  1826. begin
  1827. Result := cuStreamSynchronize_(hStream);
  1828. if Result <> CUDA_SUCCESS then
  1829. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuStreamSynchronizeName,
  1830. Get_CUDA_API_Error_String(Result)])
  1831. end;
  1832. function cuStreamDestroyShell(hStream: PCUstream): TCUresult;
  1833. stdcall;
  1834. begin
  1835. Result := cuStreamDestroy_(hStream);
  1836. if Result <> CUDA_SUCCESS then
  1837. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuStreamDestroyName,
  1838. Get_CUDA_API_Error_String(Result)])
  1839. end;
  1840. function cuGLCtxCreateShell(var pctx: PCUcontext; Flags: Cardinal;
  1841. device: TCUdevice): TCUresult;
  1842. stdcall;
  1843. begin
  1844. Result := cuGLCtxCreate_(pctx, Flags, device);
  1845. if Result <> CUDA_SUCCESS then
  1846. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1847. [cuGLCtxCreateName, Get_CUDA_API_Error_String(Result)])
  1848. end;
  1849. function cuGraphicsGLRegisterBufferShell(var pCudaResource: PCUgraphicsResource;
  1850. buffer: Cardinal; Flags: TCUgraphicsMapResourceFlags): TCUresult;
  1851. stdcall;
  1852. begin
  1853. Result := cuGraphicsGLRegisterBuffer_(pCudaResource, buffer, Flags);
  1854. if Result <> CUDA_SUCCESS then
  1855. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGraphicsGLRegisterBufferName,
  1856. Get_CUDA_API_Error_String(Result)])
  1857. end;
  1858. function cuGraphicsGLRegisterImageShell(var pCudaResource: PCUgraphicsResource;
  1859. image, target: Cardinal; Flags: TCUgraphicsMapResourceFlags): TCUresult;stdcall;
  1860. begin
  1861. Result := cuGraphicsGLRegisterImage_(pCudaResource, image, target, Flags);
  1862. if Result <> CUDA_SUCCESS then
  1863. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGraphicsGLRegisterImageName,
  1864. Get_CUDA_API_Error_String(Result)])
  1865. end;
  1866. function cuWGLGetDeviceShell(var pDevice: TCUdevice; hGpu: HGPUNV): TCUresult;stdcall;
  1867. begin
  1868. Result := cuWGLGetDevice_(pDevice, hGpu);
  1869. if Result <> CUDA_SUCCESS then
  1870. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1871. [cuWGLGetDeviceName, Get_CUDA_API_Error_String(Result)])
  1872. end;
  1873. function cuGraphicsUnregisterResourceShell(resource: PCUgraphicsResource)
  1874. : TCUresult;stdcall;
  1875. begin
  1876. Result := cuGraphicsUnregisterResource_(resource);
  1877. if Result <> CUDA_SUCCESS then
  1878. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGraphicsUnregisterResourceName,
  1879. Get_CUDA_API_Error_String(Result)])
  1880. end;
  1881. function cuGraphicsSubResourceGetMappedArrayShell(var pArray: PCUarray;
  1882. resource: PCUgraphicsResource; arrayIndex: Cardinal; mipLevel: Cardinal)
  1883. : TCUresult;stdcall;
  1884. begin
  1885. Result := cuGraphicsSubResourceGetMappedArray_(pArray, resource, arrayIndex,
  1886. mipLevel);
  1887. if Result <> CUDA_SUCCESS then
  1888. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1889. [cuGraphicsSubResourceGetMappedArrayName,
  1890. Get_CUDA_API_Error_String(Result)])
  1891. end;
  1892. function cuGraphicsResourceGetMappedPointerShell(var pDevPtr: TCUdeviceptr;
  1893. out psize: Cardinal; resource: PCUgraphicsResource): TCUresult;stdcall;
  1894. begin
  1895. Result := cuGraphicsResourceGetMappedPointer_(pDevPtr, psize, resource);
  1896. if Result <> CUDA_SUCCESS then
  1897. GLSLogger.LogErrorFmt(cudasFuncRetErr,
  1898. [cuGraphicsResourceGetMappedPointerName,
  1899. Get_CUDA_API_Error_String(Result)])
  1900. end;
  1901. function cuGraphicsResourceSetMapFlagsShell(resource: PCUgraphicsResource;
  1902. Flags: Cardinal): TCUresult;stdcall;
  1903. begin
  1904. Result := cuGraphicsResourceSetMapFlags_(resource, Flags);
  1905. if Result <> CUDA_SUCCESS then
  1906. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGraphicsResourceSetMapFlagsName,
  1907. Get_CUDA_API_Error_String(Result)])
  1908. end;
  1909. function cuGraphicsMapResourcesShell(count: Cardinal;
  1910. resources: PPCUgraphicsResource; hStream: PCUstream): TCUresult;stdcall;
  1911. begin
  1912. Result := cuGraphicsMapResources_(count, resources, hStream);
  1913. if Result <> CUDA_SUCCESS then
  1914. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGraphicsMapResourcesName,
  1915. Get_CUDA_API_Error_String(Result)])
  1916. end;
  1917. function cuGraphicsUnmapResourcesShell(count: Cardinal;
  1918. resources: PPCUgraphicsResource; hStream: PCUstream): TCUresult;stdcall;
  1919. begin
  1920. Result := cuGraphicsUnmapResources_(count, resources, hStream);
  1921. if Result <> CUDA_SUCCESS then
  1922. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGraphicsUnmapResourcesName,
  1923. Get_CUDA_API_Error_String(Result)])
  1924. end;
  1925. function cuGLRegisterBufferObjectShell(buffer: Cardinal): TCUresult;stdcall;
  1926. begin
  1927. Result := cuGLRegisterBufferObject_(buffer);
  1928. if Result <> CUDA_SUCCESS then
  1929. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGLRegisterBufferObjectName,
  1930. Get_CUDA_API_Error_String(Result)])
  1931. end;
  1932. function cuGLMapBufferObjectShell(var dptr: TCUdeviceptr; var size: Cardinal;
  1933. buffer: Cardinal): TCUresult;stdcall;
  1934. begin
  1935. Result := cuGLMapBufferObject_(dptr, size, buffer);
  1936. if Result <> CUDA_SUCCESS then
  1937. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGLMapBufferObjectName,
  1938. Get_CUDA_API_Error_String(Result)])
  1939. end;
  1940. function cuGLUnmapBufferObjectShell(buffer: Cardinal): TCUresult;stdcall;
  1941. begin
  1942. Result := cuGLUnmapBufferObject_(buffer);
  1943. if Result <> CUDA_SUCCESS then
  1944. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGLUnmapBufferObjectName,
  1945. Get_CUDA_API_Error_String(Result)])
  1946. end;
  1947. function cuGLUnregisterBufferObjectShell(buffer: Cardinal): TCUresult;stdcall;
  1948. begin
  1949. Result := cuGLUnregisterBufferObject_(buffer);
  1950. if Result <> CUDA_SUCCESS then
  1951. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGLUnregisterBufferObjectName,
  1952. Get_CUDA_API_Error_String(Result)])
  1953. end;
  1954. function cuGLSetBufferObjectMapFlagsShell(buffer: Cardinal; Flags: Cardinal)
  1955. : TCUresult;stdcall;
  1956. begin
  1957. Result := cuGLSetBufferObjectMapFlags_(buffer, Flags);
  1958. if Result <> CUDA_SUCCESS then
  1959. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGLSetBufferObjectMapFlagsName,
  1960. Get_CUDA_API_Error_String(Result)])
  1961. end;
  1962. function cuGLMapBufferObjectAsyncShell(var dptr: TCUdeviceptr;
  1963. var size: Cardinal; buffer: Cardinal; hStream: PCUstream): TCUresult;stdcall;
  1964. begin
  1965. Result := cuGLMapBufferObjectAsync_(dptr, size, buffer, hStream);
  1966. if Result <> CUDA_SUCCESS then
  1967. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGLMapBufferObjectAsyncName,
  1968. Get_CUDA_API_Error_String(Result)])
  1969. end;
  1970. function cuGLUnmapBufferObjectAsyncShell(buffer: Cardinal; hStream: PCUstream)
  1971. : TCUresult;stdcall;
  1972. begin
  1973. Result := cuGLUnmapBufferObjectAsync_(buffer, hStream);
  1974. if Result <> CUDA_SUCCESS then
  1975. GLSLogger.LogErrorFmt(cudasFuncRetErr, [cuGLUnmapBufferObjectAsyncName,
  1976. Get_CUDA_API_Error_String(Result)])
  1977. end;
  1978. {$ENDIF GLS_CUDA_DEBUG_MODE}
  1979. function GetProcAddressCUDA(ProcName: PAnsiChar): Pointer;
  1980. var
  1981. Alt: AnsiString;
  1982. begin
  1983. Alt := AnsiString(ProcName) + '_v2';
  1984. Result := GetProcAddress(Cardinal(CUDAHandle), PAnsiChar(Alt));
  1985. if Result = nil then
  1986. Result := GetProcAddress(Cardinal(CUDAHandle), ProcName);
  1987. end;
  1988. function InitCUDA: Boolean;
  1989. begin
  1990. if CUDAHandle = INVALID_MODULEHANDLE then
  1991. Result := InitCUDAFromLibrary(CUDAAPIDLL)
  1992. else
  1993. Result := True;
  1994. end;
  1995. procedure CloseCUDA;
  1996. begin
  1997. if CUDAHandle <> INVALID_MODULEHANDLE then
  1998. begin
  1999. FreeLibrary(Cardinal(CUDAHandle));
  2000. CUDAHandle := INVALID_MODULEHANDLE;
  2001. end;
  2002. end;
  2003. function InitCUDAFromLibrary(const LibName: WideString): Boolean;
  2004. var
  2005. V: Integer;
  2006. begin
  2007. Result := False;
  2008. CloseCUDA;
  2009. CUDAHandle := GetModuleHandleW(PWideChar(LibName));
  2010. if CUDAHandle = INVALID_MODULEHANDLE then
  2011. CUDAHandle := LoadLibraryW(PWideChar(LibName));
  2012. if CUDAHandle = INVALID_MODULEHANDLE then
  2013. Exit;
  2014. {$IFNDEF USE_CUDA_DEBUG_MODE}
  2015. cuInit := GetProcAddressCUDA(cuInitName);
  2016. cuDriverGetVersion := GetProcAddressCUDA(cuDriverGetVersionName);
  2017. cuDeviceGet := GetProcAddressCUDA(cuDeviceGet_Name);
  2018. cuDeviceGetCount := GetProcAddressCUDA(cuDeviceGetCountName);
  2019. cuDeviceGetName := GetProcAddressCUDA(cuDeviceGetNameName);
  2020. cuDeviceComputeCapability := GetProcAddressCUDA(cuDeviceComputeCapabilityName);
  2021. cuDeviceTotalMem := GetProcAddressCUDA(cuDeviceTotalMemName);
  2022. cuDeviceGetProperties := GetProcAddressCUDA(cuDeviceGetPropertiesName);
  2023. cuDeviceGetAttribute := GetProcAddressCUDA(cuDeviceGetAttributeName);
  2024. cuCtxCreate := GetProcAddressCUDA(cuCtxCreateName);
  2025. cuCtxDestroy := GetProcAddressCUDA(cuCtxDestroyName);
  2026. cuCtxAttach := GetProcAddressCUDA(cuCtxAttachName);
  2027. cuCtxDetach := GetProcAddressCUDA(cuCtxDetachName);
  2028. cuCtxPushCurrent := GetProcAddressCUDA(cuCtxPushCurrentName);
  2029. cuCtxPopCurrent := GetProcAddressCUDA(cuCtxPopCurrentName);
  2030. cuCtxGetDevice := GetProcAddressCUDA(cuCtxGetDeviceName);
  2031. cuCtxSynchronize := GetProcAddressCUDA(cuCtxSynchronizeName);
  2032. cuModuleLoad := GetProcAddressCUDA(cuModuleLoadName);
  2033. cuModuleLoadData := GetProcAddressCUDA(cuModuleLoadDataName);
  2034. cuModuleLoadDataEx := GetProcAddressCUDA(cuModuleLoadDataExName);
  2035. cuModuleLoadFatBinary := GetProcAddressCUDA(cuModuleLoadFatBinaryName);
  2036. cuModuleUnload := GetProcAddressCUDA(cuModuleUnloadName);
  2037. cuModuleGetFunction := GetProcAddressCUDA(cuModuleGetFunctionName);
  2038. cuModuleGetGlobal := GetProcAddressCUDA(cuModuleGetGlobalName);
  2039. cuModuleGetTexRef := GetProcAddressCUDA(cuModuleGetTexRefName);
  2040. cuMemGetInfo := GetProcAddressCUDA(cuMemGetInfoName);
  2041. cuMemAlloc := GetProcAddressCUDA(cuMemAllocName);
  2042. cuMemAllocPitch := GetProcAddressCUDA(cuMemAllocPitchName);
  2043. cuMemFree := GetProcAddressCUDA(cuMemFreeName);
  2044. cuMemGetAddressRange := GetProcAddressCUDA(cuMemGetAddressRangeName);
  2045. cuMemAllocHost := GetProcAddressCUDA(cuMemAllocHostName);
  2046. cuMemFreeHost := GetProcAddressCUDA(cuMemFreeHostName);
  2047. cuMemHostAlloc := GetProcAddressCUDA(cuMemHostAllocName);
  2048. cuMemHostGetDevicePointer := GetProcAddressCUDA(cuMemHostGetDevicePointerName);
  2049. cuMemHostGetFlags := GetProcAddressCUDA(cuMemHostGetFlagsName);
  2050. cuMemcpyHtoD := GetProcAddressCUDA(cuMemcpyHtoDName);
  2051. cuMemcpyDtoH := GetProcAddressCUDA(cuMemcpyDtoHName);
  2052. cuMemcpyDtoD := GetProcAddressCUDA(cuMemcpyDtoDName);
  2053. cuMemcpyDtoDAsync := GetProcAddressCUDA(cuMemcpyDtoDAsyncName);
  2054. cuMemcpyDtoA := GetProcAddressCUDA(cuMemcpyDtoAName);
  2055. cuMemcpyAtoD := GetProcAddressCUDA(cuMemcpyAtoDName);
  2056. cuMemcpyHtoA := GetProcAddressCUDA(cuMemcpyHtoAName);
  2057. cuMemcpyAtoH := GetProcAddressCUDA(cuMemcpyAtoHName);
  2058. cuMemcpyAtoA := GetProcAddressCUDA(cuMemcpyAtoAName);
  2059. cuMemcpy2D := GetProcAddressCUDA(cuMemcpy2DName);
  2060. cuMemcpy2DUnaligned := GetProcAddressCUDA(cuMemcpy2DUnalignedName);
  2061. cuMemcpy3D := GetProcAddressCUDA(cuMemcpy3DName);
  2062. cuMemcpyHtoDAsync := GetProcAddressCUDA(cuMemcpyHtoDAsyncName);
  2063. cuMemcpyDtoHAsync := GetProcAddressCUDA(cuMemcpyDtoHAsyncName);
  2064. cuMemcpyHtoAAsync := GetProcAddressCUDA(cuMemcpyHtoAAsyncName);
  2065. cuMemcpyAtoHAsync := GetProcAddressCUDA(cuMemcpyAtoHAsyncName);
  2066. cuMemcpy2DAsync := GetProcAddressCUDA(cuMemcpy2DAsyncName);
  2067. cuMemcpy3DAsync := GetProcAddressCUDA(cuMemcpy3DAsyncName);
  2068. cuMemsetD8 := GetProcAddressCUDA(cuMemsetD8Name);
  2069. cuMemsetD16 := GetProcAddressCUDA(cuMemsetD16Name);
  2070. cuMemsetD32 := GetProcAddressCUDA(cuMemsetD32Name);
  2071. cuMemsetD2D8 := GetProcAddressCUDA(cuMemsetD2D8Name);
  2072. cuMemsetD2D16 := GetProcAddressCUDA(cuMemsetD2D16Name);
  2073. cuMemsetD2D32 := GetProcAddressCUDA(cuMemsetD2D32Name);
  2074. cuFuncSetBlockShape := GetProcAddressCUDA(cuFuncSetBlockShapeName);
  2075. cuFuncSetSharedSize := GetProcAddressCUDA(cuFuncSetSharedSizeName);
  2076. cuFuncGetAttribute := GetProcAddressCUDA(cuFuncGetAttributeName);
  2077. cuArrayCreate := GetProcAddressCUDA(cuArrayCreateName);
  2078. cuArrayGetDescriptor := GetProcAddressCUDA(cuArrayGetDescriptorName);
  2079. cuArrayDestroy := GetProcAddressCUDA(cuArrayDestroyName);
  2080. cuArray3DCreate := GetProcAddressCUDA(cuArray3DCreateName);
  2081. cuArray3DGetDescriptor := GetProcAddressCUDA(cuArray3DGetDescriptorName);
  2082. cuTexRefCreate := GetProcAddressCUDA(cuTexRefCreateName);
  2083. cuTexRefDestroy := GetProcAddressCUDA(cuTexRefDestroyName);
  2084. cuTexRefSetArray := GetProcAddressCUDA(cuTexRefSetArrayName);
  2085. cuTexRefSetAddress := GetProcAddressCUDA(cuTexRefSetAddressName);
  2086. cuTexRefSetAddress2D := GetProcAddressCUDA(cuTexRefSetAddress2DName);
  2087. cuTexRefSetFormat := GetProcAddressCUDA(cuTexRefSetFormatName);
  2088. cuTexRefSetAddressMode := GetProcAddressCUDA(cuTexRefSetAddressModeName);
  2089. cuTexRefSetFilterMode := GetProcAddressCUDA(cuTexRefSetFilterModeName);
  2090. cuTexRefSetFlags := GetProcAddressCUDA(cuTexRefSetFlagsName);
  2091. cuTexRefGetAddress := GetProcAddressCUDA(cuTexRefGetAddressName);
  2092. cuTexRefGetArray := GetProcAddressCUDA(cuTexRefGetArrayName);
  2093. cuTexRefGetAddressMode := GetProcAddressCUDA(cuTexRefGetAddressModeName);
  2094. cuTexRefGetFilterMode := GetProcAddressCUDA(cuTexRefGetFilterModeName);
  2095. cuTexRefGetFormat := GetProcAddressCUDA(cuTexRefGetFormatName);
  2096. cuTexRefGetFlags := GetProcAddressCUDA(cuTexRefGetFlagsName);
  2097. cuParamSetSize := GetProcAddressCUDA(cuParamSetSizeName);
  2098. cuParamSeti := GetProcAddressCUDA(cuParamSetiName);
  2099. cuParamSetf := GetProcAddressCUDA(cuParamSetfName);
  2100. cuParamSetv := GetProcAddressCUDA(cuParamSetvName);
  2101. cuParamSetTexRef := GetProcAddressCUDA(cuParamSetTexRefName);
  2102. cuLaunch := GetProcAddressCUDA(cuLaunchName);
  2103. cuLaunchGrid := GetProcAddressCUDA(cuLaunchGridName);
  2104. cuLaunchGridAsync := GetProcAddressCUDA(cuLaunchGridAsyncName);
  2105. cuEventCreate := GetProcAddressCUDA(cuEventCreateName);
  2106. cuEventRecord := GetProcAddressCUDA(cuEventRecordName);
  2107. cuEventQuery := GetProcAddressCUDA(cuEventQueryName);
  2108. cuEventSynchronize := GetProcAddressCUDA(cuEventSynchronizeName);
  2109. cuEventDestroy := GetProcAddressCUDA(cuEventDestroyName);
  2110. cuEventElapsedTime := GetProcAddressCUDA(cuEventElapsedTimeName);
  2111. cuStreamCreate := GetProcAddressCUDA(cuStreamCreateName);
  2112. cuStreamQuery := GetProcAddressCUDA(cuStreamQueryName);
  2113. cuStreamSynchronize := GetProcAddressCUDA(cuStreamSynchronizeName);
  2114. cuStreamDestroy := GetProcAddressCUDA(cuStreamDestroyName);
  2115. cuGLCtxCreate := GetProcAddressCUDA(cuGLCtxCreateName);
  2116. cuGraphicsGLRegisterBuffer := GetProcAddressCUDA(cuGraphicsGLRegisterBufferName);
  2117. cuGraphicsGLRegisterImage := GetProcAddressCUDA(cuGraphicsGLRegisterImageName);
  2118. cuWGLGetDevice := GetProcAddressCUDA(cuWGLGetDeviceName);
  2119. cuGraphicsUnregisterResource := GetProcAddressCUDA(cuGraphicsUnregisterResourceName);
  2120. cuGraphicsSubResourceGetMappedArray := GetProcAddressCUDA(cuGraphicsSubResourceGetMappedArrayName);
  2121. cuGraphicsResourceGetMappedPointer := GetProcAddressCUDA(cuGraphicsResourceGetMappedPointerName);
  2122. cuGraphicsResourceSetMapFlags := GetProcAddressCUDA(cuGraphicsResourceSetMapFlagsName);
  2123. cuGraphicsMapResources := GetProcAddressCUDA(cuGraphicsMapResourcesName);
  2124. cuGraphicsUnmapResources := GetProcAddressCUDA(cuGraphicsUnmapResourcesName);
  2125. cuGLInit := GetProcAddressCUDA(cuGLInitName);
  2126. cuGLRegisterBufferObject := GetProcAddressCUDA(cuGLRegisterBufferObjectName);
  2127. cuGLMapBufferObject := GetProcAddressCUDA(cuGLMapBufferObjectName);
  2128. cuGLUnmapBufferObject := GetProcAddressCUDA(cuGLUnmapBufferObjectName);
  2129. cuGLUnregisterBufferObject := GetProcAddressCUDA(cuGLUnregisterBufferObjectName);
  2130. cuGLSetBufferObjectMapFlags := GetProcAddressCUDA(cuGLSetBufferObjectMapFlagsName);
  2131. cuGLMapBufferObjectAsync := GetProcAddressCUDA(cuGLMapBufferObjectAsyncName);
  2132. cuGLUnmapBufferObjectAsync := GetProcAddressCUDA(cuGLUnmapBufferObjectAsyncName);
  2133. {$ELSE}
  2134. cuInit_ := GetProcAddressCUDA(cuInitName);
  2135. cuInit := cuInitShell;
  2136. cuDriverGetVersion_ := GetProcAddressCUDA(cuDriverGetVersionName);
  2137. cuDriverGetVersion := cuDriverGetVersionShell;
  2138. cuDeviceGet_ := GetProcAddressCUDA(cuDeviceGet_Name);
  2139. cuDeviceGet := cuDeviceGetShell;
  2140. cuDeviceGetCount_ := GetProcAddressCUDA(cuDeviceGetCountName);
  2141. cuDeviceGetCount := cuDeviceGetCountShell;
  2142. cuDeviceGetName_ := GetProcAddressCUDA(cuDeviceGetNameName);
  2143. cuDeviceGetName := cuDeviceGetNameShell;
  2144. cuDeviceComputeCapability_ := GetProcAddressCUDA(cuDeviceComputeCapabilityName);
  2145. cuDeviceComputeCapability := cuDeviceComputeCapabilityShell;
  2146. cuDeviceTotalMem_ := GetProcAddressCUDA(cuDeviceTotalMemName);
  2147. cuDeviceTotalMem := cuDeviceTotalMemShell;
  2148. cuDeviceGetProperties_ := GetProcAddressCUDA(cuDeviceGetPropertiesName);
  2149. cuDeviceGetProperties := cuDeviceGetPropertiesShell;
  2150. cuDeviceGetAttribute_ := GetProcAddressCUDA(cuDeviceGetAttributeName);
  2151. cuDeviceGetAttribute := cuDeviceGetAttributeShell;
  2152. cuCtxCreate_ := GetProcAddressCUDA(cuCtxCreateName);
  2153. cuCtxCreate := cuCtxCreateShell;
  2154. cuCtxDestroy_ := GetProcAddressCUDA(cuCtxDestroyName);
  2155. cuCtxDestroy := cuCtxDestroyShell;
  2156. cuCtxAttach_ := GetProcAddressCUDA(cuCtxAttachName);
  2157. cuCtxAttach := cuCtxAttachShell;
  2158. cuCtxDetach_ := GetProcAddressCUDA(cuCtxDetachName);
  2159. cuCtxDetach := cuCtxDetachShell;
  2160. cuCtxPushCurrent_ := GetProcAddressCUDA(cuCtxPushCurrentName);
  2161. cuCtxPushCurrent := cuCtxPushCurrentShell;
  2162. cuCtxPopCurrent_ := GetProcAddressCUDA(cuCtxPopCurrentName);
  2163. cuCtxPopCurrent := cuCtxPopCurrentShell;
  2164. cuCtxGetDevice_ := GetProcAddressCUDA(cuCtxGetDeviceName);
  2165. cuCtxGetDevice := cuCtxGetDeviceShell;
  2166. cuCtxSynchronize_ := GetProcAddressCUDA(cuCtxSynchronizeName);
  2167. cuCtxSynchronize := cuCtxSynchronizeShell;
  2168. cuModuleLoad_ := GetProcAddressCUDA(cuModuleLoadName);
  2169. cuModuleLoad := cuModuleLoadShell;
  2170. cuModuleLoadData_ := GetProcAddressCUDA(cuModuleLoadDataName);
  2171. cuModuleLoadData := cuModuleLoadDataShell;
  2172. cuModuleLoadDataEx_ := GetProcAddressCUDA(cuModuleLoadDataExName);
  2173. cuModuleLoadDataEx := cuModuleLoadDataExShell;
  2174. cuModuleLoadFatBinary_ := GetProcAddressCUDA(cuModuleLoadFatBinaryName);
  2175. cuModuleLoadFatBinary := cuModuleLoadFatBinaryShell;
  2176. cuModuleUnload_ := GetProcAddressCUDA(cuModuleUnloadName);
  2177. cuModuleUnload := cuModuleUnloadShell;
  2178. cuModuleGetFunction_ := GetProcAddressCUDA(cuModuleGetFunctionName);
  2179. cuModuleGetFunction := cuModuleGetFunctionShell;
  2180. cuModuleGetGlobal_ := GetProcAddressCUDA(cuModuleGetGlobalName);
  2181. cuModuleGetGlobal := cuModuleGetGlobalShell;
  2182. cuModuleGetTexRef_ := GetProcAddressCUDA(cuModuleGetTexRefName);
  2183. cuModuleGetTexRef := cuModuleGetTexRefShell;
  2184. cuMemGetInfo_ := GetProcAddressCUDA(cuMemGetInfoName);
  2185. cuMemGetInfo := cuMemGetInfoShell;
  2186. cuMemAlloc_ := GetProcAddressCUDA(cuMemAllocName);
  2187. cuMemAlloc := cuMemAllocShell;
  2188. cuMemAllocPitch_ := GetProcAddressCUDA(cuMemAllocPitchName);
  2189. cuMemAllocPitch := cuMemAllocPitchShell;
  2190. cuMemFree_ := GetProcAddressCUDA(cuMemFreeName);
  2191. cuMemFree := cuMemFreeShell;
  2192. cuMemGetAddressRange_ := GetProcAddressCUDA(cuMemGetAddressRangeName);
  2193. cuMemGetAddressRange := cuMemGetAddressRangeShell;
  2194. cuMemAllocHost_ := GetProcAddressCUDA(cuMemAllocHostName);
  2195. cuMemAllocHost := cuMemAllocHostShell;
  2196. cuMemFreeHost_ := GetProcAddressCUDA(cuMemFreeHostName);
  2197. cuMemFreeHost := cuMemFreeHostShell;
  2198. cuMemHostAlloc_ := GetProcAddressCUDA(cuMemHostAllocName);
  2199. cuMemHostAlloc := cuMemHostAllocShell;
  2200. cuMemHostGetDevicePointer_ := GetProcAddressCUDA(cuMemHostGetDevicePointerName);
  2201. cuMemHostGetDevicePointer := cuMemHostGetDevicePointerShell;
  2202. cuMemHostGetFlags_ := GetProcAddressCUDA(cuMemHostGetFlagsName);
  2203. cuMemHostGetFlags := cuMemHostGetFlagsShell;
  2204. cuMemcpyHtoD_ := GetProcAddressCUDA(cuMemcpyHtoDName);
  2205. cuMemcpyHtoD := cuMemcpyHtoDShell;
  2206. cuMemcpyDtoH_ := GetProcAddressCUDA(cuMemcpyDtoHName);
  2207. cuMemcpyDtoH := cuMemcpyDtoHShell;
  2208. cuMemcpyDtoD_ := GetProcAddressCUDA(cuMemcpyDtoDName);
  2209. cuMemcpyDtoD := cuMemcpyDtoDShell;
  2210. cuMemcpyDtoDAsync_ := GetProcAddressCUDA(cuMemcpyDtoDAsyncName);
  2211. cuMemcpyDtoDAsync := cuMemcpyDtoDAsyncShell;
  2212. cuMemcpyDtoA_ := GetProcAddressCUDA(cuMemcpyDtoAName);
  2213. cuMemcpyDtoA := cuMemcpyDtoAShell;
  2214. cuMemcpyAtoD_ := GetProcAddressCUDA(cuMemcpyAtoDName);
  2215. cuMemcpyAtoD := cuMemcpyAtoDShell;
  2216. cuMemcpyHtoA_ := GetProcAddressCUDA(cuMemcpyHtoAName);
  2217. cuMemcpyHtoA := cuMemcpyHtoAShell;
  2218. cuMemcpyAtoH_ := GetProcAddressCUDA(cuMemcpyAtoHName);
  2219. cuMemcpyAtoH := cuMemcpyAtoHShell;
  2220. cuMemcpyAtoA_ := GetProcAddressCUDA(cuMemcpyAtoAName);
  2221. cuMemcpyAtoA := cuMemcpyAtoAShell;
  2222. cuMemcpy2D_ := GetProcAddressCUDA(cuMemcpy2DName);
  2223. cuMemcpy2D := cuMemcpy2DShell;
  2224. cuMemcpy2DUnaligned_ := GetProcAddressCUDA(cuMemcpy2DUnalignedName);
  2225. cuMemcpy2DUnaligned := cuMemcpy2DUnalignedShell;
  2226. cuMemcpy3D_ := GetProcAddressCUDA(cuMemcpy3DName);
  2227. cuMemcpy3D := cuMemcpy3DShell;
  2228. cuMemcpyHtoDAsync_ := GetProcAddressCUDA(cuMemcpyHtoDAsyncName);
  2229. cuMemcpyHtoDAsync := cuMemcpyHtoDAsyncShell;
  2230. cuMemcpyDtoHAsync_ := GetProcAddressCUDA(cuMemcpyDtoHAsyncName);
  2231. cuMemcpyDtoHAsync := cuMemcpyDtoHAsyncShell;
  2232. cuMemcpyHtoAAsync_ := GetProcAddressCUDA(cuMemcpyHtoAAsyncName);
  2233. cuMemcpyHtoAAsync := cuMemcpyHtoAAsyncShell;
  2234. cuMemcpyAtoHAsync_ := GetProcAddressCUDA(cuMemcpyAtoHAsyncName);
  2235. cuMemcpyAtoHAsync := cuMemcpyAtoHAsyncShell;
  2236. cuMemcpy2DAsync_ := GetProcAddressCUDA(cuMemcpy2DAsyncName);
  2237. cuMemcpy2DAsync := cuMemcpy2DAsyncShell;
  2238. cuMemcpy3DAsync_ := GetProcAddressCUDA(cuMemcpy3DAsyncName);
  2239. cuMemcpy3DAsync := cuMemcpy3DAsyncShell;
  2240. cuMemsetD8_ := GetProcAddressCUDA(cuMemsetD8Name);
  2241. cuMemsetD8 := cuMemsetD8Shell;
  2242. cuMemsetD16_ := GetProcAddressCUDA(cuMemsetD16Name);
  2243. cuMemsetD16 := cuMemsetD16Shell;
  2244. cuMemsetD32_ := GetProcAddressCUDA(cuMemsetD32Name);
  2245. cuMemsetD32 := cuMemsetD32Shell;
  2246. cuMemsetD2D8_ := GetProcAddressCUDA(cuMemsetD2D8Name);
  2247. cuMemsetD2D8 := cuMemsetD2D8Shell;
  2248. cuMemsetD2D16_ := GetProcAddressCUDA(cuMemsetD2D16Name);
  2249. cuMemsetD2D16 := cuMemsetD2D16Shell;
  2250. cuMemsetD2D32_ := GetProcAddressCUDA(cuMemsetD2D32Name);
  2251. cuMemsetD2D32 := cuMemsetD2D32Shell;
  2252. cuFuncSetBlockShape_ := GetProcAddressCUDA(cuFuncSetBlockShapeName);
  2253. cuFuncSetBlockShape := cuFuncSetBlockShapeShell;
  2254. cuFuncSetSharedSize_ := GetProcAddressCUDA(cuFuncSetSharedSizeName);
  2255. cuFuncSetSharedSize := cuFuncSetSharedSizeShell;
  2256. cuFuncGetAttribute_ := GetProcAddressCUDA(cuFuncGetAttributeName);
  2257. cuFuncGetAttribute := cuFuncGetAttributeShell;
  2258. cuArrayCreate_ := GetProcAddressCUDA(cuArrayCreateName);
  2259. cuArrayCreate := cuArrayCreateShell;
  2260. cuArrayGetDescriptor_ := GetProcAddressCUDA(cuArrayGetDescriptorName);
  2261. cuArrayGetDescriptor := cuArrayGetDescriptorShell;
  2262. cuArrayDestroy_ := GetProcAddressCUDA(cuArrayDestroyName);
  2263. cuArrayDestroy := cuArrayDestroyShell;
  2264. cuArray3DCreate_ := GetProcAddressCUDA(cuArray3DCreateName);
  2265. cuArray3DCreate := cuArray3DCreateShell;
  2266. cuArray3DGetDescriptor_ := GetProcAddressCUDA(cuArray3DGetDescriptorName);
  2267. cuArray3DGetDescriptor := cuArray3DGetDescriptorShell;
  2268. cuTexRefCreate_ := GetProcAddressCUDA(cuTexRefCreateName);
  2269. cuTexRefCreate := cuTexRefCreateShell;
  2270. cuTexRefDestroy_ := GetProcAddressCUDA(cuTexRefDestroyName);
  2271. cuTexRefDestroy := cuTexRefDestroyShell;
  2272. cuTexRefSetArray_ := GetProcAddressCUDA(cuTexRefSetArrayName);
  2273. cuTexRefSetArray := cuTexRefSetArrayShell;
  2274. cuTexRefSetAddress_ := GetProcAddressCUDA(cuTexRefSetAddressName);
  2275. cuTexRefSetAddress := cuTexRefSetAddressShell;
  2276. cuTexRefSetAddress2D_ := GetProcAddressCUDA(cuTexRefSetAddress2DName);
  2277. cuTexRefSetAddress2D := cuTexRefSetAddress2DShell;
  2278. cuTexRefSetFormat_ := GetProcAddressCUDA(cuTexRefSetFormatName);
  2279. cuTexRefSetFormat := cuTexRefSetFormatShell;
  2280. cuTexRefSetAddressMode_ := GetProcAddressCUDA(cuTexRefSetAddressModeName);
  2281. cuTexRefSetAddressMode := cuTexRefSetAddressModeShell;
  2282. cuTexRefSetFilterMode_ := GetProcAddressCUDA(cuTexRefSetFilterModeName);
  2283. cuTexRefSetFilterMode := cuTexRefSetFilterModeShell;
  2284. cuTexRefSetFlags_ := GetProcAddressCUDA(cuTexRefSetFlagsName);
  2285. cuTexRefSetFlags := cuTexRefSetFlagsShell;
  2286. cuTexRefGetAddress_ := GetProcAddressCUDA(cuTexRefGetAddressName);
  2287. cuTexRefGetAddress := cuTexRefGetAddressShell;
  2288. cuTexRefGetArray_ := GetProcAddressCUDA(cuTexRefGetArrayName);
  2289. cuTexRefGetArray := cuTexRefGetArrayShell;
  2290. cuTexRefGetAddressMode_ := GetProcAddressCUDA(cuTexRefGetAddressModeName);
  2291. cuTexRefGetAddressMode := cuTexRefGetAddressModeShell;
  2292. cuTexRefGetFilterMode_ := GetProcAddressCUDA(cuTexRefGetFilterModeName);
  2293. cuTexRefGetFilterMode := cuTexRefGetFilterModeShell;
  2294. cuTexRefGetFormat_ := GetProcAddressCUDA(cuTexRefGetFormatName);
  2295. cuTexRefGetFormat := cuTexRefGetFormatShell;
  2296. cuTexRefGetFlags_ := GetProcAddressCUDA(cuTexRefGetFlagsName);
  2297. cuTexRefGetFlags := cuTexRefGetFlagsShell;
  2298. cuParamSetSize_ := GetProcAddressCUDA(cuParamSetSizeName);
  2299. cuParamSetSize := cuParamSetSizeShell;
  2300. cuParamSeti_ := GetProcAddressCUDA(cuParamSetiName);
  2301. cuParamSeti := cuParamSetiShell;
  2302. cuParamSetf_ := GetProcAddressCUDA(cuParamSetfName);
  2303. cuParamSetf := cuParamSetfShell;
  2304. cuParamSetv_ := GetProcAddressCUDA(cuParamSetvName);
  2305. cuParamSetv := cuParamSetvShell;
  2306. cuParamSetTexRef_ := GetProcAddressCUDA(cuParamSetTexRefName);
  2307. cuParamSetTexRef := cuParamSetTexRefShell;
  2308. cuLaunch_ := GetProcAddressCUDA(cuLaunchName);
  2309. cuLaunch := cuLaunchShell;
  2310. cuLaunchGrid_ := GetProcAddressCUDA(cuLaunchGridName);
  2311. cuLaunchGrid := cuLaunchGridShell;
  2312. cuLaunchGridAsync_ := GetProcAddressCUDA(cuLaunchGridAsyncName);
  2313. cuLaunchGridAsync := cuLaunchGridAsyncShell;
  2314. cuEventCreate_ := GetProcAddressCUDA(cuEventCreateName);
  2315. cuEventCreate := cuEventCreateShell;
  2316. cuEventRecord_ := GetProcAddressCUDA(cuEventRecordName);
  2317. cuEventRecord := cuEventRecordShell;
  2318. cuEventQuery_ := GetProcAddressCUDA(cuEventQueryName);
  2319. cuEventQuery := cuEventQueryShell;
  2320. cuEventSynchronize_ := GetProcAddressCUDA(cuEventSynchronizeName);
  2321. cuEventSynchronize := cuEventSynchronizeShell;
  2322. cuEventDestroy_ := GetProcAddressCUDA(cuEventDestroyName);
  2323. cuEventDestroy := cuEventDestroyShell;
  2324. cuEventElapsedTime_ := GetProcAddressCUDA(cuEventElapsedTimeName);
  2325. cuEventElapsedTime := cuEventElapsedTimeShell;
  2326. cuStreamCreate_ := GetProcAddressCUDA(cuStreamCreateName);
  2327. cuStreamCreate := cuStreamCreateShell;
  2328. cuStreamQuery_ := GetProcAddressCUDA(cuStreamQueryName);
  2329. cuStreamQuery := cuStreamQueryShell;
  2330. cuStreamSynchronize_ := GetProcAddressCUDA(cuStreamSynchronizeName);
  2331. cuStreamSynchronize := cuStreamSynchronizeShell;
  2332. cuStreamDestroy_ := GetProcAddressCUDA(cuStreamDestroyName);
  2333. cuStreamDestroy := cuStreamDestroyShell;
  2334. cuGLCtxCreate_ := GetProcAddressCUDA(cuGLCtxCreateName);
  2335. cuGLCtxCreate := cuGLCtxCreateShell;
  2336. cuGraphicsGLRegisterBuffer_ := GetProcAddressCUDA(cuGraphicsGLRegisterBufferName);
  2337. cuGraphicsGLRegisterBuffer := cuGraphicsGLRegisterBufferShell;
  2338. cuGraphicsGLRegisterImage_ := GetProcAddressCUDA(cuGraphicsGLRegisterImageName);
  2339. cuGraphicsGLRegisterImage := cuGraphicsGLRegisterImageShell;
  2340. cuWGLGetDevice_ := GetProcAddressCUDA(cuWGLGetDeviceName);
  2341. cuWGLGetDevice := cuWGLGetDeviceShell;
  2342. cuGraphicsUnregisterResource_ := GetProcAddressCUDA(cuGraphicsUnregisterResourceName);
  2343. cuGraphicsUnregisterResource := cuGraphicsUnregisterResourceShell;
  2344. cuGraphicsSubResourceGetMappedArray_ := GetProcAddressCUDA(cuGraphicsSubResourceGetMappedArrayName);
  2345. cuGraphicsSubResourceGetMappedArray := cuGraphicsSubResourceGetMappedArrayShell;
  2346. cuGraphicsResourceGetMappedPointer_ := GetProcAddressCUDA(cuGraphicsResourceGetMappedPointerName);
  2347. cuGraphicsResourceGetMappedPointer := cuGraphicsResourceGetMappedPointerShell;
  2348. cuGraphicsResourceSetMapFlags_ := GetProcAddressCUDA(cuGraphicsResourceSetMapFlagsName);
  2349. cuGraphicsResourceSetMapFlags := cuGraphicsResourceSetMapFlagsShell;
  2350. cuGraphicsMapResources_ := GetProcAddressCUDA(cuGraphicsMapResourcesName);
  2351. cuGraphicsMapResources := cuGraphicsMapResourcesShell;
  2352. cuGraphicsUnmapResources_ := GetProcAddressCUDA(cuGraphicsUnmapResourcesName);
  2353. cuGraphicsUnmapResources := cuGraphicsUnmapResourcesShell;
  2354. cuGLInit := GetProcAddressCUDA(cuGLInitName);
  2355. cuGLRegisterBufferObject_ := GetProcAddressCUDA(cuGLRegisterBufferObjectName);
  2356. cuGLRegisterBufferObject := cuGLRegisterBufferObjectShell;
  2357. cuGLMapBufferObject_ := GetProcAddressCUDA(cuGLMapBufferObjectName);
  2358. cuGLMapBufferObject := cuGLMapBufferObjectShell;
  2359. cuGLUnmapBufferObject_ := GetProcAddressCUDA(cuGLUnmapBufferObjectName);
  2360. cuGLUnmapBufferObject := cuGLUnmapBufferObjectShell;
  2361. cuGLUnregisterBufferObject_ := GetProcAddressCUDA(cuGLUnregisterBufferObjectName);
  2362. cuGLUnregisterBufferObject := cuGLUnregisterBufferObjectShell;
  2363. cuGLSetBufferObjectMapFlags_ := GetProcAddressCUDA(cuGLSetBufferObjectMapFlagsName);
  2364. cuGLSetBufferObjectMapFlags := cuGLSetBufferObjectMapFlagsShell;
  2365. cuGLMapBufferObjectAsync_ := GetProcAddressCUDA(cuGLMapBufferObjectAsyncName);
  2366. cuGLMapBufferObjectAsync := cuGLMapBufferObjectAsyncShell;
  2367. cuGLUnmapBufferObjectAsync_ := GetProcAddressCUDA(cuGLUnmapBufferObjectAsyncName);
  2368. cuGLUnmapBufferObjectAsync := cuGLUnmapBufferObjectAsyncShell;
  2369. {$ENDIF GLS_CUDA_DEBUG_MODE}
  2370. cuDriverGetVersion(V);
  2371. {$IFDEF USE_LOGGING}
  2372. LogInfoFmt('%s version %d is loaded', [CUDAAPIDLL, V]);
  2373. {$ENDIF}
  2374. Result := True;
  2375. end;
  2376. function IsCUDAInitialized: Boolean;
  2377. begin
  2378. Result := (CUDAHandle <> INVALID_MODULEHANDLE);
  2379. end;
  2380. function Get_CUDA_API_Error_String(AError: TCUresult): string;
  2381. begin
  2382. if AError = CUDA_SUCCESS then
  2383. Result := 'No errors'
  2384. else if AError = CUDA_ERROR_INVALID_VALUE then
  2385. Result := 'Invalid value'
  2386. else if AError = CUDA_ERROR_OUT_OF_MEMORY then
  2387. Result := 'Out of memory'
  2388. else if AError = CUDA_ERROR_NOT_INITIALIZED then
  2389. Result := 'Driver not initialized'
  2390. else if AError = CUDA_ERROR_DEINITIALIZED then
  2391. Result := 'Driver deinitialized'
  2392. else if AError = CUDA_ERROR_NO_DEVICE then
  2393. Result := 'No CUDA-capable device available'
  2394. else if AError = CUDA_ERROR_INVALID_DEVICE then
  2395. Result := 'Invalid device'
  2396. else if AError = CUDA_ERROR_INVALID_IMAGE then
  2397. Result := 'Invalid kernel image'
  2398. else if AError = CUDA_ERROR_INVALID_CONTEXT then
  2399. Result := 'Invalid context'
  2400. else if AError = CUDA_ERROR_CONTEXT_ALREADY_CURRENT then
  2401. Result := 'Context already current'
  2402. else if AError = CUDA_ERROR_MAP_FAILED then
  2403. Result := 'Map failed'
  2404. else if AError = CUDA_ERROR_UNMAP_FAILED then
  2405. Result := 'Unmap failed'
  2406. else if AError = CUDA_ERROR_ARRAY_IS_MAPPED then
  2407. Result := 'Array is mapped'
  2408. else if AError = CUDA_ERROR_ALREADY_MAPPED then
  2409. Result := 'Already mapped'
  2410. else if AError = CUDA_ERROR_NO_BINARY_FOR_GPU then
  2411. Result := 'No binary for GPU'
  2412. else if AError = CUDA_ERROR_ALREADY_ACQUIRED then
  2413. Result := 'Already acquired'
  2414. else if AError = CUDA_ERROR_NOT_MAPPED then
  2415. Result := 'Not mapped'
  2416. else if AError = CUDA_ERROR_NOT_MAPPED_AS_ARRAY then
  2417. Result := 'Not mapped as array'
  2418. else if AError = CUDA_ERROR_NOT_MAPPED_AS_POINTER then
  2419. Result := 'Not mapped as pointer'
  2420. else if AError = CUDA_ERROR_INVALID_SOURCE then
  2421. Result := 'Invalid source'
  2422. else if AError = CUDA_ERROR_FILE_NOT_FOUND then
  2423. Result := 'File not found'
  2424. else if AError = CUDA_ERROR_INVALID_HANDLE then
  2425. Result := 'Invalid handle'
  2426. else if AError = CUDA_ERROR_NOT_FOUND then
  2427. Result := 'Not found'
  2428. else if AError = CUDA_ERROR_NOT_READY then
  2429. Result := 'CUDA not ready'
  2430. else if AError = CUDA_ERROR_LAUNCH_FAILED then
  2431. Result := 'Launch failed'
  2432. else if AError = CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES then
  2433. Result := 'Launch exceeded resources'
  2434. else if AError = CUDA_ERROR_LAUNCH_TIMEOUT then
  2435. Result := 'Launch exceeded timeout'
  2436. else if AError = CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING then
  2437. Result := 'Launch with incompatible texturing'
  2438. else if AError = CUDA_ERROR_POINTER_IS_64BIT then
  2439. Result := 'Pointer is 64bit'
  2440. else if AError = CUDA_ERROR_SIZE_IS_64BIT then
  2441. Result := 'Size is 64bit'
  2442. else
  2443. Result := 'Unknown error';
  2444. end;
  2445. end.