cal_boinc.h 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088
  1. /**
  2. * @file cal.h
  3. * @brief CAL Interface Header
  4. * @version 1.00.0 Beta
  5. */
  6. /* ============================================================
  7. Copyright (c) 2007 Advanced Micro Devices, Inc. All rights reserved.
  8. Redistribution and use of this material is permitted under the following
  9. conditions:
  10. Redistributions must retain the above copyright notice and all terms of this
  11. license.
  12. In no event shall anyone redistributing or accessing or using this material
  13. commence or participate in any arbitration or legal action relating to this
  14. material against Advanced Micro Devices, Inc. or any copyright holders or
  15. contributors. The foregoing shall survive any expiration or termination of
  16. this license or any agreement or access or use related to this material.
  17. ANY BREACH OF ANY TERM OF THIS LICENSE SHALL RESULT IN THE IMMEDIATE REVOCATION
  18. OF ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE THIS MATERIAL.
  19. THIS MATERIAL IS PROVIDED BY ADVANCED MICRO DEVICES, INC. AND ANY COPYRIGHT
  20. HOLDERS AND CONTRIBUTORS "AS IS" IN ITS CURRENT CONDITION AND WITHOUT ANY
  21. REPRESENTATIONS, GUARANTEE, OR WARRANTY OF ANY KIND OR IN ANY WAY RELATED TO
  22. SUPPORT, INDEMNITY, ERROR FREE OR UNINTERRUPTED OPERATION, OR THAT IT IS FREE
  23. FROM DEFECTS OR VIRUSES. ALL OBLIGATIONS ARE HEREBY DISCLAIMED - WHETHER
  24. EXPRESS, IMPLIED, OR STATUTORY - INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED
  25. WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
  26. ACCURACY, COMPLETENESS, OPERABILITY, QUALITY OF SERVICE, OR NON-INFRINGEMENT.
  27. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. OR ANY COPYRIGHT HOLDERS OR
  28. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE,
  29. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
  30. OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, REVENUE, DATA, OR PROFITS; OR
  31. BUSINESS INTERRUPTION) HOWEVER CAUSED OR BASED ON ANY THEORY OF LIABILITY
  32. ARISING IN ANY WAY RELATED TO THIS MATERIAL, EVEN IF ADVISED OF THE POSSIBILITY
  33. OF SUCH DAMAGE. THE ENTIRE AND AGGREGATE LIABILITY OF ADVANCED MICRO DEVICES,
  34. INC. AND ANY COPYRIGHT HOLDERS AND CONTRIBUTORS SHALL NOT EXCEED TEN DOLLARS
  35. (US $10.00). ANYONE REDISTRIBUTING OR ACCESSING OR USING THIS MATERIAL ACCEPTS
  36. THIS ALLOCATION OF RISK AND AGREES TO RELEASE ADVANCED MICRO DEVICES, INC. AND
  37. ANY COPYRIGHT HOLDERS AND CONTRIBUTORS FROM ANY AND ALL LIABILITIES,
  38. OBLIGATIONS, CLAIMS, OR DEMANDS IN EXCESS OF TEN DOLLARS (US $10.00). THE
  39. FOREGOING ARE ESSENTIAL TERMS OF THIS LICENSE AND, IF ANY OF THESE TERMS ARE
  40. CONSTRUED AS UNENFORCEABLE, FAIL IN ESSENTIAL PURPOSE, OR BECOME VOID OR
  41. DETRIMENTAL TO ADVANCED MICRO DEVICES, INC. OR ANY COPYRIGHT HOLDERS OR
  42. CONTRIBUTORS FOR ANY REASON, THEN ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE
  43. THIS MATERIAL SHALL TERMINATE IMMEDIATELY. MOREOVER, THE FOREGOING SHALL
  44. SURVIVE ANY EXPIRATION OR TERMINATION OF THIS LICENSE OR ANY AGREEMENT OR
  45. ACCESS OR USE RELATED TO THIS MATERIAL.
  46. NOTICE IS HEREBY PROVIDED, AND BY REDISTRIBUTING OR ACCESSING OR USING THIS
  47. MATERIAL SUCH NOTICE IS ACKNOWLEDGED, THAT THIS MATERIAL MAY BE SUBJECT TO
  48. RESTRICTIONS UNDER THE LAWS AND REGULATIONS OF THE UNITED STATES OR OTHER
  49. COUNTRIES, WHICH INCLUDE BUT ARE NOT LIMITED TO, U.S. EXPORT CONTROL LAWS SUCH
  50. AS THE EXPORT ADMINISTRATION REGULATIONS AND NATIONAL SECURITY CONTROLS AS
  51. DEFINED THEREUNDER, AS WELL AS STATE DEPARTMENT CONTROLS UNDER THE U.S.
  52. MUNITIONS LIST. THIS MATERIAL MAY NOT BE USED, RELEASED, TRANSFERRED, IMPORTED,
  53. EXPORTED AND/OR RE-EXPORTED IN ANY MANNER PROHIBITED UNDER ANY APPLICABLE LAWS,
  54. INCLUDING U.S. EXPORT CONTROL LAWS REGARDING SPECIFICALLY DESIGNATED PERSONS,
  55. COUNTRIES AND NATIONALS OF COUNTRIES SUBJECT TO NATIONAL SECURITY CONTROLS.
  56. MOREOVER, THE FOREGOING SHALL SURVIVE ANY EXPIRATION OR TERMINATION OF ANY
  57. LICENSE OR AGREEMENT OR ACCESS OR USE RELATED TO THIS MATERIAL.
  58. NOTICE REGARDING THE U.S. GOVERNMENT AND DOD AGENCIES: This material is
  59. provided with "RESTRICTED RIGHTS" and/or "LIMITED RIGHTS" as applicable to
  60. computer software and technical data, respectively. Use, duplication,
  61. distribution or disclosure by the U.S. Government and/or DOD agencies is
  62. subject to the full extent of restrictions in all applicable regulations,
  63. including those found at FAR52.227 and DFARS252.227 et seq. and any successor
  64. regulations thereof. Use of this material by the U.S. Government and/or DOD
  65. agencies is acknowledgment of the proprietary rights of any copyright holders
  66. and contributors, including those of Advanced Micro Devices, Inc., as well as
  67. the provisions of FAR52.227-14 through 23 regarding privately developed and/or
  68. commercial computer software.
  69. This license forms the entire agreement regarding the subject matter hereof and
  70. supersedes all proposals and prior discussions and writings between the parties
  71. with respect thereto. This license does not affect any ownership, rights, title,
  72. or interest in, or relating to, this material. No terms of this license can be
  73. modified or waived, and no breach of this license can be excused, unless done
  74. so in a writing signed by all affected parties. Each term of this license is
  75. separately enforceable. If any term of this license is determined to be or
  76. becomes unenforceable or illegal, such term shall be reformed to the minimum
  77. extent necessary in order for this license to remain in effect in accordance
  78. with its terms as modified by such reformation. This license shall be governed
  79. by and construed in accordance with the laws of the State of Texas without
  80. regard to rules on conflicts of law of any state or jurisdiction or the United
  81. Nations Convention on the International Sale of Goods. All disputes arising out
  82. of this license shall be subject to the jurisdiction of the federal and state
  83. courts in Austin, Texas, and all defenses are hereby waived concerning personal
  84. jurisdiction and venue of these courts.
  85. ============================================================ */
  86. #ifndef __CAL_H__
  87. #define __CAL_H__
  88. #ifdef __cplusplus
  89. extern "C" {
  90. #define CALAPI
  91. #else
  92. #define CALAPI extern
  93. #endif
  94. #ifdef _WIN32
  95. #define CALAPIENTRY __stdcall
  96. #else
  97. #define CALAPIENTRY
  98. #endif
  99. typedef void CALvoid; /**< void type */
  100. typedef char CALchar; /**< ASCII character */
  101. typedef signed char CALbyte; /**< 1 byte signed integer value */
  102. typedef unsigned char CALubyte; /**< 1 byte unsigned integer value */
  103. typedef signed short CALshort; /**< 2 byte signed integer value */
  104. typedef unsigned short CALushort; /**< 2 byte unsigned integer value */
  105. typedef signed int CALint; /**< 4 byte signed integer value */
  106. typedef unsigned int CALuint; /**< 4 byte unsigned intger value */
  107. typedef float CALfloat; /**< 32-bit IEEE floating point value */
  108. typedef double CALdouble; /**< 64-bit IEEE floating point value */
  109. typedef signed long CALlong; /**< long value */
  110. typedef unsigned long CALulong; /**< unsigned long value */
  111. #if defined(_MSC_VER)
  112. typedef signed __int64 CALint64; /**< 8 byte signed integer value */
  113. typedef unsigned __int64 CALuint64; /**< 8 byte unsigned integer value */
  114. #elif defined(__GNUC__)
  115. typedef signed long long CALint64; /**< 8 byte signed integer value */
  116. typedef unsigned long long CALuint64; /**< 8 byte unsigned integer value */
  117. #else
  118. #error "Unsupported compiler type."
  119. #endif
  120. /** Boolean type */
  121. typedef enum CALbooleanEnum {
  122. CAL_FALSE = 0, /**< Boolean false value */
  123. CAL_TRUE = 1 /**< Boolean true value */
  124. } CALboolean;
  125. /** Function call result/return codes */
  126. typedef enum CALresultEnum {
  127. CAL_RESULT_OK = 0, /**< No error */
  128. CAL_RESULT_ERROR = 1, /**< Operational error */
  129. CAL_RESULT_INVALID_PARAMETER = 2, /**< Parameter passed in is invalid */
  130. CAL_RESULT_NOT_SUPPORTED = 3, /**< Function used properly but currently not supported */
  131. CAL_RESULT_ALREADY = 4, /**< Stateful operation requested has already been performed */
  132. CAL_RESULT_NOT_INITIALIZED = 5, /**< CAL function was called without CAL being initialized */
  133. CAL_RESULT_BAD_HANDLE = 6, /**< A handle parameter is invalid */
  134. CAL_RESULT_BAD_NAME_TYPE = 7, /**< A name parameter is invalid */
  135. CAL_RESULT_PENDING = 8, /**< An asynchronous operation is still pending */
  136. CAL_RESULT_BUSY = 9, /**< The resource in question is still in use */
  137. CAL_RESULT_WARNING = 10, /**< Compiler generated a warning */
  138. } CALresult;
  139. /** Data format representation */
  140. typedef enum CALformatEnum {
  141. CAL_FORMAT_UBYTE_1, /**< A 1 component 8-bit unsigned byte format */
  142. CAL_FORMAT_UBYTE_2, /**< A 2 component 8-bit unsigned byte format */
  143. CAL_FORMAT_UBYTE_4, /**< A 4 component 8-bit unsigned byte format */
  144. CAL_FORMAT_USHORT_1, /**< A 1 component 16-bit unsigned short format */
  145. CAL_FORMAT_USHORT_2, /**< A 2 component 16-bit unsigned short format */
  146. CAL_FORMAT_USHORT_4, /**< A 4 component 16-bit unsigned short format */
  147. CAL_FORMAT_UINT_4, /**< A 4 component 32-bit unsigned integer format */
  148. CAL_FORMAT_BYTE_4, /**< A 4 component 8-bit byte format */
  149. CAL_FORMAT_SHORT_1, /**< A 1 component 16-bit short format */
  150. CAL_FORMAT_SHORT_2, /**< A 2 component 16-bit short format */
  151. CAL_FORMAT_SHORT_4, /**< A 4 component 16-bit short format */
  152. CAL_FORMAT_FLOAT_1, /**< A 1 component 32-bit float format */
  153. CAL_FORMAT_FLOAT_2, /**< A 2 component 32-bit float format */
  154. CAL_FORMAT_FLOAT_4, /**< A 4 component 32-bit float format */
  155. CAL_FORMAT_DOUBLE_1, /**< A 1 component 64-bit float format */
  156. CAL_FORMAT_DOUBLE_2, /**< A 2 component 64-bit float format */
  157. CAL_FORMAT_UINT_1, /**< A 1 component 32-bit unsigned integer format */
  158. CAL_FORMAT_UINT_2, /**< A 2 component 32-bit unsigned integer format */
  159. CAL_FORMAT_BYTE_1, /**< A 1 component 8-bit byte format */
  160. CAL_FORMAT_BYTE_2, /**< A 2 component 8-bit byte format */
  161. CAL_FORMAT_INT_1, /**< A 1 component 32-bit signed integer format */
  162. CAL_FORMAT_INT_2, /**< A 2 component 32-bit signed integer format */
  163. CAL_FORMAT_INT_4, /**< A 4 component 32-bit signed integer format */
  164. } CALformat;
  165. /** Device Kernel ISA */
  166. typedef enum CALtargetEnum {
  167. CAL_TARGET_600, /**< R600 GPU ISA */
  168. CAL_TARGET_610, /**< RV610 GPU ISA */
  169. CAL_TARGET_630, /**< RV630 GPU ISA */
  170. CAL_TARGET_670, /**< RV670 GPU ISA */
  171. CAL_TARGET_7XX, /**< R700 class GPU ISA */
  172. CAL_TARGET_770, /**< RV770 GPU ISA */
  173. CAL_TARGET_710, /**< RV710 GPU ISA */
  174. CAL_TARGET_730, /**< RV730 GPU ISA */
  175. } CALtarget;
  176. /** CAL object container */
  177. typedef struct CALobjectRec* CALobject;
  178. /** CAL image container */
  179. typedef struct CALimageRec* CALimage;
  180. typedef CALuint CALdevice; /**< Device handle */
  181. typedef CALuint CALcontext; /**< context */
  182. typedef CALuint CALresource; /**< resource handle */
  183. typedef CALuint CALmem; /**< memory handle */
  184. typedef CALuint CALfunc; /**< function handle */
  185. typedef CALuint CALname; /**< name handle */
  186. typedef CALuint CALmodule; /**< module handle */
  187. typedef CALuint CALevent; /**< event handle */
  188. /** CAL computational domain */
  189. typedef struct CALdomainRec {
  190. CALuint x; /**< x origin of domain */
  191. CALuint y; /**< y origin of domain */
  192. CALuint width; /**< width of domain */
  193. CALuint height; /**< height of domain */
  194. } CALdomain;
  195. /** CAL device information */
  196. typedef struct CALdeviceinfoRec {
  197. CALtarget target; /**< Device Kernel ISA */
  198. CALuint maxResource1DWidth; /**< Maximum resource 1D width */
  199. CALuint maxResource2DWidth; /**< Maximum resource 2D width */
  200. CALuint maxResource2DHeight; /**< Maximum resource 2D height */
  201. } CALdeviceinfo;
  202. /** CAL device attributes */
  203. typedef struct CALdeviceattribsRec {
  204. CALuint struct_size; /**< Client filled out size of CALdeviceattribs struct */
  205. CALtarget target; /**< Asic identifier */
  206. CALuint localRAM; /**< Amount of local GPU RAM in megabytes */
  207. CALuint uncachedRemoteRAM; /**< Amount of uncached remote GPU memory in megabytes */
  208. CALuint cachedRemoteRAM; /**< Amount of cached remote GPU memory in megabytes */
  209. CALuint engineClock; /**< GPU device clock rate in megahertz */
  210. CALuint memoryClock; /**< GPU memory clock rate in megahertz */
  211. CALuint wavefrontSize; /**< Wavefront size */
  212. CALuint numberOfSIMD; /**< Number of SIMDs */
  213. CALboolean doublePrecision; /**< double precision supported */
  214. CALboolean localDataShare; /**< local data share supported */
  215. CALboolean globalDataShare; /**< global data share supported */
  216. CALboolean globalGPR; /**< global GPR supported */
  217. CALboolean computeShader; /**< compute shader supported */
  218. CALboolean memExport; /**< memexport supported */
  219. CALuint pitch_alignment; /**< Required alignment for calCreateRes allocations (in data elements) */
  220. CALuint surface_alignment; /**< Required start address alignment for calCreateRes allocations (in bytes) */
  221. } CALdeviceattribs;
  222. /** CAL device status */
  223. typedef struct CALdevicestatusRec {
  224. CALuint struct_size; /**< Client filled out size of CALdevicestatus struct */
  225. CALuint availLocalRAM; /**< Amount of available local GPU RAM in megabytes */
  226. CALuint availUncachedRemoteRAM; /**< Amount of available uncached remote GPU memory in megabytes */
  227. CALuint availCachedRemoteRAM; /**< Amount of available cached remote GPU memory in megabytes */
  228. } CALdevicestatus;
  229. /** CAL resource allocation flags **/
  230. typedef enum CALresallocflagsEnum {
  231. CAL_RESALLOC_GLOBAL_BUFFER = 1, /**< used for global import/export buffer */
  232. CAL_RESALLOC_CACHEABLE = 2, /**< cacheable memory? */
  233. } CALresallocflags;
  234. /** CAL computational 3D domain */
  235. typedef struct CALdomain3DRec {
  236. CALuint width; /**< width of domain */
  237. CALuint height; /**< height of domain */
  238. CALuint depth; /**< depth of domain */
  239. } CALdomain3D;
  240. /** CAL computational grid */
  241. typedef struct CALprogramGridRec {
  242. CALfunc func; /**< CALfunc to execute */
  243. CALdomain3D gridBlock; /**< size of a block of data */
  244. CALdomain3D gridSize; /**< size of 'blocks' to execute. */
  245. CALuint flags; /**< misc grid flags */
  246. } CALprogramGrid;
  247. /** CAL computational grid array*/
  248. typedef struct CALprogramGridArrayRec {
  249. CALprogramGrid* gridArray;/**< array of programGrid structures */
  250. CALuint num; /**< number of entries in the grid array */
  251. CALuint flags; /**< misc grid array flags */
  252. } CALprogramGridArray;
  253. /** CAL function information **/
  254. typedef struct CALfuncInfoRec
  255. {
  256. CALuint maxScratchRegsNeeded; /**< Maximum number of scratch regs needed */
  257. CALuint numSharedGPRUser; /**< Number of shared GPRs */
  258. CALuint numSharedGPRTotal; /**< Number of shared GPRs including ones used by SC */
  259. CALboolean eCsSetupMode; /**< Slow mode */
  260. CALuint numThreadPerGroup; /**< Number of threads per group */
  261. CALuint totalNumThreadGroup; /**< Total number of thread groups */
  262. CALuint wavefrontPerSIMD; /**< Number of wavefronts per SIMD */ //CAL_USE_SC_PRM
  263. CALuint numWavefrontPerSIMD; /**< Number of wavefronts per SIMD */
  264. CALboolean isMaxNumWavePerSIMD; /**< Is this the max num active wavefronts per SIMD */
  265. CALboolean setBufferForNumGroup; /**< Need to set up buffer for info on number of thread groups? */
  266. } CALfuncInfo;
  267. /*============================================================================
  268. * CAL Runtime Interface
  269. *============================================================================*/
  270. /*----------------------------------------------------------------------------
  271. * CAL Subsystem Functions
  272. *----------------------------------------------------------------------------*/
  273. /**
  274. * @fn calInit(void)
  275. *
  276. * @brief Initialize the CAL subsystem.
  277. *
  278. * Initializes the CAL system for computation. The behavior of CAL methods is
  279. * undefined if the system is not initialized.
  280. *
  281. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error, and CAL_RESULT_ALREADY
  282. * of CAL has already been initialized.
  283. *
  284. * @sa calShutdown
  285. */
  286. CALAPI CALresult CALAPIENTRY calInit(void);
  287. /**
  288. * @fn calGetVersion(CALuint* major, CALuint* minor, CALuint* imp)
  289. *
  290. * @brief Retrieve the CAL version that is loaded
  291. *
  292. * CAL version is in the form of API_Major.API_Minor.Implementation where
  293. * "API_Major" is the major version number of the CAL API. "API_Minor" is the
  294. * minor version number of the CAL API. "Implementation" is the implementation
  295. * instance of the supplied API version number.
  296. *
  297. * @return Returns CAL_RESULT_OK on success.
  298. *
  299. * @sa calInit calShutdown
  300. */
  301. CALAPI CALresult CALAPIENTRY calGetVersion(CALuint* major, CALuint* minor, CALuint* imp);
  302. /**
  303. * @fn calShutdown(void)
  304. *
  305. * @brief Shuts down the CAL subsystem.
  306. *
  307. * Shuts down the CAL system. calShutdown should always be paired with
  308. * calInit. An application may have any number of calInit - calShutdown
  309. * pairs. Any CAL call outsied calInit - calShutdown pair will return
  310. * CAL_RESULT_NOT_INITIALIZED.
  311. *
  312. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  313. *
  314. * @sa calInit
  315. */
  316. CALAPI CALresult CALAPIENTRY calShutdown(void);
  317. /*----------------------------------------------------------------------------
  318. * CAL Device Functions
  319. *----------------------------------------------------------------------------*/
  320. /**
  321. * @fn calDeviceGetCount(CALuint* count)
  322. *
  323. * @brief Retrieve the number of devices available to the CAL subsystem.
  324. *
  325. * Returns in *count the total number of supported GPUs present in the system.
  326. *
  327. * @param count (out) - the number of devices available to CAL. On error, count will be zero.
  328. *
  329. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  330. *
  331. * @sa calDeviceGetInfo calDeviceOpen calDeviceClose
  332. */
  333. CALAPI CALresult CALAPIENTRY calDeviceGetCount(CALuint* count);
  334. /**
  335. * @fn calDeviceGetInfo(CALdeviceinfo* info, CALuint ordinal)
  336. *
  337. * @brief Retrieve information about a specific device available to the CAL subsystem.
  338. *
  339. * Returns the device specific information in *info. calDeviceGetInfo returns
  340. * CAL_RESULT_ERROR if the ordinal is not less than the *count returned in
  341. * calDeviceGetCount. The target instruction set, the maximum width of
  342. * 1D resources, the maximum width and height of 2D resources are part
  343. * of the CALdeviceinfo structure.
  344. *
  345. * @param info (out) - the device descriptor struct for the specified device.
  346. * @param ordinal (in) - zero based index of the device to retrieve information.
  347. *
  348. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  349. *
  350. * @sa calDeviceGetCount calDeviceOpen calDeviceClose
  351. */
  352. CALAPI CALresult CALAPIENTRY calDeviceGetInfo(CALdeviceinfo* info, CALuint ordinal);
  353. /**
  354. * @fn calDeviceGetAttribs(CALdeviceattribs* attribs, CALuint ordinal)
  355. *
  356. * @brief Retrieve information about a specific device available to the CAL subsystem.
  357. *
  358. * Returns the device specific attributes in *attribs. calDeviceGetAttribs returns
  359. * CAL_RESULT_ERROR if the ordinal is not less than the *count returned in
  360. * calDeviceGetCount.
  361. *
  362. * @param attribs (out) - the device attribute struct for the specified device.
  363. * @param ordinal (in) - zero based index of the device to retrieve information.
  364. *
  365. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  366. *
  367. * @sa calDeviceGetCount calDeviceOpen calDeviceClose
  368. */
  369. CALAPI CALresult CALAPIENTRY calDeviceGetAttribs(CALdeviceattribs* attribs, CALuint ordinal);
  370. /**
  371. * @fn calDeviceGetStatus(CALdevicestatus* status, CALdevice device)
  372. *
  373. * @brief Retrieve information about a specific device available to the CAL subsystem.
  374. *
  375. * Returns the current status of an open device in *status.
  376. *
  377. * @param status (out) - the status struct for the specified device.
  378. * @param device (in) - handle of the device from which status is to be retrieved.
  379. *
  380. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  381. *
  382. * @sa calDeviceGetAttribs calDeviceOpen calDeviceClose
  383. */
  384. CALAPI CALresult CALAPIENTRY calDeviceGetStatus(CALdevicestatus* status, CALdevice device);
  385. /**
  386. * @fn calDeviceOpen(CALdevice* dev, CALuint ordinal)
  387. *
  388. * @brief Open the specified device.
  389. *
  390. * Opens a device. A device has to be closed before it can be opened again in
  391. * the same application. This call should always be paired with calDeviceClose.
  392. * Open the device indexed by the <i>ordinal</i> parameter, which
  393. * is an unsigned integer in the range of zero to the number of available devices (minus one).
  394. *
  395. * @param dev (out) - the device handle for the specified device. On error, dev will be zero.
  396. * @param ordinal (in) - zero based index of the device to retrieve information.
  397. *
  398. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  399. *
  400. * @sa calDeviceGetCount calDeviceGetInfo calDeviceClose
  401. */
  402. CALAPI CALresult CALAPIENTRY calDeviceOpen(CALdevice* dev, CALuint ordinal);
  403. /**
  404. * @fn calDeviceClose(CALdevice dev)
  405. *
  406. * @brief Close the specified device.
  407. *
  408. * Close the device specified by <i>dev</i> parameter. The
  409. *
  410. * @param dev (in) - the device handle for the device to close
  411. *
  412. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  413. *
  414. * @sa calDeviceGetCount calDeviceGetInfo calDeviceOpen
  415. */
  416. CALAPI CALresult CALAPIENTRY calDeviceClose(CALdevice dev);
  417. /*----------------------------------------------------------------------------
  418. * CAL Resource Functions
  419. *----------------------------------------------------------------------------*/
  420. /**
  421. * @fn calResAllocLocal2D(CALresource* res, CALdevice dev, CALuint width, CALuint height, CALformat format, CALuint flags)
  422. *
  423. * @brief Allocate a memory resource local to a device
  424. *
  425. * allocates memory resource local to a device <i>dev</i> and returns a
  426. * resource handle in <i>*res</i> if successful. This memory is structured
  427. * as a 2 dimensional region of <i>width</i> and <i>height</i> with a <i>format</i>.
  428. * The maximum values of <i>width</i> and <i>height</i> are available through
  429. * the calDeviceGetInfo function. The call returns CAL_RESULT_ERROR if requested
  430. * memory was not available.
  431. *
  432. * Initial implementation will allow this memory to be accessible by all contexts
  433. * created on this device only. Contexts residing on other devices cannot access
  434. * this memory.
  435. *
  436. * <i>flags</i> can be zero or CAL_RESALLOC_GLOBAL_BUFFER
  437. * - to specify that the resource will be used as a global
  438. * buffer.
  439. *
  440. * There are some performance implications when <i>width</i> is not a multiple
  441. * of 64 for R6xx GPUs.
  442. *
  443. * @param res (out) - returned resource handle. On error, res will be zero.
  444. * @param dev (in) - device the resource should be local.
  445. * @param width (in) - width of resource (in elements).
  446. * @param height (in) - height of the resource (in elements).
  447. * @param format (in) - format/type of each element of the resource.
  448. * @param flags (in) - currently unused.
  449. *
  450. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  451. *
  452. * @sa calResFree
  453. */
  454. CALAPI CALresult CALAPIENTRY calResAllocLocal2D(CALresource* res, CALdevice dev, CALuint width, CALuint height, CALformat format, CALuint flags);
  455. /**
  456. * @fn calResAllocRemote2D(CALresource* res, CALdevice* dev, CALuint devCount, CALuint width, CALuint height, CALformat format, CALuint flags)
  457. *
  458. * @brief Allocate a memory resource remote to a set of devices
  459. *
  460. * allocates memory resource global to <i>devCount</i> number of devices in <i>dev</i> array
  461. * and returns a resource handle in <i>*res</i> if successful. This memory is structured
  462. * as a 2 dimensional region of <i>width</i> and <i>height</i> with a <i>format</i>.
  463. * The maximum values of <i>width</i> and <i>height</i> are available through
  464. * the calDeviceGetInfo function. The call returns CAL_RESULT_ERROR if requested
  465. * memory was not available.
  466. *
  467. * Currently only a single device is functional (<i>devCount</i> must be 1).
  468. *
  469. * Initial implementation will allow this memory to be accessible by all contexts
  470. * created on this device only. Contexts residing on other devices cannot access
  471. * this memory.
  472. *
  473. * <i>flags</i> can be zero or CAL_RESALLOC_GLOBAL_BUFFER - to
  474. * specify that the resource will be used as a global buffer or
  475. * CAL_RESALLOC_CACHEABLE for GART cacheable memory.
  476. *
  477. * One of the benefits with devices being able to write to remote (i.e. system)
  478. * memory is performance. For example, with large computational kernels, it is
  479. * sometimes faster for the GPU contexts to write directly to remote
  480. * memory than it is to do these in 2 steps of GPU context writing to local memory
  481. * and copying data from GPU local memory to remote system memory via calMemCopy
  482. *
  483. * @param res (out) - returned resource handle. On error, res will be zero.
  484. * @param dev (in) - list of devices the resource should be available to.
  485. * @param devCount (in) - number of devices in the device list.
  486. * @param width (in) - width of resource (in elements).
  487. * @param height (in) - height of the resource (in elements).
  488. * @param format (in) - format/type of each element of the resource.
  489. * @param flags (in) - currently unused.
  490. *
  491. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  492. *
  493. * @sa calResFree
  494. */
  495. CALAPI CALresult CALAPIENTRY calResAllocRemote2D(CALresource* res, CALdevice *dev, CALuint deviceCount, CALuint width, CALuint height, CALformat format, CALuint flags);
  496. /**
  497. * @fn calResAllocLocal1D(CALresource* res, CALdevice dev, CALuint width, CALformat format, CALuint flags)
  498. *
  499. * @brief Allocate a 1D memory resource local to a device
  500. *
  501. * allocates memory resource local to a device <i>device</i> and returns
  502. * a resource handle in <i>*res</i> if successful. This memory is
  503. * structured as a 1 dimensional array of <i>width</i> elements with a <i>format</i>}.
  504. * The maximum values of <i>width</i> is available from the calDeviceGetInfo function.
  505. * The call returns CAL_RESULT_ERROR if requested memory was not available.
  506. *
  507. * @param res (out) - returned resource handle. On error, res will be zero.
  508. * @param dev (in) - device the resource should be local.
  509. * @param width (in) - width of resource (in elements).
  510. * @param format (in) - format/type of each element of the resource.
  511. * @param flags (in) - currently unused.
  512. *
  513. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  514. *
  515. * @sa calResFree
  516. */
  517. CALAPI CALresult CALAPIENTRY calResAllocLocal1D(CALresource* res, CALdevice dev, CALuint width, CALformat format, CALuint flags);
  518. /**
  519. * @fn calResAllocRemote1D(CALresource* res, CALdevice* dev, CALuint deviceCount, CALuint width, CALformat format, CALuint flags)
  520. *
  521. * @brief Allocate a 1D memory resource remote to a device
  522. *
  523. * allocates memory resource global to <i>devCount</i> number of devices
  524. * in <i>dev</i> array and returns a resource memory handle in <i>*res</i> if
  525. * successful. This memory resource is structured as a 1 dimensional
  526. * region of <i>width</i> elements with a <i>format</i>. The maximum values of
  527. * <i>width</i> is available from the calDeviceGetInfo function. The call returns
  528. * CAL_RESULT_ERROR if requested memory was not available.
  529. *
  530. * Currently only a single device is functional (<i>devCount</i> must be 1).
  531. *
  532. * @param res (out) - returned resource handle. On error, res will be zero.
  533. * @param dev (in) - device the resource should be local.
  534. * @param deviceCount (in) - number of devices in the device list.
  535. * @param width (in) - width of resource (in elements).
  536. * @param format (in) - format/type of each element of the resource.
  537. * @param flags (in) - currently unused.
  538. *
  539. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  540. *
  541. * @sa calResFree
  542. */
  543. CALAPI CALresult CALAPIENTRY calResAllocRemote1D(CALresource* res, CALdevice* dev, CALuint deviceCount, CALuint width, CALformat format, CALuint flags);
  544. /**
  545. * @fn calResFree(CALresource res)
  546. *
  547. * @brief Free a resource
  548. *
  549. * releases allocated memory resource. calResFree returns CAL_RESULT_BUSY if
  550. * the resources is in use by any context.
  551. *
  552. * @param res (in) - resource handle to free.
  553. *
  554. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  555. *
  556. * @sa calResAllocLocal2D calResAllocRemote2D calResAllocLocal1D calResAllocRemote1D
  557. */
  558. CALAPI CALresult CALAPIENTRY calResFree(CALresource res);
  559. /**
  560. * @fn calResMap(CALvoid** pPtr, CALuint* pitch, CALresource res, CALuint flags)
  561. *
  562. * @brief Map memory to the CPU
  563. *
  564. *
  565. * returns a CPU accessible pointer to the memory surface in <i>**pPtr</i>
  566. * and the pitch in <i>*pitch</i>. All memory resources are CPU accessible. It is an
  567. * error to call <i>calResMap</i> within a <i>calResMap</i> - <i>calResUnmap</i> pair
  568. * for the same <i>CALresource</i> memory resource handle.
  569. *
  570. * A mapped surface cannot be used as input or output of a calCtxRunProgram or calMemCopy.
  571. *
  572. * @param pPtr (out) - CPU pointer to the mapped resource. On error, pPtr will be zero.
  573. * @param pitch (out) - Pitch in elements of the resource. On error, pitch will be zero.
  574. * @param res (in) - resource handle to map
  575. * @param flags (in) - not used
  576. *
  577. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  578. *
  579. * @sa calResUnmap
  580. */
  581. CALAPI CALresult CALAPIENTRY calResMap(CALvoid** pPtr, CALuint* pitch, CALresource res, CALuint flags);
  582. /**
  583. * @fn calResUnmap(CALresource res)
  584. *
  585. * @brief Unmap a CPU mapped resource.
  586. *
  587. * releases the address returned in <i>calResMap</i>. This should always be
  588. * paired with <i>calResMap</i>
  589. *
  590. * @param res (in) - resource handle to unmap
  591. *
  592. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  593. *
  594. * @sa calResMap
  595. */
  596. CALAPI CALresult CALAPIENTRY calResUnmap(CALresource res);
  597. /*----------------------------------------------------------------------------
  598. * CAL Context Functions
  599. *----------------------------------------------------------------------------*/
  600. /**
  601. * @fn calCtxCreate(CALcontext* ctx, CALdevice dev)
  602. *
  603. * @brief Create a CAL context on the specified device
  604. *
  605. * creates a context on a device. Multiple contexts can be created on
  606. * a single device.
  607. *
  608. * @param ctx (out) - handle of the newly created context. On error, ctx will be zero.
  609. * @param dev (in) - device handle to create the context on
  610. *
  611. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  612. *
  613. * @sa calCtxDestroy
  614. */
  615. CALAPI CALresult CALAPIENTRY calCtxCreate(CALcontext* ctx, CALdevice dev);
  616. /**
  617. * @fn calCtxDestroy(CALcontext ctx)
  618. *
  619. * @brief Destroy a CAL context
  620. *
  621. * destroys a context. All current modules are unloaded and all CALmem objects
  622. * mapped to the context are released. This call should be paired with
  623. * <i>calCtxCreate</i>
  624. *
  625. * @param ctx (in) - context to destroy
  626. *
  627. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  628. *
  629. * @sa calCtxCreate
  630. */
  631. CALAPI CALresult CALAPIENTRY calCtxDestroy(CALcontext ctx);
  632. /**
  633. * @fn calCtxGetMem(CALmem* mem, CALcontext ctx, CALresource res)
  634. *
  635. * @brief Map a resource to a context
  636. *
  637. * returns a memory handle in <i>*mem</i> for the resource surface <i>res</i>
  638. * for use by the context <i>ctx</i>.
  639. *
  640. * @param mem (out) - created memory handle. On error, mem will be zero.
  641. * @param ctx (in) - context in which resouce is mapped
  642. * @param res (in) - resource to map to context
  643. *
  644. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  645. *
  646. * @sa calCtxReleaseMem calCtxSetMem
  647. */
  648. CALAPI CALresult CALAPIENTRY calCtxGetMem(CALmem* mem, CALcontext ctx, CALresource res);
  649. /**
  650. * @fn calCtxReleaseMem(CALcontext ctx, CALmem mem)
  651. *
  652. * @brief Release a resource to context mapping
  653. *
  654. * releases memory handle <i>mem</i> that is obtained by <i>calCtxGetMem</i>.
  655. *
  656. * @param ctx (in) - context in which resouce is mapped
  657. * @param mem (in) - memory handle to release
  658. *
  659. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  660. *
  661. * @sa calCtxGetMem calCtxSetMem
  662. */
  663. CALAPI CALresult CALAPIENTRY calCtxReleaseMem(CALcontext ctx, CALmem mem);
  664. /**
  665. * @fn calCtxSetMem(CALcontext ctx, CALname name, CALmem mem)
  666. *
  667. * @brief Set memory used for kernel input or output
  668. *
  669. * sets a memory handle <i>mem</i> with the associated <i>name</i> in
  670. * the module to the context <i>ctx</i>. This can be input or output.
  671. *
  672. * @param ctx (in) - context to apply attachment.
  673. * @param name (in) - name to bind memory.
  674. * @param mem (in) - memory handle to apply.
  675. *
  676. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  677. *
  678. * @sa calCtxGetMem calCtxReleaseMem
  679. */
  680. CALAPI CALresult CALAPIENTRY calCtxSetMem(CALcontext ctx, CALname name, CALmem mem);
  681. /**
  682. * @fn calCtxRunProgram(CALevent* event, CALcontext ctx, CALfunc func, const CALdomain* domain)
  683. *
  684. * @brief Invoke the kernel over the specified domain.
  685. *
  686. *
  687. * issues a task to invoke the computation of the kernel identified by
  688. * <i>func</i> within a region <i>domain</i> on the context <i>ctx</i> and
  689. * returns an associated event token in <i>*event</i> with this task. This
  690. * method returns CAL_RESULT_ERROR if <i>func</i> is not found in the currently
  691. * loaded module. This method returns CAL_RESULT_ERROR, if any of the inputs,
  692. * input references, outputs and constant buffers associated with the kernel
  693. * are not setup. Completion of this event can be queried by the master process
  694. * using <i>calIsEventDone</i>
  695. *
  696. * Extended contextual information regarding a calCtxRunProgram failure
  697. * can be obtained with the calGetErrorString function.
  698. *
  699. * @param event (out) - event associated with RunProgram instance. On error, event will be zero.
  700. * @param ctx (in) - context.
  701. * @param func (in) - function to use as kernel.
  702. * @param domain (in) - domain over which kernel is applied.
  703. *
  704. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  705. *
  706. * @sa calCtxIsEventDone
  707. */
  708. CALAPI CALresult CALAPIENTRY calCtxRunProgram(CALevent* event, CALcontext ctx, CALfunc func, const CALdomain* domain);
  709. /**
  710. * @fn calCtxIsEventDone(CALcontext ctx, CALevent event)
  711. *
  712. * @brief Query to see if event has completed
  713. *
  714. *
  715. * is a mechanism for the master process to query if an event <i>event</i> on
  716. * context <i>ctx</i> from <i>calCtxRunProgram</i> or <i>calMemCopy</i> is
  717. * completed. This call also ensures that the commands associated with
  718. * the context are flushed.
  719. *
  720. * @param ctx (in) - context to query.
  721. * @param event (in) - event to query.
  722. *
  723. * @return Returns CAL_RESULT_OK if the event is complete, CAL_RESULT_PENDING if the event is
  724. * still being processed and CAL_RESULT_ERROR if there was an error.
  725. *
  726. * @sa calCtxRunProgram
  727. */
  728. CALAPI CALresult CALAPIENTRY calCtxIsEventDone(CALcontext ctx, CALevent event);
  729. /**
  730. * @fn calCtxFlush(CALcontext ctx)
  731. *
  732. * @brief Flush any commands associated with the supplied context
  733. *
  734. * This call ensures that the commands associated with the
  735. * context are flushed.
  736. *
  737. * @param ctx (in) - context to flush.
  738. *
  739. * @return Returns CAL_RESULT_OK if the event is complete, CAL_RESULT_ERROR if
  740. * there was an error.
  741. *
  742. * @sa calCtxRunProgram calCtxIsEventDone
  743. */
  744. CALAPI CALresult CALAPIENTRY calCtxFlush(CALcontext ctx);
  745. /**
  746. * @fn calMemCopy(CALevent* event, CALcontext ctx, CALmem srcMem, CALmem dstMem, CALuint flags)
  747. *
  748. * @brief Copy srcMem to dstMem
  749. *
  750. * issues a task to copy data from a source memory handle to a
  751. * destination memory handle. This method returns CAL_RESULT_ERROR if the source
  752. * and destination memory have different memory formats or if the destination
  753. * memory handle is not as big in 2 dimensions as the source memory or
  754. * if the source and destination memory handles do not belong to the
  755. * context <i>ctx</i>. An event is associated with this task and is returned in
  756. * <i>*event</i> and completion of this event can be queried by the master
  757. * process using <i>calIsEventDone</i>. Data can be copied between memory
  758. * handles from remote system memory to device local memory, remote system
  759. * memory to remote system memory, device local memory to remote
  760. * system memory, device local memory to same device local memory, device
  761. * local memory to a different device local memory. The memory is copied by
  762. * the context <i>ctx</i>
  763. *
  764. * @param event (out) - event associated with Memcopy instance. On error, event will be zero.
  765. * @param ctx (in) - context to query.
  766. * @param srcMem (in) - source of the copy.
  767. * @param dstMem (in) - destination of the copy.
  768. * @param flags (in) - currently not used.
  769. *
  770. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  771. *
  772. * @sa calCtxRunProgram
  773. */
  774. CALAPI CALresult CALAPIENTRY calMemCopy(CALevent* event, CALcontext ctx, CALmem srcMem, CALmem dstMem, CALuint flags);
  775. /*----------------------------------------------------------------------------
  776. * CAL Image Functions
  777. *----------------------------------------------------------------------------*/
  778. /**
  779. * @fn calImageRead(CALimage* image, const CALvoid* buffer, CALuint size)
  780. *
  781. * @brief Create a CALimage and serialize into it from the supplied buffer.
  782. *
  783. * Create a CALimage and populate it with information from the supplied buffer.
  784. *
  785. * @param image (out) - image created from serialization
  786. * @param buffer (in) - buffer to serialize from
  787. * @param size (in) - size of buffer
  788. *
  789. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  790. * @sa calImageFree
  791. */
  792. CALAPI CALresult CALAPIENTRY calImageRead(CALimage *image, const CALvoid* buffer, CALuint size);
  793. /**
  794. * @fn calImageFree(CALimage image)
  795. *
  796. * @brief Free the supplied CALimage.
  797. *
  798. * Free a calImage that was created with calImageRead.
  799. *
  800. * @param image (in) - image to free
  801. *
  802. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  803. *
  804. * @sa calImageRead
  805. */
  806. CALAPI CALresult CALAPIENTRY calImageFree(CALimage image);
  807. /*----------------------------------------------------------------------------
  808. * CAL Module Functions
  809. *----------------------------------------------------------------------------*/
  810. /**
  811. * @fn calModuleLoad(CALmodule* module, CALcontext ctx, CALimage image)
  812. *
  813. * @brief Load a kernel image to a context
  814. *
  815. * creates a module from precompiled image <i>image</i>, loads the module
  816. * on the context and returns the loaded module in <i>*module</i>. This
  817. * method returns CAL_RESULT_ERROR if the module cannot be loaded onto the
  818. * processor. One of the reasons why a module cannot be loaded is if the
  819. * module does not have generated ISA for the hardware that it is loaded
  820. * onto. Multiple images can be loaded onto a single context at any single time.
  821. *
  822. * @param module (out) - handle to the loaded image. On error, module will be zero.
  823. * @param ctx (in) - context to load an image.
  824. * @param image (in) - raw image to load.
  825. *
  826. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  827. *
  828. * @sa calModuleUnload calModuleGetEntry calModuleGetName
  829. */
  830. CALAPI CALresult CALAPIENTRY calModuleLoad(CALmodule* module, CALcontext ctx, CALimage image);
  831. /**
  832. * @fn calModuleUnload(CALcontext ctx, CALmodule module)
  833. *
  834. * @brief Unload a kernel image
  835. *
  836. * unloads the module from the context.
  837. *
  838. * @param ctx (in) - context.
  839. * @param module (in) - handle to the loaded image.
  840. *
  841. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  842. *
  843. * @sa calModuleLoad calModuleGetEntry calModuleGetName
  844. */
  845. CALAPI CALresult CALAPIENTRY calModuleUnload(CALcontext ctx, CALmodule module);
  846. /**
  847. * @fn calModuleGetEntry(CALfunc* func, CALcontext ctx, CALmodule module, const CALchar* procName)
  848. *
  849. * @brief Retrieve a kernel function
  850. *
  851. * returns in <i>*func</i> the entry point to the kernel function named
  852. * <i>procName</i> from the module <i>module</i>. This method returns
  853. * CAL_RESULT_ERROR if the entry point <i>procName</i> is not found in the module.
  854. *
  855. * @param func (out) - handle to kernel function. On error, func will be zero.
  856. * @param ctx (in) - context.
  857. * @param module (in) - handle to the loaded image.
  858. * @param procName (in) - name of the function.
  859. *
  860. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  861. *
  862. * @sa calModuleLoad calModuleUnload calModuleGetEntry
  863. */
  864. CALAPI CALresult CALAPIENTRY calModuleGetEntry(CALfunc* func, CALcontext ctx, CALmodule module, const CALchar* procName);
  865. /**
  866. * @fn calModuleGetName(CALname* name, CALcontext ctx, CALmodule module, const CALchar* varName)
  867. *
  868. * @brief Retrieve a kernel parameter by name
  869. *
  870. * returns in <i>*name</i> the handle to the module global variable named
  871. * <i>varName</i> that can be used to setup inputs and constant buffers to
  872. * the kernel computation. This method returns CAL_RESULT_ERROR if the variable
  873. * <i>varName</i> is not found in the module.
  874. *
  875. * @param name (out) - handle to name symbol. On error, name will be zero.
  876. * @param ctx (in) - context.
  877. * @param module (in) - handle to the loaded image.
  878. * @param varName (in) - name of the input or output.
  879. *
  880. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  881. *
  882. * @sa calModuleLoad calModuleUnload calModuleGetEntry
  883. */
  884. CALAPI CALresult CALAPIENTRY calModuleGetName(CALname* name, CALcontext ctx, CALmodule module, const CALchar* varName);
  885. /*----------------------------------------------------------------------------
  886. * CAL Error/Debug Helper Functions
  887. *----------------------------------------------------------------------------*/
  888. /**
  889. * @fn calGetErrorString(void)
  890. *
  891. * @brief Return details about current error state
  892. *
  893. * calGetErrorString returns a text string containing details about the last
  894. * returned error condition. Calling calGetErrorString does not effect the
  895. * error state.
  896. *
  897. * @return Returns a null terminated string detailing the error condition
  898. *
  899. * @sa calInit calShutdown
  900. */
  901. CALAPI const CALchar* CALAPIENTRY calGetErrorString(void);
  902. /**
  903. * @fn calCtxRunProgramGrid(CALevent* event, CALcontext ctx, CALprogramGrid* pProgramGrid)
  904. *
  905. * @brief Invoke the kernel over the specified domain.
  906. *
  907. *
  908. * issues a task to invoke the computation of the kernel identified by
  909. * <i>func</i> within a region <i>domain</i> on the context <i>ctx</i> and
  910. * returns an associated event token in <i>*event</i> with this task. This
  911. * method returns CAL_RESULT_ERROR if <i>func</i> is not found in the currently
  912. * loaded module. This method returns CAL_RESULT_ERROR, if any of the inputs,
  913. * input references, outputs and constant buffers associated with the kernel
  914. * are not setup. Completion of this event can be queried by the master process
  915. * using <i>calIsEventDone</i>
  916. *
  917. * Extended contextual information regarding a calCtxRunProgram failure
  918. * can be obtained with the calGetErrorString function.
  919. *
  920. * @param event (out) - event associated with RunProgram instance. On error, event will be zero.
  921. * @param ctx (in) - context.
  922. * @param pProgramGrid (in) - description of program information to get kernel and thread counts.
  923. *
  924. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  925. *
  926. * @sa calCtxIsEventDone
  927. */
  928. CALAPI CALresult CALAPIENTRY calCtxRunProgramGrid(CALevent* event,
  929. CALcontext ctx,
  930. CALprogramGrid* pProgramGrid);
  931. /**
  932. * @fn calModuleGetFuncInfo(CALfuncInfo* pInfo, CALcontext ctx, CALmodule module, CALfunc func)
  933. *
  934. * @brief Retrieve information regarding the named func in the
  935. * named module.
  936. *
  937. * returns in <i>*info</i> the information regarding the func.
  938. * This method returns CAL_RESULT_NOT_INITIALIZED if CAL is not
  939. * initialied.
  940. * This method returns CAL_RESULT_INVALID_PARAMETER if info is
  941. * NULL.
  942. * This method returns CAL_RESULT_BAD_HANDLE if ctx is invalid
  943. * or module is not loaded or func is not found.
  944. * This method returns CAL_RESULT_ERROR if there was an error
  945. *
  946. * @param pInfo (out) - pointer to CALmoduleInfo output
  947. * structure.
  948. * @param ctx (in) - context.
  949. * @param module (in) - handle to the loaded image.
  950. * @param func (in) - name of the function.
  951. *
  952. * @return Returns CAL_RESULT_OK on success,
  953. * CAL_RESULT_NOT_INITIALIZED,
  954. * CAL_RESULT_INVALID_PARAMETER, CAL_RESULT_BAD_HANDLE,
  955. * or CAL_RESULT_ERROR if there was an error.
  956. *
  957. */
  958. CALAPI CALresult CALAPIENTRY calModuleGetFuncInfo(CALfuncInfo* pInfo,
  959. CALcontext ctx,
  960. CALmodule module,
  961. CALfunc func);
  962. /**
  963. * @fn calCtxRunProgramGridArray(CALevent* event, CALcontext ctx, CALprogramGridArray* pGridArray)
  964. *
  965. * @brief Invoke the kernel array over the specified domain(s).
  966. *
  967. *
  968. * issues a task to invoke the computation of the kernel arrays identified by
  969. * <i>func</i> within a region <i>domain</i> on the context <i>ctx</i> and
  970. * returns an associated event token in <i>*event</i> with this task. This
  971. * method returns CAL_RESULT_ERROR if <i>func</i> is not found in the currently
  972. * loaded module. This method returns CAL_RESULT_ERROR, if any of the inputs,
  973. * input references, outputs and constant buffers associated with the kernel
  974. * are not setup. Completion of this event can be queried by the master process
  975. * using <i>calIsEventDone</i>
  976. *
  977. * Extended contextual information regarding a calCtxRunProgram failure
  978. * can be obtained with the calGetErrorString function.
  979. *
  980. * @param event (out) - event associated with RunProgram instance. On error, event will be zero.
  981. * @param ctx (in) - context.
  982. * @param pGridArray (in) - array containing kernel programs and grid information.
  983. *
  984. * @return Returns CAL_RESULT_OK on success, CAL_RESULT_ERROR if there was an error.
  985. *
  986. * @sa calCtxIsEventDone
  987. */
  988. CALAPI CALresult CALAPIENTRY calCtxRunProgramGridArray(CALevent* event,
  989. CALcontext ctx,
  990. CALprogramGridArray* pGridArray);
  991. #ifdef __cplusplus
  992. } /* extern "C" { */
  993. #endif
  994. #endif /* __CAL_H__ */