hsa.h 183 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2014-2020 Advanced Micro Devices Inc. All rights reserved.
  4. //
  5. // Permission is hereby granted, free of charge, to any person or organization
  6. // obtaining a copy of the software and accompanying documentation covered by
  7. // this license (the "Software") to use, reproduce, display, distribute,
  8. // execute, and transmit the Software, and to prepare derivative works of the
  9. // Software, and to permit third-parties to whom the Software is furnished to
  10. // do so, all subject to the following:
  11. //
  12. // The copyright notices in the Software and this entire statement, including
  13. // the above license grant, this restriction and the following disclaimer,
  14. // must be included in all copies of the Software, in whole or in part, and
  15. // all derivative works of the Software, unless such copies or derivative
  16. // works are solely in the form of machine-executable object code generated by
  17. // a source language processor.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
  22. // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
  23. // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
  24. // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  25. // DEALINGS IN THE SOFTWARE.
  26. //
  27. ////////////////////////////////////////////////////////////////////////////////
  28. #ifndef HSA_RUNTIME_INC_HSA_H_
  29. #define HSA_RUNTIME_INC_HSA_H_
  30. #include <stddef.h> /* size_t */
  31. #include <stdint.h> /* uintXX_t */
  32. #ifndef __cplusplus
  33. #include <stdbool.h> /* bool */
  34. #endif /* __cplusplus */
  35. // Placeholder for calling convention and import/export macros
  36. #ifndef HSA_CALL
  37. #define HSA_CALL
  38. #endif
  39. #ifndef HSA_EXPORT_DECORATOR
  40. #ifdef __GNUC__
  41. #define HSA_EXPORT_DECORATOR __attribute__ ((visibility ("default")))
  42. #else
  43. #define HSA_EXPORT_DECORATOR
  44. #endif
  45. #endif
  46. #define HSA_API_EXPORT HSA_EXPORT_DECORATOR HSA_CALL
  47. #define HSA_API_IMPORT HSA_CALL
  48. #if !defined(HSA_API) && defined(HSA_EXPORT)
  49. #define HSA_API HSA_API_EXPORT
  50. #else
  51. #define HSA_API HSA_API_IMPORT
  52. #endif
  53. // Detect and set large model builds.
  54. #undef HSA_LARGE_MODEL
  55. #if defined(__LP64__) || defined(_M_X64)
  56. #define HSA_LARGE_MODEL
  57. #endif
  58. // Try to detect CPU endianness
  59. #if !defined(LITTLEENDIAN_CPU) && !defined(BIGENDIAN_CPU)
  60. #if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || \
  61. defined(_M_X64)
  62. #define LITTLEENDIAN_CPU
  63. #endif
  64. #endif
  65. #undef HSA_LITTLE_ENDIAN
  66. #if defined(LITTLEENDIAN_CPU)
  67. #define HSA_LITTLE_ENDIAN
  68. #elif defined(BIGENDIAN_CPU)
  69. #else
  70. #error "BIGENDIAN_CPU or LITTLEENDIAN_CPU must be defined"
  71. #endif
  72. #ifndef HSA_DEPRECATED
  73. #define HSA_DEPRECATED
  74. //#ifdef __GNUC__
  75. //#define HSA_DEPRECATED __attribute__((deprecated))
  76. //#else
  77. //#define HSA_DEPRECATED __declspec(deprecated)
  78. //#endif
  79. #endif
  80. #define HSA_VERSION_1_0 1
  81. #ifdef __cplusplus
  82. extern "C" {
  83. #endif /* __cplusplus */
  84. /** \defgroup status Runtime Notifications
  85. * @{
  86. */
  87. /**
  88. * @brief Status codes.
  89. */
  90. typedef enum {
  91. /**
  92. * The function has been executed successfully.
  93. */
  94. HSA_STATUS_SUCCESS = 0x0,
  95. /**
  96. * A traversal over a list of elements has been interrupted by the
  97. * application before completing.
  98. */
  99. HSA_STATUS_INFO_BREAK = 0x1,
  100. /**
  101. * A generic error has occurred.
  102. */
  103. HSA_STATUS_ERROR = 0x1000,
  104. /**
  105. * One of the actual arguments does not meet a precondition stated in the
  106. * documentation of the corresponding formal argument.
  107. */
  108. HSA_STATUS_ERROR_INVALID_ARGUMENT = 0x1001,
  109. /**
  110. * The requested queue creation is not valid.
  111. */
  112. HSA_STATUS_ERROR_INVALID_QUEUE_CREATION = 0x1002,
  113. /**
  114. * The requested allocation is not valid.
  115. */
  116. HSA_STATUS_ERROR_INVALID_ALLOCATION = 0x1003,
  117. /**
  118. * The agent is invalid.
  119. */
  120. HSA_STATUS_ERROR_INVALID_AGENT = 0x1004,
  121. /**
  122. * The memory region is invalid.
  123. */
  124. HSA_STATUS_ERROR_INVALID_REGION = 0x1005,
  125. /**
  126. * The signal is invalid.
  127. */
  128. HSA_STATUS_ERROR_INVALID_SIGNAL = 0x1006,
  129. /**
  130. * The queue is invalid.
  131. */
  132. HSA_STATUS_ERROR_INVALID_QUEUE = 0x1007,
  133. /**
  134. * The HSA runtime failed to allocate the necessary resources. This error
  135. * may also occur when the HSA runtime needs to spawn threads or create
  136. * internal OS-specific events.
  137. */
  138. HSA_STATUS_ERROR_OUT_OF_RESOURCES = 0x1008,
  139. /**
  140. * The AQL packet is malformed.
  141. */
  142. HSA_STATUS_ERROR_INVALID_PACKET_FORMAT = 0x1009,
  143. /**
  144. * An error has been detected while releasing a resource.
  145. */
  146. HSA_STATUS_ERROR_RESOURCE_FREE = 0x100A,
  147. /**
  148. * An API other than ::hsa_init has been invoked while the reference count
  149. * of the HSA runtime is 0.
  150. */
  151. HSA_STATUS_ERROR_NOT_INITIALIZED = 0x100B,
  152. /**
  153. * The maximum reference count for the object has been reached.
  154. */
  155. HSA_STATUS_ERROR_REFCOUNT_OVERFLOW = 0x100C,
  156. /**
  157. * The arguments passed to a functions are not compatible.
  158. */
  159. HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS = 0x100D,
  160. /**
  161. * The index is invalid.
  162. */
  163. HSA_STATUS_ERROR_INVALID_INDEX = 0x100E,
  164. /**
  165. * The instruction set architecture is invalid.
  166. */
  167. HSA_STATUS_ERROR_INVALID_ISA = 0x100F,
  168. /**
  169. * The instruction set architecture name is invalid.
  170. */
  171. HSA_STATUS_ERROR_INVALID_ISA_NAME = 0x1017,
  172. /**
  173. * The code object is invalid.
  174. */
  175. HSA_STATUS_ERROR_INVALID_CODE_OBJECT = 0x1010,
  176. /**
  177. * The executable is invalid.
  178. */
  179. HSA_STATUS_ERROR_INVALID_EXECUTABLE = 0x1011,
  180. /**
  181. * The executable is frozen.
  182. */
  183. HSA_STATUS_ERROR_FROZEN_EXECUTABLE = 0x1012,
  184. /**
  185. * There is no symbol with the given name.
  186. */
  187. HSA_STATUS_ERROR_INVALID_SYMBOL_NAME = 0x1013,
  188. /**
  189. * The variable is already defined.
  190. */
  191. HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED = 0x1014,
  192. /**
  193. * The variable is undefined.
  194. */
  195. HSA_STATUS_ERROR_VARIABLE_UNDEFINED = 0x1015,
  196. /**
  197. * An HSAIL operation resulted in a hardware exception.
  198. */
  199. HSA_STATUS_ERROR_EXCEPTION = 0x1016,
  200. /**
  201. * The code object symbol is invalid.
  202. */
  203. HSA_STATUS_ERROR_INVALID_CODE_SYMBOL = 0x1018,
  204. /**
  205. * The executable symbol is invalid.
  206. */
  207. HSA_STATUS_ERROR_INVALID_EXECUTABLE_SYMBOL = 0x1019,
  208. /**
  209. * The file descriptor is invalid.
  210. */
  211. HSA_STATUS_ERROR_INVALID_FILE = 0x1020,
  212. /**
  213. * The code object reader is invalid.
  214. */
  215. HSA_STATUS_ERROR_INVALID_CODE_OBJECT_READER = 0x1021,
  216. /**
  217. * The cache is invalid.
  218. */
  219. HSA_STATUS_ERROR_INVALID_CACHE = 0x1022,
  220. /**
  221. * The wavefront is invalid.
  222. */
  223. HSA_STATUS_ERROR_INVALID_WAVEFRONT = 0x1023,
  224. /**
  225. * The signal group is invalid.
  226. */
  227. HSA_STATUS_ERROR_INVALID_SIGNAL_GROUP = 0x1024,
  228. /**
  229. * The HSA runtime is not in the configuration state.
  230. */
  231. HSA_STATUS_ERROR_INVALID_RUNTIME_STATE = 0x1025,
  232. /**
  233. * The queue received an error that may require process termination.
  234. */
  235. HSA_STATUS_ERROR_FATAL = 0x1026
  236. } hsa_status_t;
  237. /**
  238. * @brief Query additional information about a status code.
  239. *
  240. * @param[in] status Status code.
  241. *
  242. * @param[out] status_string A NUL-terminated string that describes the error
  243. * status.
  244. *
  245. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  246. *
  247. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  248. * initialized.
  249. *
  250. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p status is an invalid
  251. * status code, or @p status_string is NULL.
  252. */
  253. hsa_status_t HSA_API hsa_status_string(
  254. hsa_status_t status,
  255. const char ** status_string);
  256. /** @} */
  257. /** \defgroup common Common Definitions
  258. * @{
  259. */
  260. /**
  261. * @brief Three-dimensional coordinate.
  262. */
  263. typedef struct hsa_dim3_s {
  264. /**
  265. * X dimension.
  266. */
  267. uint32_t x;
  268. /**
  269. * Y dimension.
  270. */
  271. uint32_t y;
  272. /**
  273. * Z dimension.
  274. */
  275. uint32_t z;
  276. } hsa_dim3_t;
  277. /**
  278. * @brief Access permissions.
  279. */
  280. typedef enum {
  281. /**
  282. * Read-only access.
  283. */
  284. HSA_ACCESS_PERMISSION_RO = 1,
  285. /**
  286. * Write-only access.
  287. */
  288. HSA_ACCESS_PERMISSION_WO = 2,
  289. /**
  290. * Read and write access.
  291. */
  292. HSA_ACCESS_PERMISSION_RW = 3
  293. } hsa_access_permission_t;
  294. /**
  295. * @brief POSIX file descriptor.
  296. */
  297. typedef int hsa_file_t;
  298. /** @} **/
  299. /** \defgroup initshutdown Initialization and Shut Down
  300. * @{
  301. */
  302. /**
  303. * @brief Initialize the HSA runtime.
  304. *
  305. * @details Initializes the HSA runtime if it is not already initialized, and
  306. * increases the reference counter associated with the HSA runtime for the
  307. * current process. Invocation of any HSA function other than ::hsa_init results
  308. * in undefined behavior if the current HSA runtime reference counter is less
  309. * than one.
  310. *
  311. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  312. *
  313. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
  314. * the required resources.
  315. *
  316. * @retval ::HSA_STATUS_ERROR_REFCOUNT_OVERFLOW The HSA runtime reference
  317. * count reaches INT32_MAX.
  318. */
  319. hsa_status_t HSA_API hsa_init();
  320. /**
  321. * @brief Shut down the HSA runtime.
  322. *
  323. * @details Decreases the reference count of the HSA runtime instance. When the
  324. * reference count reaches 0, the HSA runtime is no longer considered valid
  325. * but the application might call ::hsa_init to initialize the HSA runtime
  326. * again.
  327. *
  328. * Once the reference count of the HSA runtime reaches 0, all the resources
  329. * associated with it (queues, signals, agent information, etc.) are
  330. * considered invalid and any attempt to reference them in subsequent API calls
  331. * results in undefined behavior. When the reference count reaches 0, the HSA
  332. * runtime may release resources associated with it.
  333. *
  334. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  335. *
  336. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  337. * initialized.
  338. *
  339. */
  340. hsa_status_t HSA_API hsa_shut_down();
  341. /** @} **/
  342. /** \defgroup agentinfo System and Agent Information
  343. * @{
  344. */
  345. /**
  346. * @brief Endianness. A convention used to interpret the bytes making up a data
  347. * word.
  348. */
  349. typedef enum {
  350. /**
  351. * The least significant byte is stored in the smallest address.
  352. */
  353. HSA_ENDIANNESS_LITTLE = 0,
  354. /**
  355. * The most significant byte is stored in the smallest address.
  356. */
  357. HSA_ENDIANNESS_BIG = 1
  358. } hsa_endianness_t;
  359. /**
  360. * @brief Machine model. A machine model determines the size of certain data
  361. * types in HSA runtime and an agent.
  362. */
  363. typedef enum {
  364. /**
  365. * Small machine model. Addresses use 32 bits.
  366. */
  367. HSA_MACHINE_MODEL_SMALL = 0,
  368. /**
  369. * Large machine model. Addresses use 64 bits.
  370. */
  371. HSA_MACHINE_MODEL_LARGE = 1
  372. } hsa_machine_model_t;
  373. /**
  374. * @brief Profile. A profile indicates a particular level of feature
  375. * support. For example, in the base profile the application must use the HSA
  376. * runtime allocator to reserve shared virtual memory, while in the full profile
  377. * any host pointer can be shared across all the agents.
  378. */
  379. typedef enum {
  380. /**
  381. * Base profile.
  382. */
  383. HSA_PROFILE_BASE = 0,
  384. /**
  385. * Full profile.
  386. */
  387. HSA_PROFILE_FULL = 1
  388. } hsa_profile_t;
  389. /**
  390. * @brief System attributes.
  391. */
  392. typedef enum {
  393. /**
  394. * Major version of the HSA runtime specification supported by the
  395. * implementation. The type of this attribute is uint16_t.
  396. */
  397. HSA_SYSTEM_INFO_VERSION_MAJOR = 0,
  398. /**
  399. * Minor version of the HSA runtime specification supported by the
  400. * implementation. The type of this attribute is uint16_t.
  401. */
  402. HSA_SYSTEM_INFO_VERSION_MINOR = 1,
  403. /**
  404. * Current timestamp. The value of this attribute monotonically increases at a
  405. * constant rate. The type of this attribute is uint64_t.
  406. */
  407. HSA_SYSTEM_INFO_TIMESTAMP = 2,
  408. /**
  409. * Timestamp value increase rate, in Hz. The timestamp (clock) frequency is
  410. * in the range 1-400MHz. The type of this attribute is uint64_t.
  411. */
  412. HSA_SYSTEM_INFO_TIMESTAMP_FREQUENCY = 3,
  413. /**
  414. * Maximum duration of a signal wait operation. Expressed as a count based on
  415. * the timestamp frequency. The type of this attribute is uint64_t.
  416. */
  417. HSA_SYSTEM_INFO_SIGNAL_MAX_WAIT = 4,
  418. /**
  419. * Endianness of the system. The type of this attribute is ::hsa_endianness_t.
  420. */
  421. HSA_SYSTEM_INFO_ENDIANNESS = 5,
  422. /**
  423. * Machine model supported by the HSA runtime. The type of this attribute is
  424. * ::hsa_machine_model_t.
  425. */
  426. HSA_SYSTEM_INFO_MACHINE_MODEL = 6,
  427. /**
  428. * Bit-mask indicating which extensions are supported by the
  429. * implementation. An extension with an ID of @p i is supported if the bit at
  430. * position @p i is set. The type of this attribute is uint8_t[128].
  431. */
  432. HSA_SYSTEM_INFO_EXTENSIONS = 7,
  433. /**
  434. * String containing the ROCr build identifier.
  435. */
  436. HSA_AMD_SYSTEM_INFO_BUILD_VERSION = 0x200
  437. } hsa_system_info_t;
  438. /**
  439. * @brief Get the current value of a system attribute.
  440. *
  441. * @param[in] attribute Attribute to query.
  442. *
  443. * @param[out] value Pointer to an application-allocated buffer where to store
  444. * the value of the attribute. If the buffer passed by the application is not
  445. * large enough to hold the value of @p attribute, the behavior is undefined.
  446. *
  447. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  448. *
  449. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  450. * initialized.
  451. *
  452. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
  453. * system attribute, or @p value is NULL.
  454. */
  455. hsa_status_t HSA_API hsa_system_get_info(
  456. hsa_system_info_t attribute,
  457. void* value);
  458. /**
  459. * @brief HSA extensions.
  460. */
  461. typedef enum {
  462. /**
  463. * Finalizer extension.
  464. */
  465. HSA_EXTENSION_FINALIZER = 0,
  466. /**
  467. * Images extension.
  468. */
  469. HSA_EXTENSION_IMAGES = 1,
  470. /**
  471. * Performance counter extension.
  472. */
  473. HSA_EXTENSION_PERFORMANCE_COUNTERS = 2,
  474. /**
  475. * Profiling events extension.
  476. */
  477. HSA_EXTENSION_PROFILING_EVENTS = 3,
  478. /**
  479. * Extension count.
  480. */
  481. HSA_EXTENSION_STD_LAST = 3,
  482. /**
  483. * First AMD extension number.
  484. */
  485. HSA_AMD_FIRST_EXTENSION = 0x200,
  486. /**
  487. * Profiler extension.
  488. */
  489. HSA_EXTENSION_AMD_PROFILER = 0x200,
  490. /**
  491. * Loader extension.
  492. */
  493. HSA_EXTENSION_AMD_LOADER = 0x201,
  494. /**
  495. * AqlProfile extension.
  496. */
  497. HSA_EXTENSION_AMD_AQLPROFILE = 0x202,
  498. /**
  499. * Last AMD extension.
  500. */
  501. HSA_AMD_LAST_EXTENSION = 0x202
  502. } hsa_extension_t;
  503. /**
  504. * @brief Query the name of a given extension.
  505. *
  506. * @param[in] extension Extension identifier. If the extension is not supported
  507. * by the implementation (see ::HSA_SYSTEM_INFO_EXTENSIONS), the behavior
  508. * is undefined.
  509. *
  510. * @param[out] name Pointer to a memory location where the HSA runtime stores
  511. * the extension name. The extension name is a NUL-terminated string.
  512. *
  513. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  514. *
  515. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  516. * initialized.
  517. *
  518. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
  519. * extension, or @p name is NULL.
  520. */
  521. hsa_status_t HSA_API hsa_extension_get_name(
  522. uint16_t extension,
  523. const char **name);
  524. /**
  525. * @deprecated
  526. *
  527. * @brief Query if a given version of an extension is supported by the HSA
  528. * implementation.
  529. *
  530. * @param[in] extension Extension identifier.
  531. *
  532. * @param[in] version_major Major version number.
  533. *
  534. * @param[in] version_minor Minor version number.
  535. *
  536. * @param[out] result Pointer to a memory location where the HSA runtime stores
  537. * the result of the check. The result is true if the specified version of the
  538. * extension is supported, and false otherwise.
  539. *
  540. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  541. *
  542. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  543. * initialized.
  544. *
  545. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
  546. * extension, or @p result is NULL.
  547. */
  548. hsa_status_t HSA_API HSA_DEPRECATED hsa_system_extension_supported(
  549. uint16_t extension,
  550. uint16_t version_major,
  551. uint16_t version_minor,
  552. bool* result);
  553. /**
  554. * @brief Query if a given version of an extension is supported by the HSA
  555. * implementation. All minor versions from 0 up to the returned @p version_minor
  556. * must be supported by the implementation.
  557. *
  558. * @param[in] extension Extension identifier.
  559. *
  560. * @param[in] version_major Major version number.
  561. *
  562. * @param[out] version_minor Minor version number.
  563. *
  564. * @param[out] result Pointer to a memory location where the HSA runtime stores
  565. * the result of the check. The result is true if the specified version of the
  566. * extension is supported, and false otherwise.
  567. *
  568. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  569. *
  570. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  571. * initialized.
  572. *
  573. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
  574. * extension, or @p version_minor is NULL, or @p result is NULL.
  575. */
  576. hsa_status_t HSA_API hsa_system_major_extension_supported(
  577. uint16_t extension,
  578. uint16_t version_major,
  579. uint16_t *version_minor,
  580. bool* result);
  581. /**
  582. * @deprecated
  583. *
  584. * @brief Retrieve the function pointers corresponding to a given version of an
  585. * extension. Portable applications are expected to invoke the extension API
  586. * using the returned function pointers
  587. *
  588. * @details The application is responsible for verifying that the given version
  589. * of the extension is supported by the HSA implementation (see
  590. * ::hsa_system_extension_supported). If the given combination of extension,
  591. * major version, and minor version is not supported by the implementation, the
  592. * behavior is undefined.
  593. *
  594. * @param[in] extension Extension identifier.
  595. *
  596. * @param[in] version_major Major version number for which to retrieve the
  597. * function pointer table.
  598. *
  599. * @param[in] version_minor Minor version number for which to retrieve the
  600. * function pointer table.
  601. *
  602. * @param[out] table Pointer to an application-allocated function pointer table
  603. * that is populated by the HSA runtime. Must not be NULL. The memory associated
  604. * with table can be reused or freed after the function returns.
  605. *
  606. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  607. *
  608. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  609. * initialized.
  610. *
  611. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
  612. * extension, or @p table is NULL.
  613. */
  614. hsa_status_t HSA_API HSA_DEPRECATED hsa_system_get_extension_table(
  615. uint16_t extension,
  616. uint16_t version_major,
  617. uint16_t version_minor,
  618. void *table);
  619. /**
  620. * @brief Retrieve the function pointers corresponding to a given major version
  621. * of an extension. Portable applications are expected to invoke the extension
  622. * API using the returned function pointers.
  623. *
  624. * @details The application is responsible for verifying that the given major
  625. * version of the extension is supported by the HSA implementation (see
  626. * ::hsa_system_major_extension_supported). If the given combination of extension
  627. * and major version is not supported by the implementation, the behavior is
  628. * undefined. Additionally if the length doesn't allow space for a full minor
  629. * version, it is implementation defined if only some of the function pointers for
  630. * that minor version get written.
  631. *
  632. * @param[in] extension Extension identifier.
  633. *
  634. * @param[in] version_major Major version number for which to retrieve the
  635. * function pointer table.
  636. *
  637. * @param[in] table_length Size in bytes of the function pointer table to be
  638. * populated. The implementation will not write more than this many bytes to the
  639. * table.
  640. *
  641. * @param[out] table Pointer to an application-allocated function pointer table
  642. * that is populated by the HSA runtime. Must not be NULL. The memory associated
  643. * with table can be reused or freed after the function returns.
  644. *
  645. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  646. *
  647. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  648. * initialized.
  649. *
  650. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
  651. * extension, or @p table is NULL.
  652. */
  653. hsa_status_t HSA_API hsa_system_get_major_extension_table(
  654. uint16_t extension,
  655. uint16_t version_major,
  656. size_t table_length,
  657. void *table);
  658. /**
  659. * @brief Struct containing an opaque handle to an agent, a device that participates in
  660. * the HSA memory model. An agent can submit AQL packets for execution, and
  661. * may also accept AQL packets for execution (agent dispatch packets or kernel
  662. * dispatch packets launching HSAIL-derived binaries).
  663. */
  664. typedef struct hsa_agent_s {
  665. /**
  666. * Opaque handle. Two handles reference the same object of the enclosing type
  667. * if and only if they are equal.
  668. */
  669. uint64_t handle;
  670. } hsa_agent_t;
  671. /**
  672. * @brief Agent features.
  673. */
  674. typedef enum {
  675. /**
  676. * The agent supports AQL packets of kernel dispatch type. If this
  677. * feature is enabled, the agent is also a kernel agent.
  678. */
  679. HSA_AGENT_FEATURE_KERNEL_DISPATCH = 1,
  680. /**
  681. * The agent supports AQL packets of agent dispatch type.
  682. */
  683. HSA_AGENT_FEATURE_AGENT_DISPATCH = 2
  684. } hsa_agent_feature_t;
  685. /**
  686. * @brief Hardware device type.
  687. */
  688. typedef enum {
  689. /**
  690. * CPU device.
  691. */
  692. HSA_DEVICE_TYPE_CPU = 0,
  693. /**
  694. * GPU device.
  695. */
  696. HSA_DEVICE_TYPE_GPU = 1,
  697. /**
  698. * DSP device.
  699. */
  700. HSA_DEVICE_TYPE_DSP = 2
  701. } hsa_device_type_t;
  702. /**
  703. * @brief Default floating-point rounding mode.
  704. */
  705. typedef enum {
  706. /**
  707. * Use a default floating-point rounding mode specified elsewhere.
  708. */
  709. HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT = 0,
  710. /**
  711. * Operations that specify the default floating-point mode are rounded to zero
  712. * by default.
  713. */
  714. HSA_DEFAULT_FLOAT_ROUNDING_MODE_ZERO = 1,
  715. /**
  716. * Operations that specify the default floating-point mode are rounded to the
  717. * nearest representable number and that ties should be broken by selecting
  718. * the value with an even least significant bit.
  719. */
  720. HSA_DEFAULT_FLOAT_ROUNDING_MODE_NEAR = 2
  721. } hsa_default_float_rounding_mode_t;
  722. /**
  723. * @brief Agent attributes.
  724. */
  725. typedef enum {
  726. /**
  727. * Agent name. The type of this attribute is a NUL-terminated char[64]. The
  728. * name must be at most 63 characters long (not including the NUL terminator)
  729. * and all array elements not used for the name must be NUL.
  730. */
  731. HSA_AGENT_INFO_NAME = 0,
  732. /**
  733. * Name of vendor. The type of this attribute is a NUL-terminated char[64].
  734. * The name must be at most 63 characters long (not including the NUL
  735. * terminator) and all array elements not used for the name must be NUL.
  736. */
  737. HSA_AGENT_INFO_VENDOR_NAME = 1,
  738. /**
  739. * Agent capability. The type of this attribute is ::hsa_agent_feature_t.
  740. */
  741. HSA_AGENT_INFO_FEATURE = 2,
  742. /**
  743. * @deprecated Query ::HSA_ISA_INFO_MACHINE_MODELS for a given intruction set
  744. * architecture supported by the agent instead. If more than one ISA is
  745. * supported by the agent, the returned value corresponds to the first ISA
  746. * enumerated by ::hsa_agent_iterate_isas.
  747. *
  748. * Machine model supported by the agent. The type of this attribute is
  749. * ::hsa_machine_model_t.
  750. */
  751. HSA_AGENT_INFO_MACHINE_MODEL = 3,
  752. /**
  753. * @deprecated Query ::HSA_ISA_INFO_PROFILES for a given intruction set
  754. * architecture supported by the agent instead. If more than one ISA is
  755. * supported by the agent, the returned value corresponds to the first ISA
  756. * enumerated by ::hsa_agent_iterate_isas.
  757. *
  758. * Profile supported by the agent. The type of this attribute is
  759. * ::hsa_profile_t.
  760. */
  761. HSA_AGENT_INFO_PROFILE = 4,
  762. /**
  763. * @deprecated Query ::HSA_ISA_INFO_DEFAULT_FLOAT_ROUNDING_MODES for a given
  764. * intruction set architecture supported by the agent instead. If more than
  765. * one ISA is supported by the agent, the returned value corresponds to the
  766. * first ISA enumerated by ::hsa_agent_iterate_isas.
  767. *
  768. * Default floating-point rounding mode. The type of this attribute is
  769. * ::hsa_default_float_rounding_mode_t, but the value
  770. * ::HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT is not allowed.
  771. */
  772. HSA_AGENT_INFO_DEFAULT_FLOAT_ROUNDING_MODE = 5,
  773. /**
  774. * @deprecated Query ::HSA_ISA_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES
  775. * for a given intruction set architecture supported by the agent instead. If
  776. * more than one ISA is supported by the agent, the returned value corresponds
  777. * to the first ISA enumerated by ::hsa_agent_iterate_isas.
  778. *
  779. * A bit-mask of ::hsa_default_float_rounding_mode_t values, representing the
  780. * default floating-point rounding modes supported by the agent in the Base
  781. * profile. The type of this attribute is uint32_t. The default floating-point
  782. * rounding mode (::HSA_AGENT_INFO_DEFAULT_FLOAT_ROUNDING_MODE) bit must not
  783. * be set.
  784. */
  785. HSA_AGENT_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES = 23,
  786. /**
  787. * @deprecated Query ::HSA_ISA_INFO_FAST_F16_OPERATION for a given intruction
  788. * set architecture supported by the agent instead. If more than one ISA is
  789. * supported by the agent, the returned value corresponds to the first ISA
  790. * enumerated by ::hsa_agent_iterate_isas.
  791. *
  792. * Flag indicating that the f16 HSAIL operation is at least as fast as the
  793. * f32 operation in the current agent. The value of this attribute is
  794. * undefined if the agent is not a kernel agent. The type of this
  795. * attribute is bool.
  796. */
  797. HSA_AGENT_INFO_FAST_F16_OPERATION = 24,
  798. /**
  799. * @deprecated Query ::HSA_WAVEFRONT_INFO_SIZE for a given wavefront and
  800. * intruction set architecture supported by the agent instead. If more than
  801. * one ISA is supported by the agent, the returned value corresponds to the
  802. * first ISA enumerated by ::hsa_agent_iterate_isas and the first wavefront
  803. * enumerated by ::hsa_isa_iterate_wavefronts for that ISA.
  804. *
  805. * Number of work-items in a wavefront. Must be a power of 2 in the range
  806. * [1,256]. The value of this attribute is undefined if the agent is not
  807. * a kernel agent. The type of this attribute is uint32_t.
  808. */
  809. HSA_AGENT_INFO_WAVEFRONT_SIZE = 6,
  810. /**
  811. * @deprecated Query ::HSA_ISA_INFO_WORKGROUP_MAX_DIM for a given intruction
  812. * set architecture supported by the agent instead. If more than one ISA is
  813. * supported by the agent, the returned value corresponds to the first ISA
  814. * enumerated by ::hsa_agent_iterate_isas.
  815. *
  816. * Maximum number of work-items of each dimension of a work-group. Each
  817. * maximum must be greater than 0. No maximum can exceed the value of
  818. * ::HSA_AGENT_INFO_WORKGROUP_MAX_SIZE. The value of this attribute is
  819. * undefined if the agent is not a kernel agent. The type of this
  820. * attribute is uint16_t[3].
  821. */
  822. HSA_AGENT_INFO_WORKGROUP_MAX_DIM = 7,
  823. /**
  824. * @deprecated Query ::HSA_ISA_INFO_WORKGROUP_MAX_SIZE for a given intruction
  825. * set architecture supported by the agent instead. If more than one ISA is
  826. * supported by the agent, the returned value corresponds to the first ISA
  827. * enumerated by ::hsa_agent_iterate_isas.
  828. *
  829. * Maximum total number of work-items in a work-group. The value of this
  830. * attribute is undefined if the agent is not a kernel agent. The type
  831. * of this attribute is uint32_t.
  832. */
  833. HSA_AGENT_INFO_WORKGROUP_MAX_SIZE = 8,
  834. /**
  835. * @deprecated Query ::HSA_ISA_INFO_GRID_MAX_DIM for a given intruction set
  836. * architecture supported by the agent instead.
  837. *
  838. * Maximum number of work-items of each dimension of a grid. Each maximum must
  839. * be greater than 0, and must not be smaller than the corresponding value in
  840. * ::HSA_AGENT_INFO_WORKGROUP_MAX_DIM. No maximum can exceed the value of
  841. * ::HSA_AGENT_INFO_GRID_MAX_SIZE. The value of this attribute is undefined
  842. * if the agent is not a kernel agent. The type of this attribute is
  843. * ::hsa_dim3_t.
  844. */
  845. HSA_AGENT_INFO_GRID_MAX_DIM = 9,
  846. /**
  847. * @deprecated Query ::HSA_ISA_INFO_GRID_MAX_SIZE for a given intruction set
  848. * architecture supported by the agent instead. If more than one ISA is
  849. * supported by the agent, the returned value corresponds to the first ISA
  850. * enumerated by ::hsa_agent_iterate_isas.
  851. *
  852. * Maximum total number of work-items in a grid. The value of this attribute
  853. * is undefined if the agent is not a kernel agent. The type of this
  854. * attribute is uint32_t.
  855. */
  856. HSA_AGENT_INFO_GRID_MAX_SIZE = 10,
  857. /**
  858. * @deprecated Query ::HSA_ISA_INFO_FBARRIER_MAX_SIZE for a given intruction
  859. * set architecture supported by the agent instead. If more than one ISA is
  860. * supported by the agent, the returned value corresponds to the first ISA
  861. * enumerated by ::hsa_agent_iterate_isas.
  862. *
  863. * Maximum number of fbarriers per work-group. Must be at least 32. The value
  864. * of this attribute is undefined if the agent is not a kernel agent. The
  865. * type of this attribute is uint32_t.
  866. */
  867. HSA_AGENT_INFO_FBARRIER_MAX_SIZE = 11,
  868. /**
  869. * @deprecated The maximum number of queues is not statically determined.
  870. *
  871. * Maximum number of queues that can be active (created but not destroyed) at
  872. * one time in the agent. The type of this attribute is uint32_t.
  873. */
  874. HSA_AGENT_INFO_QUEUES_MAX = 12,
  875. /**
  876. * Minimum number of packets that a queue created in the agent
  877. * can hold. Must be a power of 2 greater than 0. Must not exceed
  878. * the value of ::HSA_AGENT_INFO_QUEUE_MAX_SIZE. The type of this
  879. * attribute is uint32_t.
  880. */
  881. HSA_AGENT_INFO_QUEUE_MIN_SIZE = 13,
  882. /**
  883. * Maximum number of packets that a queue created in the agent can
  884. * hold. Must be a power of 2 greater than 0. The type of this attribute
  885. * is uint32_t.
  886. */
  887. HSA_AGENT_INFO_QUEUE_MAX_SIZE = 14,
  888. /**
  889. * Type of a queue created in the agent. The type of this attribute is
  890. * ::hsa_queue_type32_t.
  891. */
  892. HSA_AGENT_INFO_QUEUE_TYPE = 15,
  893. /**
  894. * @deprecated NUMA information is not exposed anywhere else in the API.
  895. *
  896. * Identifier of the NUMA node associated with the agent. The type of this
  897. * attribute is uint32_t.
  898. */
  899. HSA_AGENT_INFO_NODE = 16,
  900. /**
  901. * Type of hardware device associated with the agent. The type of this
  902. * attribute is ::hsa_device_type_t.
  903. */
  904. HSA_AGENT_INFO_DEVICE = 17,
  905. /**
  906. * @deprecated Query ::hsa_agent_iterate_caches to retrieve information about
  907. * the caches present in a given agent.
  908. *
  909. * Array of data cache sizes (L1..L4). Each size is expressed in bytes. A size
  910. * of 0 for a particular level indicates that there is no cache information
  911. * for that level. The type of this attribute is uint32_t[4].
  912. */
  913. HSA_AGENT_INFO_CACHE_SIZE = 18,
  914. /**
  915. * @deprecated An agent may support multiple instruction set
  916. * architectures. See ::hsa_agent_iterate_isas. If more than one ISA is
  917. * supported by the agent, the returned value corresponds to the first ISA
  918. * enumerated by ::hsa_agent_iterate_isas.
  919. *
  920. * Instruction set architecture of the agent. The type of this attribute
  921. * is ::hsa_isa_t.
  922. */
  923. HSA_AGENT_INFO_ISA = 19,
  924. /**
  925. * Bit-mask indicating which extensions are supported by the agent. An
  926. * extension with an ID of @p i is supported if the bit at position @p i is
  927. * set. The type of this attribute is uint8_t[128].
  928. */
  929. HSA_AGENT_INFO_EXTENSIONS = 20,
  930. /**
  931. * Major version of the HSA runtime specification supported by the
  932. * agent. The type of this attribute is uint16_t.
  933. */
  934. HSA_AGENT_INFO_VERSION_MAJOR = 21,
  935. /**
  936. * Minor version of the HSA runtime specification supported by the
  937. * agent. The type of this attribute is uint16_t.
  938. */
  939. HSA_AGENT_INFO_VERSION_MINOR = 22
  940. } hsa_agent_info_t;
  941. /**
  942. * @brief Get the current value of an attribute for a given agent.
  943. *
  944. * @param[in] agent A valid agent.
  945. *
  946. * @param[in] attribute Attribute to query.
  947. *
  948. * @param[out] value Pointer to an application-allocated buffer where to store
  949. * the value of the attribute. If the buffer passed by the application is not
  950. * large enough to hold the value of @p attribute, the behavior is undefined.
  951. *
  952. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  953. *
  954. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  955. * initialized.
  956. *
  957. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  958. *
  959. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
  960. * agent attribute, or @p value is NULL.
  961. */
  962. hsa_status_t HSA_API hsa_agent_get_info(
  963. hsa_agent_t agent,
  964. hsa_agent_info_t attribute,
  965. void* value);
  966. /**
  967. * @brief Iterate over the available agents, and invoke an
  968. * application-defined callback on every iteration.
  969. *
  970. * @param[in] callback Callback to be invoked once per agent. The HSA
  971. * runtime passes two arguments to the callback: the agent and the
  972. * application data. If @p callback returns a status other than
  973. * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
  974. * ::hsa_iterate_agents returns that status value.
  975. *
  976. * @param[in] data Application data that is passed to @p callback on every
  977. * iteration. May be NULL.
  978. *
  979. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  980. *
  981. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  982. * initialized.
  983. *
  984. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
  985. */
  986. hsa_status_t HSA_API hsa_iterate_agents(
  987. hsa_status_t (*callback)(hsa_agent_t agent, void* data),
  988. void* data);
  989. /*
  990. // If we do not know the size of an attribute, we need to query it first
  991. // Note: this API will not be in the spec unless needed
  992. hsa_status_t HSA_API hsa_agent_get_info_size(
  993. hsa_agent_t agent,
  994. hsa_agent_info_t attribute,
  995. size_t* size);
  996. // Set the value of an agents attribute
  997. // Note: this API will not be in the spec unless needed
  998. hsa_status_t HSA_API hsa_agent_set_info(
  999. hsa_agent_t agent,
  1000. hsa_agent_info_t attribute,
  1001. void* value);
  1002. */
  1003. /**
  1004. * @brief Exception policies applied in the presence of hardware exceptions.
  1005. */
  1006. typedef enum {
  1007. /**
  1008. * If a hardware exception is detected, a work-item signals an exception.
  1009. */
  1010. HSA_EXCEPTION_POLICY_BREAK = 1,
  1011. /**
  1012. * If a hardware exception is detected, a hardware status bit is set.
  1013. */
  1014. HSA_EXCEPTION_POLICY_DETECT = 2
  1015. } hsa_exception_policy_t;
  1016. /**
  1017. * @deprecated Use ::hsa_isa_get_exception_policies for a given intruction set
  1018. * architecture supported by the agent instead. If more than one ISA is
  1019. * supported by the agent, this function uses the first value returned by
  1020. * ::hsa_agent_iterate_isas.
  1021. *
  1022. * @brief Retrieve the exception policy support for a given combination of
  1023. * agent and profile
  1024. *
  1025. * @param[in] agent Agent.
  1026. *
  1027. * @param[in] profile Profile.
  1028. *
  1029. * @param[out] mask Pointer to a memory location where the HSA runtime stores a
  1030. * mask of ::hsa_exception_policy_t values. Must not be NULL.
  1031. *
  1032. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1033. *
  1034. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  1035. * initialized.
  1036. *
  1037. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  1038. *
  1039. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p profile is not a valid
  1040. * profile, or @p mask is NULL.
  1041. *
  1042. */
  1043. hsa_status_t HSA_API HSA_DEPRECATED hsa_agent_get_exception_policies(
  1044. hsa_agent_t agent,
  1045. hsa_profile_t profile,
  1046. uint16_t *mask);
  1047. /**
  1048. * @brief Cache handle.
  1049. */
  1050. typedef struct hsa_cache_s {
  1051. /**
  1052. * Opaque handle. Two handles reference the same object of the enclosing type
  1053. * if and only if they are equal.
  1054. */
  1055. uint64_t handle;
  1056. } hsa_cache_t;
  1057. /**
  1058. * @brief Cache attributes.
  1059. */
  1060. typedef enum {
  1061. /**
  1062. * The length of the cache name in bytes, not including the NUL terminator.
  1063. * The type of this attribute is uint32_t.
  1064. */
  1065. HSA_CACHE_INFO_NAME_LENGTH = 0,
  1066. /**
  1067. * Human-readable description. The type of this attribute is a NUL-terminated
  1068. * character array with the length equal to the value of
  1069. * ::HSA_CACHE_INFO_NAME_LENGTH attribute.
  1070. */
  1071. HSA_CACHE_INFO_NAME = 1,
  1072. /**
  1073. * Cache level. A L1 cache must return a value of 1, a L2 must return a value
  1074. * of 2, and so on. The type of this attribute is uint8_t.
  1075. */
  1076. HSA_CACHE_INFO_LEVEL = 2,
  1077. /**
  1078. * Cache size, in bytes. A value of 0 indicates that there is no size
  1079. * information available. The type of this attribute is uint32_t.
  1080. */
  1081. HSA_CACHE_INFO_SIZE = 3
  1082. } hsa_cache_info_t;
  1083. /**
  1084. * @brief Get the current value of an attribute for a given cache object.
  1085. *
  1086. * @param[in] cache Cache.
  1087. *
  1088. * @param[in] attribute Attribute to query.
  1089. *
  1090. * @param[out] value Pointer to an application-allocated buffer where to store
  1091. * the value of the attribute. If the buffer passed by the application is not
  1092. * large enough to hold the value of @p attribute, the behavior is undefined.
  1093. *
  1094. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1095. *
  1096. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  1097. * initialized.
  1098. *
  1099. * @retval ::HSA_STATUS_ERROR_INVALID_CACHE The cache is invalid.
  1100. *
  1101. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
  1102. * instruction set architecture attribute, or @p value is
  1103. * NULL.
  1104. */
  1105. hsa_status_t HSA_API hsa_cache_get_info(
  1106. hsa_cache_t cache,
  1107. hsa_cache_info_t attribute,
  1108. void* value);
  1109. /**
  1110. * @brief Iterate over the memory caches of a given agent, and
  1111. * invoke an application-defined callback on every iteration.
  1112. *
  1113. * @details Caches are visited in ascending order according to the value of the
  1114. * ::HSA_CACHE_INFO_LEVEL attribute.
  1115. *
  1116. * @param[in] agent A valid agent.
  1117. *
  1118. * @param[in] callback Callback to be invoked once per cache that is present in
  1119. * the agent. The HSA runtime passes two arguments to the callback: the cache
  1120. * and the application data. If @p callback returns a status other than
  1121. * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
  1122. * that value is returned.
  1123. *
  1124. * @param[in] data Application data that is passed to @p callback on every
  1125. * iteration. May be NULL.
  1126. *
  1127. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1128. *
  1129. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  1130. * initialized.
  1131. *
  1132. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  1133. *
  1134. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
  1135. */
  1136. hsa_status_t HSA_API hsa_agent_iterate_caches(
  1137. hsa_agent_t agent,
  1138. hsa_status_t (*callback)(hsa_cache_t cache, void* data),
  1139. void* data);
  1140. /**
  1141. * @deprecated
  1142. *
  1143. * @brief Query if a given version of an extension is supported by an agent
  1144. *
  1145. * @param[in] extension Extension identifier.
  1146. *
  1147. * @param[in] agent Agent.
  1148. *
  1149. * @param[in] version_major Major version number.
  1150. *
  1151. * @param[in] version_minor Minor version number.
  1152. *
  1153. * @param[out] result Pointer to a memory location where the HSA runtime stores
  1154. * the result of the check. The result is true if the specified version of the
  1155. * extension is supported, and false otherwise. The result must be false if
  1156. * ::hsa_system_extension_supported returns false for the same extension
  1157. * version.
  1158. *
  1159. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1160. *
  1161. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  1162. * initialized.
  1163. *
  1164. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  1165. *
  1166. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
  1167. * extension, or @p result is NULL.
  1168. */
  1169. hsa_status_t HSA_API HSA_DEPRECATED hsa_agent_extension_supported(
  1170. uint16_t extension,
  1171. hsa_agent_t agent,
  1172. uint16_t version_major,
  1173. uint16_t version_minor,
  1174. bool* result);
  1175. /**
  1176. * @brief Query if a given version of an extension is supported by an agent. All
  1177. * minor versions from 0 up to the returned @p version_minor must be supported.
  1178. *
  1179. * @param[in] extension Extension identifier.
  1180. *
  1181. * @param[in] agent Agent.
  1182. *
  1183. * @param[in] version_major Major version number.
  1184. *
  1185. * @param[out] version_minor Minor version number.
  1186. *
  1187. * @param[out] result Pointer to a memory location where the HSA runtime stores
  1188. * the result of the check. The result is true if the specified version of the
  1189. * extension is supported, and false otherwise. The result must be false if
  1190. * ::hsa_system_extension_supported returns false for the same extension
  1191. * version.
  1192. *
  1193. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1194. *
  1195. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  1196. * initialized.
  1197. *
  1198. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  1199. *
  1200. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p extension is not a valid
  1201. * extension, or @p version_minor is NULL, or @p result is NULL.
  1202. */
  1203. hsa_status_t HSA_API hsa_agent_major_extension_supported(
  1204. uint16_t extension,
  1205. hsa_agent_t agent,
  1206. uint16_t version_major,
  1207. uint16_t *version_minor,
  1208. bool* result);
  1209. /** @} */
  1210. /** \defgroup signals Signals
  1211. * @{
  1212. */
  1213. /**
  1214. * @brief Signal handle.
  1215. */
  1216. typedef struct hsa_signal_s {
  1217. /**
  1218. * Opaque handle. Two handles reference the same object of the enclosing type
  1219. * if and only if they are equal. The value 0 is reserved.
  1220. */
  1221. uint64_t handle;
  1222. } hsa_signal_t;
  1223. /**
  1224. * @brief Signal value. The value occupies 32 bits in small machine mode, and 64
  1225. * bits in large machine mode.
  1226. */
  1227. #ifdef HSA_LARGE_MODEL
  1228. typedef int64_t hsa_signal_value_t;
  1229. #else
  1230. typedef int32_t hsa_signal_value_t;
  1231. #endif
  1232. /**
  1233. * @brief Create a signal.
  1234. *
  1235. * @param[in] initial_value Initial value of the signal.
  1236. *
  1237. * @param[in] num_consumers Size of @p consumers. A value of 0 indicates that
  1238. * any agent might wait on the signal.
  1239. *
  1240. * @param[in] consumers List of agents that might consume (wait on) the
  1241. * signal. If @p num_consumers is 0, this argument is ignored; otherwise, the
  1242. * HSA runtime might use the list to optimize the handling of the signal
  1243. * object. If an agent not listed in @p consumers waits on the returned
  1244. * signal, the behavior is undefined. The memory associated with @p consumers
  1245. * can be reused or freed after the function returns.
  1246. *
  1247. * @param[out] signal Pointer to a memory location where the HSA runtime will
  1248. * store the newly created signal handle. Must not be NULL.
  1249. *
  1250. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1251. *
  1252. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  1253. * initialized.
  1254. *
  1255. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
  1256. * the required resources.
  1257. *
  1258. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p signal is NULL, @p
  1259. * num_consumers is greater than 0 but @p consumers is NULL, or @p consumers
  1260. * contains duplicates.
  1261. */
  1262. hsa_status_t HSA_API hsa_signal_create(
  1263. hsa_signal_value_t initial_value,
  1264. uint32_t num_consumers,
  1265. const hsa_agent_t *consumers,
  1266. hsa_signal_t *signal);
  1267. /**
  1268. * @brief Destroy a signal previous created by ::hsa_signal_create.
  1269. *
  1270. * @param[in] signal Signal.
  1271. *
  1272. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1273. *
  1274. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  1275. * initialized.
  1276. *
  1277. * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL @p signal is invalid.
  1278. *
  1279. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT The handle in @p signal is 0.
  1280. */
  1281. hsa_status_t HSA_API hsa_signal_destroy(
  1282. hsa_signal_t signal);
  1283. /**
  1284. * @brief Atomically read the current value of a signal.
  1285. *
  1286. * @param[in] signal Signal.
  1287. *
  1288. * @return Value of the signal.
  1289. */
  1290. hsa_signal_value_t HSA_API hsa_signal_load_scacquire(
  1291. hsa_signal_t signal);
  1292. /**
  1293. * @copydoc hsa_signal_load_scacquire
  1294. */
  1295. hsa_signal_value_t HSA_API hsa_signal_load_relaxed(
  1296. hsa_signal_t signal);
  1297. /**
  1298. * @deprecated Renamed as ::hsa_signal_load_scacquire.
  1299. *
  1300. * @copydoc hsa_signal_load_scacquire
  1301. */
  1302. hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_load_acquire(
  1303. hsa_signal_t signal);
  1304. /**
  1305. * @brief Atomically set the value of a signal.
  1306. *
  1307. * @details If the value of the signal is changed, all the agents waiting
  1308. * on @p signal for which @p value satisfies their wait condition are awakened.
  1309. *
  1310. * @param[in] signal Signal.
  1311. *
  1312. * @param[in] value New signal value.
  1313. */
  1314. void HSA_API hsa_signal_store_relaxed(
  1315. hsa_signal_t signal,
  1316. hsa_signal_value_t value);
  1317. /**
  1318. * @copydoc hsa_signal_store_relaxed
  1319. */
  1320. void HSA_API hsa_signal_store_screlease(
  1321. hsa_signal_t signal,
  1322. hsa_signal_value_t value);
  1323. /**
  1324. * @deprecated Renamed as ::hsa_signal_store_screlease.
  1325. *
  1326. * @copydoc hsa_signal_store_screlease
  1327. */
  1328. void HSA_API HSA_DEPRECATED hsa_signal_store_release(
  1329. hsa_signal_t signal,
  1330. hsa_signal_value_t value);
  1331. /**
  1332. * @brief Atomically set the value of a signal without necessarily notifying the
  1333. * the agents waiting on it.
  1334. *
  1335. * @details The agents waiting on @p signal may not wake up even when the new
  1336. * value satisfies their wait condition. If the application wants to update the
  1337. * signal and there is no need to notify any agent, invoking this function can
  1338. * be more efficient than calling the non-silent counterpart.
  1339. *
  1340. * @param[in] signal Signal.
  1341. *
  1342. * @param[in] value New signal value.
  1343. */
  1344. void HSA_API hsa_signal_silent_store_relaxed(
  1345. hsa_signal_t signal,
  1346. hsa_signal_value_t value);
  1347. /**
  1348. * @copydoc hsa_signal_silent_store_relaxed
  1349. */
  1350. void HSA_API hsa_signal_silent_store_screlease(
  1351. hsa_signal_t signal,
  1352. hsa_signal_value_t value);
  1353. /**
  1354. * @brief Atomically set the value of a signal and return its previous value.
  1355. *
  1356. * @details If the value of the signal is changed, all the agents waiting
  1357. * on @p signal for which @p value satisfies their wait condition are awakened.
  1358. *
  1359. * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
  1360. * behavior is undefined.
  1361. *
  1362. * @param[in] value New value.
  1363. *
  1364. * @return Value of the signal prior to the exchange.
  1365. *
  1366. */
  1367. hsa_signal_value_t HSA_API hsa_signal_exchange_scacq_screl(
  1368. hsa_signal_t signal,
  1369. hsa_signal_value_t value);
  1370. /**
  1371. * @deprecated Renamed as ::hsa_signal_exchange_scacq_screl.
  1372. *
  1373. * @copydoc hsa_signal_exchange_scacq_screl
  1374. */
  1375. hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_exchange_acq_rel(
  1376. hsa_signal_t signal,
  1377. hsa_signal_value_t value);
  1378. /**
  1379. * @copydoc hsa_signal_exchange_scacq_screl
  1380. */
  1381. hsa_signal_value_t HSA_API hsa_signal_exchange_scacquire(
  1382. hsa_signal_t signal,
  1383. hsa_signal_value_t value);
  1384. /**
  1385. * @deprecated Renamed as ::hsa_signal_exchange_scacquire.
  1386. *
  1387. * @copydoc hsa_signal_exchange_scacquire
  1388. */
  1389. hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_exchange_acquire(
  1390. hsa_signal_t signal,
  1391. hsa_signal_value_t value);
  1392. /**
  1393. * @copydoc hsa_signal_exchange_scacq_screl
  1394. */
  1395. hsa_signal_value_t HSA_API hsa_signal_exchange_relaxed(
  1396. hsa_signal_t signal,
  1397. hsa_signal_value_t value);
  1398. /**
  1399. * @copydoc hsa_signal_exchange_scacq_screl
  1400. */
  1401. hsa_signal_value_t HSA_API hsa_signal_exchange_screlease(
  1402. hsa_signal_t signal,
  1403. hsa_signal_value_t value);
  1404. /**
  1405. * @deprecated Renamed as ::hsa_signal_exchange_screlease.
  1406. *
  1407. * @copydoc hsa_signal_exchange_screlease
  1408. */
  1409. hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_exchange_release(
  1410. hsa_signal_t signal,
  1411. hsa_signal_value_t value);
  1412. /**
  1413. * @brief Atomically set the value of a signal if the observed value is equal to
  1414. * the expected value. The observed value is returned regardless of whether the
  1415. * replacement was done.
  1416. *
  1417. * @details If the value of the signal is changed, all the agents waiting
  1418. * on @p signal for which @p value satisfies their wait condition are awakened.
  1419. *
  1420. * @param[in] signal Signal. If @p signal is a queue
  1421. * doorbell signal, the behavior is undefined.
  1422. *
  1423. * @param[in] expected Value to compare with.
  1424. *
  1425. * @param[in] value New value.
  1426. *
  1427. * @return Observed value of the signal.
  1428. *
  1429. */
  1430. hsa_signal_value_t HSA_API hsa_signal_cas_scacq_screl(
  1431. hsa_signal_t signal,
  1432. hsa_signal_value_t expected,
  1433. hsa_signal_value_t value);
  1434. /**
  1435. * @deprecated Renamed as ::hsa_signal_cas_scacq_screl.
  1436. *
  1437. * @copydoc hsa_signal_cas_scacq_screl
  1438. */
  1439. hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_cas_acq_rel(
  1440. hsa_signal_t signal,
  1441. hsa_signal_value_t expected,
  1442. hsa_signal_value_t value);
  1443. /**
  1444. * @copydoc hsa_signal_cas_scacq_screl
  1445. */
  1446. hsa_signal_value_t HSA_API hsa_signal_cas_scacquire(
  1447. hsa_signal_t signal,
  1448. hsa_signal_value_t expected,
  1449. hsa_signal_value_t value);
  1450. /**
  1451. * @deprecated Renamed as ::hsa_signal_cas_scacquire.
  1452. *
  1453. * @copydoc hsa_signal_cas_scacquire
  1454. */
  1455. hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_cas_acquire(
  1456. hsa_signal_t signal,
  1457. hsa_signal_value_t expected,
  1458. hsa_signal_value_t value);
  1459. /**
  1460. * @copydoc hsa_signal_cas_scacq_screl
  1461. */
  1462. hsa_signal_value_t HSA_API hsa_signal_cas_relaxed(
  1463. hsa_signal_t signal,
  1464. hsa_signal_value_t expected,
  1465. hsa_signal_value_t value);
  1466. /**
  1467. * @copydoc hsa_signal_cas_scacq_screl
  1468. */
  1469. hsa_signal_value_t HSA_API hsa_signal_cas_screlease(
  1470. hsa_signal_t signal,
  1471. hsa_signal_value_t expected,
  1472. hsa_signal_value_t value);
  1473. /**
  1474. * @deprecated Renamed as ::hsa_signal_cas_screlease.
  1475. *
  1476. * @copydoc hsa_signal_cas_screlease
  1477. */
  1478. hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_cas_release(
  1479. hsa_signal_t signal,
  1480. hsa_signal_value_t expected,
  1481. hsa_signal_value_t value);
  1482. /**
  1483. * @brief Atomically increment the value of a signal by a given amount.
  1484. *
  1485. * @details If the value of the signal is changed, all the agents waiting on
  1486. * @p signal for which @p value satisfies their wait condition are awakened.
  1487. *
  1488. * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
  1489. * behavior is undefined.
  1490. *
  1491. * @param[in] value Value to add to the value of the signal.
  1492. *
  1493. */
  1494. void HSA_API hsa_signal_add_scacq_screl(
  1495. hsa_signal_t signal,
  1496. hsa_signal_value_t value);
  1497. /**
  1498. * @deprecated Renamed as ::hsa_signal_add_scacq_screl.
  1499. *
  1500. * @copydoc hsa_signal_add_scacq_screl
  1501. */
  1502. void HSA_API HSA_DEPRECATED hsa_signal_add_acq_rel(
  1503. hsa_signal_t signal,
  1504. hsa_signal_value_t value);
  1505. /**
  1506. * @copydoc hsa_signal_add_scacq_screl
  1507. */
  1508. void HSA_API hsa_signal_add_scacquire(
  1509. hsa_signal_t signal,
  1510. hsa_signal_value_t value);
  1511. /**
  1512. * @deprecated Renamed as ::hsa_signal_add_scacquire.
  1513. *
  1514. * @copydoc hsa_signal_add_scacquire
  1515. */
  1516. void HSA_API HSA_DEPRECATED hsa_signal_add_acquire(
  1517. hsa_signal_t signal,
  1518. hsa_signal_value_t value);
  1519. /**
  1520. * @copydoc hsa_signal_add_scacq_screl
  1521. */
  1522. void HSA_API hsa_signal_add_relaxed(
  1523. hsa_signal_t signal,
  1524. hsa_signal_value_t value);
  1525. /**
  1526. * @copydoc hsa_signal_add_scacq_screl
  1527. */
  1528. void HSA_API hsa_signal_add_screlease(
  1529. hsa_signal_t signal,
  1530. hsa_signal_value_t value);
  1531. /**
  1532. * @deprecated Renamed as ::hsa_signal_add_screlease.
  1533. *
  1534. * @copydoc hsa_signal_add_screlease
  1535. */
  1536. void HSA_API HSA_DEPRECATED hsa_signal_add_release(
  1537. hsa_signal_t signal,
  1538. hsa_signal_value_t value);
  1539. /**
  1540. * @brief Atomically decrement the value of a signal by a given amount.
  1541. *
  1542. * @details If the value of the signal is changed, all the agents waiting on
  1543. * @p signal for which @p value satisfies their wait condition are awakened.
  1544. *
  1545. * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
  1546. * behavior is undefined.
  1547. *
  1548. * @param[in] value Value to subtract from the value of the signal.
  1549. *
  1550. */
  1551. void HSA_API hsa_signal_subtract_scacq_screl(
  1552. hsa_signal_t signal,
  1553. hsa_signal_value_t value);
  1554. /**
  1555. * @deprecated Renamed as ::hsa_signal_subtract_scacq_screl.
  1556. *
  1557. * @copydoc hsa_signal_subtract_scacq_screl
  1558. */
  1559. void HSA_API HSA_DEPRECATED hsa_signal_subtract_acq_rel(
  1560. hsa_signal_t signal,
  1561. hsa_signal_value_t value);
  1562. /**
  1563. * @copydoc hsa_signal_subtract_scacq_screl
  1564. */
  1565. void HSA_API hsa_signal_subtract_scacquire(
  1566. hsa_signal_t signal,
  1567. hsa_signal_value_t value);
  1568. /**
  1569. * @deprecated Renamed as ::hsa_signal_subtract_scacquire.
  1570. *
  1571. * @copydoc hsa_signal_subtract_scacquire
  1572. */
  1573. void HSA_API HSA_DEPRECATED hsa_signal_subtract_acquire(
  1574. hsa_signal_t signal,
  1575. hsa_signal_value_t value);
  1576. /**
  1577. * @copydoc hsa_signal_subtract_scacq_screl
  1578. */
  1579. void HSA_API hsa_signal_subtract_relaxed(
  1580. hsa_signal_t signal,
  1581. hsa_signal_value_t value);
  1582. /**
  1583. * @copydoc hsa_signal_subtract_scacq_screl
  1584. */
  1585. void HSA_API hsa_signal_subtract_screlease(
  1586. hsa_signal_t signal,
  1587. hsa_signal_value_t value);
  1588. /**
  1589. * @deprecated Renamed as ::hsa_signal_subtract_screlease.
  1590. *
  1591. * @copydoc hsa_signal_subtract_screlease
  1592. */
  1593. void HSA_API HSA_DEPRECATED hsa_signal_subtract_release(
  1594. hsa_signal_t signal,
  1595. hsa_signal_value_t value);
  1596. /**
  1597. * @brief Atomically perform a bitwise AND operation between the value of a
  1598. * signal and a given value.
  1599. *
  1600. * @details If the value of the signal is changed, all the agents waiting on
  1601. * @p signal for which @p value satisfies their wait condition are awakened.
  1602. *
  1603. * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
  1604. * behavior is undefined.
  1605. *
  1606. * @param[in] value Value to AND with the value of the signal.
  1607. *
  1608. */
  1609. void HSA_API hsa_signal_and_scacq_screl(
  1610. hsa_signal_t signal,
  1611. hsa_signal_value_t value);
  1612. /**
  1613. * @deprecated Renamed as ::hsa_signal_and_scacq_screl.
  1614. *
  1615. * @copydoc hsa_signal_and_scacq_screl
  1616. */
  1617. void HSA_API HSA_DEPRECATED hsa_signal_and_acq_rel(
  1618. hsa_signal_t signal,
  1619. hsa_signal_value_t value);
  1620. /**
  1621. * @copydoc hsa_signal_and_scacq_screl
  1622. */
  1623. void HSA_API hsa_signal_and_scacquire(
  1624. hsa_signal_t signal,
  1625. hsa_signal_value_t value);
  1626. /**
  1627. * @deprecated Renamed as ::hsa_signal_and_scacquire.
  1628. *
  1629. * @copydoc hsa_signal_and_scacquire
  1630. */
  1631. void HSA_API HSA_DEPRECATED hsa_signal_and_acquire(
  1632. hsa_signal_t signal,
  1633. hsa_signal_value_t value);
  1634. /**
  1635. * @copydoc hsa_signal_and_scacq_screl
  1636. */
  1637. void HSA_API hsa_signal_and_relaxed(
  1638. hsa_signal_t signal,
  1639. hsa_signal_value_t value);
  1640. /**
  1641. * @copydoc hsa_signal_and_scacq_screl
  1642. */
  1643. void HSA_API hsa_signal_and_screlease(
  1644. hsa_signal_t signal,
  1645. hsa_signal_value_t value);
  1646. /**
  1647. * @deprecated Renamed as ::hsa_signal_and_screlease.
  1648. *
  1649. * @copydoc hsa_signal_and_screlease
  1650. */
  1651. void HSA_API HSA_DEPRECATED hsa_signal_and_release(
  1652. hsa_signal_t signal,
  1653. hsa_signal_value_t value);
  1654. /**
  1655. * @brief Atomically perform a bitwise OR operation between the value of a
  1656. * signal and a given value.
  1657. *
  1658. * @details If the value of the signal is changed, all the agents waiting on
  1659. * @p signal for which @p value satisfies their wait condition are awakened.
  1660. *
  1661. * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
  1662. * behavior is undefined.
  1663. *
  1664. * @param[in] value Value to OR with the value of the signal.
  1665. */
  1666. void HSA_API hsa_signal_or_scacq_screl(
  1667. hsa_signal_t signal,
  1668. hsa_signal_value_t value);
  1669. /**
  1670. * @deprecated Renamed as ::hsa_signal_or_scacq_screl.
  1671. *
  1672. * @copydoc hsa_signal_or_scacq_screl
  1673. */
  1674. void HSA_API HSA_DEPRECATED hsa_signal_or_acq_rel(
  1675. hsa_signal_t signal,
  1676. hsa_signal_value_t value);
  1677. /**
  1678. * @copydoc hsa_signal_or_scacq_screl
  1679. */
  1680. void HSA_API hsa_signal_or_scacquire(
  1681. hsa_signal_t signal,
  1682. hsa_signal_value_t value);
  1683. /**
  1684. * @deprecated Renamed as ::hsa_signal_or_scacquire.
  1685. *
  1686. * @copydoc hsa_signal_or_scacquire
  1687. */
  1688. void HSA_API HSA_DEPRECATED hsa_signal_or_acquire(
  1689. hsa_signal_t signal,
  1690. hsa_signal_value_t value);
  1691. /**
  1692. * @copydoc hsa_signal_or_scacq_screl
  1693. */
  1694. void HSA_API hsa_signal_or_relaxed(
  1695. hsa_signal_t signal,
  1696. hsa_signal_value_t value);
  1697. /**
  1698. * @copydoc hsa_signal_or_scacq_screl
  1699. */
  1700. void HSA_API hsa_signal_or_screlease(
  1701. hsa_signal_t signal,
  1702. hsa_signal_value_t value);
  1703. /**
  1704. * @deprecated Renamed as ::hsa_signal_or_screlease.
  1705. *
  1706. * @copydoc hsa_signal_or_screlease
  1707. */
  1708. void HSA_API HSA_DEPRECATED hsa_signal_or_release(
  1709. hsa_signal_t signal,
  1710. hsa_signal_value_t value);
  1711. /**
  1712. * @brief Atomically perform a bitwise XOR operation between the value of a
  1713. * signal and a given value.
  1714. *
  1715. * @details If the value of the signal is changed, all the agents waiting on
  1716. * @p signal for which @p value satisfies their wait condition are awakened.
  1717. *
  1718. * @param[in] signal Signal. If @p signal is a queue doorbell signal, the
  1719. * behavior is undefined.
  1720. *
  1721. * @param[in] value Value to XOR with the value of the signal.
  1722. *
  1723. */
  1724. void HSA_API hsa_signal_xor_scacq_screl(
  1725. hsa_signal_t signal,
  1726. hsa_signal_value_t value);
  1727. /**
  1728. * @deprecated Renamed as ::hsa_signal_xor_scacq_screl.
  1729. *
  1730. * @copydoc hsa_signal_xor_scacq_screl
  1731. */
  1732. void HSA_API HSA_DEPRECATED hsa_signal_xor_acq_rel(
  1733. hsa_signal_t signal,
  1734. hsa_signal_value_t value);
  1735. /**
  1736. * @copydoc hsa_signal_xor_scacq_screl
  1737. */
  1738. void HSA_API hsa_signal_xor_scacquire(
  1739. hsa_signal_t signal,
  1740. hsa_signal_value_t value);
  1741. /**
  1742. * @deprecated Renamed as ::hsa_signal_xor_scacquire.
  1743. *
  1744. * @copydoc hsa_signal_xor_scacquire
  1745. */
  1746. void HSA_API HSA_DEPRECATED hsa_signal_xor_acquire(
  1747. hsa_signal_t signal,
  1748. hsa_signal_value_t value);
  1749. /**
  1750. * @copydoc hsa_signal_xor_scacq_screl
  1751. */
  1752. void HSA_API hsa_signal_xor_relaxed(
  1753. hsa_signal_t signal,
  1754. hsa_signal_value_t value);
  1755. /**
  1756. * @copydoc hsa_signal_xor_scacq_screl
  1757. */
  1758. void HSA_API hsa_signal_xor_screlease(
  1759. hsa_signal_t signal,
  1760. hsa_signal_value_t value);
  1761. /**
  1762. * @deprecated Renamed as ::hsa_signal_xor_screlease.
  1763. *
  1764. * @copydoc hsa_signal_xor_screlease
  1765. */
  1766. void HSA_API HSA_DEPRECATED hsa_signal_xor_release(
  1767. hsa_signal_t signal,
  1768. hsa_signal_value_t value);
  1769. /**
  1770. * @brief Wait condition operator.
  1771. */
  1772. typedef enum {
  1773. /**
  1774. * The two operands are equal.
  1775. */
  1776. HSA_SIGNAL_CONDITION_EQ = 0,
  1777. /**
  1778. * The two operands are not equal.
  1779. */
  1780. HSA_SIGNAL_CONDITION_NE = 1,
  1781. /**
  1782. * The first operand is less than the second operand.
  1783. */
  1784. HSA_SIGNAL_CONDITION_LT = 2,
  1785. /**
  1786. * The first operand is greater than or equal to the second operand.
  1787. */
  1788. HSA_SIGNAL_CONDITION_GTE = 3
  1789. } hsa_signal_condition_t;
  1790. /**
  1791. * @brief State of the application thread during a signal wait.
  1792. */
  1793. typedef enum {
  1794. /**
  1795. * The application thread may be rescheduled while waiting on the signal.
  1796. */
  1797. HSA_WAIT_STATE_BLOCKED = 0,
  1798. /**
  1799. * The application thread stays active while waiting on a signal.
  1800. */
  1801. HSA_WAIT_STATE_ACTIVE = 1
  1802. } hsa_wait_state_t;
  1803. /**
  1804. * @brief Wait until a signal value satisfies a specified condition, or a
  1805. * certain amount of time has elapsed.
  1806. *
  1807. * @details A wait operation can spuriously resume at any time sooner than the
  1808. * timeout (for example, due to system or other external factors) even when the
  1809. * condition has not been met.
  1810. *
  1811. * The function is guaranteed to return if the signal value satisfies the
  1812. * condition at some point in time during the wait, but the value returned to
  1813. * the application might not satisfy the condition. The application must ensure
  1814. * that signals are used in such way that wait wakeup conditions are not
  1815. * invalidated before dependent threads have woken up.
  1816. *
  1817. * When the wait operation internally loads the value of the passed signal, it
  1818. * uses the memory order indicated in the function name.
  1819. *
  1820. * @param[in] signal Signal.
  1821. *
  1822. * @param[in] condition Condition used to compare the signal value with @p
  1823. * compare_value.
  1824. *
  1825. * @param[in] compare_value Value to compare with.
  1826. *
  1827. * @param[in] timeout_hint Maximum duration of the wait. Specified in the same
  1828. * unit as the system timestamp. The operation might block for a shorter or
  1829. * longer time even if the condition is not met. A value of UINT64_MAX indicates
  1830. * no maximum.
  1831. *
  1832. * @param[in] wait_state_hint Hint used by the application to indicate the
  1833. * preferred waiting state. The actual waiting state is ultimately decided by
  1834. * HSA runtime and may not match the provided hint. A value of
  1835. * ::HSA_WAIT_STATE_ACTIVE may improve the latency of response to a signal
  1836. * update by avoiding rescheduling overhead.
  1837. *
  1838. * @return Observed value of the signal, which might not satisfy the specified
  1839. * condition.
  1840. *
  1841. */
  1842. hsa_signal_value_t HSA_API hsa_signal_wait_scacquire(
  1843. hsa_signal_t signal,
  1844. hsa_signal_condition_t condition,
  1845. hsa_signal_value_t compare_value,
  1846. uint64_t timeout_hint,
  1847. hsa_wait_state_t wait_state_hint);
  1848. /**
  1849. * @copydoc hsa_signal_wait_scacquire
  1850. */
  1851. hsa_signal_value_t HSA_API hsa_signal_wait_relaxed(
  1852. hsa_signal_t signal,
  1853. hsa_signal_condition_t condition,
  1854. hsa_signal_value_t compare_value,
  1855. uint64_t timeout_hint,
  1856. hsa_wait_state_t wait_state_hint);
  1857. /**
  1858. * @deprecated Renamed as ::hsa_signal_wait_scacquire.
  1859. *
  1860. * @copydoc hsa_signal_wait_scacquire
  1861. */
  1862. hsa_signal_value_t HSA_API HSA_DEPRECATED hsa_signal_wait_acquire(
  1863. hsa_signal_t signal,
  1864. hsa_signal_condition_t condition,
  1865. hsa_signal_value_t compare_value,
  1866. uint64_t timeout_hint,
  1867. hsa_wait_state_t wait_state_hint);
  1868. /**
  1869. * @brief Group of signals.
  1870. */
  1871. typedef struct hsa_signal_group_s {
  1872. /**
  1873. * Opaque handle. Two handles reference the same object of the enclosing type
  1874. * if and only if they are equal.
  1875. */
  1876. uint64_t handle;
  1877. } hsa_signal_group_t;
  1878. /**
  1879. * @brief Create a signal group.
  1880. *
  1881. * @param[in] num_signals Number of elements in @p signals. Must not be 0.
  1882. *
  1883. * @param[in] signals List of signals in the group. The list must not contain
  1884. * any repeated elements. Must not be NULL.
  1885. *
  1886. * @param[in] num_consumers Number of elements in @p consumers. Must not be 0.
  1887. *
  1888. * @param[in] consumers List of agents that might consume (wait on) the signal
  1889. * group. The list must not contain repeated elements, and must be a subset of
  1890. * the set of agents that are allowed to wait on all the signals in the
  1891. * group. If an agent not listed in @p consumers waits on the returned group,
  1892. * the behavior is undefined. The memory associated with @p consumers can be
  1893. * reused or freed after the function returns. Must not be NULL.
  1894. *
  1895. * @param[out] signal_group Pointer to newly created signal group. Must not be
  1896. * NULL.
  1897. *
  1898. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1899. *
  1900. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  1901. * initialized.
  1902. *
  1903. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
  1904. * the required resources.
  1905. *
  1906. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p num_signals is 0, @p signals
  1907. * is NULL, @p num_consumers is 0, @p consumers is NULL, or @p signal_group is
  1908. * NULL.
  1909. */
  1910. hsa_status_t HSA_API hsa_signal_group_create(
  1911. uint32_t num_signals,
  1912. const hsa_signal_t *signals,
  1913. uint32_t num_consumers,
  1914. const hsa_agent_t *consumers,
  1915. hsa_signal_group_t *signal_group);
  1916. /**
  1917. * @brief Destroy a signal group previous created by ::hsa_signal_group_create.
  1918. *
  1919. * @param[in] signal_group Signal group.
  1920. *
  1921. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1922. *
  1923. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  1924. * initialized.
  1925. *
  1926. * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL_GROUP @p signal_group is invalid.
  1927. */
  1928. hsa_status_t HSA_API hsa_signal_group_destroy(
  1929. hsa_signal_group_t signal_group);
  1930. /**
  1931. * @brief Wait until the value of at least one of the signals in a signal group
  1932. * satisfies its associated condition.
  1933. *
  1934. * @details The function is guaranteed to return if the value of at least one of
  1935. * the signals in the group satisfies its associated condition at some point in
  1936. * time during the wait, but the signal value returned to the application may no
  1937. * longer satisfy the condition. The application must ensure that signals in the
  1938. * group are used in such way that wait wakeup conditions are not invalidated
  1939. * before dependent threads have woken up.
  1940. *
  1941. * When this operation internally loads the value of the passed signal, it uses
  1942. * the memory order indicated in the function name.
  1943. *
  1944. * @param[in] signal_group Signal group.
  1945. *
  1946. * @param[in] conditions List of conditions. Each condition, and the value at
  1947. * the same index in @p compare_values, is used to compare the value of the
  1948. * signal at that index in @p signal_group (the signal passed by the application
  1949. * to ::hsa_signal_group_create at that particular index). The size of @p
  1950. * conditions must not be smaller than the number of signals in @p signal_group;
  1951. * any extra elements are ignored. Must not be NULL.
  1952. *
  1953. * @param[in] compare_values List of comparison values. The size of @p
  1954. * compare_values must not be smaller than the number of signals in @p
  1955. * signal_group; any extra elements are ignored. Must not be NULL.
  1956. *
  1957. * @param[in] wait_state_hint Hint used by the application to indicate the
  1958. * preferred waiting state. The actual waiting state is decided by the HSA runtime
  1959. * and may not match the provided hint. A value of ::HSA_WAIT_STATE_ACTIVE may
  1960. * improve the latency of response to a signal update by avoiding rescheduling
  1961. * overhead.
  1962. *
  1963. * @param[out] signal Signal in the group that satisfied the associated
  1964. * condition. If several signals satisfied their condition, the function can
  1965. * return any of those signals. Must not be NULL.
  1966. *
  1967. * @param[out] value Observed value for @p signal, which might no longer satisfy
  1968. * the specified condition. Must not be NULL.
  1969. *
  1970. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  1971. *
  1972. * @retval ::HSA_STATUS_ERROR_INVALID_SIGNAL_GROUP @p signal_group is invalid.
  1973. *
  1974. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p conditions is NULL, @p
  1975. * compare_values is NULL, @p signal is NULL, or @p value is NULL.
  1976. */
  1977. hsa_status_t HSA_API hsa_signal_group_wait_any_scacquire(
  1978. hsa_signal_group_t signal_group,
  1979. const hsa_signal_condition_t *conditions,
  1980. const hsa_signal_value_t *compare_values,
  1981. hsa_wait_state_t wait_state_hint,
  1982. hsa_signal_t *signal,
  1983. hsa_signal_value_t *value);
  1984. /**
  1985. * @copydoc hsa_signal_group_wait_any_scacquire
  1986. */
  1987. hsa_status_t HSA_API hsa_signal_group_wait_any_relaxed(
  1988. hsa_signal_group_t signal_group,
  1989. const hsa_signal_condition_t *conditions,
  1990. const hsa_signal_value_t *compare_values,
  1991. hsa_wait_state_t wait_state_hint,
  1992. hsa_signal_t *signal,
  1993. hsa_signal_value_t *value);
  1994. /** @} */
  1995. /** \defgroup memory Memory
  1996. * @{
  1997. */
  1998. /**
  1999. * @brief A memory region represents a block of virtual memory with certain
  2000. * properties. For example, the HSA runtime represents fine-grained memory in
  2001. * the global segment using a region. A region might be associated with more
  2002. * than one agent.
  2003. */
  2004. typedef struct hsa_region_s {
  2005. /**
  2006. * Opaque handle. Two handles reference the same object of the enclosing type
  2007. * if and only if they are equal.
  2008. */
  2009. uint64_t handle;
  2010. } hsa_region_t;
  2011. /** @} */
  2012. /** \defgroup queue Queues
  2013. * @{
  2014. */
  2015. /**
  2016. * @brief Queue type. Intended to be used for dynamic queue protocol
  2017. * determination.
  2018. */
  2019. typedef enum {
  2020. /**
  2021. * Queue supports multiple producers. Use of multiproducer queue mechanics is
  2022. * required.
  2023. */
  2024. HSA_QUEUE_TYPE_MULTI = 0,
  2025. /**
  2026. * Queue only supports a single producer. In some scenarios, the application
  2027. * may want to limit the submission of AQL packets to a single agent. Queues
  2028. * that support a single producer may be more efficient than queues supporting
  2029. * multiple producers. Use of multiproducer queue mechanics is not supported.
  2030. */
  2031. HSA_QUEUE_TYPE_SINGLE = 1,
  2032. /**
  2033. * Queue supports multiple producers and cooperative dispatches. Cooperative
  2034. * dispatches are able to use GWS synchronization. Queues of this type may be
  2035. * limited in number. The runtime may return the same queue to serve multiple
  2036. * ::hsa_queue_create calls when this type is given. Callers must inspect the
  2037. * returned queue to discover queue size. Queues of this type are reference
  2038. * counted and require a matching number of ::hsa_queue_destroy calls to
  2039. * release. Use of multiproducer queue mechanics is required. See
  2040. * ::HSA_AMD_AGENT_INFO_COOPERATIVE_QUEUES to query agent support for this
  2041. * type.
  2042. */
  2043. HSA_QUEUE_TYPE_COOPERATIVE = 2
  2044. } hsa_queue_type_t;
  2045. /**
  2046. * @brief A fixed-size type used to represent ::hsa_queue_type_t constants.
  2047. */
  2048. typedef uint32_t hsa_queue_type32_t;
  2049. /**
  2050. * @brief Queue features.
  2051. */
  2052. typedef enum {
  2053. /**
  2054. * Queue supports kernel dispatch packets.
  2055. */
  2056. HSA_QUEUE_FEATURE_KERNEL_DISPATCH = 1,
  2057. /**
  2058. * Queue supports agent dispatch packets.
  2059. */
  2060. HSA_QUEUE_FEATURE_AGENT_DISPATCH = 2
  2061. } hsa_queue_feature_t;
  2062. /**
  2063. * @brief User mode queue.
  2064. *
  2065. * @details The queue structure is read-only and allocated by the HSA runtime,
  2066. * but agents can directly modify the contents of the buffer pointed by @a
  2067. * base_address, or use HSA runtime APIs to access the doorbell signal.
  2068. *
  2069. */
  2070. typedef struct hsa_queue_s {
  2071. /**
  2072. * Queue type.
  2073. */
  2074. hsa_queue_type32_t type;
  2075. /**
  2076. * Queue features mask. This is a bit-field of ::hsa_queue_feature_t
  2077. * values. Applications should ignore any unknown set bits.
  2078. */
  2079. uint32_t features;
  2080. #ifdef HSA_LARGE_MODEL
  2081. void* base_address;
  2082. #elif defined HSA_LITTLE_ENDIAN
  2083. /**
  2084. * Starting address of the HSA runtime-allocated buffer used to store the AQL
  2085. * packets. Must be aligned to the size of an AQL packet.
  2086. */
  2087. void* base_address;
  2088. /**
  2089. * Reserved. Must be 0.
  2090. */
  2091. uint32_t reserved0;
  2092. #else
  2093. uint32_t reserved0;
  2094. void* base_address;
  2095. #endif
  2096. /**
  2097. * Signal object used by the application to indicate the ID of a packet that
  2098. * is ready to be processed. The HSA runtime manages the doorbell signal. If
  2099. * the application tries to replace or destroy this signal, the behavior is
  2100. * undefined.
  2101. *
  2102. * If @a type is ::HSA_QUEUE_TYPE_SINGLE, the doorbell signal value must be
  2103. * updated in a monotonically increasing fashion. If @a type is
  2104. * ::HSA_QUEUE_TYPE_MULTI, the doorbell signal value can be updated with any
  2105. * value.
  2106. */
  2107. hsa_signal_t doorbell_signal;
  2108. /**
  2109. * Maximum number of packets the queue can hold. Must be a power of 2.
  2110. */
  2111. uint32_t size;
  2112. /**
  2113. * Reserved. Must be 0.
  2114. */
  2115. uint32_t reserved1;
  2116. /**
  2117. * Queue identifier, which is unique over the lifetime of the application.
  2118. */
  2119. uint64_t id;
  2120. } hsa_queue_t;
  2121. /**
  2122. * @brief Create a user mode queue.
  2123. *
  2124. * @details The HSA runtime creates the queue structure, the underlying packet
  2125. * buffer, the completion signal, and the write and read indexes. The initial
  2126. * value of the write and read indexes is 0. The type of every packet in the
  2127. * buffer is initialized to ::HSA_PACKET_TYPE_INVALID.
  2128. *
  2129. * The application should only rely on the error code returned to determine if
  2130. * the queue is valid.
  2131. *
  2132. * @param[in] agent Agent where to create the queue.
  2133. *
  2134. * @param[in] size Number of packets the queue is expected to
  2135. * hold. Must be a power of 2 between 1 and the value of
  2136. * ::HSA_AGENT_INFO_QUEUE_MAX_SIZE in @p agent. The size of the newly
  2137. * created queue is the maximum of @p size and the value of
  2138. * ::HSA_AGENT_INFO_QUEUE_MIN_SIZE in @p agent.
  2139. *
  2140. * @param[in] type Type of the queue, a bitwise OR of hsa_queue_type_t values.
  2141. * If the value of ::HSA_AGENT_INFO_QUEUE_TYPE in @p agent is ::HSA_QUEUE_TYPE_SINGLE,
  2142. * then @p type must also be ::HSA_QUEUE_TYPE_SINGLE.
  2143. *
  2144. * @param[in] callback Callback invoked by the HSA runtime for every
  2145. * asynchronous event related to the newly created queue. May be NULL. The HSA
  2146. * runtime passes three arguments to the callback: a code identifying the event
  2147. * that triggered the invocation, a pointer to the queue where the event
  2148. * originated, and the application data.
  2149. *
  2150. * @param[in] data Application data that is passed to @p callback on every
  2151. * iteration. May be NULL.
  2152. *
  2153. * @param[in] private_segment_size Hint indicating the maximum
  2154. * expected private segment usage per work-item, in bytes. There may
  2155. * be performance degradation if the application places a kernel
  2156. * dispatch packet in the queue and the corresponding private segment
  2157. * usage exceeds @p private_segment_size. If the application does not
  2158. * want to specify any particular value for this argument, @p
  2159. * private_segment_size must be UINT32_MAX. If the queue does not
  2160. * support kernel dispatch packets, this argument is ignored.
  2161. *
  2162. * @param[in] group_segment_size Hint indicating the maximum expected
  2163. * group segment usage per work-group, in bytes. There may be
  2164. * performance degradation if the application places a kernel dispatch
  2165. * packet in the queue and the corresponding group segment usage
  2166. * exceeds @p group_segment_size. If the application does not want to
  2167. * specify any particular value for this argument, @p
  2168. * group_segment_size must be UINT32_MAX. If the queue does not
  2169. * support kernel dispatch packets, this argument is ignored.
  2170. *
  2171. * @param[out] queue Memory location where the HSA runtime stores a pointer to
  2172. * the newly created queue.
  2173. *
  2174. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  2175. *
  2176. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  2177. * initialized.
  2178. *
  2179. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
  2180. * the required resources.
  2181. *
  2182. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  2183. *
  2184. * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE_CREATION @p agent does not
  2185. * support queues of the given type.
  2186. *
  2187. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is not a power of two,
  2188. * @p size is 0, @p type is an invalid queue type, or @p queue is NULL.
  2189. *
  2190. */
  2191. hsa_status_t HSA_API hsa_queue_create(
  2192. hsa_agent_t agent,
  2193. uint32_t size,
  2194. hsa_queue_type32_t type,
  2195. void (*callback)(hsa_status_t status, hsa_queue_t *source, void *data),
  2196. void *data,
  2197. uint32_t private_segment_size,
  2198. uint32_t group_segment_size,
  2199. hsa_queue_t **queue);
  2200. /**
  2201. * @brief Create a queue for which the application or a kernel is responsible
  2202. * for processing the AQL packets.
  2203. *
  2204. * @details The application can use this function to create queues where AQL
  2205. * packets are not parsed by the packet processor associated with an agent,
  2206. * but rather by a unit of execution running on that agent (for example, a
  2207. * thread in the host application).
  2208. *
  2209. * The application is responsible for ensuring that all the producers and
  2210. * consumers of the resulting queue can access the provided doorbell signal
  2211. * and memory region. The application is also responsible for ensuring that the
  2212. * unit of execution processing the queue packets supports the indicated
  2213. * features (AQL packet types).
  2214. *
  2215. * When the queue is created, the HSA runtime allocates the packet buffer using
  2216. * @p region, and the write and read indexes. The initial value of the write and
  2217. * read indexes is 0, and the type of every packet in the buffer is initialized
  2218. * to ::HSA_PACKET_TYPE_INVALID. The value of the @e size, @e type, @e features,
  2219. * and @e doorbell_signal fields in the returned queue match the values passed
  2220. * by the application.
  2221. *
  2222. * @param[in] region Memory region that the HSA runtime should use to allocate
  2223. * the AQL packet buffer and any other queue metadata.
  2224. *
  2225. * @param[in] size Number of packets the queue is expected to hold. Must be a
  2226. * power of 2 greater than 0.
  2227. *
  2228. * @param[in] type Queue type.
  2229. *
  2230. * @param[in] features Supported queue features. This is a bit-field of
  2231. * ::hsa_queue_feature_t values.
  2232. *
  2233. * @param[in] doorbell_signal Doorbell signal that the HSA runtime must
  2234. * associate with the returned queue. The signal handle must not be 0.
  2235. *
  2236. * @param[out] queue Memory location where the HSA runtime stores a pointer to
  2237. * the newly created queue. The application should not rely on the value
  2238. * returned for this argument but only in the status code to determine if the
  2239. * queue is valid. Must not be NULL.
  2240. *
  2241. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  2242. *
  2243. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  2244. * initialized.
  2245. *
  2246. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
  2247. * the required resources.
  2248. *
  2249. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is not a power of two, @p
  2250. * size is 0, @p type is an invalid queue type, the doorbell signal handle is
  2251. * 0, or @p queue is NULL.
  2252. *
  2253. */
  2254. hsa_status_t HSA_API hsa_soft_queue_create(
  2255. hsa_region_t region,
  2256. uint32_t size,
  2257. hsa_queue_type32_t type,
  2258. uint32_t features,
  2259. hsa_signal_t doorbell_signal,
  2260. hsa_queue_t **queue);
  2261. /**
  2262. * @brief Destroy a user mode queue.
  2263. *
  2264. * @details When a queue is destroyed, the state of the AQL packets that have
  2265. * not been yet fully processed (their completion phase has not finished)
  2266. * becomes undefined. It is the responsibility of the application to ensure that
  2267. * all pending queue operations are finished if their results are required.
  2268. *
  2269. * The resources allocated by the HSA runtime during queue creation (queue
  2270. * structure, ring buffer, doorbell signal) are released. The queue should not
  2271. * be accessed after being destroyed.
  2272. *
  2273. * @param[in] queue Pointer to a queue created using ::hsa_queue_create.
  2274. *
  2275. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  2276. *
  2277. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  2278. * initialized.
  2279. *
  2280. * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE The queue is invalid.
  2281. *
  2282. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p queue is NULL.
  2283. */
  2284. hsa_status_t HSA_API hsa_queue_destroy(
  2285. hsa_queue_t *queue);
  2286. /**
  2287. * @brief Inactivate a queue.
  2288. *
  2289. * @details Inactivating the queue aborts any pending executions and prevent any
  2290. * new packets from being processed. Any more packets written to the queue once
  2291. * it is inactivated will be ignored by the packet processor.
  2292. *
  2293. * @param[in] queue Pointer to a queue.
  2294. *
  2295. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  2296. *
  2297. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  2298. * initialized.
  2299. *
  2300. * @retval ::HSA_STATUS_ERROR_INVALID_QUEUE The queue is invalid.
  2301. *
  2302. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p queue is NULL.
  2303. */
  2304. hsa_status_t HSA_API hsa_queue_inactivate(
  2305. hsa_queue_t *queue);
  2306. /**
  2307. * @deprecated Renamed as ::hsa_queue_load_read_index_scacquire.
  2308. *
  2309. * @copydoc hsa_queue_load_read_index_scacquire
  2310. */
  2311. uint64_t HSA_API HSA_DEPRECATED hsa_queue_load_read_index_acquire(
  2312. const hsa_queue_t *queue);
  2313. /**
  2314. * @brief Atomically load the read index of a queue.
  2315. *
  2316. * @param[in] queue Pointer to a queue.
  2317. *
  2318. * @return Read index of the queue pointed by @p queue.
  2319. */
  2320. uint64_t HSA_API hsa_queue_load_read_index_scacquire(
  2321. const hsa_queue_t *queue);
  2322. /**
  2323. * @copydoc hsa_queue_load_read_index_scacquire
  2324. */
  2325. uint64_t HSA_API hsa_queue_load_read_index_relaxed(
  2326. const hsa_queue_t *queue);
  2327. /**
  2328. * @deprecated Renamed as ::hsa_queue_load_write_index_scacquire.
  2329. *
  2330. * @copydoc hsa_queue_load_write_index_scacquire
  2331. */
  2332. uint64_t HSA_API HSA_DEPRECATED hsa_queue_load_write_index_acquire(
  2333. const hsa_queue_t *queue);
  2334. /**
  2335. * @brief Atomically load the write index of a queue.
  2336. *
  2337. * @param[in] queue Pointer to a queue.
  2338. *
  2339. * @return Write index of the queue pointed by @p queue.
  2340. */
  2341. uint64_t HSA_API hsa_queue_load_write_index_scacquire(
  2342. const hsa_queue_t *queue);
  2343. /**
  2344. * @copydoc hsa_queue_load_write_index_scacquire
  2345. */
  2346. uint64_t HSA_API hsa_queue_load_write_index_relaxed(
  2347. const hsa_queue_t *queue);
  2348. /**
  2349. * @brief Atomically set the write index of a queue.
  2350. *
  2351. * @details It is recommended that the application uses this function to update
  2352. * the write index when there is a single agent submitting work to the queue
  2353. * (the queue type is ::HSA_QUEUE_TYPE_SINGLE).
  2354. *
  2355. * @param[in] queue Pointer to a queue.
  2356. *
  2357. * @param[in] value Value to assign to the write index.
  2358. *
  2359. */
  2360. void HSA_API hsa_queue_store_write_index_relaxed(
  2361. const hsa_queue_t *queue,
  2362. uint64_t value);
  2363. /**
  2364. * @deprecated Renamed as ::hsa_queue_store_write_index_screlease.
  2365. *
  2366. * @copydoc hsa_queue_store_write_index_screlease
  2367. */
  2368. void HSA_API HSA_DEPRECATED hsa_queue_store_write_index_release(
  2369. const hsa_queue_t *queue,
  2370. uint64_t value);
  2371. /**
  2372. * @copydoc hsa_queue_store_write_index_relaxed
  2373. */
  2374. void HSA_API hsa_queue_store_write_index_screlease(
  2375. const hsa_queue_t *queue,
  2376. uint64_t value);
  2377. /**
  2378. * @deprecated Renamed as ::hsa_queue_cas_write_index_scacq_screl.
  2379. *
  2380. * @copydoc hsa_queue_cas_write_index_scacq_screl
  2381. */
  2382. uint64_t HSA_API HSA_DEPRECATED hsa_queue_cas_write_index_acq_rel(
  2383. const hsa_queue_t *queue,
  2384. uint64_t expected,
  2385. uint64_t value);
  2386. /**
  2387. * @brief Atomically set the write index of a queue if the observed value is
  2388. * equal to the expected value. The application can inspect the returned value
  2389. * to determine if the replacement was done.
  2390. *
  2391. * @param[in] queue Pointer to a queue.
  2392. *
  2393. * @param[in] expected Expected value.
  2394. *
  2395. * @param[in] value Value to assign to the write index if @p expected matches
  2396. * the observed write index. Must be greater than @p expected.
  2397. *
  2398. * @return Previous value of the write index.
  2399. */
  2400. uint64_t HSA_API hsa_queue_cas_write_index_scacq_screl(
  2401. const hsa_queue_t *queue,
  2402. uint64_t expected,
  2403. uint64_t value);
  2404. /**
  2405. * @deprecated Renamed as ::hsa_queue_cas_write_index_scacquire.
  2406. *
  2407. * @copydoc hsa_queue_cas_write_index_scacquire
  2408. */
  2409. uint64_t HSA_API HSA_DEPRECATED hsa_queue_cas_write_index_acquire(
  2410. const hsa_queue_t *queue,
  2411. uint64_t expected,
  2412. uint64_t value);
  2413. /**
  2414. * @copydoc hsa_queue_cas_write_index_scacq_screl
  2415. */
  2416. uint64_t HSA_API hsa_queue_cas_write_index_scacquire(
  2417. const hsa_queue_t *queue,
  2418. uint64_t expected,
  2419. uint64_t value);
  2420. /**
  2421. * @copydoc hsa_queue_cas_write_index_scacq_screl
  2422. */
  2423. uint64_t HSA_API hsa_queue_cas_write_index_relaxed(
  2424. const hsa_queue_t *queue,
  2425. uint64_t expected,
  2426. uint64_t value);
  2427. /**
  2428. * @deprecated Renamed as ::hsa_queue_cas_write_index_screlease.
  2429. *
  2430. * @copydoc hsa_queue_cas_write_index_screlease
  2431. */
  2432. uint64_t HSA_API HSA_DEPRECATED hsa_queue_cas_write_index_release(
  2433. const hsa_queue_t *queue,
  2434. uint64_t expected,
  2435. uint64_t value);
  2436. /**
  2437. * @copydoc hsa_queue_cas_write_index_scacq_screl
  2438. */
  2439. uint64_t HSA_API hsa_queue_cas_write_index_screlease(
  2440. const hsa_queue_t *queue,
  2441. uint64_t expected,
  2442. uint64_t value);
  2443. /**
  2444. * @deprecated Renamed as ::hsa_queue_add_write_index_scacq_screl.
  2445. *
  2446. * @copydoc hsa_queue_add_write_index_scacq_screl
  2447. */
  2448. uint64_t HSA_API HSA_DEPRECATED hsa_queue_add_write_index_acq_rel(
  2449. const hsa_queue_t *queue,
  2450. uint64_t value);
  2451. /**
  2452. * @brief Atomically increment the write index of a queue by an offset.
  2453. *
  2454. * @param[in] queue Pointer to a queue.
  2455. *
  2456. * @param[in] value Value to add to the write index.
  2457. *
  2458. * @return Previous value of the write index.
  2459. */
  2460. uint64_t HSA_API hsa_queue_add_write_index_scacq_screl(
  2461. const hsa_queue_t *queue,
  2462. uint64_t value);
  2463. /**
  2464. * @deprecated Renamed as ::hsa_queue_add_write_index_scacquire.
  2465. *
  2466. * @copydoc hsa_queue_add_write_index_scacquire
  2467. */
  2468. uint64_t HSA_API HSA_DEPRECATED hsa_queue_add_write_index_acquire(
  2469. const hsa_queue_t *queue,
  2470. uint64_t value);
  2471. /**
  2472. * @copydoc hsa_queue_add_write_index_scacq_screl
  2473. */
  2474. uint64_t HSA_API hsa_queue_add_write_index_scacquire(
  2475. const hsa_queue_t *queue,
  2476. uint64_t value);
  2477. /**
  2478. * @copydoc hsa_queue_add_write_index_scacq_screl
  2479. */
  2480. uint64_t HSA_API hsa_queue_add_write_index_relaxed(
  2481. const hsa_queue_t *queue,
  2482. uint64_t value);
  2483. /**
  2484. * @deprecated Renamed as ::hsa_queue_add_write_index_screlease.
  2485. *
  2486. * @copydoc hsa_queue_add_write_index_screlease
  2487. */
  2488. uint64_t HSA_API HSA_DEPRECATED hsa_queue_add_write_index_release(
  2489. const hsa_queue_t *queue,
  2490. uint64_t value);
  2491. /**
  2492. * @copydoc hsa_queue_add_write_index_scacq_screl
  2493. */
  2494. uint64_t HSA_API hsa_queue_add_write_index_screlease(
  2495. const hsa_queue_t *queue,
  2496. uint64_t value);
  2497. /**
  2498. * @brief Atomically set the read index of a queue.
  2499. *
  2500. * @details Modifications of the read index are not allowed and result in
  2501. * undefined behavior if the queue is associated with an agent for which
  2502. * only the corresponding packet processor is permitted to update the read
  2503. * index.
  2504. *
  2505. * @param[in] queue Pointer to a queue.
  2506. *
  2507. * @param[in] value Value to assign to the read index.
  2508. *
  2509. */
  2510. void HSA_API hsa_queue_store_read_index_relaxed(
  2511. const hsa_queue_t *queue,
  2512. uint64_t value);
  2513. /**
  2514. * @deprecated Renamed as ::hsa_queue_store_read_index_screlease.
  2515. *
  2516. * @copydoc hsa_queue_store_read_index_screlease
  2517. */
  2518. void HSA_API HSA_DEPRECATED hsa_queue_store_read_index_release(
  2519. const hsa_queue_t *queue,
  2520. uint64_t value);
  2521. /**
  2522. * @copydoc hsa_queue_store_read_index_relaxed
  2523. */
  2524. void HSA_API hsa_queue_store_read_index_screlease(
  2525. const hsa_queue_t *queue,
  2526. uint64_t value);
  2527. /** @} */
  2528. /** \defgroup aql Architected Queuing Language
  2529. * @{
  2530. */
  2531. /**
  2532. * @brief Packet type.
  2533. */
  2534. typedef enum {
  2535. /**
  2536. * Vendor-specific packet.
  2537. */
  2538. HSA_PACKET_TYPE_VENDOR_SPECIFIC = 0,
  2539. /**
  2540. * The packet has been processed in the past, but has not been reassigned to
  2541. * the packet processor. A packet processor must not process a packet of this
  2542. * type. All queues support this packet type.
  2543. */
  2544. HSA_PACKET_TYPE_INVALID = 1,
  2545. /**
  2546. * Packet used by agents for dispatching jobs to kernel agents. Not all
  2547. * queues support packets of this type (see ::hsa_queue_feature_t).
  2548. */
  2549. HSA_PACKET_TYPE_KERNEL_DISPATCH = 2,
  2550. /**
  2551. * Packet used by agents to delay processing of subsequent packets, and to
  2552. * express complex dependencies between multiple packets. All queues support
  2553. * this packet type.
  2554. */
  2555. HSA_PACKET_TYPE_BARRIER_AND = 3,
  2556. /**
  2557. * Packet used by agents for dispatching jobs to agents. Not all
  2558. * queues support packets of this type (see ::hsa_queue_feature_t).
  2559. */
  2560. HSA_PACKET_TYPE_AGENT_DISPATCH = 4,
  2561. /**
  2562. * Packet used by agents to delay processing of subsequent packets, and to
  2563. * express complex dependencies between multiple packets. All queues support
  2564. * this packet type.
  2565. */
  2566. HSA_PACKET_TYPE_BARRIER_OR = 5
  2567. } hsa_packet_type_t;
  2568. /**
  2569. * @brief Scope of the memory fence operation associated with a packet.
  2570. */
  2571. typedef enum {
  2572. /**
  2573. * No scope (no fence is applied). The packet relies on external fences to
  2574. * ensure visibility of memory updates.
  2575. */
  2576. HSA_FENCE_SCOPE_NONE = 0,
  2577. /**
  2578. * The fence is applied with agent scope for the global segment.
  2579. */
  2580. HSA_FENCE_SCOPE_AGENT = 1,
  2581. /**
  2582. * The fence is applied across both agent and system scope for the global
  2583. * segment.
  2584. */
  2585. HSA_FENCE_SCOPE_SYSTEM = 2
  2586. } hsa_fence_scope_t;
  2587. /**
  2588. * @brief Sub-fields of the @a header field that is present in any AQL
  2589. * packet. The offset (with respect to the address of @a header) of a sub-field
  2590. * is identical to its enumeration constant. The width of each sub-field is
  2591. * determined by the corresponding value in ::hsa_packet_header_width_t. The
  2592. * offset and the width are expressed in bits.
  2593. */
  2594. typedef enum {
  2595. /**
  2596. * Packet type. The value of this sub-field must be one of
  2597. * ::hsa_packet_type_t. If the type is ::HSA_PACKET_TYPE_VENDOR_SPECIFIC, the
  2598. * packet layout is vendor-specific.
  2599. */
  2600. HSA_PACKET_HEADER_TYPE = 0,
  2601. /**
  2602. * Barrier bit. If the barrier bit is set, the processing of the current
  2603. * packet only launches when all preceding packets (within the same queue) are
  2604. * complete.
  2605. */
  2606. HSA_PACKET_HEADER_BARRIER = 8,
  2607. /**
  2608. * Acquire fence scope. The value of this sub-field determines the scope and
  2609. * type of the memory fence operation applied before the packet enters the
  2610. * active phase. An acquire fence ensures that any subsequent global segment
  2611. * or image loads by any unit of execution that belongs to a dispatch that has
  2612. * not yet entered the active phase on any queue of the same kernel agent,
  2613. * sees any data previously released at the scopes specified by the acquire
  2614. * fence. The value of this sub-field must be one of ::hsa_fence_scope_t.
  2615. */
  2616. HSA_PACKET_HEADER_SCACQUIRE_FENCE_SCOPE = 9,
  2617. /**
  2618. * @deprecated Renamed as ::HSA_PACKET_HEADER_SCACQUIRE_FENCE_SCOPE.
  2619. */
  2620. HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE = 9,
  2621. /**
  2622. * Release fence scope, The value of this sub-field determines the scope and
  2623. * type of the memory fence operation applied after kernel completion but
  2624. * before the packet is completed. A release fence makes any global segment or
  2625. * image data that was stored by any unit of execution that belonged to a
  2626. * dispatch that has completed the active phase on any queue of the same
  2627. * kernel agent visible in all the scopes specified by the release fence. The
  2628. * value of this sub-field must be one of ::hsa_fence_scope_t.
  2629. */
  2630. HSA_PACKET_HEADER_SCRELEASE_FENCE_SCOPE = 11,
  2631. /**
  2632. * @deprecated Renamed as ::HSA_PACKET_HEADER_SCRELEASE_FENCE_SCOPE.
  2633. */
  2634. HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE = 11
  2635. } hsa_packet_header_t;
  2636. /**
  2637. * @brief Width (in bits) of the sub-fields in ::hsa_packet_header_t.
  2638. */
  2639. typedef enum {
  2640. HSA_PACKET_HEADER_WIDTH_TYPE = 8,
  2641. HSA_PACKET_HEADER_WIDTH_BARRIER = 1,
  2642. HSA_PACKET_HEADER_WIDTH_SCACQUIRE_FENCE_SCOPE = 2,
  2643. /**
  2644. * @deprecated Use HSA_PACKET_HEADER_WIDTH_SCACQUIRE_FENCE_SCOPE.
  2645. */
  2646. HSA_PACKET_HEADER_WIDTH_ACQUIRE_FENCE_SCOPE = 2,
  2647. HSA_PACKET_HEADER_WIDTH_SCRELEASE_FENCE_SCOPE = 2,
  2648. /**
  2649. * @deprecated Use HSA_PACKET_HEADER_WIDTH_SCRELEASE_FENCE_SCOPE.
  2650. */
  2651. HSA_PACKET_HEADER_WIDTH_RELEASE_FENCE_SCOPE = 2
  2652. } hsa_packet_header_width_t;
  2653. /**
  2654. * @brief Sub-fields of the kernel dispatch packet @a setup field. The offset
  2655. * (with respect to the address of @a setup) of a sub-field is identical to its
  2656. * enumeration constant. The width of each sub-field is determined by the
  2657. * corresponding value in ::hsa_kernel_dispatch_packet_setup_width_t. The
  2658. * offset and the width are expressed in bits.
  2659. */
  2660. typedef enum {
  2661. /**
  2662. * Number of dimensions of the grid. Valid values are 1, 2, or 3.
  2663. *
  2664. */
  2665. HSA_KERNEL_DISPATCH_PACKET_SETUP_DIMENSIONS = 0
  2666. } hsa_kernel_dispatch_packet_setup_t;
  2667. /**
  2668. * @brief Width (in bits) of the sub-fields in
  2669. * ::hsa_kernel_dispatch_packet_setup_t.
  2670. */
  2671. typedef enum {
  2672. HSA_KERNEL_DISPATCH_PACKET_SETUP_WIDTH_DIMENSIONS = 2
  2673. } hsa_kernel_dispatch_packet_setup_width_t;
  2674. /**
  2675. * @brief AQL kernel dispatch packet
  2676. */
  2677. typedef struct hsa_kernel_dispatch_packet_s {
  2678. /**
  2679. * Packet header. Used to configure multiple packet parameters such as the
  2680. * packet type. The parameters are described by ::hsa_packet_header_t.
  2681. */
  2682. uint16_t header;
  2683. /**
  2684. * Dispatch setup parameters. Used to configure kernel dispatch parameters
  2685. * such as the number of dimensions in the grid. The parameters are described
  2686. * by ::hsa_kernel_dispatch_packet_setup_t.
  2687. */
  2688. uint16_t setup;
  2689. /**
  2690. * X dimension of work-group, in work-items. Must be greater than 0.
  2691. */
  2692. uint16_t workgroup_size_x;
  2693. /**
  2694. * Y dimension of work-group, in work-items. Must be greater than
  2695. * 0. If the grid has 1 dimension, the only valid value is 1.
  2696. */
  2697. uint16_t workgroup_size_y;
  2698. /**
  2699. * Z dimension of work-group, in work-items. Must be greater than
  2700. * 0. If the grid has 1 or 2 dimensions, the only valid value is 1.
  2701. */
  2702. uint16_t workgroup_size_z;
  2703. /**
  2704. * Reserved. Must be 0.
  2705. */
  2706. uint16_t reserved0;
  2707. /**
  2708. * X dimension of grid, in work-items. Must be greater than 0. Must
  2709. * not be smaller than @a workgroup_size_x.
  2710. */
  2711. uint32_t grid_size_x;
  2712. /**
  2713. * Y dimension of grid, in work-items. Must be greater than 0. If the grid has
  2714. * 1 dimension, the only valid value is 1. Must not be smaller than @a
  2715. * workgroup_size_y.
  2716. */
  2717. uint32_t grid_size_y;
  2718. /**
  2719. * Z dimension of grid, in work-items. Must be greater than 0. If the grid has
  2720. * 1 or 2 dimensions, the only valid value is 1. Must not be smaller than @a
  2721. * workgroup_size_z.
  2722. */
  2723. uint32_t grid_size_z;
  2724. /**
  2725. * Size in bytes of private memory allocation request (per work-item).
  2726. */
  2727. uint32_t private_segment_size;
  2728. /**
  2729. * Size in bytes of group memory allocation request (per work-group). Must not
  2730. * be less than the sum of the group memory used by the kernel (and the
  2731. * functions it calls directly or indirectly) and the dynamically allocated
  2732. * group segment variables.
  2733. */
  2734. uint32_t group_segment_size;
  2735. /**
  2736. * Opaque handle to a code object that includes an implementation-defined
  2737. * executable code for the kernel.
  2738. */
  2739. uint64_t kernel_object;
  2740. #ifdef HSA_LARGE_MODEL
  2741. void* kernarg_address;
  2742. #elif defined HSA_LITTLE_ENDIAN
  2743. /**
  2744. * Pointer to a buffer containing the kernel arguments. May be NULL.
  2745. *
  2746. * The buffer must be allocated using ::hsa_memory_allocate, and must not be
  2747. * modified once the kernel dispatch packet is enqueued until the dispatch has
  2748. * completed execution.
  2749. */
  2750. void* kernarg_address;
  2751. /**
  2752. * Reserved. Must be 0.
  2753. */
  2754. uint32_t reserved1;
  2755. #else
  2756. uint32_t reserved1;
  2757. void* kernarg_address;
  2758. #endif
  2759. /**
  2760. * Reserved. Must be 0.
  2761. */
  2762. uint64_t reserved2;
  2763. /**
  2764. * Signal used to indicate completion of the job. The application can use the
  2765. * special signal handle 0 to indicate that no signal is used.
  2766. */
  2767. hsa_signal_t completion_signal;
  2768. } hsa_kernel_dispatch_packet_t;
  2769. /**
  2770. * @brief Agent dispatch packet.
  2771. */
  2772. typedef struct hsa_agent_dispatch_packet_s {
  2773. /**
  2774. * Packet header. Used to configure multiple packet parameters such as the
  2775. * packet type. The parameters are described by ::hsa_packet_header_t.
  2776. */
  2777. uint16_t header;
  2778. /**
  2779. * Application-defined function to be performed by the destination agent.
  2780. */
  2781. uint16_t type;
  2782. /**
  2783. * Reserved. Must be 0.
  2784. */
  2785. uint32_t reserved0;
  2786. #ifdef HSA_LARGE_MODEL
  2787. void* return_address;
  2788. #elif defined HSA_LITTLE_ENDIAN
  2789. /**
  2790. * Address where to store the function return values, if any.
  2791. */
  2792. void* return_address;
  2793. /**
  2794. * Reserved. Must be 0.
  2795. */
  2796. uint32_t reserved1;
  2797. #else
  2798. uint32_t reserved1;
  2799. void* return_address;
  2800. #endif
  2801. /**
  2802. * Function arguments.
  2803. */
  2804. uint64_t arg[4];
  2805. /**
  2806. * Reserved. Must be 0.
  2807. */
  2808. uint64_t reserved2;
  2809. /**
  2810. * Signal used to indicate completion of the job. The application can use the
  2811. * special signal handle 0 to indicate that no signal is used.
  2812. */
  2813. hsa_signal_t completion_signal;
  2814. } hsa_agent_dispatch_packet_t;
  2815. /**
  2816. * @brief Barrier-AND packet.
  2817. */
  2818. typedef struct hsa_barrier_and_packet_s {
  2819. /**
  2820. * Packet header. Used to configure multiple packet parameters such as the
  2821. * packet type. The parameters are described by ::hsa_packet_header_t.
  2822. */
  2823. uint16_t header;
  2824. /**
  2825. * Reserved. Must be 0.
  2826. */
  2827. uint16_t reserved0;
  2828. /**
  2829. * Reserved. Must be 0.
  2830. */
  2831. uint32_t reserved1;
  2832. /**
  2833. * Array of dependent signal objects. Signals with a handle value of 0 are
  2834. * allowed and are interpreted by the packet processor as satisfied
  2835. * dependencies.
  2836. */
  2837. hsa_signal_t dep_signal[5];
  2838. /**
  2839. * Reserved. Must be 0.
  2840. */
  2841. uint64_t reserved2;
  2842. /**
  2843. * Signal used to indicate completion of the job. The application can use the
  2844. * special signal handle 0 to indicate that no signal is used.
  2845. */
  2846. hsa_signal_t completion_signal;
  2847. } hsa_barrier_and_packet_t;
  2848. /**
  2849. * @brief Barrier-OR packet.
  2850. */
  2851. typedef struct hsa_barrier_or_packet_s {
  2852. /**
  2853. * Packet header. Used to configure multiple packet parameters such as the
  2854. * packet type. The parameters are described by ::hsa_packet_header_t.
  2855. */
  2856. uint16_t header;
  2857. /**
  2858. * Reserved. Must be 0.
  2859. */
  2860. uint16_t reserved0;
  2861. /**
  2862. * Reserved. Must be 0.
  2863. */
  2864. uint32_t reserved1;
  2865. /**
  2866. * Array of dependent signal objects. Signals with a handle value of 0 are
  2867. * allowed and are interpreted by the packet processor as dependencies not
  2868. * satisfied.
  2869. */
  2870. hsa_signal_t dep_signal[5];
  2871. /**
  2872. * Reserved. Must be 0.
  2873. */
  2874. uint64_t reserved2;
  2875. /**
  2876. * Signal used to indicate completion of the job. The application can use the
  2877. * special signal handle 0 to indicate that no signal is used.
  2878. */
  2879. hsa_signal_t completion_signal;
  2880. } hsa_barrier_or_packet_t;
  2881. /** @} */
  2882. /** \addtogroup memory Memory
  2883. * @{
  2884. */
  2885. /**
  2886. * @brief Memory segments associated with a region.
  2887. */
  2888. typedef enum {
  2889. /**
  2890. * Global segment. Used to hold data that is shared by all agents.
  2891. */
  2892. HSA_REGION_SEGMENT_GLOBAL = 0,
  2893. /**
  2894. * Read-only segment. Used to hold data that remains constant during the
  2895. * execution of a kernel.
  2896. */
  2897. HSA_REGION_SEGMENT_READONLY = 1,
  2898. /**
  2899. * Private segment. Used to hold data that is local to a single work-item.
  2900. */
  2901. HSA_REGION_SEGMENT_PRIVATE = 2,
  2902. /**
  2903. * Group segment. Used to hold data that is shared by the work-items of a
  2904. * work-group.
  2905. */
  2906. HSA_REGION_SEGMENT_GROUP = 3,
  2907. /**
  2908. * Kernarg segment. Used to store kernel arguments.
  2909. */
  2910. HSA_REGION_SEGMENT_KERNARG = 4
  2911. } hsa_region_segment_t;
  2912. /**
  2913. * @brief Global region flags.
  2914. */
  2915. typedef enum {
  2916. /**
  2917. * The application can use memory in the region to store kernel arguments, and
  2918. * provide the values for the kernarg segment of a kernel dispatch. If this
  2919. * flag is set, then ::HSA_REGION_GLOBAL_FLAG_FINE_GRAINED must be set.
  2920. */
  2921. HSA_REGION_GLOBAL_FLAG_KERNARG = 1,
  2922. /**
  2923. * Updates to memory in this region are immediately visible to all the
  2924. * agents under the terms of the HSA memory model. If this
  2925. * flag is set, then ::HSA_REGION_GLOBAL_FLAG_COARSE_GRAINED must not be set.
  2926. */
  2927. HSA_REGION_GLOBAL_FLAG_FINE_GRAINED = 2,
  2928. /**
  2929. * Updates to memory in this region can be performed by a single agent at
  2930. * a time. If a different agent in the system is allowed to access the
  2931. * region, the application must explicitely invoke ::hsa_memory_assign_agent
  2932. * in order to transfer ownership to that agent for a particular buffer.
  2933. */
  2934. HSA_REGION_GLOBAL_FLAG_COARSE_GRAINED = 4
  2935. } hsa_region_global_flag_t;
  2936. /**
  2937. * @brief Attributes of a memory region.
  2938. */
  2939. typedef enum {
  2940. /**
  2941. * Segment where memory in the region can be used. The type of this
  2942. * attribute is ::hsa_region_segment_t.
  2943. */
  2944. HSA_REGION_INFO_SEGMENT = 0,
  2945. /**
  2946. * Flag mask. The value of this attribute is undefined if the value of
  2947. * ::HSA_REGION_INFO_SEGMENT is not ::HSA_REGION_SEGMENT_GLOBAL. The type of
  2948. * this attribute is uint32_t, a bit-field of ::hsa_region_global_flag_t
  2949. * values.
  2950. */
  2951. HSA_REGION_INFO_GLOBAL_FLAGS = 1,
  2952. /**
  2953. * Size of this region, in bytes. The type of this attribute is size_t.
  2954. */
  2955. HSA_REGION_INFO_SIZE = 2,
  2956. /**
  2957. * Maximum allocation size in this region, in bytes. Must not exceed the value
  2958. * of ::HSA_REGION_INFO_SIZE. The type of this attribute is size_t.
  2959. *
  2960. * If the region is in the global or readonly segments, this is the maximum
  2961. * size that the application can pass to ::hsa_memory_allocate.
  2962. *
  2963. * If the region is in the group segment, this is the maximum size (per
  2964. * work-group) that can be requested for a given kernel dispatch. If the
  2965. * region is in the private segment, this is the maximum size (per work-item)
  2966. * that can be requested for a specific kernel dispatch, and must be at least
  2967. * 256 bytes.
  2968. */
  2969. HSA_REGION_INFO_ALLOC_MAX_SIZE = 4,
  2970. /**
  2971. * Maximum size (per work-group) of private memory that can be requested for a
  2972. * specific kernel dispatch. Must be at least 65536 bytes. The type of this
  2973. * attribute is uint32_t. The value of this attribute is undefined if the
  2974. * region is not in the private segment.
  2975. */
  2976. HSA_REGION_INFO_ALLOC_MAX_PRIVATE_WORKGROUP_SIZE = 8,
  2977. /**
  2978. * Indicates whether memory in this region can be allocated using
  2979. * ::hsa_memory_allocate. The type of this attribute is bool.
  2980. *
  2981. * The value of this flag is always false for regions in the group and private
  2982. * segments.
  2983. */
  2984. HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED = 5,
  2985. /**
  2986. * Allocation granularity of buffers allocated by ::hsa_memory_allocate in
  2987. * this region. The size of a buffer allocated in this region is a multiple of
  2988. * the value of this attribute. The value of this attribute is only defined if
  2989. * ::HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED is true for this region. The type
  2990. * of this attribute is size_t.
  2991. */
  2992. HSA_REGION_INFO_RUNTIME_ALLOC_GRANULE = 6,
  2993. /**
  2994. * Alignment of buffers allocated by ::hsa_memory_allocate in this region. The
  2995. * value of this attribute is only defined if
  2996. * ::HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED is true for this region, and must be
  2997. * a power of 2. The type of this attribute is size_t.
  2998. */
  2999. HSA_REGION_INFO_RUNTIME_ALLOC_ALIGNMENT = 7
  3000. } hsa_region_info_t;
  3001. /**
  3002. * @brief Get the current value of an attribute of a region.
  3003. *
  3004. * @param[in] region A valid region.
  3005. *
  3006. * @param[in] attribute Attribute to query.
  3007. *
  3008. * @param[out] value Pointer to a application-allocated buffer where to store
  3009. * the value of the attribute. If the buffer passed by the application is not
  3010. * large enough to hold the value of @p attribute, the behavior is undefined.
  3011. *
  3012. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3013. *
  3014. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3015. * initialized.
  3016. *
  3017. * @retval ::HSA_STATUS_ERROR_INVALID_REGION The region is invalid.
  3018. *
  3019. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
  3020. * region attribute, or @p value is NULL.
  3021. */
  3022. hsa_status_t HSA_API hsa_region_get_info(
  3023. hsa_region_t region,
  3024. hsa_region_info_t attribute,
  3025. void* value);
  3026. /**
  3027. * @brief Iterate over the memory regions associated with a given agent, and
  3028. * invoke an application-defined callback on every iteration.
  3029. *
  3030. * @param[in] agent A valid agent.
  3031. *
  3032. * @param[in] callback Callback to be invoked once per region that is
  3033. * accessible from the agent. The HSA runtime passes two arguments to the
  3034. * callback, the region and the application data. If @p callback returns a
  3035. * status other than ::HSA_STATUS_SUCCESS for a particular iteration, the
  3036. * traversal stops and ::hsa_agent_iterate_regions returns that status value.
  3037. *
  3038. * @param[in] data Application data that is passed to @p callback on every
  3039. * iteration. May be NULL.
  3040. *
  3041. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3042. *
  3043. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3044. * initialized.
  3045. *
  3046. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  3047. *
  3048. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
  3049. */
  3050. hsa_status_t HSA_API hsa_agent_iterate_regions(
  3051. hsa_agent_t agent,
  3052. hsa_status_t (*callback)(hsa_region_t region, void* data),
  3053. void* data);
  3054. /**
  3055. * @brief Allocate a block of memory in a given region.
  3056. *
  3057. * @param[in] region Region where to allocate memory from. The region must have
  3058. * the ::HSA_REGION_INFO_RUNTIME_ALLOC_ALLOWED flag set.
  3059. *
  3060. * @param[in] size Allocation size, in bytes. Must not be zero. This value is
  3061. * rounded up to the nearest multiple of ::HSA_REGION_INFO_RUNTIME_ALLOC_GRANULE
  3062. * in @p region.
  3063. *
  3064. * @param[out] ptr Pointer to the location where to store the base address of
  3065. * the allocated block. The returned base address is aligned to the value of
  3066. * ::HSA_REGION_INFO_RUNTIME_ALLOC_ALIGNMENT in @p region. If the allocation
  3067. * fails, the returned value is undefined.
  3068. *
  3069. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3070. *
  3071. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3072. * initialized.
  3073. *
  3074. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
  3075. * the required resources.
  3076. *
  3077. * @retval ::HSA_STATUS_ERROR_INVALID_REGION The region is invalid.
  3078. *
  3079. * @retval ::HSA_STATUS_ERROR_INVALID_ALLOCATION The host is not allowed to
  3080. * allocate memory in @p region, or @p size is greater than the value of
  3081. * HSA_REGION_INFO_ALLOC_MAX_SIZE in @p region.
  3082. *
  3083. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is NULL, or @p size is 0.
  3084. */
  3085. hsa_status_t HSA_API hsa_memory_allocate(hsa_region_t region,
  3086. size_t size,
  3087. void** ptr);
  3088. /**
  3089. * @brief Deallocate a block of memory previously allocated using
  3090. * ::hsa_memory_allocate.
  3091. *
  3092. * @param[in] ptr Pointer to a memory block. If @p ptr does not match a value
  3093. * previously returned by ::hsa_memory_allocate, the behavior is undefined.
  3094. *
  3095. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3096. *
  3097. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3098. * initialized.
  3099. */
  3100. hsa_status_t HSA_API hsa_memory_free(void* ptr);
  3101. /**
  3102. * @brief Copy a block of memory from the location pointed to by @p src to the
  3103. * memory block pointed to by @p dst.
  3104. *
  3105. * @param[out] dst Buffer where the content is to be copied. If @p dst is in
  3106. * coarse-grained memory, the copied data is only visible to the agent currently
  3107. * assigned (::hsa_memory_assign_agent) to @p dst.
  3108. *
  3109. * @param[in] src A valid pointer to the source of data to be copied. The source
  3110. * buffer must not overlap with the destination buffer. If the source buffer is
  3111. * in coarse-grained memory then it must be assigned to an agent, from which the
  3112. * data will be retrieved.
  3113. *
  3114. * @param[in] size Number of bytes to copy. If @p size is 0, no copy is
  3115. * performed and the function returns success. Copying a number of bytes larger
  3116. * than the size of the buffers pointed by @p dst or @p src results in undefined
  3117. * behavior.
  3118. *
  3119. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3120. *
  3121. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3122. * initialized.
  3123. *
  3124. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT The source or destination
  3125. * pointers are NULL.
  3126. */
  3127. hsa_status_t HSA_API hsa_memory_copy(
  3128. void *dst,
  3129. const void *src,
  3130. size_t size);
  3131. /**
  3132. * @brief Change the ownership of a global, coarse-grained buffer.
  3133. *
  3134. * @details The contents of a coarse-grained buffer are visible to an agent
  3135. * only after ownership has been explicitely transferred to that agent. Once the
  3136. * operation completes, the previous owner cannot longer access the data in the
  3137. * buffer.
  3138. *
  3139. * An implementation of the HSA runtime is allowed, but not required, to change
  3140. * the physical location of the buffer when ownership is transferred to a
  3141. * different agent. In general the application must not assume this
  3142. * behavior. The virtual location (address) of the passed buffer is never
  3143. * modified.
  3144. *
  3145. * @param[in] ptr Base address of a global buffer. The pointer must match an
  3146. * address previously returned by ::hsa_memory_allocate. The size of the buffer
  3147. * affected by the ownership change is identical to the size of that previous
  3148. * allocation. If @p ptr points to a fine-grained global buffer, no operation is
  3149. * performed and the function returns success. If @p ptr does not point to
  3150. * global memory, the behavior is undefined.
  3151. *
  3152. * @param[in] agent Agent that becomes the owner of the buffer. The
  3153. * application is responsible for ensuring that @p agent has access to the
  3154. * region that contains the buffer. It is allowed to change ownership to an
  3155. * agent that is already the owner of the buffer, with the same or different
  3156. * access permissions.
  3157. *
  3158. * @param[in] access Access permissions requested for the new owner.
  3159. *
  3160. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3161. *
  3162. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3163. * initialized.
  3164. *
  3165. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  3166. *
  3167. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
  3168. * the required resources.
  3169. *
  3170. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p ptr is NULL, or @p access is
  3171. * not a valid access value.
  3172. */
  3173. hsa_status_t HSA_API hsa_memory_assign_agent(
  3174. void *ptr,
  3175. hsa_agent_t agent,
  3176. hsa_access_permission_t access);
  3177. /**
  3178. *
  3179. * @brief Register a global, fine-grained buffer.
  3180. *
  3181. * @details Registering a buffer serves as an indication to the HSA runtime that
  3182. * the memory might be accessed from a kernel agent other than the
  3183. * host. Registration is a performance hint that allows the HSA runtime
  3184. * implementation to know which buffers will be accessed by some of the kernel
  3185. * agents ahead of time.
  3186. *
  3187. * Registration is only recommended for buffers in the global segment that have
  3188. * not been allocated using the HSA allocator (::hsa_memory_allocate), but an OS
  3189. * allocator instead. Registering an OS-allocated buffer in the base profile is
  3190. * equivalent to a no-op.
  3191. *
  3192. * Registrations should not overlap.
  3193. *
  3194. * @param[in] ptr A buffer in global, fine-grained memory. If a NULL pointer is
  3195. * passed, no operation is performed. If the buffer has been allocated using
  3196. * ::hsa_memory_allocate, or has already been registered, no operation is
  3197. * performed.
  3198. *
  3199. * @param[in] size Requested registration size in bytes. A size of 0 is
  3200. * only allowed if @p ptr is NULL.
  3201. *
  3202. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3203. *
  3204. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3205. * initialized.
  3206. *
  3207. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate
  3208. * the required resources.
  3209. *
  3210. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p size is 0 but @p ptr
  3211. * is not NULL.
  3212. */
  3213. hsa_status_t HSA_API hsa_memory_register(
  3214. void *ptr,
  3215. size_t size);
  3216. /**
  3217. *
  3218. * @brief Deregister memory previously registered using ::hsa_memory_register.
  3219. *
  3220. * @details If the memory interval being deregistered does not match a previous
  3221. * registration (start and end addresses), the behavior is undefined.
  3222. *
  3223. * @param[in] ptr A pointer to the base of the buffer to be deregistered. If
  3224. * a NULL pointer is passed, no operation is performed.
  3225. *
  3226. * @param[in] size Size of the buffer to be deregistered.
  3227. *
  3228. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3229. *
  3230. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3231. * initialized.
  3232. *
  3233. */
  3234. hsa_status_t HSA_API hsa_memory_deregister(
  3235. void *ptr,
  3236. size_t size);
  3237. /** @} */
  3238. /** \defgroup instruction-set-architecture Instruction Set Architecture.
  3239. * @{
  3240. */
  3241. /**
  3242. * @brief Instruction set architecture.
  3243. */
  3244. typedef struct hsa_isa_s {
  3245. /**
  3246. * Opaque handle. Two handles reference the same object of the enclosing type
  3247. * if and only if they are equal.
  3248. */
  3249. uint64_t handle;
  3250. } hsa_isa_t;
  3251. /**
  3252. * @brief Retrieve a reference to an instruction set architecture handle out of
  3253. * a symbolic name.
  3254. *
  3255. * @param[in] name Vendor-specific name associated with a a particular
  3256. * instruction set architecture. @p name must start with the vendor name and a
  3257. * colon (for example, "AMD:"). The rest of the name is vendor-specific. Must be
  3258. * a NUL-terminated string.
  3259. *
  3260. * @param[out] isa Memory location where the HSA runtime stores the ISA handle
  3261. * corresponding to the given name. Must not be NULL.
  3262. *
  3263. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3264. *
  3265. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3266. * initialized.
  3267. *
  3268. * @retval ::HSA_STATUS_ERROR_INVALID_ISA_NAME The given name does not
  3269. * correspond to any instruction set architecture.
  3270. *
  3271. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  3272. * allocate the required resources.
  3273. *
  3274. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p name is NULL, or @p isa is
  3275. * NULL.
  3276. */
  3277. hsa_status_t HSA_API hsa_isa_from_name(
  3278. const char *name,
  3279. hsa_isa_t *isa);
  3280. /**
  3281. * @brief Iterate over the instruction sets supported by the given agent, and
  3282. * invoke an application-defined callback on every iteration. The iterator is
  3283. * deterministic: if an agent supports several instruction set architectures,
  3284. * they are traversed in the same order in every invocation of this function.
  3285. *
  3286. * @param[in] agent A valid agent.
  3287. *
  3288. * @param[in] callback Callback to be invoked once per instruction set
  3289. * architecture. The HSA runtime passes two arguments to the callback: the
  3290. * ISA and the application data. If @p callback returns a status other than
  3291. * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
  3292. * that status value is returned.
  3293. *
  3294. * @param[in] data Application data that is passed to @p callback on every
  3295. * iteration. May be NULL.
  3296. *
  3297. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3298. *
  3299. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3300. * initialized.
  3301. *
  3302. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  3303. *
  3304. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
  3305. */
  3306. hsa_status_t HSA_API hsa_agent_iterate_isas(
  3307. hsa_agent_t agent,
  3308. hsa_status_t (*callback)(hsa_isa_t isa, void *data),
  3309. void *data);
  3310. /**
  3311. * @brief Instruction set architecture attributes.
  3312. */
  3313. typedef enum {
  3314. /**
  3315. * The length of the ISA name in bytes, not including the NUL terminator. The
  3316. * type of this attribute is uint32_t.
  3317. */
  3318. HSA_ISA_INFO_NAME_LENGTH = 0,
  3319. /**
  3320. * Human-readable description. The type of this attribute is character array
  3321. * with the length equal to the value of ::HSA_ISA_INFO_NAME_LENGTH attribute.
  3322. */
  3323. HSA_ISA_INFO_NAME = 1,
  3324. /**
  3325. * @deprecated
  3326. *
  3327. * Number of call conventions supported by the instruction set architecture.
  3328. * Must be greater than zero. The type of this attribute is uint32_t.
  3329. */
  3330. HSA_ISA_INFO_CALL_CONVENTION_COUNT = 2,
  3331. /**
  3332. * @deprecated
  3333. *
  3334. * Number of work-items in a wavefront for a given call convention. Must be a
  3335. * power of 2 in the range [1,256]. The type of this attribute is uint32_t.
  3336. */
  3337. HSA_ISA_INFO_CALL_CONVENTION_INFO_WAVEFRONT_SIZE = 3,
  3338. /**
  3339. * @deprecated
  3340. *
  3341. * Number of wavefronts per compute unit for a given call convention. In
  3342. * practice, other factors (for example, the amount of group memory used by a
  3343. * work-group) may further limit the number of wavefronts per compute
  3344. * unit. The type of this attribute is uint32_t.
  3345. */
  3346. HSA_ISA_INFO_CALL_CONVENTION_INFO_WAVEFRONTS_PER_COMPUTE_UNIT = 4,
  3347. /**
  3348. * Machine models supported by the instruction set architecture. The type of
  3349. * this attribute is a bool[2]. If the ISA supports the small machine model,
  3350. * the element at index ::HSA_MACHINE_MODEL_SMALL is true. If the ISA supports
  3351. * the large model, the element at index ::HSA_MACHINE_MODEL_LARGE is true.
  3352. */
  3353. HSA_ISA_INFO_MACHINE_MODELS = 5,
  3354. /**
  3355. * Profiles supported by the instruction set architecture. The type of this
  3356. * attribute is a bool[2]. If the ISA supports the base profile, the element
  3357. * at index ::HSA_PROFILE_BASE is true. If the ISA supports the full profile,
  3358. * the element at index ::HSA_PROFILE_FULL is true.
  3359. */
  3360. HSA_ISA_INFO_PROFILES = 6,
  3361. /**
  3362. * Default floating-point rounding modes supported by the instruction set
  3363. * architecture. The type of this attribute is a bool[3]. The value at a given
  3364. * index is true if the corresponding rounding mode in
  3365. * ::hsa_default_float_rounding_mode_t is supported. At least one default mode
  3366. * has to be supported.
  3367. *
  3368. * If the default mode is supported, then
  3369. * ::HSA_ISA_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES must report that
  3370. * both the zero and the near roundings modes are supported.
  3371. */
  3372. HSA_ISA_INFO_DEFAULT_FLOAT_ROUNDING_MODES = 7,
  3373. /**
  3374. * Default floating-point rounding modes supported by the instruction set
  3375. * architecture in the Base profile. The type of this attribute is a
  3376. * bool[3]. The value at a given index is true if the corresponding rounding
  3377. * mode in ::hsa_default_float_rounding_mode_t is supported. The value at
  3378. * index HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT must be false. At least one
  3379. * of the values at indexes ::HSA_DEFAULT_FLOAT_ROUNDING_MODE_ZERO or
  3380. * HSA_DEFAULT_FLOAT_ROUNDING_MODE_NEAR must be true.
  3381. */
  3382. HSA_ISA_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES = 8,
  3383. /**
  3384. * Flag indicating that the f16 HSAIL operation is at least as fast as the
  3385. * f32 operation in the instruction set architecture. The type of this
  3386. * attribute is bool.
  3387. */
  3388. HSA_ISA_INFO_FAST_F16_OPERATION = 9,
  3389. /**
  3390. * Maximum number of work-items of each dimension of a work-group. Each
  3391. * maximum must be greater than 0. No maximum can exceed the value of
  3392. * ::HSA_ISA_INFO_WORKGROUP_MAX_SIZE. The type of this attribute is
  3393. * uint16_t[3].
  3394. */
  3395. HSA_ISA_INFO_WORKGROUP_MAX_DIM = 12,
  3396. /**
  3397. * Maximum total number of work-items in a work-group. The type
  3398. * of this attribute is uint32_t.
  3399. */
  3400. HSA_ISA_INFO_WORKGROUP_MAX_SIZE = 13,
  3401. /**
  3402. * Maximum number of work-items of each dimension of a grid. Each maximum must
  3403. * be greater than 0, and must not be smaller than the corresponding value in
  3404. * ::HSA_ISA_INFO_WORKGROUP_MAX_DIM. No maximum can exceed the value of
  3405. * ::HSA_ISA_INFO_GRID_MAX_SIZE. The type of this attribute is
  3406. * ::hsa_dim3_t.
  3407. */
  3408. HSA_ISA_INFO_GRID_MAX_DIM = 14,
  3409. /**
  3410. * Maximum total number of work-items in a grid. The type of this
  3411. * attribute is uint64_t.
  3412. */
  3413. HSA_ISA_INFO_GRID_MAX_SIZE = 16,
  3414. /**
  3415. * Maximum number of fbarriers per work-group. Must be at least 32. The
  3416. * type of this attribute is uint32_t.
  3417. */
  3418. HSA_ISA_INFO_FBARRIER_MAX_SIZE = 17
  3419. } hsa_isa_info_t;
  3420. /**
  3421. * @deprecated The concept of call convention has been deprecated. If the
  3422. * application wants to query the value of an attribute for a given instruction
  3423. * set architecture, use ::hsa_isa_get_info_alt instead. If the application
  3424. * wants to query an attribute that is specific to a given combination of ISA
  3425. * and wavefront, use ::hsa_wavefront_get_info.
  3426. *
  3427. * @brief Get the current value of an attribute for a given instruction set
  3428. * architecture (ISA).
  3429. *
  3430. * @param[in] isa A valid instruction set architecture.
  3431. *
  3432. * @param[in] attribute Attribute to query.
  3433. *
  3434. * @param[in] index Call convention index. Used only for call convention
  3435. * attributes, otherwise ignored. Must have a value between 0 (inclusive) and
  3436. * the value of the attribute ::HSA_ISA_INFO_CALL_CONVENTION_COUNT (not
  3437. * inclusive) in @p isa.
  3438. *
  3439. * @param[out] value Pointer to an application-allocated buffer where to store
  3440. * the value of the attribute. If the buffer passed by the application is not
  3441. * large enough to hold the value of @p attribute, the behavior is undefined.
  3442. *
  3443. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3444. *
  3445. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3446. * initialized.
  3447. *
  3448. * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
  3449. * invalid.
  3450. *
  3451. * @retval ::HSA_STATUS_ERROR_INVALID_INDEX The index is out of range.
  3452. *
  3453. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
  3454. * instruction set architecture attribute, or @p value is
  3455. * NULL.
  3456. */
  3457. hsa_status_t HSA_API HSA_DEPRECATED hsa_isa_get_info(
  3458. hsa_isa_t isa,
  3459. hsa_isa_info_t attribute,
  3460. uint32_t index,
  3461. void *value);
  3462. /**
  3463. * @brief Get the current value of an attribute for a given instruction set
  3464. * architecture (ISA).
  3465. *
  3466. * @param[in] isa A valid instruction set architecture.
  3467. *
  3468. * @param[in] attribute Attribute to query.
  3469. *
  3470. * @param[out] value Pointer to an application-allocated buffer where to store
  3471. * the value of the attribute. If the buffer passed by the application is not
  3472. * large enough to hold the value of @p attribute, the behavior is undefined.
  3473. *
  3474. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3475. *
  3476. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3477. * initialized.
  3478. *
  3479. * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
  3480. * invalid.
  3481. *
  3482. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
  3483. * instruction set architecture attribute, or @p value is
  3484. * NULL.
  3485. */
  3486. hsa_status_t HSA_API hsa_isa_get_info_alt(
  3487. hsa_isa_t isa,
  3488. hsa_isa_info_t attribute,
  3489. void *value);
  3490. /**
  3491. * @brief Retrieve the exception policy support for a given combination of
  3492. * instruction set architecture and profile.
  3493. *
  3494. * @param[in] isa A valid instruction set architecture.
  3495. *
  3496. * @param[in] profile Profile.
  3497. *
  3498. * @param[out] mask Pointer to a memory location where the HSA runtime stores a
  3499. * mask of ::hsa_exception_policy_t values. Must not be NULL.
  3500. *
  3501. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3502. *
  3503. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3504. * initialized.
  3505. *
  3506. * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
  3507. * invalid.
  3508. *
  3509. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p profile is not a valid
  3510. * profile, or @p mask is NULL.
  3511. */
  3512. hsa_status_t HSA_API hsa_isa_get_exception_policies(
  3513. hsa_isa_t isa,
  3514. hsa_profile_t profile,
  3515. uint16_t *mask);
  3516. /**
  3517. * @brief Floating-point types.
  3518. */
  3519. typedef enum {
  3520. /**
  3521. * 16-bit floating-point type.
  3522. */
  3523. HSA_FP_TYPE_16 = 1,
  3524. /**
  3525. * 32-bit floating-point type.
  3526. */
  3527. HSA_FP_TYPE_32 = 2,
  3528. /**
  3529. * 64-bit floating-point type.
  3530. */
  3531. HSA_FP_TYPE_64 = 4
  3532. } hsa_fp_type_t;
  3533. /**
  3534. * @brief Flush to zero modes.
  3535. */
  3536. typedef enum {
  3537. /**
  3538. * Flush to zero.
  3539. */
  3540. HSA_FLUSH_MODE_FTZ = 1,
  3541. /**
  3542. * Do not flush to zero.
  3543. */
  3544. HSA_FLUSH_MODE_NON_FTZ = 2
  3545. } hsa_flush_mode_t;
  3546. /**
  3547. * @brief Round methods.
  3548. */
  3549. typedef enum {
  3550. /**
  3551. * Single round method.
  3552. */
  3553. HSA_ROUND_METHOD_SINGLE = 1,
  3554. /**
  3555. * Double round method.
  3556. */
  3557. HSA_ROUND_METHOD_DOUBLE = 2
  3558. } hsa_round_method_t;
  3559. /**
  3560. * @brief Retrieve the round method (single or double) used to implement the
  3561. * floating-point multiply add instruction (mad) for a given combination of
  3562. * instruction set architecture, floating-point type, and flush to zero
  3563. * modifier.
  3564. *
  3565. * @param[in] isa Instruction set architecture.
  3566. *
  3567. * @param[in] fp_type Floating-point type.
  3568. *
  3569. * @param[in] flush_mode Flush to zero modifier.
  3570. *
  3571. * @param[out] round_method Pointer to a memory location where the HSA
  3572. * runtime stores the round method used by the implementation. Must not be NULL.
  3573. *
  3574. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3575. *
  3576. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3577. * initialized.
  3578. *
  3579. * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
  3580. * invalid.
  3581. *
  3582. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p fp_type is not a valid
  3583. * floating-point type, or @p flush_mode is not a valid flush to zero modifier,
  3584. * or @p round_method is NULL.
  3585. */
  3586. hsa_status_t HSA_API hsa_isa_get_round_method(
  3587. hsa_isa_t isa,
  3588. hsa_fp_type_t fp_type,
  3589. hsa_flush_mode_t flush_mode,
  3590. hsa_round_method_t *round_method);
  3591. /**
  3592. * @brief Wavefront handle
  3593. */
  3594. typedef struct hsa_wavefront_s {
  3595. /**
  3596. * Opaque handle. Two handles reference the same object of the enclosing type
  3597. * if and only if they are equal.
  3598. */
  3599. uint64_t handle;
  3600. } hsa_wavefront_t;
  3601. /**
  3602. * @brief Wavefront attributes.
  3603. */
  3604. typedef enum {
  3605. /**
  3606. * Number of work-items in the wavefront. Must be a power of 2 in the range
  3607. * [1,256]. The type of this attribute is uint32_t.
  3608. */
  3609. HSA_WAVEFRONT_INFO_SIZE = 0
  3610. } hsa_wavefront_info_t;
  3611. /**
  3612. * @brief Get the current value of a wavefront attribute.
  3613. *
  3614. * @param[in] wavefront A wavefront.
  3615. *
  3616. * @param[in] attribute Attribute to query.
  3617. *
  3618. * @param[out] value Pointer to an application-allocated buffer where to store
  3619. * the value of the attribute. If the buffer passed by the application is not
  3620. * large enough to hold the value of @p attribute, the behavior is undefined.
  3621. *
  3622. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3623. *
  3624. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3625. * initialized.
  3626. *
  3627. * @retval ::HSA_STATUS_ERROR_INVALID_WAVEFRONT The wavefront is invalid.
  3628. *
  3629. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
  3630. * wavefront attribute, or @p value is NULL.
  3631. */
  3632. hsa_status_t HSA_API hsa_wavefront_get_info(
  3633. hsa_wavefront_t wavefront,
  3634. hsa_wavefront_info_t attribute,
  3635. void *value);
  3636. /**
  3637. * @brief Iterate over the different wavefronts supported by an instruction set
  3638. * architecture, and invoke an application-defined callback on every iteration.
  3639. *
  3640. * @param[in] isa Instruction set architecture.
  3641. *
  3642. * @param[in] callback Callback to be invoked once per wavefront that is
  3643. * supported by the agent. The HSA runtime passes two arguments to the callback:
  3644. * the wavefront handle and the application data. If @p callback returns a
  3645. * status other than ::HSA_STATUS_SUCCESS for a particular iteration, the
  3646. * traversal stops and that value is returned.
  3647. *
  3648. * @param[in] data Application data that is passed to @p callback on every
  3649. * iteration. May be NULL.
  3650. *
  3651. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3652. *
  3653. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3654. * initialized.
  3655. *
  3656. * @retval ::HSA_STATUS_ERROR_INVALID_ISA The instruction set architecture is
  3657. * invalid.
  3658. *
  3659. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
  3660. */
  3661. hsa_status_t HSA_API hsa_isa_iterate_wavefronts(
  3662. hsa_isa_t isa,
  3663. hsa_status_t (*callback)(hsa_wavefront_t wavefront, void *data),
  3664. void *data);
  3665. /**
  3666. * @deprecated Use ::hsa_agent_iterate_isas to query which instructions set
  3667. * architectures are supported by a given agent.
  3668. *
  3669. * @brief Check if the instruction set architecture of a code object can be
  3670. * executed on an agent associated with another architecture.
  3671. *
  3672. * @param[in] code_object_isa Instruction set architecture associated with a
  3673. * code object.
  3674. *
  3675. * @param[in] agent_isa Instruction set architecture associated with an agent.
  3676. *
  3677. * @param[out] result Pointer to a memory location where the HSA runtime stores
  3678. * the result of the check. If the two architectures are compatible, the result
  3679. * is true; if they are incompatible, the result is false.
  3680. *
  3681. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3682. *
  3683. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3684. * initialized.
  3685. *
  3686. * @retval ::HSA_STATUS_ERROR_INVALID_ISA @p code_object_isa or @p agent_isa are
  3687. * invalid.
  3688. *
  3689. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p result is NULL.
  3690. */
  3691. hsa_status_t HSA_API HSA_DEPRECATED hsa_isa_compatible(
  3692. hsa_isa_t code_object_isa,
  3693. hsa_isa_t agent_isa,
  3694. bool *result);
  3695. /** @} */
  3696. /** \defgroup executable Executable
  3697. * @{
  3698. */
  3699. /**
  3700. * @brief Code object reader handle. A code object reader is used to
  3701. * load a code object from file (when created using
  3702. * ::hsa_code_object_reader_create_from_file), or from memory (if created using
  3703. * ::hsa_code_object_reader_create_from_memory).
  3704. */
  3705. typedef struct hsa_code_object_reader_s {
  3706. /**
  3707. * Opaque handle. Two handles reference the same object of the enclosing type
  3708. * if and only if they are equal.
  3709. */
  3710. uint64_t handle;
  3711. } hsa_code_object_reader_t;
  3712. /**
  3713. * @brief Create a code object reader to operate on a file.
  3714. *
  3715. * @param[in] file File descriptor. The file must have been opened by
  3716. * application with at least read permissions prior calling this function. The
  3717. * file must contain a vendor-specific code object.
  3718. *
  3719. * The file is owned and managed by the application; the lifetime of the file
  3720. * descriptor must exceed that of any associated code object reader.
  3721. *
  3722. * @param[out] code_object_reader Memory location to store the newly created
  3723. * code object reader handle. Must not be NULL.
  3724. *
  3725. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3726. *
  3727. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3728. * initialized.
  3729. *
  3730. * @retval ::HSA_STATUS_ERROR_INVALID_FILE @p file is invalid.
  3731. *
  3732. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  3733. * allocate the required resources.
  3734. *
  3735. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p code_object_reader is NULL.
  3736. */
  3737. hsa_status_t HSA_API hsa_code_object_reader_create_from_file(
  3738. hsa_file_t file,
  3739. hsa_code_object_reader_t *code_object_reader);
  3740. /**
  3741. * @brief Create a code object reader to operate on memory.
  3742. *
  3743. * @param[in] code_object Memory buffer that contains a vendor-specific code
  3744. * object. The buffer is owned and managed by the application; the lifetime of
  3745. * the buffer must exceed that of any associated code object reader.
  3746. *
  3747. * @param[in] size Size of the buffer pointed to by @p code_object. Must not be
  3748. * 0.
  3749. *
  3750. * @param[out] code_object_reader Memory location to store newly created code
  3751. * object reader handle. Must not be NULL.
  3752. *
  3753. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3754. *
  3755. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3756. * initialized.
  3757. *
  3758. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  3759. * allocate the required resources.
  3760. *
  3761. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p code_object is NULL, @p size
  3762. * is zero, or @p code_object_reader is NULL.
  3763. */
  3764. hsa_status_t HSA_API hsa_code_object_reader_create_from_memory(
  3765. const void *code_object,
  3766. size_t size,
  3767. hsa_code_object_reader_t *code_object_reader);
  3768. /**
  3769. * @brief Destroy a code object reader.
  3770. *
  3771. * @details The code object reader handle becomes invalid after completion of
  3772. * this function. Any file or memory used to create the code object read is not
  3773. * closed, removed, or deallocated by this function.
  3774. *
  3775. * @param[in] code_object_reader Code object reader to destroy.
  3776. *
  3777. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3778. *
  3779. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3780. * initialized.
  3781. *
  3782. * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT_READER @p code_object_reader
  3783. * is invalid.
  3784. */
  3785. hsa_status_t HSA_API hsa_code_object_reader_destroy(
  3786. hsa_code_object_reader_t code_object_reader);
  3787. /**
  3788. * @brief Struct containing an opaque handle to an executable, which contains
  3789. * ISA for finalized kernels and indirect functions together with the allocated
  3790. * global or readonly segment variables they reference.
  3791. */
  3792. typedef struct hsa_executable_s {
  3793. /**
  3794. * Opaque handle. Two handles reference the same object of the enclosing type
  3795. * if and only if they are equal.
  3796. */
  3797. uint64_t handle;
  3798. } hsa_executable_t;
  3799. /**
  3800. * @brief Executable state.
  3801. */
  3802. typedef enum {
  3803. /**
  3804. * Executable state, which allows the user to load code objects and define
  3805. * external variables. Variable addresses, kernel code handles, and
  3806. * indirect function code handles are not available in query operations until
  3807. * the executable is frozen (zero always returned).
  3808. */
  3809. HSA_EXECUTABLE_STATE_UNFROZEN = 0,
  3810. /**
  3811. * Executable state, which allows the user to query variable addresses,
  3812. * kernel code handles, and indirect function code handles using query
  3813. * operations. Loading new code objects, as well as defining external
  3814. * variables, is not allowed in this state.
  3815. */
  3816. HSA_EXECUTABLE_STATE_FROZEN = 1
  3817. } hsa_executable_state_t;
  3818. /**
  3819. * @deprecated Use ::hsa_executable_create_alt instead, which allows the
  3820. * application to specify the default floating-point rounding mode of the
  3821. * executable and assumes an unfrozen initial state.
  3822. *
  3823. * @brief Create an empty executable.
  3824. *
  3825. * @param[in] profile Profile used in the executable.
  3826. *
  3827. * @param[in] executable_state Executable state. If the state is
  3828. * ::HSA_EXECUTABLE_STATE_FROZEN, the resulting executable is useless because no
  3829. * code objects can be loaded, and no variables can be defined.
  3830. *
  3831. * @param[in] options Standard and vendor-specific options. Unknown options are
  3832. * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
  3833. * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
  3834. * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
  3835. * NUL-terminated string. May be NULL.
  3836. *
  3837. * @param[out] executable Memory location where the HSA runtime stores the newly
  3838. * created executable handle.
  3839. *
  3840. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3841. *
  3842. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3843. * initialized.
  3844. *
  3845. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  3846. * allocate the required resources.
  3847. *
  3848. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p profile is invalid, or
  3849. * @p executable is NULL.
  3850. */
  3851. hsa_status_t HSA_API HSA_DEPRECATED hsa_executable_create(
  3852. hsa_profile_t profile,
  3853. hsa_executable_state_t executable_state,
  3854. const char *options,
  3855. hsa_executable_t *executable);
  3856. /**
  3857. * @brief Create an empty executable.
  3858. *
  3859. * @param[in] profile Profile used in the executable.
  3860. *
  3861. * @param[in] default_float_rounding_mode Default floating-point rounding mode
  3862. * used in the executable. Allowed rounding modes are near and zero (default is
  3863. * not allowed).
  3864. *
  3865. * @param[in] options Standard and vendor-specific options. Unknown options are
  3866. * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
  3867. * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
  3868. * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
  3869. * NUL-terminated string. May be NULL.
  3870. *
  3871. * @param[out] executable Memory location where the HSA runtime stores newly
  3872. * created executable handle. The initial state of the executable is
  3873. * ::HSA_EXECUTABLE_STATE_UNFROZEN.
  3874. *
  3875. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3876. *
  3877. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3878. * initialized.
  3879. *
  3880. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  3881. * allocate the required resources.
  3882. *
  3883. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p profile is invalid, or
  3884. * @p executable is NULL.
  3885. */
  3886. hsa_status_t HSA_API hsa_executable_create_alt(
  3887. hsa_profile_t profile,
  3888. hsa_default_float_rounding_mode_t default_float_rounding_mode,
  3889. const char *options,
  3890. hsa_executable_t *executable);
  3891. /**
  3892. * @brief Destroy an executable.
  3893. *
  3894. * @details An executable handle becomes invalid after the executable has been
  3895. * destroyed. Code object handles that were loaded into this executable are
  3896. * still valid after the executable has been destroyed, and can be used as
  3897. * intended. Resources allocated outside and associated with this executable
  3898. * (such as external global or readonly variables) can be released after the
  3899. * executable has been destroyed.
  3900. *
  3901. * Executable should not be destroyed while kernels are in flight.
  3902. *
  3903. * @param[in] executable Executable.
  3904. *
  3905. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3906. *
  3907. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3908. * initialized.
  3909. *
  3910. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  3911. */
  3912. hsa_status_t HSA_API hsa_executable_destroy(
  3913. hsa_executable_t executable);
  3914. /**
  3915. * @brief Loaded code object handle.
  3916. */
  3917. typedef struct hsa_loaded_code_object_s {
  3918. /**
  3919. * Opaque handle. Two handles reference the same object of the enclosing type
  3920. * if and only if they are equal.
  3921. */
  3922. uint64_t handle;
  3923. } hsa_loaded_code_object_t;
  3924. /**
  3925. * @brief Load a program code object into an executable.
  3926. *
  3927. * @details A program code object contains information about resources that are
  3928. * accessible by all kernel agents that run the executable, and can be loaded
  3929. * at most once into an executable.
  3930. *
  3931. * If the program code object uses extensions, the implementation must support
  3932. * them for this operation to return successfully.
  3933. *
  3934. * @param[in] executable Executable.
  3935. *
  3936. * @param[in] code_object_reader A code object reader that holds the program
  3937. * code object to load. If a code object reader is destroyed before all the
  3938. * associated executables are destroyed, the behavior is undefined.
  3939. *
  3940. * @param[in] options Standard and vendor-specific options. Unknown options are
  3941. * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
  3942. * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
  3943. * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
  3944. * NUL-terminated string. May be NULL.
  3945. *
  3946. * @param[out] loaded_code_object Pointer to a memory location where the HSA
  3947. * runtime stores the loaded code object handle. May be NULL.
  3948. *
  3949. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  3950. *
  3951. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  3952. * initialized.
  3953. *
  3954. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  3955. * allocate the required resources.
  3956. *
  3957. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  3958. *
  3959. * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE The executable is frozen.
  3960. *
  3961. * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT_READER @p code_object_reader
  3962. * is invalid.
  3963. *
  3964. * @retval ::HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS The program code object is
  3965. * not compatible with the executable or the implementation (for example, the
  3966. * code object uses an extension that is not supported by the implementation).
  3967. */
  3968. hsa_status_t HSA_API hsa_executable_load_program_code_object(
  3969. hsa_executable_t executable,
  3970. hsa_code_object_reader_t code_object_reader,
  3971. const char *options,
  3972. hsa_loaded_code_object_t *loaded_code_object);
  3973. /**
  3974. * @brief Load an agent code object into an executable.
  3975. *
  3976. * @details The agent code object contains all defined agent
  3977. * allocation variables, functions, indirect functions, and kernels in a given
  3978. * program for a given instruction set architecture.
  3979. *
  3980. * Any module linkage declaration must have been defined either by a define
  3981. * variable or by loading a code object that has a symbol with module linkage
  3982. * definition.
  3983. *
  3984. * The default floating-point rounding mode of the code object associated with
  3985. * @p code_object_reader must match that of the executable
  3986. * (::HSA_EXECUTABLE_INFO_DEFAULT_FLOAT_ROUNDING_MODE), or be default (in which
  3987. * case the value of ::HSA_EXECUTABLE_INFO_DEFAULT_FLOAT_ROUNDING_MODE is used).
  3988. * If the agent code object uses extensions, the implementation and the agent
  3989. * must support them for this operation to return successfully.
  3990. *
  3991. * @param[in] executable Executable.
  3992. *
  3993. * @param[in] agent Agent to load code object for. A code object can be loaded
  3994. * into an executable at most once for a given agent. The instruction set
  3995. * architecture of the code object must be supported by the agent.
  3996. *
  3997. * @param[in] code_object_reader A code object reader that holds the code object
  3998. * to load. If a code object reader is destroyed before all the associated
  3999. * executables are destroyed, the behavior is undefined.
  4000. *
  4001. * @param[in] options Standard and vendor-specific options. Unknown options are
  4002. * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
  4003. * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
  4004. * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
  4005. * NUL-terminated string. May be NULL.
  4006. *
  4007. * @param[out] loaded_code_object Pointer to a memory location where the HSA
  4008. * runtime stores the loaded code object handle. May be NULL.
  4009. *
  4010. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4011. *
  4012. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4013. * initialized.
  4014. *
  4015. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  4016. * allocate the required resources.
  4017. *
  4018. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  4019. *
  4020. * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE The executable is frozen.
  4021. *
  4022. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  4023. *
  4024. * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT_READER @p code_object_reader
  4025. * is invalid.
  4026. *
  4027. * @retval ::HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS The code object read by @p
  4028. * code_object_reader is not compatible with the agent (for example, the agent
  4029. * does not support the instruction set architecture of the code object), the
  4030. * executable (for example, there is a default floating-point mode mismatch
  4031. * between the two), or the implementation.
  4032. */
  4033. hsa_status_t HSA_API hsa_executable_load_agent_code_object(
  4034. hsa_executable_t executable,
  4035. hsa_agent_t agent,
  4036. hsa_code_object_reader_t code_object_reader,
  4037. const char *options,
  4038. hsa_loaded_code_object_t *loaded_code_object);
  4039. /**
  4040. * @brief Freeze the executable.
  4041. *
  4042. * @details No modifications to executable can be made after freezing: no code
  4043. * objects can be loaded to the executable, and no external variables can be
  4044. * defined. Freezing the executable does not prevent querying the executable's
  4045. * attributes. The application must define all the external variables in an
  4046. * executable before freezing it.
  4047. *
  4048. * @param[in] executable Executable.
  4049. *
  4050. * @param[in] options Standard and vendor-specific options. Unknown options are
  4051. * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
  4052. * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
  4053. * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
  4054. * NUL-terminated string. May be NULL.
  4055. *
  4056. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4057. *
  4058. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4059. * initialized.
  4060. *
  4061. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  4062. *
  4063. * @retval ::HSA_STATUS_ERROR_VARIABLE_UNDEFINED One or more variables are
  4064. * undefined in the executable.
  4065. *
  4066. * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is already frozen.
  4067. */
  4068. hsa_status_t HSA_API hsa_executable_freeze(
  4069. hsa_executable_t executable,
  4070. const char *options);
  4071. /**
  4072. * @brief Executable attributes.
  4073. */
  4074. typedef enum {
  4075. /**
  4076. * Profile this executable is created for. The type of this attribute is
  4077. * ::hsa_profile_t.
  4078. */
  4079. HSA_EXECUTABLE_INFO_PROFILE = 1,
  4080. /**
  4081. * Executable state. The type of this attribute is ::hsa_executable_state_t.
  4082. */
  4083. HSA_EXECUTABLE_INFO_STATE = 2,
  4084. /**
  4085. * Default floating-point rounding mode specified when executable was created.
  4086. * The type of this attribute is ::hsa_default_float_rounding_mode_t.
  4087. */
  4088. HSA_EXECUTABLE_INFO_DEFAULT_FLOAT_ROUNDING_MODE = 3
  4089. } hsa_executable_info_t;
  4090. /**
  4091. * @brief Get the current value of an attribute for a given executable.
  4092. *
  4093. * @param[in] executable Executable.
  4094. *
  4095. * @param[in] attribute Attribute to query.
  4096. *
  4097. * @param[out] value Pointer to an application-allocated buffer where to store
  4098. * the value of the attribute. If the buffer passed by the application is not
  4099. * large enough to hold the value of @p attribute, the behavior is undefined.
  4100. *
  4101. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4102. *
  4103. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4104. * initialized.
  4105. *
  4106. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  4107. *
  4108. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
  4109. * executable attribute, or @p value is NULL.
  4110. */
  4111. hsa_status_t HSA_API hsa_executable_get_info(
  4112. hsa_executable_t executable,
  4113. hsa_executable_info_t attribute,
  4114. void *value);
  4115. /**
  4116. * @brief Define an external global variable with program allocation.
  4117. *
  4118. * @details This function allows the application to provide the definition
  4119. * of a variable in the global segment memory with program allocation. The
  4120. * variable must be defined before loading a code object into an executable.
  4121. * In addition, code objects loaded must not define the variable.
  4122. *
  4123. * @param[in] executable Executable. Must not be in frozen state.
  4124. *
  4125. * @param[in] variable_name Name of the variable. The Programmer's Reference
  4126. * Manual describes the standard name mangling scheme.
  4127. *
  4128. * @param[in] address Address where the variable is defined. This address must
  4129. * be in global memory and can be read and written by any agent in the
  4130. * system. The application cannot deallocate the buffer pointed by @p address
  4131. * before @p executable is destroyed.
  4132. *
  4133. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4134. *
  4135. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4136. * initialized.
  4137. *
  4138. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  4139. * allocate the required resources.
  4140. *
  4141. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  4142. *
  4143. * @retval ::HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED The variable is
  4144. * already defined.
  4145. *
  4146. * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no variable with the
  4147. * @p variable_name.
  4148. *
  4149. * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is frozen.
  4150. *
  4151. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p variable_name is NULL.
  4152. */
  4153. hsa_status_t HSA_API hsa_executable_global_variable_define(
  4154. hsa_executable_t executable,
  4155. const char *variable_name,
  4156. void *address);
  4157. /**
  4158. * @brief Define an external global variable with agent allocation.
  4159. *
  4160. * @details This function allows the application to provide the definition
  4161. * of a variable in the global segment memory with agent allocation. The
  4162. * variable must be defined before loading a code object into an executable.
  4163. * In addition, code objects loaded must not define the variable.
  4164. *
  4165. * @param[in] executable Executable. Must not be in frozen state.
  4166. *
  4167. * @param[in] agent Agent for which the variable is being defined.
  4168. *
  4169. * @param[in] variable_name Name of the variable. The Programmer's Reference
  4170. * Manual describes the standard name mangling scheme.
  4171. *
  4172. * @param[in] address Address where the variable is defined. This address must
  4173. * have been previously allocated using ::hsa_memory_allocate in a global region
  4174. * that is only visible to @p agent. The application cannot deallocate the
  4175. * buffer pointed by @p address before @p executable is destroyed.
  4176. *
  4177. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4178. *
  4179. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4180. * initialized.
  4181. *
  4182. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  4183. * allocate the required resources.
  4184. *
  4185. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  4186. *
  4187. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT @p agent is invalid.
  4188. *
  4189. * @retval ::HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED The variable is
  4190. * already defined.
  4191. *
  4192. * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no variable with the
  4193. * @p variable_name.
  4194. *
  4195. * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is frozen.
  4196. *
  4197. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p variable_name is NULL.
  4198. */
  4199. hsa_status_t HSA_API hsa_executable_agent_global_variable_define(
  4200. hsa_executable_t executable,
  4201. hsa_agent_t agent,
  4202. const char *variable_name,
  4203. void *address);
  4204. /**
  4205. * @brief Define an external readonly variable.
  4206. *
  4207. * @details This function allows the application to provide the definition
  4208. * of a variable in the readonly segment memory. The variable must be defined
  4209. * before loading a code object into an executable. In addition, code objects
  4210. * loaded must not define the variable.
  4211. *
  4212. * @param[in] executable Executable. Must not be in frozen state.
  4213. *
  4214. * @param[in] agent Agent for which the variable is being defined.
  4215. *
  4216. * @param[in] variable_name Name of the variable. The Programmer's Reference
  4217. * Manual describes the standard name mangling scheme.
  4218. *
  4219. * @param[in] address Address where the variable is defined. This address must
  4220. * have been previously allocated using ::hsa_memory_allocate in a readonly
  4221. * region associated with @p agent. The application cannot deallocate the buffer
  4222. * pointed by @p address before @p executable is destroyed.
  4223. *
  4224. * @param[in] address Address where the variable is defined. The buffer pointed
  4225. * by @p address is owned by the application, and cannot be deallocated before
  4226. * @p executable is destroyed.
  4227. *
  4228. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4229. *
  4230. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4231. * initialized.
  4232. *
  4233. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  4234. * allocate the required resources.
  4235. *
  4236. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE Executable is invalid.
  4237. *
  4238. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT @p agent is invalid.
  4239. *
  4240. * @retval ::HSA_STATUS_ERROR_VARIABLE_ALREADY_DEFINED The variable is
  4241. * already defined.
  4242. *
  4243. * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no variable with the
  4244. * @p variable_name.
  4245. *
  4246. * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is frozen.
  4247. *
  4248. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p variable_name is NULL.
  4249. */
  4250. hsa_status_t HSA_API hsa_executable_readonly_variable_define(
  4251. hsa_executable_t executable,
  4252. hsa_agent_t agent,
  4253. const char *variable_name,
  4254. void *address);
  4255. /**
  4256. * @brief Validate an executable. Checks that all code objects have matching
  4257. * machine model, profile, and default floating-point rounding mode. Checks that
  4258. * all declarations have definitions. Checks declaration-definition
  4259. * compatibility (see the HSA Programming Reference Manual for compatibility
  4260. * rules). Invoking this function is equivalent to invoking
  4261. * ::hsa_executable_validate_alt with no options.
  4262. *
  4263. * @param[in] executable Executable. Must be in frozen state.
  4264. *
  4265. * @param[out] result Memory location where the HSA runtime stores the
  4266. * validation result. If the executable passes validation, the result is 0.
  4267. *
  4268. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4269. *
  4270. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4271. * initialized.
  4272. *
  4273. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE @p executable is invalid.
  4274. *
  4275. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p result is NULL.
  4276. */
  4277. hsa_status_t HSA_API hsa_executable_validate(
  4278. hsa_executable_t executable,
  4279. uint32_t *result);
  4280. /**
  4281. * @brief Validate an executable. Checks that all code objects have matching
  4282. * machine model, profile, and default floating-point rounding mode. Checks that
  4283. * all declarations have definitions. Checks declaration-definition
  4284. * compatibility (see the HSA Programming Reference Manual for compatibility
  4285. * rules).
  4286. *
  4287. * @param[in] executable Executable. Must be in frozen state.
  4288. *
  4289. * @param[in] options Standard and vendor-specific options. Unknown options are
  4290. * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
  4291. * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
  4292. * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
  4293. * NUL-terminated string. May be NULL.
  4294. *
  4295. * @param[out] result Memory location where the HSA runtime stores the
  4296. * validation result. If the executable passes validation, the result is 0.
  4297. *
  4298. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4299. *
  4300. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4301. * initialized.
  4302. *
  4303. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE @p executable is invalid.
  4304. *
  4305. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p result is NULL.
  4306. */
  4307. hsa_status_t HSA_API hsa_executable_validate_alt(
  4308. hsa_executable_t executable,
  4309. const char *options,
  4310. uint32_t *result);
  4311. /**
  4312. * @brief Executable symbol handle.
  4313. *
  4314. * The lifetime of an executable object symbol matches that of the executable
  4315. * associated with it. An operation on a symbol whose associated executable has
  4316. * been destroyed results in undefined behavior.
  4317. */
  4318. typedef struct hsa_executable_symbol_s {
  4319. /**
  4320. * Opaque handle. Two handles reference the same object of the enclosing type
  4321. * if and only if they are equal.
  4322. */
  4323. uint64_t handle;
  4324. } hsa_executable_symbol_t;
  4325. /**
  4326. * @deprecated Use ::hsa_executable_get_symbol_by_name instead.
  4327. *
  4328. * @brief Get the symbol handle for a given a symbol name.
  4329. *
  4330. * @param[in] executable Executable.
  4331. *
  4332. * @param[in] module_name Module name. Must be NULL if the symbol has
  4333. * program linkage.
  4334. *
  4335. * @param[in] symbol_name Symbol name.
  4336. *
  4337. * @param[in] agent Agent associated with the symbol. If the symbol is
  4338. * independent of any agent (for example, a variable with program
  4339. * allocation), this argument is ignored.
  4340. *
  4341. * @param[in] call_convention Call convention associated with the symbol. If the
  4342. * symbol does not correspond to an indirect function, this argument is ignored.
  4343. *
  4344. * @param[out] symbol Memory location where the HSA runtime stores the symbol
  4345. * handle.
  4346. *
  4347. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4348. *
  4349. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4350. * initialized.
  4351. *
  4352. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  4353. *
  4354. * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no symbol with a name
  4355. * that matches @p symbol_name.
  4356. *
  4357. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p symbol_name is NULL, or
  4358. * @p symbol is NULL.
  4359. */
  4360. hsa_status_t HSA_API HSA_DEPRECATED hsa_executable_get_symbol(
  4361. hsa_executable_t executable,
  4362. const char *module_name,
  4363. const char *symbol_name,
  4364. hsa_agent_t agent,
  4365. int32_t call_convention,
  4366. hsa_executable_symbol_t *symbol);
  4367. /**
  4368. * @brief Retrieve the symbol handle corresponding to a given a symbol name.
  4369. *
  4370. * @param[in] executable Executable.
  4371. *
  4372. * @param[in] symbol_name Symbol name. Must be a NUL-terminated character
  4373. * array. The Programmer's Reference Manual describes the standard name mangling
  4374. * scheme.
  4375. *
  4376. * @param[in] agent Pointer to the agent for which the symbol with the given
  4377. * name is defined. If the symbol corresponding to the given name has program
  4378. * allocation, @p agent must be NULL.
  4379. *
  4380. * @param[out] symbol Memory location where the HSA runtime stores the symbol
  4381. * handle. Must not be NULL.
  4382. *
  4383. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4384. *
  4385. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4386. * initialized.
  4387. *
  4388. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  4389. *
  4390. * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no symbol with a name
  4391. * that matches @p symbol_name.
  4392. *
  4393. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p symbol_name is NULL, or @p
  4394. * symbol is NULL.
  4395. */
  4396. hsa_status_t HSA_API hsa_executable_get_symbol_by_name(
  4397. hsa_executable_t executable,
  4398. const char *symbol_name,
  4399. const hsa_agent_t *agent,
  4400. hsa_executable_symbol_t *symbol);
  4401. /**
  4402. * @brief Symbol type.
  4403. */
  4404. typedef enum {
  4405. /**
  4406. * Variable.
  4407. */
  4408. HSA_SYMBOL_KIND_VARIABLE = 0,
  4409. /**
  4410. * Kernel.
  4411. */
  4412. HSA_SYMBOL_KIND_KERNEL = 1,
  4413. /**
  4414. * Indirect function.
  4415. */
  4416. HSA_SYMBOL_KIND_INDIRECT_FUNCTION = 2
  4417. } hsa_symbol_kind_t;
  4418. /**
  4419. * @brief Linkage type of a symbol.
  4420. */
  4421. typedef enum {
  4422. /**
  4423. * Module linkage.
  4424. */
  4425. HSA_SYMBOL_LINKAGE_MODULE = 0,
  4426. /**
  4427. * Program linkage.
  4428. */
  4429. HSA_SYMBOL_LINKAGE_PROGRAM = 1
  4430. } hsa_symbol_linkage_t;
  4431. /**
  4432. * @brief Allocation type of a variable.
  4433. */
  4434. typedef enum {
  4435. /**
  4436. * Agent allocation.
  4437. */
  4438. HSA_VARIABLE_ALLOCATION_AGENT = 0,
  4439. /**
  4440. * Program allocation.
  4441. */
  4442. HSA_VARIABLE_ALLOCATION_PROGRAM = 1
  4443. } hsa_variable_allocation_t;
  4444. /**
  4445. * @brief Memory segment associated with a variable.
  4446. */
  4447. typedef enum {
  4448. /**
  4449. * Global memory segment.
  4450. */
  4451. HSA_VARIABLE_SEGMENT_GLOBAL = 0,
  4452. /**
  4453. * Readonly memory segment.
  4454. */
  4455. HSA_VARIABLE_SEGMENT_READONLY = 1
  4456. } hsa_variable_segment_t;
  4457. /**
  4458. * @brief Executable symbol attributes.
  4459. */
  4460. typedef enum {
  4461. /**
  4462. * The kind of the symbol. The type of this attribute is ::hsa_symbol_kind_t.
  4463. */
  4464. HSA_EXECUTABLE_SYMBOL_INFO_TYPE = 0,
  4465. /**
  4466. * The length of the symbol name in bytes, not including the NUL terminator.
  4467. * The type of this attribute is uint32_t.
  4468. */
  4469. HSA_EXECUTABLE_SYMBOL_INFO_NAME_LENGTH = 1,
  4470. /**
  4471. * The name of the symbol. The type of this attribute is character array with
  4472. * the length equal to the value of ::HSA_EXECUTABLE_SYMBOL_INFO_NAME_LENGTH
  4473. * attribute.
  4474. */
  4475. HSA_EXECUTABLE_SYMBOL_INFO_NAME = 2,
  4476. /**
  4477. * @deprecated
  4478. *
  4479. * The length of the module name in bytes (not including the NUL terminator)
  4480. * to which this symbol belongs if this symbol has module linkage, otherwise 0
  4481. * is returned. The type of this attribute is uint32_t.
  4482. */
  4483. HSA_EXECUTABLE_SYMBOL_INFO_MODULE_NAME_LENGTH = 3,
  4484. /**
  4485. * @deprecated
  4486. *
  4487. * The module name to which this symbol belongs if this symbol has module
  4488. * linkage, otherwise an empty string is returned. The type of this attribute
  4489. * is character array with the length equal to the value of
  4490. * ::HSA_EXECUTABLE_SYMBOL_INFO_MODULE_NAME_LENGTH attribute.
  4491. */
  4492. HSA_EXECUTABLE_SYMBOL_INFO_MODULE_NAME = 4,
  4493. /**
  4494. * @deprecated
  4495. *
  4496. * Agent associated with this symbol. If the symbol is a variable, the
  4497. * value of this attribute is only defined if
  4498. * ::HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ALLOCATION is
  4499. * ::HSA_VARIABLE_ALLOCATION_AGENT. The type of this attribute is hsa_agent_t.
  4500. */
  4501. HSA_EXECUTABLE_SYMBOL_INFO_AGENT = 20,
  4502. /**
  4503. * The address of the variable. The value of this attribute is undefined if
  4504. * the symbol is not a variable. The type of this attribute is uint64_t.
  4505. *
  4506. * If executable's state is ::HSA_EXECUTABLE_STATE_UNFROZEN, then 0 is
  4507. * returned.
  4508. */
  4509. HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS = 21,
  4510. /**
  4511. * The linkage kind of the symbol. The type of this attribute is
  4512. * ::hsa_symbol_linkage_t.
  4513. */
  4514. HSA_EXECUTABLE_SYMBOL_INFO_LINKAGE = 5,
  4515. /**
  4516. * Indicates whether the symbol corresponds to a definition. The type of this
  4517. * attribute is bool.
  4518. */
  4519. HSA_EXECUTABLE_SYMBOL_INFO_IS_DEFINITION = 17,
  4520. /**
  4521. * @deprecated
  4522. *
  4523. * The allocation kind of the variable. The value of this attribute is
  4524. * undefined if the symbol is not a variable. The type of this attribute is
  4525. * ::hsa_variable_allocation_t.
  4526. */
  4527. HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ALLOCATION = 6,
  4528. /**
  4529. * @deprecated
  4530. *
  4531. * The segment kind of the variable. The value of this attribute is undefined
  4532. * if the symbol is not a variable. The type of this attribute is
  4533. * ::hsa_variable_segment_t.
  4534. */
  4535. HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_SEGMENT = 7,
  4536. /**
  4537. * @deprecated
  4538. *
  4539. * Alignment of the symbol in memory. The value of this attribute is undefined
  4540. * if the symbol is not a variable. The type of this attribute is uint32_t.
  4541. *
  4542. * The current alignment of the variable in memory may be greater than the
  4543. * value specified in the source program variable declaration.
  4544. */
  4545. HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ALIGNMENT = 8,
  4546. /**
  4547. * @deprecated
  4548. *
  4549. * Size of the variable. The value of this attribute is undefined if
  4550. * the symbol is not a variable. The type of this attribute is uint32_t.
  4551. *
  4552. * A value of 0 is returned if the variable is an external variable and has an
  4553. * unknown dimension.
  4554. */
  4555. HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_SIZE = 9,
  4556. /**
  4557. * @deprecated
  4558. *
  4559. * Indicates whether the variable is constant. The value of this attribute is
  4560. * undefined if the symbol is not a variable. The type of this attribute is
  4561. * bool.
  4562. */
  4563. HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_IS_CONST = 10,
  4564. /**
  4565. * Kernel object handle, used in the kernel dispatch packet. The value of this
  4566. * attribute is undefined if the symbol is not a kernel. The type of this
  4567. * attribute is uint64_t.
  4568. *
  4569. * If the state of the executable is ::HSA_EXECUTABLE_STATE_UNFROZEN, then 0
  4570. * is returned.
  4571. */
  4572. HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT = 22,
  4573. /**
  4574. * Size of kernarg segment memory that is required to hold the values of the
  4575. * kernel arguments, in bytes. Must be a multiple of 16. The value of this
  4576. * attribute is undefined if the symbol is not a kernel. The type of this
  4577. * attribute is uint32_t.
  4578. */
  4579. HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_SIZE = 11,
  4580. /**
  4581. * Alignment (in bytes) of the buffer used to pass arguments to the kernel,
  4582. * which is the maximum of 16 and the maximum alignment of any of the kernel
  4583. * arguments. The value of this attribute is undefined if the symbol is not a
  4584. * kernel. The type of this attribute is uint32_t.
  4585. */
  4586. HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_ALIGNMENT = 12,
  4587. /**
  4588. * Size of static group segment memory required by the kernel (per
  4589. * work-group), in bytes. The value of this attribute is undefined
  4590. * if the symbol is not a kernel. The type of this attribute is uint32_t.
  4591. *
  4592. * The reported amount does not include any dynamically allocated group
  4593. * segment memory that may be requested by the application when a kernel is
  4594. * dispatched.
  4595. */
  4596. HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE = 13,
  4597. /**
  4598. * Size of static private, spill, and arg segment memory required by
  4599. * this kernel (per work-item), in bytes. The value of this attribute is
  4600. * undefined if the symbol is not a kernel. The type of this attribute is
  4601. * uint32_t.
  4602. *
  4603. * If the value of ::HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK is
  4604. * true, the kernel may use more private memory than the reported value, and
  4605. * the application must add the dynamic call stack usage to @a
  4606. * private_segment_size when populating a kernel dispatch packet.
  4607. */
  4608. HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE = 14,
  4609. /**
  4610. * Dynamic callstack flag. The value of this attribute is undefined if the
  4611. * symbol is not a kernel. The type of this attribute is bool.
  4612. *
  4613. * If this flag is set (the value is true), the kernel uses a dynamically
  4614. * sized call stack. This can happen if recursive calls, calls to indirect
  4615. * functions, or the HSAIL alloca instruction are present in the kernel.
  4616. */
  4617. HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK = 15,
  4618. /**
  4619. * @deprecated
  4620. *
  4621. * Call convention of the kernel. The value of this attribute is undefined if
  4622. * the symbol is not a kernel. The type of this attribute is uint32_t.
  4623. */
  4624. HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_CALL_CONVENTION = 18,
  4625. /**
  4626. * Indirect function object handle. The value of this attribute is undefined
  4627. * if the symbol is not an indirect function, or the associated agent does
  4628. * not support the Full Profile. The type of this attribute depends on the
  4629. * machine model: the type is uint32_t for small machine model, and uint64_t
  4630. * for large model.
  4631. *
  4632. * If the state of the executable is ::HSA_EXECUTABLE_STATE_UNFROZEN, then 0
  4633. * is returned.
  4634. */
  4635. HSA_EXECUTABLE_SYMBOL_INFO_INDIRECT_FUNCTION_OBJECT = 23,
  4636. /**
  4637. * @deprecated
  4638. *
  4639. * Call convention of the indirect function. The value of this attribute is
  4640. * undefined if the symbol is not an indirect function, or the associated
  4641. * agent does not support the Full Profile. The type of this attribute is
  4642. * uint32_t.
  4643. */
  4644. HSA_EXECUTABLE_SYMBOL_INFO_INDIRECT_FUNCTION_CALL_CONVENTION = 16
  4645. } hsa_executable_symbol_info_t;
  4646. /**
  4647. * @brief Get the current value of an attribute for a given executable symbol.
  4648. *
  4649. * @param[in] executable_symbol Executable symbol.
  4650. *
  4651. * @param[in] attribute Attribute to query.
  4652. *
  4653. * @param[out] value Pointer to an application-allocated buffer where to store
  4654. * the value of the attribute. If the buffer passed by the application is not
  4655. * large enough to hold the value of @p attribute, the behavior is undefined.
  4656. *
  4657. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4658. *
  4659. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4660. * initialized.
  4661. *
  4662. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE_SYMBOL The executable symbol is
  4663. * invalid.
  4664. *
  4665. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
  4666. * executable symbol attribute, or @p value is NULL.
  4667. */
  4668. hsa_status_t HSA_API hsa_executable_symbol_get_info(
  4669. hsa_executable_symbol_t executable_symbol,
  4670. hsa_executable_symbol_info_t attribute,
  4671. void *value);
  4672. /**
  4673. * @deprecated
  4674. *
  4675. * @brief Iterate over the symbols in a executable, and invoke an
  4676. * application-defined callback on every iteration.
  4677. *
  4678. * @param[in] executable Executable.
  4679. *
  4680. * @param[in] callback Callback to be invoked once per executable symbol. The
  4681. * HSA runtime passes three arguments to the callback: the executable, a symbol,
  4682. * and the application data. If @p callback returns a status other than
  4683. * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
  4684. * ::hsa_executable_iterate_symbols returns that status value.
  4685. *
  4686. * @param[in] data Application data that is passed to @p callback on every
  4687. * iteration. May be NULL.
  4688. *
  4689. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4690. *
  4691. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4692. * initialized.
  4693. *
  4694. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  4695. *
  4696. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
  4697. */
  4698. hsa_status_t HSA_API HSA_DEPRECATED hsa_executable_iterate_symbols(
  4699. hsa_executable_t executable,
  4700. hsa_status_t (*callback)(hsa_executable_t exec,
  4701. hsa_executable_symbol_t symbol,
  4702. void *data),
  4703. void *data);
  4704. /**
  4705. * @brief Iterate over the kernels, indirect functions, and agent allocation
  4706. * variables in an executable for a given agent, and invoke an application-
  4707. * defined callback on every iteration.
  4708. *
  4709. * @param[in] executable Executable.
  4710. *
  4711. * @param[in] agent Agent.
  4712. *
  4713. * @param[in] callback Callback to be invoked once per executable symbol. The
  4714. * HSA runtime passes three arguments to the callback: the executable, a symbol,
  4715. * and the application data. If @p callback returns a status other than
  4716. * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
  4717. * ::hsa_executable_iterate_symbols returns that status value.
  4718. *
  4719. * @param[in] data Application data that is passed to @p callback on every
  4720. * iteration. May be NULL.
  4721. *
  4722. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4723. *
  4724. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4725. * initialized.
  4726. *
  4727. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  4728. *
  4729. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
  4730. */
  4731. hsa_status_t HSA_API hsa_executable_iterate_agent_symbols(
  4732. hsa_executable_t executable,
  4733. hsa_agent_t agent,
  4734. hsa_status_t (*callback)(hsa_executable_t exec,
  4735. hsa_agent_t agent,
  4736. hsa_executable_symbol_t symbol,
  4737. void *data),
  4738. void *data);
  4739. /**
  4740. * @brief Iterate over the program allocation variables in an executable, and
  4741. * invoke an application-defined callback on every iteration.
  4742. *
  4743. * @param[in] executable Executable.
  4744. *
  4745. * @param[in] callback Callback to be invoked once per executable symbol. The
  4746. * HSA runtime passes three arguments to the callback: the executable, a symbol,
  4747. * and the application data. If @p callback returns a status other than
  4748. * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
  4749. * ::hsa_executable_iterate_symbols returns that status value.
  4750. *
  4751. * @param[in] data Application data that is passed to @p callback on every
  4752. * iteration. May be NULL.
  4753. *
  4754. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4755. *
  4756. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4757. * initialized.
  4758. *
  4759. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  4760. *
  4761. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
  4762. */
  4763. hsa_status_t HSA_API hsa_executable_iterate_program_symbols(
  4764. hsa_executable_t executable,
  4765. hsa_status_t (*callback)(hsa_executable_t exec,
  4766. hsa_executable_symbol_t symbol,
  4767. void *data),
  4768. void *data);
  4769. /** @} */
  4770. /** \defgroup code-object Code Objects (deprecated).
  4771. * @{
  4772. */
  4773. /**
  4774. * @deprecated
  4775. *
  4776. * @brief Struct containing an opaque handle to a code object, which contains
  4777. * ISA for finalized kernels and indirect functions together with information
  4778. * about the global or readonly segment variables they reference.
  4779. */
  4780. typedef struct hsa_code_object_s {
  4781. /**
  4782. * Opaque handle. Two handles reference the same object of the enclosing type
  4783. * if and only if they are equal.
  4784. */
  4785. uint64_t handle;
  4786. } hsa_code_object_t;
  4787. /**
  4788. * @deprecated
  4789. *
  4790. * @brief Application data handle that is passed to the serialization
  4791. * and deserialization functions.
  4792. */
  4793. typedef struct hsa_callback_data_s {
  4794. /**
  4795. * Opaque handle.
  4796. */
  4797. uint64_t handle;
  4798. } hsa_callback_data_t;
  4799. /**
  4800. * @deprecated
  4801. *
  4802. * @brief Serialize a code object. Can be used for offline finalization,
  4803. * install-time finalization, disk code caching, etc.
  4804. *
  4805. * @param[in] code_object Code object.
  4806. *
  4807. * @param[in] alloc_callback Callback function for memory allocation. Must not
  4808. * be NULL. The HSA runtime passes three arguments to the callback: the
  4809. * allocation size, the application data, and a pointer to a memory location
  4810. * where the application stores the allocation result. The HSA runtime invokes
  4811. * @p alloc_callback once to allocate a buffer that contains the serialized
  4812. * version of @p code_object. If the callback returns a status code other than
  4813. * ::HSA_STATUS_SUCCESS, this function returns the same code.
  4814. *
  4815. * @param[in] callback_data Application data that is passed to @p
  4816. * alloc_callback. May be NULL.
  4817. *
  4818. * @param[in] options Standard and vendor-specific options. Unknown options are
  4819. * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
  4820. * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
  4821. * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
  4822. * NUL-terminated string. May be NULL.
  4823. *
  4824. * @param[out] serialized_code_object Memory location where the HSA runtime
  4825. * stores a pointer to the serialized code object. Must not be NULL.
  4826. *
  4827. * @param[out] serialized_code_object_size Memory location where the HSA runtime
  4828. * stores the size (in bytes) of @p serialized_code_object. The returned value
  4829. * matches the allocation size passed by the HSA runtime to @p
  4830. * alloc_callback. Must not be NULL.
  4831. *
  4832. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4833. *
  4834. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4835. * initialized.
  4836. *
  4837. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  4838. * allocate the required resources.
  4839. *
  4840. * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
  4841. *
  4842. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p alloc_callback, @p
  4843. * serialized_code_object, or @p serialized_code_object_size are NULL.
  4844. */
  4845. hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_serialize(
  4846. hsa_code_object_t code_object,
  4847. hsa_status_t (*alloc_callback)(size_t size,
  4848. hsa_callback_data_t data,
  4849. void **address),
  4850. hsa_callback_data_t callback_data,
  4851. const char *options,
  4852. void **serialized_code_object,
  4853. size_t *serialized_code_object_size);
  4854. /**
  4855. * @deprecated
  4856. *
  4857. * @brief Deserialize a code object.
  4858. *
  4859. * @param[in] serialized_code_object A serialized code object. Must not be NULL.
  4860. *
  4861. * @param[in] serialized_code_object_size The size (in bytes) of @p
  4862. * serialized_code_object. Must not be 0.
  4863. *
  4864. * @param[in] options Standard and vendor-specific options. Unknown options are
  4865. * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
  4866. * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
  4867. * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
  4868. * NUL-terminated string. May be NULL.
  4869. *
  4870. * @param[out] code_object Memory location where the HSA runtime stores the
  4871. * deserialized code object.
  4872. *
  4873. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4874. *
  4875. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4876. * initialized.
  4877. *
  4878. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  4879. * allocate the required resources.
  4880. *
  4881. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p serialized_code_object, or @p
  4882. * code_object are NULL, or @p serialized_code_object_size is 0.
  4883. */
  4884. hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_deserialize(
  4885. void *serialized_code_object,
  4886. size_t serialized_code_object_size,
  4887. const char *options,
  4888. hsa_code_object_t *code_object);
  4889. /**
  4890. * @deprecated
  4891. *
  4892. * @brief Destroy a code object.
  4893. *
  4894. * @details The lifetime of a code object must exceed that of any executable
  4895. * where it has been loaded. If an executable that loaded @p code_object has not
  4896. * been destroyed, the behavior is undefined.
  4897. *
  4898. * @param[in] code_object Code object. The handle becomes invalid after it has
  4899. * been destroyed.
  4900. *
  4901. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4902. *
  4903. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4904. * initialized.
  4905. *
  4906. * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
  4907. */
  4908. hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_destroy(
  4909. hsa_code_object_t code_object);
  4910. /**
  4911. * @deprecated
  4912. *
  4913. * @brief Code object type.
  4914. */
  4915. typedef enum {
  4916. /**
  4917. * Produces code object that contains ISA for all kernels and indirect
  4918. * functions in HSA source.
  4919. */
  4920. HSA_CODE_OBJECT_TYPE_PROGRAM = 0
  4921. } hsa_code_object_type_t;
  4922. /**
  4923. * @deprecated
  4924. *
  4925. * @brief Code object attributes.
  4926. */
  4927. typedef enum {
  4928. /**
  4929. * The version of the code object. The type of this attribute is a
  4930. * NUL-terminated char[64]. The name must be at most 63 characters long (not
  4931. * including the NUL terminator) and all array elements not used for the name
  4932. * must be NUL.
  4933. */
  4934. HSA_CODE_OBJECT_INFO_VERSION = 0,
  4935. /**
  4936. * Type of code object. The type of this attribute is
  4937. * ::hsa_code_object_type_t.
  4938. */
  4939. HSA_CODE_OBJECT_INFO_TYPE = 1,
  4940. /**
  4941. * Instruction set architecture this code object is produced for. The type of
  4942. * this attribute is ::hsa_isa_t.
  4943. */
  4944. HSA_CODE_OBJECT_INFO_ISA = 2,
  4945. /**
  4946. * Machine model this code object is produced for. The type of this attribute
  4947. * is ::hsa_machine_model_t.
  4948. */
  4949. HSA_CODE_OBJECT_INFO_MACHINE_MODEL = 3,
  4950. /**
  4951. * Profile this code object is produced for. The type of this attribute is
  4952. * ::hsa_profile_t.
  4953. */
  4954. HSA_CODE_OBJECT_INFO_PROFILE = 4,
  4955. /**
  4956. * Default floating-point rounding mode used when the code object is
  4957. * produced. The type of this attribute is
  4958. * ::hsa_default_float_rounding_mode_t.
  4959. */
  4960. HSA_CODE_OBJECT_INFO_DEFAULT_FLOAT_ROUNDING_MODE = 5
  4961. } hsa_code_object_info_t;
  4962. /**
  4963. * @deprecated
  4964. *
  4965. * @brief Get the current value of an attribute for a given code object.
  4966. *
  4967. * @param[in] code_object Code object.
  4968. *
  4969. * @param[in] attribute Attribute to query.
  4970. *
  4971. * @param[out] value Pointer to an application-allocated buffer where to store
  4972. * the value of the attribute. If the buffer passed by the application is not
  4973. * large enough to hold the value of @p attribute, the behavior is undefined.
  4974. *
  4975. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  4976. *
  4977. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  4978. * initialized.
  4979. *
  4980. * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
  4981. *
  4982. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
  4983. * code object attribute, or @p value is NULL.
  4984. */
  4985. hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_get_info(
  4986. hsa_code_object_t code_object,
  4987. hsa_code_object_info_t attribute,
  4988. void *value);
  4989. /**
  4990. * @deprecated
  4991. *
  4992. * @brief Load code object into the executable.
  4993. *
  4994. * @details Every global or readonly variable that is external must be defined
  4995. * before loading the code object. An internal global or readonly variable is
  4996. * allocated once the code object, that is being loaded, references this
  4997. * variable and this variable is not allocated.
  4998. *
  4999. * Any module linkage declaration must have been defined either by a define
  5000. * variable or by loading a code object that has a symbol with module linkage
  5001. * definition.
  5002. *
  5003. * @param[in] executable Executable.
  5004. *
  5005. * @param[in] agent Agent to load code object for. The agent must support the
  5006. * default floating-point rounding mode used by @p code_object.
  5007. *
  5008. * @param[in] code_object Code object to load. The lifetime of the code object
  5009. * must exceed that of the executable: if @p code_object is destroyed before @p
  5010. * executable, the behavior is undefined.
  5011. *
  5012. * @param[in] options Standard and vendor-specific options. Unknown options are
  5013. * ignored. A standard option begins with the "-hsa_" prefix. Options beginning
  5014. * with the "-hsa_ext_<extension_name>_" prefix are reserved for extensions. A
  5015. * vendor-specific option begins with the "-<vendor_name>_" prefix. Must be a
  5016. * NUL-terminated string. May be NULL.
  5017. *
  5018. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  5019. *
  5020. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  5021. * initialized.
  5022. *
  5023. * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to
  5024. * allocate the required resources.
  5025. *
  5026. * @retval ::HSA_STATUS_ERROR_INVALID_EXECUTABLE The executable is invalid.
  5027. *
  5028. * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid.
  5029. *
  5030. * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
  5031. *
  5032. * @retval ::HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS @p agent is not compatible
  5033. * with @p code_object (for example, @p agent does not support the default
  5034. * floating-point rounding mode specified by @p code_object), or @p code_object
  5035. * is not compatible with @p executable (for example, @p code_object and @p
  5036. * executable have different machine models or profiles).
  5037. *
  5038. * @retval ::HSA_STATUS_ERROR_FROZEN_EXECUTABLE @p executable is frozen.
  5039. */
  5040. hsa_status_t HSA_API HSA_DEPRECATED hsa_executable_load_code_object(
  5041. hsa_executable_t executable,
  5042. hsa_agent_t agent,
  5043. hsa_code_object_t code_object,
  5044. const char *options);
  5045. /**
  5046. * @deprecated
  5047. *
  5048. * @brief Code object symbol handle.
  5049. *
  5050. * The lifetime of a code object symbol matches that of the code object
  5051. * associated with it. An operation on a symbol whose associated code object has
  5052. * been destroyed results in undefined behavior.
  5053. */
  5054. typedef struct hsa_code_symbol_s {
  5055. /**
  5056. * Opaque handle. Two handles reference the same object of the enclosing type
  5057. * if and only if they are equal.
  5058. */
  5059. uint64_t handle;
  5060. } hsa_code_symbol_t;
  5061. /**
  5062. * @deprecated
  5063. *
  5064. * @brief Get the symbol handle within a code object for a given a symbol name.
  5065. *
  5066. * @param[in] code_object Code object.
  5067. *
  5068. * @param[in] symbol_name Symbol name.
  5069. *
  5070. * @param[out] symbol Memory location where the HSA runtime stores the symbol
  5071. * handle.
  5072. *
  5073. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  5074. *
  5075. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  5076. * initialized.
  5077. *
  5078. * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
  5079. *
  5080. * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no symbol with a name
  5081. * that matches @p symbol_name.
  5082. *
  5083. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p symbol_name is NULL, or
  5084. * @p symbol is NULL.
  5085. */
  5086. hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_get_symbol(
  5087. hsa_code_object_t code_object,
  5088. const char *symbol_name,
  5089. hsa_code_symbol_t *symbol);
  5090. /**
  5091. * @deprecated
  5092. *
  5093. * @brief Get the symbol handle within a code object for a given a symbol name.
  5094. *
  5095. * @param[in] code_object Code object.
  5096. *
  5097. * @param[in] module_name Module name. Must be NULL if the symbol has
  5098. * program linkage.
  5099. *
  5100. * @param[in] symbol_name Symbol name.
  5101. *
  5102. * @param[out] symbol Memory location where the HSA runtime stores the symbol
  5103. * handle.
  5104. *
  5105. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  5106. *
  5107. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  5108. * initialized.
  5109. *
  5110. * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
  5111. *
  5112. * @retval ::HSA_STATUS_ERROR_INVALID_SYMBOL_NAME There is no symbol with a name
  5113. * that matches @p symbol_name.
  5114. *
  5115. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p symbol_name is NULL, or
  5116. * @p symbol is NULL.
  5117. */
  5118. hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_get_symbol_from_name(
  5119. hsa_code_object_t code_object,
  5120. const char *module_name,
  5121. const char *symbol_name,
  5122. hsa_code_symbol_t *symbol);
  5123. /**
  5124. * @deprecated
  5125. *
  5126. * @brief Code object symbol attributes.
  5127. */
  5128. typedef enum {
  5129. /**
  5130. * The type of the symbol. The type of this attribute is ::hsa_symbol_kind_t.
  5131. */
  5132. HSA_CODE_SYMBOL_INFO_TYPE = 0,
  5133. /**
  5134. * The length of the symbol name in bytes, not including the NUL terminator.
  5135. * The type of this attribute is uint32_t.
  5136. */
  5137. HSA_CODE_SYMBOL_INFO_NAME_LENGTH = 1,
  5138. /**
  5139. * The name of the symbol. The type of this attribute is character array with
  5140. * the length equal to the value of ::HSA_CODE_SYMBOL_INFO_NAME_LENGTH
  5141. * attribute.
  5142. */
  5143. HSA_CODE_SYMBOL_INFO_NAME = 2,
  5144. /**
  5145. * The length of the module name in bytes (not including the NUL terminator)
  5146. * to which this symbol belongs if this symbol has module linkage, otherwise 0
  5147. * is returned. The type of this attribute is uint32_t.
  5148. */
  5149. HSA_CODE_SYMBOL_INFO_MODULE_NAME_LENGTH = 3,
  5150. /**
  5151. * The module name to which this symbol belongs if this symbol has module
  5152. * linkage, otherwise an empty string is returned. The type of this attribute
  5153. * is character array with the length equal to the value of
  5154. * ::HSA_CODE_SYMBOL_INFO_MODULE_NAME_LENGTH attribute.
  5155. */
  5156. HSA_CODE_SYMBOL_INFO_MODULE_NAME = 4,
  5157. /**
  5158. * The linkage kind of the symbol. The type of this attribute is
  5159. * ::hsa_symbol_linkage_t.
  5160. */
  5161. HSA_CODE_SYMBOL_INFO_LINKAGE = 5,
  5162. /**
  5163. * Indicates whether the symbol corresponds to a definition. The type of this
  5164. * attribute is bool.
  5165. */
  5166. HSA_CODE_SYMBOL_INFO_IS_DEFINITION = 17,
  5167. /**
  5168. * The allocation kind of the variable. The value of this attribute is
  5169. * undefined if the symbol is not a variable. The type of this attribute is
  5170. * ::hsa_variable_allocation_t.
  5171. */
  5172. HSA_CODE_SYMBOL_INFO_VARIABLE_ALLOCATION = 6,
  5173. /**
  5174. * The segment kind of the variable. The value of this attribute is
  5175. * undefined if the symbol is not a variable. The type of this attribute is
  5176. * ::hsa_variable_segment_t.
  5177. */
  5178. HSA_CODE_SYMBOL_INFO_VARIABLE_SEGMENT = 7,
  5179. /**
  5180. * Alignment of the symbol in memory. The value of this attribute is undefined
  5181. * if the symbol is not a variable. The type of this attribute is uint32_t.
  5182. *
  5183. * The current alignment of the variable in memory may be greater than the
  5184. * value specified in the source program variable declaration.
  5185. */
  5186. HSA_CODE_SYMBOL_INFO_VARIABLE_ALIGNMENT = 8,
  5187. /**
  5188. * Size of the variable. The value of this attribute is undefined if the
  5189. * symbol is not a variable. The type of this attribute is uint32_t.
  5190. *
  5191. * A size of 0 is returned if the variable is an external variable and has an
  5192. * unknown dimension.
  5193. */
  5194. HSA_CODE_SYMBOL_INFO_VARIABLE_SIZE = 9,
  5195. /**
  5196. * Indicates whether the variable is constant. The value of this attribute is
  5197. * undefined if the symbol is not a variable. The type of this attribute is
  5198. * bool.
  5199. */
  5200. HSA_CODE_SYMBOL_INFO_VARIABLE_IS_CONST = 10,
  5201. /**
  5202. * Size of kernarg segment memory that is required to hold the values of the
  5203. * kernel arguments, in bytes. Must be a multiple of 16. The value of this
  5204. * attribute is undefined if the symbol is not a kernel. The type of this
  5205. * attribute is uint32_t.
  5206. */
  5207. HSA_CODE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_SIZE = 11,
  5208. /**
  5209. * Alignment (in bytes) of the buffer used to pass arguments to the kernel,
  5210. * which is the maximum of 16 and the maximum alignment of any of the kernel
  5211. * arguments. The value of this attribute is undefined if the symbol is not a
  5212. * kernel. The type of this attribute is uint32_t.
  5213. */
  5214. HSA_CODE_SYMBOL_INFO_KERNEL_KERNARG_SEGMENT_ALIGNMENT = 12,
  5215. /**
  5216. * Size of static group segment memory required by the kernel (per
  5217. * work-group), in bytes. The value of this attribute is undefined
  5218. * if the symbol is not a kernel. The type of this attribute is uint32_t.
  5219. *
  5220. * The reported amount does not include any dynamically allocated group
  5221. * segment memory that may be requested by the application when a kernel is
  5222. * dispatched.
  5223. */
  5224. HSA_CODE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE = 13,
  5225. /**
  5226. * Size of static private, spill, and arg segment memory required by
  5227. * this kernel (per work-item), in bytes. The value of this attribute is
  5228. * undefined if the symbol is not a kernel. The type of this attribute is
  5229. * uint32_t.
  5230. *
  5231. * If the value of ::HSA_CODE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK is true,
  5232. * the kernel may use more private memory than the reported value, and the
  5233. * application must add the dynamic call stack usage to @a
  5234. * private_segment_size when populating a kernel dispatch packet.
  5235. */
  5236. HSA_CODE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE = 14,
  5237. /**
  5238. * Dynamic callstack flag. The value of this attribute is undefined if the
  5239. * symbol is not a kernel. The type of this attribute is bool.
  5240. *
  5241. * If this flag is set (the value is true), the kernel uses a dynamically
  5242. * sized call stack. This can happen if recursive calls, calls to indirect
  5243. * functions, or the HSAIL alloca instruction are present in the kernel.
  5244. */
  5245. HSA_CODE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK = 15,
  5246. /**
  5247. * Call convention of the kernel. The value of this attribute is undefined if
  5248. * the symbol is not a kernel. The type of this attribute is uint32_t.
  5249. */
  5250. HSA_CODE_SYMBOL_INFO_KERNEL_CALL_CONVENTION = 18,
  5251. /**
  5252. * Call convention of the indirect function. The value of this attribute is
  5253. * undefined if the symbol is not an indirect function. The type of this
  5254. * attribute is uint32_t.
  5255. */
  5256. HSA_CODE_SYMBOL_INFO_INDIRECT_FUNCTION_CALL_CONVENTION = 16
  5257. } hsa_code_symbol_info_t;
  5258. /**
  5259. * @deprecated
  5260. *
  5261. * @brief Get the current value of an attribute for a given code symbol.
  5262. *
  5263. * @param[in] code_symbol Code symbol.
  5264. *
  5265. * @param[in] attribute Attribute to query.
  5266. *
  5267. * @param[out] value Pointer to an application-allocated buffer where to store
  5268. * the value of the attribute. If the buffer passed by the application is not
  5269. * large enough to hold the value of @p attribute, the behavior is undefined.
  5270. *
  5271. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  5272. *
  5273. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  5274. * initialized.
  5275. *
  5276. * @retval ::HSA_STATUS_ERROR_INVALID_CODE_SYMBOL The code symbol is invalid.
  5277. *
  5278. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p attribute is an invalid
  5279. * code symbol attribute, or @p value is NULL.
  5280. */
  5281. hsa_status_t HSA_API HSA_DEPRECATED hsa_code_symbol_get_info(
  5282. hsa_code_symbol_t code_symbol,
  5283. hsa_code_symbol_info_t attribute,
  5284. void *value);
  5285. /**
  5286. * @deprecated
  5287. *
  5288. * @brief Iterate over the symbols in a code object, and invoke an
  5289. * application-defined callback on every iteration.
  5290. *
  5291. * @param[in] code_object Code object.
  5292. *
  5293. * @param[in] callback Callback to be invoked once per code object symbol. The
  5294. * HSA runtime passes three arguments to the callback: the code object, a
  5295. * symbol, and the application data. If @p callback returns a status other than
  5296. * ::HSA_STATUS_SUCCESS for a particular iteration, the traversal stops and
  5297. * ::hsa_code_object_iterate_symbols returns that status value.
  5298. *
  5299. * @param[in] data Application data that is passed to @p callback on every
  5300. * iteration. May be NULL.
  5301. *
  5302. * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully.
  5303. *
  5304. * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been
  5305. * initialized.
  5306. *
  5307. * @retval ::HSA_STATUS_ERROR_INVALID_CODE_OBJECT @p code_object is invalid.
  5308. *
  5309. * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p callback is NULL.
  5310. */
  5311. hsa_status_t HSA_API HSA_DEPRECATED hsa_code_object_iterate_symbols(
  5312. hsa_code_object_t code_object,
  5313. hsa_status_t (*callback)(hsa_code_object_t code_object,
  5314. hsa_code_symbol_t symbol,
  5315. void *data),
  5316. void *data);
  5317. /** @} */
  5318. #ifdef __cplusplus
  5319. } // end extern "C" block
  5320. #endif
  5321. #endif // header guard