libgomp.texi 159 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653
  1. \input texinfo @c -*-texinfo-*-
  2. @c %**start of header
  3. @setfilename libgomp.info
  4. @settitle GNU libgomp
  5. @c %**end of header
  6. @copying
  7. Copyright @copyright{} 2006-2022 Free Software Foundation, Inc.
  8. Permission is granted to copy, distribute and/or modify this document
  9. under the terms of the GNU Free Documentation License, Version 1.3 or
  10. any later version published by the Free Software Foundation; with the
  11. Invariant Sections being ``Funding Free Software'', the Front-Cover
  12. texts being (a) (see below), and with the Back-Cover Texts being (b)
  13. (see below). A copy of the license is included in the section entitled
  14. ``GNU Free Documentation License''.
  15. (a) The FSF's Front-Cover Text is:
  16. A GNU Manual
  17. (b) The FSF's Back-Cover Text is:
  18. You have freedom to copy and modify this GNU Manual, like GNU
  19. software. Copies published by the Free Software Foundation raise
  20. funds for GNU development.
  21. @end copying
  22. @ifinfo
  23. @dircategory GNU Libraries
  24. @direntry
  25. * libgomp: (libgomp). GNU Offloading and Multi Processing Runtime Library.
  26. @end direntry
  27. This manual documents libgomp, the GNU Offloading and Multi Processing
  28. Runtime library. This is the GNU implementation of the OpenMP and
  29. OpenACC APIs for parallel and accelerator programming in C/C++ and
  30. Fortran.
  31. Published by the Free Software Foundation
  32. 51 Franklin Street, Fifth Floor
  33. Boston, MA 02110-1301 USA
  34. @insertcopying
  35. @end ifinfo
  36. @setchapternewpage odd
  37. @titlepage
  38. @title GNU Offloading and Multi Processing Runtime Library
  39. @subtitle The GNU OpenMP and OpenACC Implementation
  40. @page
  41. @vskip 0pt plus 1filll
  42. @comment For the @value{version-GCC} Version*
  43. @sp 1
  44. Published by the Free Software Foundation @*
  45. 51 Franklin Street, Fifth Floor@*
  46. Boston, MA 02110-1301, USA@*
  47. @sp 1
  48. @insertcopying
  49. @end titlepage
  50. @summarycontents
  51. @contents
  52. @page
  53. @node Top, Enabling OpenMP
  54. @top Introduction
  55. @cindex Introduction
  56. This manual documents the usage of libgomp, the GNU Offloading and
  57. Multi Processing Runtime Library. This includes the GNU
  58. implementation of the @uref{https://www.openmp.org, OpenMP} Application
  59. Programming Interface (API) for multi-platform shared-memory parallel
  60. programming in C/C++ and Fortran, and the GNU implementation of the
  61. @uref{https://www.openacc.org, OpenACC} Application Programming
  62. Interface (API) for offloading of code to accelerator devices in C/C++
  63. and Fortran.
  64. Originally, libgomp implemented the GNU OpenMP Runtime Library. Based
  65. on this, support for OpenACC and offloading (both OpenACC and OpenMP
  66. 4's target construct) has been added later on, and the library's name
  67. changed to GNU Offloading and Multi Processing Runtime Library.
  68. @comment
  69. @comment When you add a new menu item, please keep the right hand
  70. @comment aligned to the same column. Do not use tabs. This provides
  71. @comment better formatting.
  72. @comment
  73. @menu
  74. * Enabling OpenMP:: How to enable OpenMP for your applications.
  75. * OpenMP Implementation Status:: List of implemented features by OpenMP version
  76. * OpenMP Runtime Library Routines: Runtime Library Routines.
  77. The OpenMP runtime application programming
  78. interface.
  79. * OpenMP Environment Variables: Environment Variables.
  80. Influencing OpenMP runtime behavior with
  81. environment variables.
  82. * Enabling OpenACC:: How to enable OpenACC for your
  83. applications.
  84. * OpenACC Runtime Library Routines:: The OpenACC runtime application
  85. programming interface.
  86. * OpenACC Environment Variables:: Influencing OpenACC runtime behavior with
  87. environment variables.
  88. * CUDA Streams Usage:: Notes on the implementation of
  89. asynchronous operations.
  90. * OpenACC Library Interoperability:: OpenACC library interoperability with the
  91. NVIDIA CUBLAS library.
  92. * OpenACC Profiling Interface::
  93. * The libgomp ABI:: Notes on the external ABI presented by libgomp.
  94. * Reporting Bugs:: How to report bugs in the GNU Offloading and
  95. Multi Processing Runtime Library.
  96. * Copying:: GNU general public license says
  97. how you can copy and share libgomp.
  98. * GNU Free Documentation License::
  99. How you can copy and share this manual.
  100. * Funding:: How to help assure continued work for free
  101. software.
  102. * Library Index:: Index of this documentation.
  103. @end menu
  104. @c ---------------------------------------------------------------------
  105. @c Enabling OpenMP
  106. @c ---------------------------------------------------------------------
  107. @node Enabling OpenMP
  108. @chapter Enabling OpenMP
  109. To activate the OpenMP extensions for C/C++ and Fortran, the compile-time
  110. flag @command{-fopenmp} must be specified. This enables the OpenMP directive
  111. @code{#pragma omp} in C/C++ and @code{!$omp} directives in free form,
  112. @code{c$omp}, @code{*$omp} and @code{!$omp} directives in fixed form,
  113. @code{!$} conditional compilation sentinels in free form and @code{c$},
  114. @code{*$} and @code{!$} sentinels in fixed form, for Fortran. The flag also
  115. arranges for automatic linking of the OpenMP runtime library
  116. (@ref{Runtime Library Routines}).
  117. A complete description of all OpenMP directives may be found in the
  118. @uref{https://www.openmp.org, OpenMP Application Program Interface} manuals.
  119. See also @ref{OpenMP Implementation Status}.
  120. @c ---------------------------------------------------------------------
  121. @c OpenMP Implementation Status
  122. @c ---------------------------------------------------------------------
  123. @node OpenMP Implementation Status
  124. @chapter OpenMP Implementation Status
  125. @menu
  126. * OpenMP 4.5:: Feature completion status to 4.5 specification
  127. * OpenMP 5.0:: Feature completion status to 5.0 specification
  128. * OpenMP 5.1:: Feature completion status to 5.1 specification
  129. @end menu
  130. The @code{_OPENMP} preprocessor macro and Fortran's @code{openmp_version}
  131. parameter, provided by @code{omp_lib.h} and the @code{omp_lib} module, have
  132. the value @code{201511} (i.e. OpenMP 4.5).
  133. @node OpenMP 4.5
  134. @section OpenMP 4.5
  135. The OpenMP 4.5 specification is fully supported.
  136. @node OpenMP 5.0
  137. @section OpenMP 5.0
  138. @unnumberedsubsec New features listed in Appendix B of the OpenMP specification
  139. @c This list is sorted as in OpenMP 5.1's B.3 not as in OpenMP 5.0's B.2
  140. @multitable @columnfractions .60 .10 .25
  141. @headitem Description @tab Status @tab Comments
  142. @item Array shaping @tab N @tab
  143. @item Array sections with non-unit strides in C and C++ @tab N @tab
  144. @item Iterators @tab Y @tab
  145. @item @code{metadirective} directive @tab N @tab
  146. @item @code{declare variant} directive
  147. @tab P @tab simd traits not handled correctly
  148. @item @emph{target-offload-var} ICV and @code{OMP_TARGET_OFFLOAD}
  149. env variable @tab Y @tab
  150. @item Nested-parallel changes to @emph{max-active-levels-var} ICV @tab Y @tab
  151. @item @code{requires} directive @tab P
  152. @tab Only fulfillable requirement are @code{atomic_default_mem_order}
  153. and @code{dynamic_allocators}
  154. @item @code{teams} construct outside an enclosing target region @tab Y @tab
  155. @item Non-rectangular loop nests @tab P @tab Only C/C++
  156. @item @code{!=} as relational-op in canonical loop form for C/C++ @tab Y @tab
  157. @item @code{nonmonotonic} as default loop schedule modifier for worksharing-loop
  158. constructs @tab Y @tab
  159. @item Collapse of associated loops that are imperfectly nested loops @tab N @tab
  160. @item Clauses @code{if}, @code{nontemporal} and @code{order(concurrent)} in
  161. @code{simd} construct @tab Y @tab
  162. @item @code{atomic} constructs in @code{simd} @tab Y @tab
  163. @item @code{loop} construct @tab Y @tab
  164. @item @code{order(concurrent)} clause @tab Y @tab
  165. @item @code{scan} directive and @code{in_scan} modifier for the
  166. @code{reduction} clause @tab Y @tab
  167. @item @code{in_reduction} clause on @code{task} constructs @tab Y @tab
  168. @item @code{in_reduction} clause on @code{target} constructs @tab P
  169. @tab @code{nowait} only stub
  170. @item @code{task_reduction} clause with @code{taskgroup} @tab Y @tab
  171. @item @code{task} modifier to @code{reduction} clause @tab Y @tab
  172. @item @code{affinity} clause to @code{task} construct @tab Y @tab Stub only
  173. @item @code{detach} clause to @code{task} construct @tab Y @tab
  174. @item @code{omp_fulfill_event} runtime routine @tab Y @tab
  175. @item @code{reduction} and @code{in_reduction} clauses on @code{taskloop}
  176. and @code{taskloop simd} constructs @tab Y @tab
  177. @item @code{taskloop} construct cancelable by @code{cancel} construct
  178. @tab Y @tab
  179. @item @code{mutexinouset} @emph{dependence-type} for @code{depend} clause
  180. @tab Y @tab
  181. @item Predefined memory spaces, memory allocators, allocator traits
  182. @tab Y @tab Some are only stubs
  183. @item Memory management routines @tab Y @tab
  184. @item @code{allocate} directive @tab N @tab
  185. @item @code{allocate} clause @tab P @tab initial support
  186. @item @code{use_device_addr} clause on @code{target data} @tab Y @tab
  187. @item @code{ancestor} modifier on @code{device} clause
  188. @tab P @tab Reverse offload unsupported
  189. @item Implicit declare target directive @tab Y @tab
  190. @item Discontiguous array section with @code{target update} construct
  191. @tab N @tab
  192. @item C/C++'s lvalue expressions in @code{to}, @code{from}
  193. and @code{map} clauses @tab N @tab
  194. @item C/C++'s lvalue expressions in @code{depend} clauses @tab Y @tab
  195. @item Nested @code{declare target} directive @tab Y @tab
  196. @item Combined @code{master} constructs @tab Y @tab
  197. @item @code{depend} clause on @code{taskwait} @tab Y @tab
  198. @item Weak memory ordering clauses on @code{atomic} and @code{flush} construct
  199. @tab Y @tab
  200. @item @code{hint} clause on the @code{atomic} construct @tab Y @tab Stub only
  201. @item @code{depobj} construct and depend objects @tab Y @tab
  202. @item Lock hints were renamed to synchronization hints @tab Y @tab
  203. @item @code{conditional} modifier to @code{lastprivate} clause @tab Y @tab
  204. @item Map-order clarifications @tab P @tab
  205. @item @code{close} @emph{map-type-modifier} @tab Y @tab
  206. @item Mapping C/C++ pointer variables and to assign the address of
  207. device memory mapped by an array section @tab P @tab
  208. @item Mapping of Fortran pointer and allocatable variables, including pointer
  209. and allocatable components of variables
  210. @tab P @tab Mapping of vars with allocatable components unsupported
  211. @item @code{defaultmap} extensions @tab Y @tab
  212. @item @code{declare mapper} directive @tab N @tab
  213. @item @code{omp_get_supported_active_levels} routine @tab Y @tab
  214. @item Runtime routines and environment variables to display runtime thread
  215. affinity information @tab Y @tab
  216. @item @code{omp_pause_resource} and @code{omp_pause_resource_all} runtime
  217. routines @tab Y @tab
  218. @item @code{omp_get_device_num} runtime routine @tab Y @tab
  219. @item OMPT interface @tab N @tab
  220. @item OMPD interface @tab N @tab
  221. @end multitable
  222. @unnumberedsubsec Other new OpenMP 5.0 features
  223. @multitable @columnfractions .60 .10 .25
  224. @headitem Description @tab Status @tab Comments
  225. @item Supporting C++'s range-based for loop @tab Y @tab
  226. @end multitable
  227. @node OpenMP 5.1
  228. @section OpenMP 5.1
  229. @unnumberedsubsec New features listed in Appendix B of the OpenMP specification
  230. @multitable @columnfractions .60 .10 .25
  231. @headitem Description @tab Status @tab Comments
  232. @item OpenMP directive as C++ attribute specifiers @tab Y @tab
  233. @item @code{omp_all_memory} reserved locator @tab N @tab
  234. @item @emph{target_device trait} in OpenMP Context @tab N @tab
  235. @item @code{target_device} selector set in context selectors @tab N @tab
  236. @item C/C++'s @code{declare variant} directive: elision support of
  237. preprocessed code @tab N @tab
  238. @item @code{declare variant}: new clauses @code{adjust_args} and
  239. @code{append_args} @tab N @tab
  240. @item @code{dispatch} construct @tab N @tab
  241. @item device-specific ICV settings the environment variables @tab N @tab
  242. @item assume directive @tab N @tab
  243. @item @code{nothing} directive @tab Y @tab
  244. @item @code{error} directive @tab Y @tab
  245. @item @code{masked} construct @tab Y @tab
  246. @item @code{scope} directive @tab Y @tab
  247. @item Loop transformation constructs @tab N @tab
  248. @item @code{strict} modifier in the @code{grainsize} and @code{num_tasks}
  249. clauses of the taskloop construct @tab Y @tab
  250. @item @code{align} clause/modifier in @code{allocate} directive/clause
  251. and @code{allocator} directive @tab P @tab C/C++ on clause only
  252. @item @code{thread_limit} clause to @code{target} construct @tab Y @tab
  253. @item @code{has_device_addr} clause to @code{target} construct @tab Y @tab
  254. @item iterators in @code{target update} motion clauses and @code{map}
  255. clauses @tab N @tab
  256. @item indirect calls to the device version of a procedure or function in
  257. @code{target} regions @tab N @tab
  258. @item @code{interop} directive @tab N @tab
  259. @item @code{omp_interop_t} object support in runtime routines @tab N @tab
  260. @item @code{nowait} clause in @code{taskwait} directive @tab N @tab
  261. @item Extensions to the @code{atomic} directive @tab Y @tab
  262. @item @code{seq_cst} clause on a @code{flush} construct @tab Y @tab
  263. @item @code{inoutset} argument to the @code{depend} clause @tab N @tab
  264. @item @code{private} and @code{firstprivate} argument to @code{default}
  265. clause in C and C++ @tab Y @tab
  266. @item @code{present} argument to @code{defaultmap} clause @tab N @tab
  267. @item @code{omp_set_num_teams}, @code{omp_set_teams_thread_limit},
  268. @code{omp_get_max_teams}, @code{omp_get_teams_thread_limit} runtime
  269. routines @tab Y @tab
  270. @item @code{omp_target_is_accessible} runtime routine @tab N @tab
  271. @item @code{omp_target_memcpy_async} and @code{omp_target_memcpy_rect_async}
  272. runtime routines @tab N @tab
  273. @item @code{omp_get_mapped_ptr} runtime routine @tab N @tab
  274. @item @code{omp_calloc}, @code{omp_realloc}, @code{omp_aligned_alloc} and
  275. @code{omp_aligned_calloc} runtime routines @tab Y @tab
  276. @item @code{omp_alloctrait_key_t} enum: @code{omp_atv_serialized} added,
  277. @code{omp_atv_default} changed @tab Y @tab
  278. @item @code{omp_display_env} runtime routine @tab Y
  279. @tab Not inside @code{target} regions
  280. @item @code{ompt_scope_endpoint_t} enum: @code{ompt_scope_beginend} @tab N @tab
  281. @item @code{ompt_sync_region_t} enum additions @tab N @tab
  282. @item @code{ompt_state_t} enum: @code{ompt_state_wait_barrier_implementation}
  283. and @code{ompt_state_wait_barrier_teams} @tab N @tab
  284. @item @code{ompt_callback_target_data_op_emi_t},
  285. @code{ompt_callback_target_emi_t}, @code{ompt_callback_target_map_emi_t}
  286. and @code{ompt_callback_target_submit_emi_t} @tab N @tab
  287. @item @code{ompt_callback_error_t} type @tab N @tab
  288. @item @code{OMP_PLACES} syntax extensions @tab Y @tab
  289. @item @code{OMP_NUM_TEAMS} and @code{OMP_TEAMS_THREAD_LIMIT} environment
  290. variables @tab Y @tab
  291. @end multitable
  292. @unnumberedsubsec Other new OpenMP 5.1 features
  293. @multitable @columnfractions .60 .10 .25
  294. @headitem Description @tab Status @tab Comments
  295. @item Support of strictly structured blocks in Fortran @tab Y @tab
  296. @item Support of structured block sequences in C/C++ @tab Y @tab
  297. @item @code{unconstrained} and @code{reproducible} modifiers on @code{order}
  298. clause @tab Y @tab
  299. @end multitable
  300. @c ---------------------------------------------------------------------
  301. @c OpenMP Runtime Library Routines
  302. @c ---------------------------------------------------------------------
  303. @node Runtime Library Routines
  304. @chapter OpenMP Runtime Library Routines
  305. The runtime routines described here are defined by Section 3 of the OpenMP
  306. specification in version 4.5. The routines are structured in following
  307. three parts:
  308. @menu
  309. Control threads, processors and the parallel environment. They have C
  310. linkage, and do not throw exceptions.
  311. * omp_get_active_level:: Number of active parallel regions
  312. * omp_get_ancestor_thread_num:: Ancestor thread ID
  313. * omp_get_cancellation:: Whether cancellation support is enabled
  314. * omp_get_default_device:: Get the default device for target regions
  315. * omp_get_device_num:: Get device that current thread is running on
  316. * omp_get_dynamic:: Dynamic teams setting
  317. * omp_get_initial_device:: Device number of host device
  318. * omp_get_level:: Number of parallel regions
  319. * omp_get_max_active_levels:: Current maximum number of active regions
  320. * omp_get_max_task_priority:: Maximum task priority value that can be set
  321. * omp_get_max_teams:: Maximum number of teams for teams region
  322. * omp_get_max_threads:: Maximum number of threads of parallel region
  323. * omp_get_nested:: Nested parallel regions
  324. * omp_get_num_devices:: Number of target devices
  325. * omp_get_num_procs:: Number of processors online
  326. * omp_get_num_teams:: Number of teams
  327. * omp_get_num_threads:: Size of the active team
  328. * omp_get_proc_bind:: Whether theads may be moved between CPUs
  329. * omp_get_schedule:: Obtain the runtime scheduling method
  330. * omp_get_supported_active_levels:: Maximum number of active regions supported
  331. * omp_get_team_num:: Get team number
  332. * omp_get_team_size:: Number of threads in a team
  333. * omp_get_teams_thread_limit:: Maximum number of threads imposed by teams
  334. * omp_get_thread_limit:: Maximum number of threads
  335. * omp_get_thread_num:: Current thread ID
  336. * omp_in_parallel:: Whether a parallel region is active
  337. * omp_in_final:: Whether in final or included task region
  338. * omp_is_initial_device:: Whether executing on the host device
  339. * omp_set_default_device:: Set the default device for target regions
  340. * omp_set_dynamic:: Enable/disable dynamic teams
  341. * omp_set_max_active_levels:: Limits the number of active parallel regions
  342. * omp_set_nested:: Enable/disable nested parallel regions
  343. * omp_set_num_teams:: Set upper teams limit for teams region
  344. * omp_set_num_threads:: Set upper team size limit
  345. * omp_set_schedule:: Set the runtime scheduling method
  346. * omp_set_teams_thread_limit:: Set upper thread limit for teams construct
  347. Initialize, set, test, unset and destroy simple and nested locks.
  348. * omp_init_lock:: Initialize simple lock
  349. * omp_set_lock:: Wait for and set simple lock
  350. * omp_test_lock:: Test and set simple lock if available
  351. * omp_unset_lock:: Unset simple lock
  352. * omp_destroy_lock:: Destroy simple lock
  353. * omp_init_nest_lock:: Initialize nested lock
  354. * omp_set_nest_lock:: Wait for and set simple lock
  355. * omp_test_nest_lock:: Test and set nested lock if available
  356. * omp_unset_nest_lock:: Unset nested lock
  357. * omp_destroy_nest_lock:: Destroy nested lock
  358. Portable, thread-based, wall clock timer.
  359. * omp_get_wtick:: Get timer precision.
  360. * omp_get_wtime:: Elapsed wall clock time.
  361. Support for event objects.
  362. * omp_fulfill_event:: Fulfill and destroy an OpenMP event.
  363. @end menu
  364. @node omp_get_active_level
  365. @section @code{omp_get_active_level} -- Number of parallel regions
  366. @table @asis
  367. @item @emph{Description}:
  368. This function returns the nesting level for the active parallel blocks,
  369. which enclose the calling call.
  370. @item @emph{C/C++}
  371. @multitable @columnfractions .20 .80
  372. @item @emph{Prototype}: @tab @code{int omp_get_active_level(void);}
  373. @end multitable
  374. @item @emph{Fortran}:
  375. @multitable @columnfractions .20 .80
  376. @item @emph{Interface}: @tab @code{integer function omp_get_active_level()}
  377. @end multitable
  378. @item @emph{See also}:
  379. @ref{omp_get_level}, @ref{omp_get_max_active_levels}, @ref{omp_set_max_active_levels}
  380. @item @emph{Reference}:
  381. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.20.
  382. @end table
  383. @node omp_get_ancestor_thread_num
  384. @section @code{omp_get_ancestor_thread_num} -- Ancestor thread ID
  385. @table @asis
  386. @item @emph{Description}:
  387. This function returns the thread identification number for the given
  388. nesting level of the current thread. For values of @var{level} outside
  389. zero to @code{omp_get_level} -1 is returned; if @var{level} is
  390. @code{omp_get_level} the result is identical to @code{omp_get_thread_num}.
  391. @item @emph{C/C++}
  392. @multitable @columnfractions .20 .80
  393. @item @emph{Prototype}: @tab @code{int omp_get_ancestor_thread_num(int level);}
  394. @end multitable
  395. @item @emph{Fortran}:
  396. @multitable @columnfractions .20 .80
  397. @item @emph{Interface}: @tab @code{integer function omp_get_ancestor_thread_num(level)}
  398. @item @tab @code{integer level}
  399. @end multitable
  400. @item @emph{See also}:
  401. @ref{omp_get_level}, @ref{omp_get_thread_num}, @ref{omp_get_team_size}
  402. @item @emph{Reference}:
  403. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.18.
  404. @end table
  405. @node omp_get_cancellation
  406. @section @code{omp_get_cancellation} -- Whether cancellation support is enabled
  407. @table @asis
  408. @item @emph{Description}:
  409. This function returns @code{true} if cancellation is activated, @code{false}
  410. otherwise. Here, @code{true} and @code{false} represent their language-specific
  411. counterparts. Unless @env{OMP_CANCELLATION} is set true, cancellations are
  412. deactivated.
  413. @item @emph{C/C++}:
  414. @multitable @columnfractions .20 .80
  415. @item @emph{Prototype}: @tab @code{int omp_get_cancellation(void);}
  416. @end multitable
  417. @item @emph{Fortran}:
  418. @multitable @columnfractions .20 .80
  419. @item @emph{Interface}: @tab @code{logical function omp_get_cancellation()}
  420. @end multitable
  421. @item @emph{See also}:
  422. @ref{OMP_CANCELLATION}
  423. @item @emph{Reference}:
  424. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.9.
  425. @end table
  426. @node omp_get_default_device
  427. @section @code{omp_get_default_device} -- Get the default device for target regions
  428. @table @asis
  429. @item @emph{Description}:
  430. Get the default device for target regions without device clause.
  431. @item @emph{C/C++}:
  432. @multitable @columnfractions .20 .80
  433. @item @emph{Prototype}: @tab @code{int omp_get_default_device(void);}
  434. @end multitable
  435. @item @emph{Fortran}:
  436. @multitable @columnfractions .20 .80
  437. @item @emph{Interface}: @tab @code{integer function omp_get_default_device()}
  438. @end multitable
  439. @item @emph{See also}:
  440. @ref{OMP_DEFAULT_DEVICE}, @ref{omp_set_default_device}
  441. @item @emph{Reference}:
  442. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.30.
  443. @end table
  444. @node omp_get_device_num
  445. @section @code{omp_get_device_num} -- Return device number of current device
  446. @table @asis
  447. @item @emph{Description}:
  448. This function returns a device number that represents the device that the
  449. current thread is executing on. For OpenMP 5.0, this must be equal to the
  450. value returned by the @code{omp_get_initial_device} function when called
  451. from the host.
  452. @item @emph{C/C++}
  453. @multitable @columnfractions .20 .80
  454. @item @emph{Prototype}: @tab @code{int omp_get_device_num(void);}
  455. @end multitable
  456. @item @emph{Fortran}:
  457. @multitable @columnfractions .20 .80
  458. @item @emph{Interface}: @tab @code{integer function omp_get_device_num()}
  459. @end multitable
  460. @item @emph{See also}:
  461. @ref{omp_get_initial_device}
  462. @item @emph{Reference}:
  463. @uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.2.37.
  464. @end table
  465. @node omp_get_dynamic
  466. @section @code{omp_get_dynamic} -- Dynamic teams setting
  467. @table @asis
  468. @item @emph{Description}:
  469. This function returns @code{true} if enabled, @code{false} otherwise.
  470. Here, @code{true} and @code{false} represent their language-specific
  471. counterparts.
  472. The dynamic team setting may be initialized at startup by the
  473. @env{OMP_DYNAMIC} environment variable or at runtime using
  474. @code{omp_set_dynamic}. If undefined, dynamic adjustment is
  475. disabled by default.
  476. @item @emph{C/C++}:
  477. @multitable @columnfractions .20 .80
  478. @item @emph{Prototype}: @tab @code{int omp_get_dynamic(void);}
  479. @end multitable
  480. @item @emph{Fortran}:
  481. @multitable @columnfractions .20 .80
  482. @item @emph{Interface}: @tab @code{logical function omp_get_dynamic()}
  483. @end multitable
  484. @item @emph{See also}:
  485. @ref{omp_set_dynamic}, @ref{OMP_DYNAMIC}
  486. @item @emph{Reference}:
  487. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.8.
  488. @end table
  489. @node omp_get_initial_device
  490. @section @code{omp_get_initial_device} -- Return device number of initial device
  491. @table @asis
  492. @item @emph{Description}:
  493. This function returns a device number that represents the host device.
  494. For OpenMP 5.1, this must be equal to the value returned by the
  495. @code{omp_get_num_devices} function.
  496. @item @emph{C/C++}
  497. @multitable @columnfractions .20 .80
  498. @item @emph{Prototype}: @tab @code{int omp_get_initial_device(void);}
  499. @end multitable
  500. @item @emph{Fortran}:
  501. @multitable @columnfractions .20 .80
  502. @item @emph{Interface}: @tab @code{integer function omp_get_initial_device()}
  503. @end multitable
  504. @item @emph{See also}:
  505. @ref{omp_get_num_devices}
  506. @item @emph{Reference}:
  507. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.35.
  508. @end table
  509. @node omp_get_level
  510. @section @code{omp_get_level} -- Obtain the current nesting level
  511. @table @asis
  512. @item @emph{Description}:
  513. This function returns the nesting level for the parallel blocks,
  514. which enclose the calling call.
  515. @item @emph{C/C++}
  516. @multitable @columnfractions .20 .80
  517. @item @emph{Prototype}: @tab @code{int omp_get_level(void);}
  518. @end multitable
  519. @item @emph{Fortran}:
  520. @multitable @columnfractions .20 .80
  521. @item @emph{Interface}: @tab @code{integer function omp_level()}
  522. @end multitable
  523. @item @emph{See also}:
  524. @ref{omp_get_active_level}
  525. @item @emph{Reference}:
  526. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.17.
  527. @end table
  528. @node omp_get_max_active_levels
  529. @section @code{omp_get_max_active_levels} -- Current maximum number of active regions
  530. @table @asis
  531. @item @emph{Description}:
  532. This function obtains the maximum allowed number of nested, active parallel regions.
  533. @item @emph{C/C++}
  534. @multitable @columnfractions .20 .80
  535. @item @emph{Prototype}: @tab @code{int omp_get_max_active_levels(void);}
  536. @end multitable
  537. @item @emph{Fortran}:
  538. @multitable @columnfractions .20 .80
  539. @item @emph{Interface}: @tab @code{integer function omp_get_max_active_levels()}
  540. @end multitable
  541. @item @emph{See also}:
  542. @ref{omp_set_max_active_levels}, @ref{omp_get_active_level}
  543. @item @emph{Reference}:
  544. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.16.
  545. @end table
  546. @node omp_get_max_task_priority
  547. @section @code{omp_get_max_task_priority} -- Maximum priority value
  548. that can be set for tasks.
  549. @table @asis
  550. @item @emph{Description}:
  551. This function obtains the maximum allowed priority number for tasks.
  552. @item @emph{C/C++}
  553. @multitable @columnfractions .20 .80
  554. @item @emph{Prototype}: @tab @code{int omp_get_max_task_priority(void);}
  555. @end multitable
  556. @item @emph{Fortran}:
  557. @multitable @columnfractions .20 .80
  558. @item @emph{Interface}: @tab @code{integer function omp_get_max_task_priority()}
  559. @end multitable
  560. @item @emph{Reference}:
  561. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.29.
  562. @end table
  563. @node omp_get_max_teams
  564. @section @code{omp_get_max_teams} -- Maximum number of teams of teams region
  565. @table @asis
  566. @item @emph{Description}:
  567. Return the maximum number of teams used for the teams region
  568. that does not use the clause @code{num_teams}.
  569. @item @emph{C/C++}:
  570. @multitable @columnfractions .20 .80
  571. @item @emph{Prototype}: @tab @code{int omp_get_max_teams(void);}
  572. @end multitable
  573. @item @emph{Fortran}:
  574. @multitable @columnfractions .20 .80
  575. @item @emph{Interface}: @tab @code{integer function omp_get_max_teams()}
  576. @end multitable
  577. @item @emph{See also}:
  578. @ref{omp_set_num_teams}, @ref{omp_get_num_teams}
  579. @item @emph{Reference}:
  580. @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.4.4.
  581. @end table
  582. @node omp_get_max_threads
  583. @section @code{omp_get_max_threads} -- Maximum number of threads of parallel region
  584. @table @asis
  585. @item @emph{Description}:
  586. Return the maximum number of threads used for the current parallel region
  587. that does not use the clause @code{num_threads}.
  588. @item @emph{C/C++}:
  589. @multitable @columnfractions .20 .80
  590. @item @emph{Prototype}: @tab @code{int omp_get_max_threads(void);}
  591. @end multitable
  592. @item @emph{Fortran}:
  593. @multitable @columnfractions .20 .80
  594. @item @emph{Interface}: @tab @code{integer function omp_get_max_threads()}
  595. @end multitable
  596. @item @emph{See also}:
  597. @ref{omp_set_num_threads}, @ref{omp_set_dynamic}, @ref{omp_get_thread_limit}
  598. @item @emph{Reference}:
  599. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.3.
  600. @end table
  601. @node omp_get_nested
  602. @section @code{omp_get_nested} -- Nested parallel regions
  603. @table @asis
  604. @item @emph{Description}:
  605. This function returns @code{true} if nested parallel regions are
  606. enabled, @code{false} otherwise. Here, @code{true} and @code{false}
  607. represent their language-specific counterparts.
  608. The state of nested parallel regions at startup depends on several
  609. environment variables. If @env{OMP_MAX_ACTIVE_LEVELS} is defined
  610. and is set to greater than one, then nested parallel regions will be
  611. enabled. If not defined, then the value of the @env{OMP_NESTED}
  612. environment variable will be followed if defined. If neither are
  613. defined, then if either @env{OMP_NUM_THREADS} or @env{OMP_PROC_BIND}
  614. are defined with a list of more than one value, then nested parallel
  615. regions are enabled. If none of these are defined, then nested parallel
  616. regions are disabled by default.
  617. Nested parallel regions can be enabled or disabled at runtime using
  618. @code{omp_set_nested}, or by setting the maximum number of nested
  619. regions with @code{omp_set_max_active_levels} to one to disable, or
  620. above one to enable.
  621. @item @emph{C/C++}:
  622. @multitable @columnfractions .20 .80
  623. @item @emph{Prototype}: @tab @code{int omp_get_nested(void);}
  624. @end multitable
  625. @item @emph{Fortran}:
  626. @multitable @columnfractions .20 .80
  627. @item @emph{Interface}: @tab @code{logical function omp_get_nested()}
  628. @end multitable
  629. @item @emph{See also}:
  630. @ref{omp_set_max_active_levels}, @ref{omp_set_nested},
  631. @ref{OMP_MAX_ACTIVE_LEVELS}, @ref{OMP_NESTED}
  632. @item @emph{Reference}:
  633. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.11.
  634. @end table
  635. @node omp_get_num_devices
  636. @section @code{omp_get_num_devices} -- Number of target devices
  637. @table @asis
  638. @item @emph{Description}:
  639. Returns the number of target devices.
  640. @item @emph{C/C++}:
  641. @multitable @columnfractions .20 .80
  642. @item @emph{Prototype}: @tab @code{int omp_get_num_devices(void);}
  643. @end multitable
  644. @item @emph{Fortran}:
  645. @multitable @columnfractions .20 .80
  646. @item @emph{Interface}: @tab @code{integer function omp_get_num_devices()}
  647. @end multitable
  648. @item @emph{Reference}:
  649. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.31.
  650. @end table
  651. @node omp_get_num_procs
  652. @section @code{omp_get_num_procs} -- Number of processors online
  653. @table @asis
  654. @item @emph{Description}:
  655. Returns the number of processors online on that device.
  656. @item @emph{C/C++}:
  657. @multitable @columnfractions .20 .80
  658. @item @emph{Prototype}: @tab @code{int omp_get_num_procs(void);}
  659. @end multitable
  660. @item @emph{Fortran}:
  661. @multitable @columnfractions .20 .80
  662. @item @emph{Interface}: @tab @code{integer function omp_get_num_procs()}
  663. @end multitable
  664. @item @emph{Reference}:
  665. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.5.
  666. @end table
  667. @node omp_get_num_teams
  668. @section @code{omp_get_num_teams} -- Number of teams
  669. @table @asis
  670. @item @emph{Description}:
  671. Returns the number of teams in the current team region.
  672. @item @emph{C/C++}:
  673. @multitable @columnfractions .20 .80
  674. @item @emph{Prototype}: @tab @code{int omp_get_num_teams(void);}
  675. @end multitable
  676. @item @emph{Fortran}:
  677. @multitable @columnfractions .20 .80
  678. @item @emph{Interface}: @tab @code{integer function omp_get_num_teams()}
  679. @end multitable
  680. @item @emph{Reference}:
  681. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.32.
  682. @end table
  683. @node omp_get_num_threads
  684. @section @code{omp_get_num_threads} -- Size of the active team
  685. @table @asis
  686. @item @emph{Description}:
  687. Returns the number of threads in the current team. In a sequential section of
  688. the program @code{omp_get_num_threads} returns 1.
  689. The default team size may be initialized at startup by the
  690. @env{OMP_NUM_THREADS} environment variable. At runtime, the size
  691. of the current team may be set either by the @code{NUM_THREADS}
  692. clause or by @code{omp_set_num_threads}. If none of the above were
  693. used to define a specific value and @env{OMP_DYNAMIC} is disabled,
  694. one thread per CPU online is used.
  695. @item @emph{C/C++}:
  696. @multitable @columnfractions .20 .80
  697. @item @emph{Prototype}: @tab @code{int omp_get_num_threads(void);}
  698. @end multitable
  699. @item @emph{Fortran}:
  700. @multitable @columnfractions .20 .80
  701. @item @emph{Interface}: @tab @code{integer function omp_get_num_threads()}
  702. @end multitable
  703. @item @emph{See also}:
  704. @ref{omp_get_max_threads}, @ref{omp_set_num_threads}, @ref{OMP_NUM_THREADS}
  705. @item @emph{Reference}:
  706. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.2.
  707. @end table
  708. @node omp_get_proc_bind
  709. @section @code{omp_get_proc_bind} -- Whether theads may be moved between CPUs
  710. @table @asis
  711. @item @emph{Description}:
  712. This functions returns the currently active thread affinity policy, which is
  713. set via @env{OMP_PROC_BIND}. Possible values are @code{omp_proc_bind_false},
  714. @code{omp_proc_bind_true}, @code{omp_proc_bind_primary},
  715. @code{omp_proc_bind_master}, @code{omp_proc_bind_close} and @code{omp_proc_bind_spread},
  716. where @code{omp_proc_bind_master} is an alias for @code{omp_proc_bind_primary}.
  717. @item @emph{C/C++}:
  718. @multitable @columnfractions .20 .80
  719. @item @emph{Prototype}: @tab @code{omp_proc_bind_t omp_get_proc_bind(void);}
  720. @end multitable
  721. @item @emph{Fortran}:
  722. @multitable @columnfractions .20 .80
  723. @item @emph{Interface}: @tab @code{integer(kind=omp_proc_bind_kind) function omp_get_proc_bind()}
  724. @end multitable
  725. @item @emph{See also}:
  726. @ref{OMP_PROC_BIND}, @ref{OMP_PLACES}, @ref{GOMP_CPU_AFFINITY},
  727. @item @emph{Reference}:
  728. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.22.
  729. @end table
  730. @node omp_get_schedule
  731. @section @code{omp_get_schedule} -- Obtain the runtime scheduling method
  732. @table @asis
  733. @item @emph{Description}:
  734. Obtain the runtime scheduling method. The @var{kind} argument will be
  735. set to the value @code{omp_sched_static}, @code{omp_sched_dynamic},
  736. @code{omp_sched_guided} or @code{omp_sched_auto}. The second argument,
  737. @var{chunk_size}, is set to the chunk size.
  738. @item @emph{C/C++}
  739. @multitable @columnfractions .20 .80
  740. @item @emph{Prototype}: @tab @code{void omp_get_schedule(omp_sched_t *kind, int *chunk_size);}
  741. @end multitable
  742. @item @emph{Fortran}:
  743. @multitable @columnfractions .20 .80
  744. @item @emph{Interface}: @tab @code{subroutine omp_get_schedule(kind, chunk_size)}
  745. @item @tab @code{integer(kind=omp_sched_kind) kind}
  746. @item @tab @code{integer chunk_size}
  747. @end multitable
  748. @item @emph{See also}:
  749. @ref{omp_set_schedule}, @ref{OMP_SCHEDULE}
  750. @item @emph{Reference}:
  751. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.13.
  752. @end table
  753. @node omp_get_supported_active_levels
  754. @section @code{omp_get_supported_active_levels} -- Maximum number of active regions supported
  755. @table @asis
  756. @item @emph{Description}:
  757. This function returns the maximum number of nested, active parallel regions
  758. supported by this implementation.
  759. @item @emph{C/C++}
  760. @multitable @columnfractions .20 .80
  761. @item @emph{Prototype}: @tab @code{int omp_get_supported_active_levels(void);}
  762. @end multitable
  763. @item @emph{Fortran}:
  764. @multitable @columnfractions .20 .80
  765. @item @emph{Interface}: @tab @code{integer function omp_get_supported_active_levels()}
  766. @end multitable
  767. @item @emph{See also}:
  768. @ref{omp_get_max_active_levels}, @ref{omp_set_max_active_levels}
  769. @item @emph{Reference}:
  770. @uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.2.15.
  771. @end table
  772. @node omp_get_team_num
  773. @section @code{omp_get_team_num} -- Get team number
  774. @table @asis
  775. @item @emph{Description}:
  776. Returns the team number of the calling thread.
  777. @item @emph{C/C++}:
  778. @multitable @columnfractions .20 .80
  779. @item @emph{Prototype}: @tab @code{int omp_get_team_num(void);}
  780. @end multitable
  781. @item @emph{Fortran}:
  782. @multitable @columnfractions .20 .80
  783. @item @emph{Interface}: @tab @code{integer function omp_get_team_num()}
  784. @end multitable
  785. @item @emph{Reference}:
  786. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.33.
  787. @end table
  788. @node omp_get_team_size
  789. @section @code{omp_get_team_size} -- Number of threads in a team
  790. @table @asis
  791. @item @emph{Description}:
  792. This function returns the number of threads in a thread team to which
  793. either the current thread or its ancestor belongs. For values of @var{level}
  794. outside zero to @code{omp_get_level}, -1 is returned; if @var{level} is zero,
  795. 1 is returned, and for @code{omp_get_level}, the result is identical
  796. to @code{omp_get_num_threads}.
  797. @item @emph{C/C++}:
  798. @multitable @columnfractions .20 .80
  799. @item @emph{Prototype}: @tab @code{int omp_get_team_size(int level);}
  800. @end multitable
  801. @item @emph{Fortran}:
  802. @multitable @columnfractions .20 .80
  803. @item @emph{Interface}: @tab @code{integer function omp_get_team_size(level)}
  804. @item @tab @code{integer level}
  805. @end multitable
  806. @item @emph{See also}:
  807. @ref{omp_get_num_threads}, @ref{omp_get_level}, @ref{omp_get_ancestor_thread_num}
  808. @item @emph{Reference}:
  809. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.19.
  810. @end table
  811. @node omp_get_teams_thread_limit
  812. @section @code{omp_get_teams_thread_limit} -- Maximum number of threads imposed by teams
  813. @table @asis
  814. @item @emph{Description}:
  815. Return the maximum number of threads that will be able to participate in
  816. each team created by a teams construct.
  817. @item @emph{C/C++}:
  818. @multitable @columnfractions .20 .80
  819. @item @emph{Prototype}: @tab @code{int omp_get_teams_thread_limit(void);}
  820. @end multitable
  821. @item @emph{Fortran}:
  822. @multitable @columnfractions .20 .80
  823. @item @emph{Interface}: @tab @code{integer function omp_get_teams_thread_limit()}
  824. @end multitable
  825. @item @emph{See also}:
  826. @ref{omp_set_teams_thread_limit}, @ref{OMP_TEAMS_THREAD_LIMIT}
  827. @item @emph{Reference}:
  828. @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.4.6.
  829. @end table
  830. @node omp_get_thread_limit
  831. @section @code{omp_get_thread_limit} -- Maximum number of threads
  832. @table @asis
  833. @item @emph{Description}:
  834. Return the maximum number of threads of the program.
  835. @item @emph{C/C++}:
  836. @multitable @columnfractions .20 .80
  837. @item @emph{Prototype}: @tab @code{int omp_get_thread_limit(void);}
  838. @end multitable
  839. @item @emph{Fortran}:
  840. @multitable @columnfractions .20 .80
  841. @item @emph{Interface}: @tab @code{integer function omp_get_thread_limit()}
  842. @end multitable
  843. @item @emph{See also}:
  844. @ref{omp_get_max_threads}, @ref{OMP_THREAD_LIMIT}
  845. @item @emph{Reference}:
  846. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.14.
  847. @end table
  848. @node omp_get_thread_num
  849. @section @code{omp_get_thread_num} -- Current thread ID
  850. @table @asis
  851. @item @emph{Description}:
  852. Returns a unique thread identification number within the current team.
  853. In a sequential parts of the program, @code{omp_get_thread_num}
  854. always returns 0. In parallel regions the return value varies
  855. from 0 to @code{omp_get_num_threads}-1 inclusive. The return
  856. value of the primary thread of a team is always 0.
  857. @item @emph{C/C++}:
  858. @multitable @columnfractions .20 .80
  859. @item @emph{Prototype}: @tab @code{int omp_get_thread_num(void);}
  860. @end multitable
  861. @item @emph{Fortran}:
  862. @multitable @columnfractions .20 .80
  863. @item @emph{Interface}: @tab @code{integer function omp_get_thread_num()}
  864. @end multitable
  865. @item @emph{See also}:
  866. @ref{omp_get_num_threads}, @ref{omp_get_ancestor_thread_num}
  867. @item @emph{Reference}:
  868. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.4.
  869. @end table
  870. @node omp_in_parallel
  871. @section @code{omp_in_parallel} -- Whether a parallel region is active
  872. @table @asis
  873. @item @emph{Description}:
  874. This function returns @code{true} if currently running in parallel,
  875. @code{false} otherwise. Here, @code{true} and @code{false} represent
  876. their language-specific counterparts.
  877. @item @emph{C/C++}:
  878. @multitable @columnfractions .20 .80
  879. @item @emph{Prototype}: @tab @code{int omp_in_parallel(void);}
  880. @end multitable
  881. @item @emph{Fortran}:
  882. @multitable @columnfractions .20 .80
  883. @item @emph{Interface}: @tab @code{logical function omp_in_parallel()}
  884. @end multitable
  885. @item @emph{Reference}:
  886. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.6.
  887. @end table
  888. @node omp_in_final
  889. @section @code{omp_in_final} -- Whether in final or included task region
  890. @table @asis
  891. @item @emph{Description}:
  892. This function returns @code{true} if currently running in a final
  893. or included task region, @code{false} otherwise. Here, @code{true}
  894. and @code{false} represent their language-specific counterparts.
  895. @item @emph{C/C++}:
  896. @multitable @columnfractions .20 .80
  897. @item @emph{Prototype}: @tab @code{int omp_in_final(void);}
  898. @end multitable
  899. @item @emph{Fortran}:
  900. @multitable @columnfractions .20 .80
  901. @item @emph{Interface}: @tab @code{logical function omp_in_final()}
  902. @end multitable
  903. @item @emph{Reference}:
  904. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.21.
  905. @end table
  906. @node omp_is_initial_device
  907. @section @code{omp_is_initial_device} -- Whether executing on the host device
  908. @table @asis
  909. @item @emph{Description}:
  910. This function returns @code{true} if currently running on the host device,
  911. @code{false} otherwise. Here, @code{true} and @code{false} represent
  912. their language-specific counterparts.
  913. @item @emph{C/C++}:
  914. @multitable @columnfractions .20 .80
  915. @item @emph{Prototype}: @tab @code{int omp_is_initial_device(void);}
  916. @end multitable
  917. @item @emph{Fortran}:
  918. @multitable @columnfractions .20 .80
  919. @item @emph{Interface}: @tab @code{logical function omp_is_initial_device()}
  920. @end multitable
  921. @item @emph{Reference}:
  922. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.34.
  923. @end table
  924. @node omp_set_default_device
  925. @section @code{omp_set_default_device} -- Set the default device for target regions
  926. @table @asis
  927. @item @emph{Description}:
  928. Set the default device for target regions without device clause. The argument
  929. shall be a nonnegative device number.
  930. @item @emph{C/C++}:
  931. @multitable @columnfractions .20 .80
  932. @item @emph{Prototype}: @tab @code{void omp_set_default_device(int device_num);}
  933. @end multitable
  934. @item @emph{Fortran}:
  935. @multitable @columnfractions .20 .80
  936. @item @emph{Interface}: @tab @code{subroutine omp_set_default_device(device_num)}
  937. @item @tab @code{integer device_num}
  938. @end multitable
  939. @item @emph{See also}:
  940. @ref{OMP_DEFAULT_DEVICE}, @ref{omp_get_default_device}
  941. @item @emph{Reference}:
  942. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.29.
  943. @end table
  944. @node omp_set_dynamic
  945. @section @code{omp_set_dynamic} -- Enable/disable dynamic teams
  946. @table @asis
  947. @item @emph{Description}:
  948. Enable or disable the dynamic adjustment of the number of threads
  949. within a team. The function takes the language-specific equivalent
  950. of @code{true} and @code{false}, where @code{true} enables dynamic
  951. adjustment of team sizes and @code{false} disables it.
  952. @item @emph{C/C++}:
  953. @multitable @columnfractions .20 .80
  954. @item @emph{Prototype}: @tab @code{void omp_set_dynamic(int dynamic_threads);}
  955. @end multitable
  956. @item @emph{Fortran}:
  957. @multitable @columnfractions .20 .80
  958. @item @emph{Interface}: @tab @code{subroutine omp_set_dynamic(dynamic_threads)}
  959. @item @tab @code{logical, intent(in) :: dynamic_threads}
  960. @end multitable
  961. @item @emph{See also}:
  962. @ref{OMP_DYNAMIC}, @ref{omp_get_dynamic}
  963. @item @emph{Reference}:
  964. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.7.
  965. @end table
  966. @node omp_set_max_active_levels
  967. @section @code{omp_set_max_active_levels} -- Limits the number of active parallel regions
  968. @table @asis
  969. @item @emph{Description}:
  970. This function limits the maximum allowed number of nested, active
  971. parallel regions. @var{max_levels} must be less or equal to
  972. the value returned by @code{omp_get_supported_active_levels}.
  973. @item @emph{C/C++}
  974. @multitable @columnfractions .20 .80
  975. @item @emph{Prototype}: @tab @code{void omp_set_max_active_levels(int max_levels);}
  976. @end multitable
  977. @item @emph{Fortran}:
  978. @multitable @columnfractions .20 .80
  979. @item @emph{Interface}: @tab @code{subroutine omp_set_max_active_levels(max_levels)}
  980. @item @tab @code{integer max_levels}
  981. @end multitable
  982. @item @emph{See also}:
  983. @ref{omp_get_max_active_levels}, @ref{omp_get_active_level},
  984. @ref{omp_get_supported_active_levels}
  985. @item @emph{Reference}:
  986. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.15.
  987. @end table
  988. @node omp_set_nested
  989. @section @code{omp_set_nested} -- Enable/disable nested parallel regions
  990. @table @asis
  991. @item @emph{Description}:
  992. Enable or disable nested parallel regions, i.e., whether team members
  993. are allowed to create new teams. The function takes the language-specific
  994. equivalent of @code{true} and @code{false}, where @code{true} enables
  995. dynamic adjustment of team sizes and @code{false} disables it.
  996. Enabling nested parallel regions will also set the maximum number of
  997. active nested regions to the maximum supported. Disabling nested parallel
  998. regions will set the maximum number of active nested regions to one.
  999. @item @emph{C/C++}:
  1000. @multitable @columnfractions .20 .80
  1001. @item @emph{Prototype}: @tab @code{void omp_set_nested(int nested);}
  1002. @end multitable
  1003. @item @emph{Fortran}:
  1004. @multitable @columnfractions .20 .80
  1005. @item @emph{Interface}: @tab @code{subroutine omp_set_nested(nested)}
  1006. @item @tab @code{logical, intent(in) :: nested}
  1007. @end multitable
  1008. @item @emph{See also}:
  1009. @ref{omp_get_nested}, @ref{omp_set_max_active_levels},
  1010. @ref{OMP_MAX_ACTIVE_LEVELS}, @ref{OMP_NESTED}
  1011. @item @emph{Reference}:
  1012. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.10.
  1013. @end table
  1014. @node omp_set_num_teams
  1015. @section @code{omp_set_num_teams} -- Set upper teams limit for teams construct
  1016. @table @asis
  1017. @item @emph{Description}:
  1018. Specifies the upper bound for number of teams created by the teams construct
  1019. which does not specify a @code{num_teams} clause. The
  1020. argument of @code{omp_set_num_teams} shall be a positive integer.
  1021. @item @emph{C/C++}:
  1022. @multitable @columnfractions .20 .80
  1023. @item @emph{Prototype}: @tab @code{void omp_set_num_teams(int num_teams);}
  1024. @end multitable
  1025. @item @emph{Fortran}:
  1026. @multitable @columnfractions .20 .80
  1027. @item @emph{Interface}: @tab @code{subroutine omp_set_num_teams(num_teams)}
  1028. @item @tab @code{integer, intent(in) :: num_teams}
  1029. @end multitable
  1030. @item @emph{See also}:
  1031. @ref{OMP_NUM_TEAMS}, @ref{omp_get_num_teams}, @ref{omp_get_max_teams}
  1032. @item @emph{Reference}:
  1033. @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.4.3.
  1034. @end table
  1035. @node omp_set_num_threads
  1036. @section @code{omp_set_num_threads} -- Set upper team size limit
  1037. @table @asis
  1038. @item @emph{Description}:
  1039. Specifies the number of threads used by default in subsequent parallel
  1040. sections, if those do not specify a @code{num_threads} clause. The
  1041. argument of @code{omp_set_num_threads} shall be a positive integer.
  1042. @item @emph{C/C++}:
  1043. @multitable @columnfractions .20 .80
  1044. @item @emph{Prototype}: @tab @code{void omp_set_num_threads(int num_threads);}
  1045. @end multitable
  1046. @item @emph{Fortran}:
  1047. @multitable @columnfractions .20 .80
  1048. @item @emph{Interface}: @tab @code{subroutine omp_set_num_threads(num_threads)}
  1049. @item @tab @code{integer, intent(in) :: num_threads}
  1050. @end multitable
  1051. @item @emph{See also}:
  1052. @ref{OMP_NUM_THREADS}, @ref{omp_get_num_threads}, @ref{omp_get_max_threads}
  1053. @item @emph{Reference}:
  1054. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.1.
  1055. @end table
  1056. @node omp_set_schedule
  1057. @section @code{omp_set_schedule} -- Set the runtime scheduling method
  1058. @table @asis
  1059. @item @emph{Description}:
  1060. Sets the runtime scheduling method. The @var{kind} argument can have the
  1061. value @code{omp_sched_static}, @code{omp_sched_dynamic},
  1062. @code{omp_sched_guided} or @code{omp_sched_auto}. Except for
  1063. @code{omp_sched_auto}, the chunk size is set to the value of
  1064. @var{chunk_size} if positive, or to the default value if zero or negative.
  1065. For @code{omp_sched_auto} the @var{chunk_size} argument is ignored.
  1066. @item @emph{C/C++}
  1067. @multitable @columnfractions .20 .80
  1068. @item @emph{Prototype}: @tab @code{void omp_set_schedule(omp_sched_t kind, int chunk_size);}
  1069. @end multitable
  1070. @item @emph{Fortran}:
  1071. @multitable @columnfractions .20 .80
  1072. @item @emph{Interface}: @tab @code{subroutine omp_set_schedule(kind, chunk_size)}
  1073. @item @tab @code{integer(kind=omp_sched_kind) kind}
  1074. @item @tab @code{integer chunk_size}
  1075. @end multitable
  1076. @item @emph{See also}:
  1077. @ref{omp_get_schedule}
  1078. @ref{OMP_SCHEDULE}
  1079. @item @emph{Reference}:
  1080. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.12.
  1081. @end table
  1082. @node omp_set_teams_thread_limit
  1083. @section @code{omp_set_teams_thread_limit} -- Set upper thread limit for teams construct
  1084. @table @asis
  1085. @item @emph{Description}:
  1086. Specifies the upper bound for number of threads that will be available
  1087. for each team created by the teams construct which does not specify a
  1088. @code{thread_limit} clause. The argument of
  1089. @code{omp_set_teams_thread_limit} shall be a positive integer.
  1090. @item @emph{C/C++}:
  1091. @multitable @columnfractions .20 .80
  1092. @item @emph{Prototype}: @tab @code{void omp_set_teams_thread_limit(int thread_limit);}
  1093. @end multitable
  1094. @item @emph{Fortran}:
  1095. @multitable @columnfractions .20 .80
  1096. @item @emph{Interface}: @tab @code{subroutine omp_set_teams_thread_limit(thread_limit)}
  1097. @item @tab @code{integer, intent(in) :: thread_limit}
  1098. @end multitable
  1099. @item @emph{See also}:
  1100. @ref{OMP_TEAMS_THREAD_LIMIT}, @ref{omp_get_teams_thread_limit}, @ref{omp_get_thread_limit}
  1101. @item @emph{Reference}:
  1102. @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.4.5.
  1103. @end table
  1104. @node omp_init_lock
  1105. @section @code{omp_init_lock} -- Initialize simple lock
  1106. @table @asis
  1107. @item @emph{Description}:
  1108. Initialize a simple lock. After initialization, the lock is in
  1109. an unlocked state.
  1110. @item @emph{C/C++}:
  1111. @multitable @columnfractions .20 .80
  1112. @item @emph{Prototype}: @tab @code{void omp_init_lock(omp_lock_t *lock);}
  1113. @end multitable
  1114. @item @emph{Fortran}:
  1115. @multitable @columnfractions .20 .80
  1116. @item @emph{Interface}: @tab @code{subroutine omp_init_lock(svar)}
  1117. @item @tab @code{integer(omp_lock_kind), intent(out) :: svar}
  1118. @end multitable
  1119. @item @emph{See also}:
  1120. @ref{omp_destroy_lock}
  1121. @item @emph{Reference}:
  1122. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.1.
  1123. @end table
  1124. @node omp_set_lock
  1125. @section @code{omp_set_lock} -- Wait for and set simple lock
  1126. @table @asis
  1127. @item @emph{Description}:
  1128. Before setting a simple lock, the lock variable must be initialized by
  1129. @code{omp_init_lock}. The calling thread is blocked until the lock
  1130. is available. If the lock is already held by the current thread,
  1131. a deadlock occurs.
  1132. @item @emph{C/C++}:
  1133. @multitable @columnfractions .20 .80
  1134. @item @emph{Prototype}: @tab @code{void omp_set_lock(omp_lock_t *lock);}
  1135. @end multitable
  1136. @item @emph{Fortran}:
  1137. @multitable @columnfractions .20 .80
  1138. @item @emph{Interface}: @tab @code{subroutine omp_set_lock(svar)}
  1139. @item @tab @code{integer(omp_lock_kind), intent(inout) :: svar}
  1140. @end multitable
  1141. @item @emph{See also}:
  1142. @ref{omp_init_lock}, @ref{omp_test_lock}, @ref{omp_unset_lock}
  1143. @item @emph{Reference}:
  1144. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.4.
  1145. @end table
  1146. @node omp_test_lock
  1147. @section @code{omp_test_lock} -- Test and set simple lock if available
  1148. @table @asis
  1149. @item @emph{Description}:
  1150. Before setting a simple lock, the lock variable must be initialized by
  1151. @code{omp_init_lock}. Contrary to @code{omp_set_lock}, @code{omp_test_lock}
  1152. does not block if the lock is not available. This function returns
  1153. @code{true} upon success, @code{false} otherwise. Here, @code{true} and
  1154. @code{false} represent their language-specific counterparts.
  1155. @item @emph{C/C++}:
  1156. @multitable @columnfractions .20 .80
  1157. @item @emph{Prototype}: @tab @code{int omp_test_lock(omp_lock_t *lock);}
  1158. @end multitable
  1159. @item @emph{Fortran}:
  1160. @multitable @columnfractions .20 .80
  1161. @item @emph{Interface}: @tab @code{logical function omp_test_lock(svar)}
  1162. @item @tab @code{integer(omp_lock_kind), intent(inout) :: svar}
  1163. @end multitable
  1164. @item @emph{See also}:
  1165. @ref{omp_init_lock}, @ref{omp_set_lock}, @ref{omp_set_lock}
  1166. @item @emph{Reference}:
  1167. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.6.
  1168. @end table
  1169. @node omp_unset_lock
  1170. @section @code{omp_unset_lock} -- Unset simple lock
  1171. @table @asis
  1172. @item @emph{Description}:
  1173. A simple lock about to be unset must have been locked by @code{omp_set_lock}
  1174. or @code{omp_test_lock} before. In addition, the lock must be held by the
  1175. thread calling @code{omp_unset_lock}. Then, the lock becomes unlocked. If one
  1176. or more threads attempted to set the lock before, one of them is chosen to,
  1177. again, set the lock to itself.
  1178. @item @emph{C/C++}:
  1179. @multitable @columnfractions .20 .80
  1180. @item @emph{Prototype}: @tab @code{void omp_unset_lock(omp_lock_t *lock);}
  1181. @end multitable
  1182. @item @emph{Fortran}:
  1183. @multitable @columnfractions .20 .80
  1184. @item @emph{Interface}: @tab @code{subroutine omp_unset_lock(svar)}
  1185. @item @tab @code{integer(omp_lock_kind), intent(inout) :: svar}
  1186. @end multitable
  1187. @item @emph{See also}:
  1188. @ref{omp_set_lock}, @ref{omp_test_lock}
  1189. @item @emph{Reference}:
  1190. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.5.
  1191. @end table
  1192. @node omp_destroy_lock
  1193. @section @code{omp_destroy_lock} -- Destroy simple lock
  1194. @table @asis
  1195. @item @emph{Description}:
  1196. Destroy a simple lock. In order to be destroyed, a simple lock must be
  1197. in the unlocked state.
  1198. @item @emph{C/C++}:
  1199. @multitable @columnfractions .20 .80
  1200. @item @emph{Prototype}: @tab @code{void omp_destroy_lock(omp_lock_t *lock);}
  1201. @end multitable
  1202. @item @emph{Fortran}:
  1203. @multitable @columnfractions .20 .80
  1204. @item @emph{Interface}: @tab @code{subroutine omp_destroy_lock(svar)}
  1205. @item @tab @code{integer(omp_lock_kind), intent(inout) :: svar}
  1206. @end multitable
  1207. @item @emph{See also}:
  1208. @ref{omp_init_lock}
  1209. @item @emph{Reference}:
  1210. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.3.
  1211. @end table
  1212. @node omp_init_nest_lock
  1213. @section @code{omp_init_nest_lock} -- Initialize nested lock
  1214. @table @asis
  1215. @item @emph{Description}:
  1216. Initialize a nested lock. After initialization, the lock is in
  1217. an unlocked state and the nesting count is set to zero.
  1218. @item @emph{C/C++}:
  1219. @multitable @columnfractions .20 .80
  1220. @item @emph{Prototype}: @tab @code{void omp_init_nest_lock(omp_nest_lock_t *lock);}
  1221. @end multitable
  1222. @item @emph{Fortran}:
  1223. @multitable @columnfractions .20 .80
  1224. @item @emph{Interface}: @tab @code{subroutine omp_init_nest_lock(nvar)}
  1225. @item @tab @code{integer(omp_nest_lock_kind), intent(out) :: nvar}
  1226. @end multitable
  1227. @item @emph{See also}:
  1228. @ref{omp_destroy_nest_lock}
  1229. @item @emph{Reference}:
  1230. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.1.
  1231. @end table
  1232. @node omp_set_nest_lock
  1233. @section @code{omp_set_nest_lock} -- Wait for and set nested lock
  1234. @table @asis
  1235. @item @emph{Description}:
  1236. Before setting a nested lock, the lock variable must be initialized by
  1237. @code{omp_init_nest_lock}. The calling thread is blocked until the lock
  1238. is available. If the lock is already held by the current thread, the
  1239. nesting count for the lock is incremented.
  1240. @item @emph{C/C++}:
  1241. @multitable @columnfractions .20 .80
  1242. @item @emph{Prototype}: @tab @code{void omp_set_nest_lock(omp_nest_lock_t *lock);}
  1243. @end multitable
  1244. @item @emph{Fortran}:
  1245. @multitable @columnfractions .20 .80
  1246. @item @emph{Interface}: @tab @code{subroutine omp_set_nest_lock(nvar)}
  1247. @item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: nvar}
  1248. @end multitable
  1249. @item @emph{See also}:
  1250. @ref{omp_init_nest_lock}, @ref{omp_unset_nest_lock}
  1251. @item @emph{Reference}:
  1252. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.4.
  1253. @end table
  1254. @node omp_test_nest_lock
  1255. @section @code{omp_test_nest_lock} -- Test and set nested lock if available
  1256. @table @asis
  1257. @item @emph{Description}:
  1258. Before setting a nested lock, the lock variable must be initialized by
  1259. @code{omp_init_nest_lock}. Contrary to @code{omp_set_nest_lock},
  1260. @code{omp_test_nest_lock} does not block if the lock is not available.
  1261. If the lock is already held by the current thread, the new nesting count
  1262. is returned. Otherwise, the return value equals zero.
  1263. @item @emph{C/C++}:
  1264. @multitable @columnfractions .20 .80
  1265. @item @emph{Prototype}: @tab @code{int omp_test_nest_lock(omp_nest_lock_t *lock);}
  1266. @end multitable
  1267. @item @emph{Fortran}:
  1268. @multitable @columnfractions .20 .80
  1269. @item @emph{Interface}: @tab @code{logical function omp_test_nest_lock(nvar)}
  1270. @item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: nvar}
  1271. @end multitable
  1272. @item @emph{See also}:
  1273. @ref{omp_init_lock}, @ref{omp_set_lock}, @ref{omp_set_lock}
  1274. @item @emph{Reference}:
  1275. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.6.
  1276. @end table
  1277. @node omp_unset_nest_lock
  1278. @section @code{omp_unset_nest_lock} -- Unset nested lock
  1279. @table @asis
  1280. @item @emph{Description}:
  1281. A nested lock about to be unset must have been locked by @code{omp_set_nested_lock}
  1282. or @code{omp_test_nested_lock} before. In addition, the lock must be held by the
  1283. thread calling @code{omp_unset_nested_lock}. If the nesting count drops to zero, the
  1284. lock becomes unlocked. If one ore more threads attempted to set the lock before,
  1285. one of them is chosen to, again, set the lock to itself.
  1286. @item @emph{C/C++}:
  1287. @multitable @columnfractions .20 .80
  1288. @item @emph{Prototype}: @tab @code{void omp_unset_nest_lock(omp_nest_lock_t *lock);}
  1289. @end multitable
  1290. @item @emph{Fortran}:
  1291. @multitable @columnfractions .20 .80
  1292. @item @emph{Interface}: @tab @code{subroutine omp_unset_nest_lock(nvar)}
  1293. @item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: nvar}
  1294. @end multitable
  1295. @item @emph{See also}:
  1296. @ref{omp_set_nest_lock}
  1297. @item @emph{Reference}:
  1298. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.5.
  1299. @end table
  1300. @node omp_destroy_nest_lock
  1301. @section @code{omp_destroy_nest_lock} -- Destroy nested lock
  1302. @table @asis
  1303. @item @emph{Description}:
  1304. Destroy a nested lock. In order to be destroyed, a nested lock must be
  1305. in the unlocked state and its nesting count must equal zero.
  1306. @item @emph{C/C++}:
  1307. @multitable @columnfractions .20 .80
  1308. @item @emph{Prototype}: @tab @code{void omp_destroy_nest_lock(omp_nest_lock_t *);}
  1309. @end multitable
  1310. @item @emph{Fortran}:
  1311. @multitable @columnfractions .20 .80
  1312. @item @emph{Interface}: @tab @code{subroutine omp_destroy_nest_lock(nvar)}
  1313. @item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: nvar}
  1314. @end multitable
  1315. @item @emph{See also}:
  1316. @ref{omp_init_lock}
  1317. @item @emph{Reference}:
  1318. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.3.
  1319. @end table
  1320. @node omp_get_wtick
  1321. @section @code{omp_get_wtick} -- Get timer precision
  1322. @table @asis
  1323. @item @emph{Description}:
  1324. Gets the timer precision, i.e., the number of seconds between two
  1325. successive clock ticks.
  1326. @item @emph{C/C++}:
  1327. @multitable @columnfractions .20 .80
  1328. @item @emph{Prototype}: @tab @code{double omp_get_wtick(void);}
  1329. @end multitable
  1330. @item @emph{Fortran}:
  1331. @multitable @columnfractions .20 .80
  1332. @item @emph{Interface}: @tab @code{double precision function omp_get_wtick()}
  1333. @end multitable
  1334. @item @emph{See also}:
  1335. @ref{omp_get_wtime}
  1336. @item @emph{Reference}:
  1337. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.4.2.
  1338. @end table
  1339. @node omp_get_wtime
  1340. @section @code{omp_get_wtime} -- Elapsed wall clock time
  1341. @table @asis
  1342. @item @emph{Description}:
  1343. Elapsed wall clock time in seconds. The time is measured per thread, no
  1344. guarantee can be made that two distinct threads measure the same time.
  1345. Time is measured from some "time in the past", which is an arbitrary time
  1346. guaranteed not to change during the execution of the program.
  1347. @item @emph{C/C++}:
  1348. @multitable @columnfractions .20 .80
  1349. @item @emph{Prototype}: @tab @code{double omp_get_wtime(void);}
  1350. @end multitable
  1351. @item @emph{Fortran}:
  1352. @multitable @columnfractions .20 .80
  1353. @item @emph{Interface}: @tab @code{double precision function omp_get_wtime()}
  1354. @end multitable
  1355. @item @emph{See also}:
  1356. @ref{omp_get_wtick}
  1357. @item @emph{Reference}:
  1358. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.4.1.
  1359. @end table
  1360. @node omp_fulfill_event
  1361. @section @code{omp_fulfill_event} -- Fulfill and destroy an OpenMP event
  1362. @table @asis
  1363. @item @emph{Description}:
  1364. Fulfill the event associated with the event handle argument. Currently, it
  1365. is only used to fulfill events generated by detach clauses on task
  1366. constructs - the effect of fulfilling the event is to allow the task to
  1367. complete.
  1368. The result of calling @code{omp_fulfill_event} with an event handle other
  1369. than that generated by a detach clause is undefined. Calling it with an
  1370. event handle that has already been fulfilled is also undefined.
  1371. @item @emph{C/C++}:
  1372. @multitable @columnfractions .20 .80
  1373. @item @emph{Prototype}: @tab @code{void omp_fulfill_event(omp_event_handle_t event);}
  1374. @end multitable
  1375. @item @emph{Fortran}:
  1376. @multitable @columnfractions .20 .80
  1377. @item @emph{Interface}: @tab @code{subroutine omp_fulfill_event(event)}
  1378. @item @tab @code{integer (kind=omp_event_handle_kind) :: event}
  1379. @end multitable
  1380. @item @emph{Reference}:
  1381. @uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.5.1.
  1382. @end table
  1383. @c ---------------------------------------------------------------------
  1384. @c OpenMP Environment Variables
  1385. @c ---------------------------------------------------------------------
  1386. @node Environment Variables
  1387. @chapter OpenMP Environment Variables
  1388. The environment variables which beginning with @env{OMP_} are defined by
  1389. section 4 of the OpenMP specification in version 4.5, while those
  1390. beginning with @env{GOMP_} are GNU extensions.
  1391. @menu
  1392. * OMP_CANCELLATION:: Set whether cancellation is activated
  1393. * OMP_DISPLAY_ENV:: Show OpenMP version and environment variables
  1394. * OMP_DEFAULT_DEVICE:: Set the device used in target regions
  1395. * OMP_DYNAMIC:: Dynamic adjustment of threads
  1396. * OMP_MAX_ACTIVE_LEVELS:: Set the maximum number of nested parallel regions
  1397. * OMP_MAX_TASK_PRIORITY:: Set the maximum task priority value
  1398. * OMP_NESTED:: Nested parallel regions
  1399. * OMP_NUM_TEAMS:: Specifies the number of teams to use by teams region
  1400. * OMP_NUM_THREADS:: Specifies the number of threads to use
  1401. * OMP_PROC_BIND:: Whether theads may be moved between CPUs
  1402. * OMP_PLACES:: Specifies on which CPUs the theads should be placed
  1403. * OMP_STACKSIZE:: Set default thread stack size
  1404. * OMP_SCHEDULE:: How threads are scheduled
  1405. * OMP_TARGET_OFFLOAD:: Controls offloading behaviour
  1406. * OMP_TEAMS_THREAD_LIMIT:: Set the maximum number of threads imposed by teams
  1407. * OMP_THREAD_LIMIT:: Set the maximum number of threads
  1408. * OMP_WAIT_POLICY:: How waiting threads are handled
  1409. * GOMP_CPU_AFFINITY:: Bind threads to specific CPUs
  1410. * GOMP_DEBUG:: Enable debugging output
  1411. * GOMP_STACKSIZE:: Set default thread stack size
  1412. * GOMP_SPINCOUNT:: Set the busy-wait spin count
  1413. * GOMP_RTEMS_THREAD_POOLS:: Set the RTEMS specific thread pools
  1414. @end menu
  1415. @node OMP_CANCELLATION
  1416. @section @env{OMP_CANCELLATION} -- Set whether cancellation is activated
  1417. @cindex Environment Variable
  1418. @table @asis
  1419. @item @emph{Description}:
  1420. If set to @code{TRUE}, the cancellation is activated. If set to @code{FALSE} or
  1421. if unset, cancellation is disabled and the @code{cancel} construct is ignored.
  1422. @item @emph{See also}:
  1423. @ref{omp_get_cancellation}
  1424. @item @emph{Reference}:
  1425. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.11
  1426. @end table
  1427. @node OMP_DISPLAY_ENV
  1428. @section @env{OMP_DISPLAY_ENV} -- Show OpenMP version and environment variables
  1429. @cindex Environment Variable
  1430. @table @asis
  1431. @item @emph{Description}:
  1432. If set to @code{TRUE}, the OpenMP version number and the values
  1433. associated with the OpenMP environment variables are printed to @code{stderr}.
  1434. If set to @code{VERBOSE}, it additionally shows the value of the environment
  1435. variables which are GNU extensions. If undefined or set to @code{FALSE},
  1436. this information will not be shown.
  1437. @item @emph{Reference}:
  1438. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.12
  1439. @end table
  1440. @node OMP_DEFAULT_DEVICE
  1441. @section @env{OMP_DEFAULT_DEVICE} -- Set the device used in target regions
  1442. @cindex Environment Variable
  1443. @table @asis
  1444. @item @emph{Description}:
  1445. Set to choose the device which is used in a @code{target} region, unless the
  1446. value is overridden by @code{omp_set_default_device} or by a @code{device}
  1447. clause. The value shall be the nonnegative device number. If no device with
  1448. the given device number exists, the code is executed on the host. If unset,
  1449. device number 0 will be used.
  1450. @item @emph{See also}:
  1451. @ref{omp_get_default_device}, @ref{omp_set_default_device},
  1452. @item @emph{Reference}:
  1453. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.13
  1454. @end table
  1455. @node OMP_DYNAMIC
  1456. @section @env{OMP_DYNAMIC} -- Dynamic adjustment of threads
  1457. @cindex Environment Variable
  1458. @table @asis
  1459. @item @emph{Description}:
  1460. Enable or disable the dynamic adjustment of the number of threads
  1461. within a team. The value of this environment variable shall be
  1462. @code{TRUE} or @code{FALSE}. If undefined, dynamic adjustment is
  1463. disabled by default.
  1464. @item @emph{See also}:
  1465. @ref{omp_set_dynamic}
  1466. @item @emph{Reference}:
  1467. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.3
  1468. @end table
  1469. @node OMP_MAX_ACTIVE_LEVELS
  1470. @section @env{OMP_MAX_ACTIVE_LEVELS} -- Set the maximum number of nested parallel regions
  1471. @cindex Environment Variable
  1472. @table @asis
  1473. @item @emph{Description}:
  1474. Specifies the initial value for the maximum number of nested parallel
  1475. regions. The value of this variable shall be a positive integer.
  1476. If undefined, then if @env{OMP_NESTED} is defined and set to true, or
  1477. if @env{OMP_NUM_THREADS} or @env{OMP_PROC_BIND} are defined and set to
  1478. a list with more than one item, the maximum number of nested parallel
  1479. regions will be initialized to the largest number supported, otherwise
  1480. it will be set to one.
  1481. @item @emph{See also}:
  1482. @ref{omp_set_max_active_levels}, @ref{OMP_NESTED}
  1483. @item @emph{Reference}:
  1484. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.9
  1485. @end table
  1486. @node OMP_MAX_TASK_PRIORITY
  1487. @section @env{OMP_MAX_TASK_PRIORITY} -- Set the maximum priority
  1488. number that can be set for a task.
  1489. @cindex Environment Variable
  1490. @table @asis
  1491. @item @emph{Description}:
  1492. Specifies the initial value for the maximum priority value that can be
  1493. set for a task. The value of this variable shall be a non-negative
  1494. integer, and zero is allowed. If undefined, the default priority is
  1495. 0.
  1496. @item @emph{See also}:
  1497. @ref{omp_get_max_task_priority}
  1498. @item @emph{Reference}:
  1499. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.14
  1500. @end table
  1501. @node OMP_NESTED
  1502. @section @env{OMP_NESTED} -- Nested parallel regions
  1503. @cindex Environment Variable
  1504. @cindex Implementation specific setting
  1505. @table @asis
  1506. @item @emph{Description}:
  1507. Enable or disable nested parallel regions, i.e., whether team members
  1508. are allowed to create new teams. The value of this environment variable
  1509. shall be @code{TRUE} or @code{FALSE}. If set to @code{TRUE}, the number
  1510. of maximum active nested regions supported will by default be set to the
  1511. maximum supported, otherwise it will be set to one. If
  1512. @env{OMP_MAX_ACTIVE_LEVELS} is defined, its setting will override this
  1513. setting. If both are undefined, nested parallel regions are enabled if
  1514. @env{OMP_NUM_THREADS} or @env{OMP_PROC_BINDS} are defined to a list with
  1515. more than one item, otherwise they are disabled by default.
  1516. @item @emph{See also}:
  1517. @ref{omp_set_max_active_levels}, @ref{omp_set_nested}
  1518. @item @emph{Reference}:
  1519. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.6
  1520. @end table
  1521. @node OMP_NUM_TEAMS
  1522. @section @env{OMP_NUM_TEAMS} -- Specifies the number of teams to use by teams region
  1523. @cindex Environment Variable
  1524. @table @asis
  1525. @item @emph{Description}:
  1526. Specifies the upper bound for number of teams to use in teams regions
  1527. without explicit @code{num_teams} clause. The value of this variable shall
  1528. be a positive integer. If undefined it defaults to 0 which means
  1529. implementation defined upper bound.
  1530. @item @emph{See also}:
  1531. @ref{omp_set_num_teams}
  1532. @item @emph{Reference}:
  1533. @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 6.23
  1534. @end table
  1535. @node OMP_NUM_THREADS
  1536. @section @env{OMP_NUM_THREADS} -- Specifies the number of threads to use
  1537. @cindex Environment Variable
  1538. @cindex Implementation specific setting
  1539. @table @asis
  1540. @item @emph{Description}:
  1541. Specifies the default number of threads to use in parallel regions. The
  1542. value of this variable shall be a comma-separated list of positive integers;
  1543. the value specifies the number of threads to use for the corresponding nested
  1544. level. Specifying more than one item in the list will automatically enable
  1545. nesting by default. If undefined one thread per CPU is used.
  1546. @item @emph{See also}:
  1547. @ref{omp_set_num_threads}, @ref{OMP_NESTED}
  1548. @item @emph{Reference}:
  1549. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.2
  1550. @end table
  1551. @node OMP_PROC_BIND
  1552. @section @env{OMP_PROC_BIND} -- Whether theads may be moved between CPUs
  1553. @cindex Environment Variable
  1554. @table @asis
  1555. @item @emph{Description}:
  1556. Specifies whether threads may be moved between processors. If set to
  1557. @code{TRUE}, OpenMP theads should not be moved; if set to @code{FALSE}
  1558. they may be moved. Alternatively, a comma separated list with the
  1559. values @code{PRIMARY}, @code{MASTER}, @code{CLOSE} and @code{SPREAD} can
  1560. be used to specify the thread affinity policy for the corresponding nesting
  1561. level. With @code{PRIMARY} and @code{MASTER} the worker threads are in the
  1562. same place partition as the primary thread. With @code{CLOSE} those are
  1563. kept close to the primary thread in contiguous place partitions. And
  1564. with @code{SPREAD} a sparse distribution
  1565. across the place partitions is used. Specifying more than one item in the
  1566. list will automatically enable nesting by default.
  1567. When undefined, @env{OMP_PROC_BIND} defaults to @code{TRUE} when
  1568. @env{OMP_PLACES} or @env{GOMP_CPU_AFFINITY} is set and @code{FALSE} otherwise.
  1569. @item @emph{See also}:
  1570. @ref{omp_get_proc_bind}, @ref{GOMP_CPU_AFFINITY},
  1571. @ref{OMP_NESTED}, @ref{OMP_PLACES}
  1572. @item @emph{Reference}:
  1573. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.4
  1574. @end table
  1575. @node OMP_PLACES
  1576. @section @env{OMP_PLACES} -- Specifies on which CPUs the theads should be placed
  1577. @cindex Environment Variable
  1578. @table @asis
  1579. @item @emph{Description}:
  1580. The thread placement can be either specified using an abstract name or by an
  1581. explicit list of the places. The abstract names @code{threads}, @code{cores},
  1582. @code{sockets}, @code{ll_caches} and @code{numa_domains} can be optionally
  1583. followed by a positive number in parentheses, which denotes the how many places
  1584. shall be created. With @code{threads} each place corresponds to a single
  1585. hardware thread; @code{cores} to a single core with the corresponding number of
  1586. hardware threads; with @code{sockets} the place corresponds to a single
  1587. socket; with @code{ll_caches} to a set of cores that shares the last level
  1588. cache on the device; and @code{numa_domains} to a set of cores for which their
  1589. closest memory on the device is the same memory and at a similar distance from
  1590. the cores. The resulting placement can be shown by setting the
  1591. @env{OMP_DISPLAY_ENV} environment variable.
  1592. Alternatively, the placement can be specified explicitly as comma-separated
  1593. list of places. A place is specified by set of nonnegative numbers in curly
  1594. braces, denoting the hardware threads. The curly braces can be omitted
  1595. when only a single number has been specified. The hardware threads
  1596. belonging to a place can either be specified as comma-separated list of
  1597. nonnegative thread numbers or using an interval. Multiple places can also be
  1598. either specified by a comma-separated list of places or by an interval. To
  1599. specify an interval, a colon followed by the count is placed after
  1600. the hardware thread number or the place. Optionally, the length can be
  1601. followed by a colon and the stride number -- otherwise a unit stride is
  1602. assumed. Placing an exclamation mark (@code{!}) directly before a curly
  1603. brace or numbers inside the curly braces (excluding intervals) will
  1604. exclude those hardware threads.
  1605. For instance, the following specifies the same places list:
  1606. @code{"@{0,1,2@}, @{3,4,6@}, @{7,8,9@}, @{10,11,12@}"};
  1607. @code{"@{0:3@}, @{3:3@}, @{7:3@}, @{10:3@}"}; and @code{"@{0:2@}:4:3"}.
  1608. If @env{OMP_PLACES} and @env{GOMP_CPU_AFFINITY} are unset and
  1609. @env{OMP_PROC_BIND} is either unset or @code{false}, threads may be moved
  1610. between CPUs following no placement policy.
  1611. @item @emph{See also}:
  1612. @ref{OMP_PROC_BIND}, @ref{GOMP_CPU_AFFINITY}, @ref{omp_get_proc_bind},
  1613. @ref{OMP_DISPLAY_ENV}
  1614. @item @emph{Reference}:
  1615. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.5
  1616. @end table
  1617. @node OMP_STACKSIZE
  1618. @section @env{OMP_STACKSIZE} -- Set default thread stack size
  1619. @cindex Environment Variable
  1620. @table @asis
  1621. @item @emph{Description}:
  1622. Set the default thread stack size in kilobytes, unless the number
  1623. is suffixed by @code{B}, @code{K}, @code{M} or @code{G}, in which
  1624. case the size is, respectively, in bytes, kilobytes, megabytes
  1625. or gigabytes. This is different from @code{pthread_attr_setstacksize}
  1626. which gets the number of bytes as an argument. If the stack size cannot
  1627. be set due to system constraints, an error is reported and the initial
  1628. stack size is left unchanged. If undefined, the stack size is system
  1629. dependent.
  1630. @item @emph{Reference}:
  1631. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.7
  1632. @end table
  1633. @node OMP_SCHEDULE
  1634. @section @env{OMP_SCHEDULE} -- How threads are scheduled
  1635. @cindex Environment Variable
  1636. @cindex Implementation specific setting
  1637. @table @asis
  1638. @item @emph{Description}:
  1639. Allows to specify @code{schedule type} and @code{chunk size}.
  1640. The value of the variable shall have the form: @code{type[,chunk]} where
  1641. @code{type} is one of @code{static}, @code{dynamic}, @code{guided} or @code{auto}
  1642. The optional @code{chunk} size shall be a positive integer. If undefined,
  1643. dynamic scheduling and a chunk size of 1 is used.
  1644. @item @emph{See also}:
  1645. @ref{omp_set_schedule}
  1646. @item @emph{Reference}:
  1647. @uref{https://www.openmp.org, OpenMP specification v4.5}, Sections 2.7.1.1 and 4.1
  1648. @end table
  1649. @node OMP_TARGET_OFFLOAD
  1650. @section @env{OMP_TARGET_OFFLOAD} -- Controls offloading behaviour
  1651. @cindex Environment Variable
  1652. @cindex Implementation specific setting
  1653. @table @asis
  1654. @item @emph{Description}:
  1655. Specifies the behaviour with regard to offloading code to a device. This
  1656. variable can be set to one of three values - @code{MANDATORY}, @code{DISABLED}
  1657. or @code{DEFAULT}.
  1658. If set to @code{MANDATORY}, the program will terminate with an error if
  1659. the offload device is not present or is not supported. If set to
  1660. @code{DISABLED}, then offloading is disabled and all code will run on the
  1661. host. If set to @code{DEFAULT}, the program will try offloading to the
  1662. device first, then fall back to running code on the host if it cannot.
  1663. If undefined, then the program will behave as if @code{DEFAULT} was set.
  1664. @item @emph{Reference}:
  1665. @uref{https://www.openmp.org, OpenMP specification v5.0}, Section 6.17
  1666. @end table
  1667. @node OMP_TEAMS_THREAD_LIMIT
  1668. @section @env{OMP_TEAMS_THREAD_LIMIT} -- Set the maximum number of threads imposed by teams
  1669. @cindex Environment Variable
  1670. @table @asis
  1671. @item @emph{Description}:
  1672. Specifies an upper bound for the number of threads to use by each contention
  1673. group created by a teams construct without explicit @code{thread_limit}
  1674. clause. The value of this variable shall be a positive integer. If undefined,
  1675. the value of 0 is used which stands for an implementation defined upper
  1676. limit.
  1677. @item @emph{See also}:
  1678. @ref{OMP_THREAD_LIMIT}, @ref{omp_set_teams_thread_limit}
  1679. @item @emph{Reference}:
  1680. @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 6.24
  1681. @end table
  1682. @node OMP_THREAD_LIMIT
  1683. @section @env{OMP_THREAD_LIMIT} -- Set the maximum number of threads
  1684. @cindex Environment Variable
  1685. @table @asis
  1686. @item @emph{Description}:
  1687. Specifies the number of threads to use for the whole program. The
  1688. value of this variable shall be a positive integer. If undefined,
  1689. the number of threads is not limited.
  1690. @item @emph{See also}:
  1691. @ref{OMP_NUM_THREADS}, @ref{omp_get_thread_limit}
  1692. @item @emph{Reference}:
  1693. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.10
  1694. @end table
  1695. @node OMP_WAIT_POLICY
  1696. @section @env{OMP_WAIT_POLICY} -- How waiting threads are handled
  1697. @cindex Environment Variable
  1698. @table @asis
  1699. @item @emph{Description}:
  1700. Specifies whether waiting threads should be active or passive. If
  1701. the value is @code{PASSIVE}, waiting threads should not consume CPU
  1702. power while waiting; while the value is @code{ACTIVE} specifies that
  1703. they should. If undefined, threads wait actively for a short time
  1704. before waiting passively.
  1705. @item @emph{See also}:
  1706. @ref{GOMP_SPINCOUNT}
  1707. @item @emph{Reference}:
  1708. @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.8
  1709. @end table
  1710. @node GOMP_CPU_AFFINITY
  1711. @section @env{GOMP_CPU_AFFINITY} -- Bind threads to specific CPUs
  1712. @cindex Environment Variable
  1713. @table @asis
  1714. @item @emph{Description}:
  1715. Binds threads to specific CPUs. The variable should contain a space-separated
  1716. or comma-separated list of CPUs. This list may contain different kinds of
  1717. entries: either single CPU numbers in any order, a range of CPUs (M-N)
  1718. or a range with some stride (M-N:S). CPU numbers are zero based. For example,
  1719. @code{GOMP_CPU_AFFINITY="0 3 1-2 4-15:2"} will bind the initial thread
  1720. to CPU 0, the second to CPU 3, the third to CPU 1, the fourth to
  1721. CPU 2, the fifth to CPU 4, the sixth through tenth to CPUs 6, 8, 10, 12,
  1722. and 14 respectively and then start assigning back from the beginning of
  1723. the list. @code{GOMP_CPU_AFFINITY=0} binds all threads to CPU 0.
  1724. There is no libgomp library routine to determine whether a CPU affinity
  1725. specification is in effect. As a workaround, language-specific library
  1726. functions, e.g., @code{getenv} in C or @code{GET_ENVIRONMENT_VARIABLE} in
  1727. Fortran, may be used to query the setting of the @code{GOMP_CPU_AFFINITY}
  1728. environment variable. A defined CPU affinity on startup cannot be changed
  1729. or disabled during the runtime of the application.
  1730. If both @env{GOMP_CPU_AFFINITY} and @env{OMP_PROC_BIND} are set,
  1731. @env{OMP_PROC_BIND} has a higher precedence. If neither has been set and
  1732. @env{OMP_PROC_BIND} is unset, or when @env{OMP_PROC_BIND} is set to
  1733. @code{FALSE}, the host system will handle the assignment of threads to CPUs.
  1734. @item @emph{See also}:
  1735. @ref{OMP_PLACES}, @ref{OMP_PROC_BIND}
  1736. @end table
  1737. @node GOMP_DEBUG
  1738. @section @env{GOMP_DEBUG} -- Enable debugging output
  1739. @cindex Environment Variable
  1740. @table @asis
  1741. @item @emph{Description}:
  1742. Enable debugging output. The variable should be set to @code{0}
  1743. (disabled, also the default if not set), or @code{1} (enabled).
  1744. If enabled, some debugging output will be printed during execution.
  1745. This is currently not specified in more detail, and subject to change.
  1746. @end table
  1747. @node GOMP_STACKSIZE
  1748. @section @env{GOMP_STACKSIZE} -- Set default thread stack size
  1749. @cindex Environment Variable
  1750. @cindex Implementation specific setting
  1751. @table @asis
  1752. @item @emph{Description}:
  1753. Set the default thread stack size in kilobytes. This is different from
  1754. @code{pthread_attr_setstacksize} which gets the number of bytes as an
  1755. argument. If the stack size cannot be set due to system constraints, an
  1756. error is reported and the initial stack size is left unchanged. If undefined,
  1757. the stack size is system dependent.
  1758. @item @emph{See also}:
  1759. @ref{OMP_STACKSIZE}
  1760. @item @emph{Reference}:
  1761. @uref{https://gcc.gnu.org/ml/gcc-patches/2006-06/msg00493.html,
  1762. GCC Patches Mailinglist},
  1763. @uref{https://gcc.gnu.org/ml/gcc-patches/2006-06/msg00496.html,
  1764. GCC Patches Mailinglist}
  1765. @end table
  1766. @node GOMP_SPINCOUNT
  1767. @section @env{GOMP_SPINCOUNT} -- Set the busy-wait spin count
  1768. @cindex Environment Variable
  1769. @cindex Implementation specific setting
  1770. @table @asis
  1771. @item @emph{Description}:
  1772. Determines how long a threads waits actively with consuming CPU power
  1773. before waiting passively without consuming CPU power. The value may be
  1774. either @code{INFINITE}, @code{INFINITY} to always wait actively or an
  1775. integer which gives the number of spins of the busy-wait loop. The
  1776. integer may optionally be followed by the following suffixes acting
  1777. as multiplication factors: @code{k} (kilo, thousand), @code{M} (mega,
  1778. million), @code{G} (giga, billion), or @code{T} (tera, trillion).
  1779. If undefined, 0 is used when @env{OMP_WAIT_POLICY} is @code{PASSIVE},
  1780. 300,000 is used when @env{OMP_WAIT_POLICY} is undefined and
  1781. 30 billion is used when @env{OMP_WAIT_POLICY} is @code{ACTIVE}.
  1782. If there are more OpenMP threads than available CPUs, 1000 and 100
  1783. spins are used for @env{OMP_WAIT_POLICY} being @code{ACTIVE} or
  1784. undefined, respectively; unless the @env{GOMP_SPINCOUNT} is lower
  1785. or @env{OMP_WAIT_POLICY} is @code{PASSIVE}.
  1786. @item @emph{See also}:
  1787. @ref{OMP_WAIT_POLICY}
  1788. @end table
  1789. @node GOMP_RTEMS_THREAD_POOLS
  1790. @section @env{GOMP_RTEMS_THREAD_POOLS} -- Set the RTEMS specific thread pools
  1791. @cindex Environment Variable
  1792. @cindex Implementation specific setting
  1793. @table @asis
  1794. @item @emph{Description}:
  1795. This environment variable is only used on the RTEMS real-time operating system.
  1796. It determines the scheduler instance specific thread pools. The format for
  1797. @env{GOMP_RTEMS_THREAD_POOLS} is a list of optional
  1798. @code{<thread-pool-count>[$<priority>]@@<scheduler-name>} configurations
  1799. separated by @code{:} where:
  1800. @itemize @bullet
  1801. @item @code{<thread-pool-count>} is the thread pool count for this scheduler
  1802. instance.
  1803. @item @code{$<priority>} is an optional priority for the worker threads of a
  1804. thread pool according to @code{pthread_setschedparam}. In case a priority
  1805. value is omitted, then a worker thread will inherit the priority of the OpenMP
  1806. primary thread that created it. The priority of the worker thread is not
  1807. changed after creation, even if a new OpenMP primary thread using the worker has
  1808. a different priority.
  1809. @item @code{@@<scheduler-name>} is the scheduler instance name according to the
  1810. RTEMS application configuration.
  1811. @end itemize
  1812. In case no thread pool configuration is specified for a scheduler instance,
  1813. then each OpenMP primary thread of this scheduler instance will use its own
  1814. dynamically allocated thread pool. To limit the worker thread count of the
  1815. thread pools, each OpenMP primary thread must call @code{omp_set_num_threads}.
  1816. @item @emph{Example}:
  1817. Lets suppose we have three scheduler instances @code{IO}, @code{WRK0}, and
  1818. @code{WRK1} with @env{GOMP_RTEMS_THREAD_POOLS} set to
  1819. @code{"1@@WRK0:3$4@@WRK1"}. Then there are no thread pool restrictions for
  1820. scheduler instance @code{IO}. In the scheduler instance @code{WRK0} there is
  1821. one thread pool available. Since no priority is specified for this scheduler
  1822. instance, the worker thread inherits the priority of the OpenMP primary thread
  1823. that created it. In the scheduler instance @code{WRK1} there are three thread
  1824. pools available and their worker threads run at priority four.
  1825. @end table
  1826. @c ---------------------------------------------------------------------
  1827. @c Enabling OpenACC
  1828. @c ---------------------------------------------------------------------
  1829. @node Enabling OpenACC
  1830. @chapter Enabling OpenACC
  1831. To activate the OpenACC extensions for C/C++ and Fortran, the compile-time
  1832. flag @option{-fopenacc} must be specified. This enables the OpenACC directive
  1833. @code{#pragma acc} in C/C++ and @code{!$acc} directives in free form,
  1834. @code{c$acc}, @code{*$acc} and @code{!$acc} directives in fixed form,
  1835. @code{!$} conditional compilation sentinels in free form and @code{c$},
  1836. @code{*$} and @code{!$} sentinels in fixed form, for Fortran. The flag also
  1837. arranges for automatic linking of the OpenACC runtime library
  1838. (@ref{OpenACC Runtime Library Routines}).
  1839. See @uref{https://gcc.gnu.org/wiki/OpenACC} for more information.
  1840. A complete description of all OpenACC directives accepted may be found in
  1841. the @uref{https://www.openacc.org, OpenACC} Application Programming
  1842. Interface manual, version 2.6.
  1843. @c ---------------------------------------------------------------------
  1844. @c OpenACC Runtime Library Routines
  1845. @c ---------------------------------------------------------------------
  1846. @node OpenACC Runtime Library Routines
  1847. @chapter OpenACC Runtime Library Routines
  1848. The runtime routines described here are defined by section 3 of the OpenACC
  1849. specifications in version 2.6.
  1850. They have C linkage, and do not throw exceptions.
  1851. Generally, they are available only for the host, with the exception of
  1852. @code{acc_on_device}, which is available for both the host and the
  1853. acceleration device.
  1854. @menu
  1855. * acc_get_num_devices:: Get number of devices for the given device
  1856. type.
  1857. * acc_set_device_type:: Set type of device accelerator to use.
  1858. * acc_get_device_type:: Get type of device accelerator to be used.
  1859. * acc_set_device_num:: Set device number to use.
  1860. * acc_get_device_num:: Get device number to be used.
  1861. * acc_get_property:: Get device property.
  1862. * acc_async_test:: Tests for completion of a specific asynchronous
  1863. operation.
  1864. * acc_async_test_all:: Tests for completion of all asynchronous
  1865. operations.
  1866. * acc_wait:: Wait for completion of a specific asynchronous
  1867. operation.
  1868. * acc_wait_all:: Waits for completion of all asynchronous
  1869. operations.
  1870. * acc_wait_all_async:: Wait for completion of all asynchronous
  1871. operations.
  1872. * acc_wait_async:: Wait for completion of asynchronous operations.
  1873. * acc_init:: Initialize runtime for a specific device type.
  1874. * acc_shutdown:: Shuts down the runtime for a specific device
  1875. type.
  1876. * acc_on_device:: Whether executing on a particular device
  1877. * acc_malloc:: Allocate device memory.
  1878. * acc_free:: Free device memory.
  1879. * acc_copyin:: Allocate device memory and copy host memory to
  1880. it.
  1881. * acc_present_or_copyin:: If the data is not present on the device,
  1882. allocate device memory and copy from host
  1883. memory.
  1884. * acc_create:: Allocate device memory and map it to host
  1885. memory.
  1886. * acc_present_or_create:: If the data is not present on the device,
  1887. allocate device memory and map it to host
  1888. memory.
  1889. * acc_copyout:: Copy device memory to host memory.
  1890. * acc_delete:: Free device memory.
  1891. * acc_update_device:: Update device memory from mapped host memory.
  1892. * acc_update_self:: Update host memory from mapped device memory.
  1893. * acc_map_data:: Map previously allocated device memory to host
  1894. memory.
  1895. * acc_unmap_data:: Unmap device memory from host memory.
  1896. * acc_deviceptr:: Get device pointer associated with specific
  1897. host address.
  1898. * acc_hostptr:: Get host pointer associated with specific
  1899. device address.
  1900. * acc_is_present:: Indicate whether host variable / array is
  1901. present on device.
  1902. * acc_memcpy_to_device:: Copy host memory to device memory.
  1903. * acc_memcpy_from_device:: Copy device memory to host memory.
  1904. * acc_attach:: Let device pointer point to device-pointer target.
  1905. * acc_detach:: Let device pointer point to host-pointer target.
  1906. API routines for target platforms.
  1907. * acc_get_current_cuda_device:: Get CUDA device handle.
  1908. * acc_get_current_cuda_context::Get CUDA context handle.
  1909. * acc_get_cuda_stream:: Get CUDA stream handle.
  1910. * acc_set_cuda_stream:: Set CUDA stream handle.
  1911. API routines for the OpenACC Profiling Interface.
  1912. * acc_prof_register:: Register callbacks.
  1913. * acc_prof_unregister:: Unregister callbacks.
  1914. * acc_prof_lookup:: Obtain inquiry functions.
  1915. * acc_register_library:: Library registration.
  1916. @end menu
  1917. @node acc_get_num_devices
  1918. @section @code{acc_get_num_devices} -- Get number of devices for given device type
  1919. @table @asis
  1920. @item @emph{Description}
  1921. This function returns a value indicating the number of devices available
  1922. for the device type specified in @var{devicetype}.
  1923. @item @emph{C/C++}:
  1924. @multitable @columnfractions .20 .80
  1925. @item @emph{Prototype}: @tab @code{int acc_get_num_devices(acc_device_t devicetype);}
  1926. @end multitable
  1927. @item @emph{Fortran}:
  1928. @multitable @columnfractions .20 .80
  1929. @item @emph{Interface}: @tab @code{integer function acc_get_num_devices(devicetype)}
  1930. @item @tab @code{integer(kind=acc_device_kind) devicetype}
  1931. @end multitable
  1932. @item @emph{Reference}:
  1933. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  1934. 3.2.1.
  1935. @end table
  1936. @node acc_set_device_type
  1937. @section @code{acc_set_device_type} -- Set type of device accelerator to use.
  1938. @table @asis
  1939. @item @emph{Description}
  1940. This function indicates to the runtime library which device type, specified
  1941. in @var{devicetype}, to use when executing a parallel or kernels region.
  1942. @item @emph{C/C++}:
  1943. @multitable @columnfractions .20 .80
  1944. @item @emph{Prototype}: @tab @code{acc_set_device_type(acc_device_t devicetype);}
  1945. @end multitable
  1946. @item @emph{Fortran}:
  1947. @multitable @columnfractions .20 .80
  1948. @item @emph{Interface}: @tab @code{subroutine acc_set_device_type(devicetype)}
  1949. @item @tab @code{integer(kind=acc_device_kind) devicetype}
  1950. @end multitable
  1951. @item @emph{Reference}:
  1952. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  1953. 3.2.2.
  1954. @end table
  1955. @node acc_get_device_type
  1956. @section @code{acc_get_device_type} -- Get type of device accelerator to be used.
  1957. @table @asis
  1958. @item @emph{Description}
  1959. This function returns what device type will be used when executing a
  1960. parallel or kernels region.
  1961. This function returns @code{acc_device_none} if
  1962. @code{acc_get_device_type} is called from
  1963. @code{acc_ev_device_init_start}, @code{acc_ev_device_init_end}
  1964. callbacks of the OpenACC Profiling Interface (@ref{OpenACC Profiling
  1965. Interface}), that is, if the device is currently being initialized.
  1966. @item @emph{C/C++}:
  1967. @multitable @columnfractions .20 .80
  1968. @item @emph{Prototype}: @tab @code{acc_device_t acc_get_device_type(void);}
  1969. @end multitable
  1970. @item @emph{Fortran}:
  1971. @multitable @columnfractions .20 .80
  1972. @item @emph{Interface}: @tab @code{function acc_get_device_type(void)}
  1973. @item @tab @code{integer(kind=acc_device_kind) acc_get_device_type}
  1974. @end multitable
  1975. @item @emph{Reference}:
  1976. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  1977. 3.2.3.
  1978. @end table
  1979. @node acc_set_device_num
  1980. @section @code{acc_set_device_num} -- Set device number to use.
  1981. @table @asis
  1982. @item @emph{Description}
  1983. This function will indicate to the runtime which device number,
  1984. specified by @var{devicenum}, associated with the specified device
  1985. type @var{devicetype}.
  1986. @item @emph{C/C++}:
  1987. @multitable @columnfractions .20 .80
  1988. @item @emph{Prototype}: @tab @code{acc_set_device_num(int devicenum, acc_device_t devicetype);}
  1989. @end multitable
  1990. @item @emph{Fortran}:
  1991. @multitable @columnfractions .20 .80
  1992. @item @emph{Interface}: @tab @code{subroutine acc_set_device_num(devicenum, devicetype)}
  1993. @item @tab @code{integer devicenum}
  1994. @item @tab @code{integer(kind=acc_device_kind) devicetype}
  1995. @end multitable
  1996. @item @emph{Reference}:
  1997. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  1998. 3.2.4.
  1999. @end table
  2000. @node acc_get_device_num
  2001. @section @code{acc_get_device_num} -- Get device number to be used.
  2002. @table @asis
  2003. @item @emph{Description}
  2004. This function returns which device number associated with the specified device
  2005. type @var{devicetype}, will be used when executing a parallel or kernels
  2006. region.
  2007. @item @emph{C/C++}:
  2008. @multitable @columnfractions .20 .80
  2009. @item @emph{Prototype}: @tab @code{int acc_get_device_num(acc_device_t devicetype);}
  2010. @end multitable
  2011. @item @emph{Fortran}:
  2012. @multitable @columnfractions .20 .80
  2013. @item @emph{Interface}: @tab @code{function acc_get_device_num(devicetype)}
  2014. @item @tab @code{integer(kind=acc_device_kind) devicetype}
  2015. @item @tab @code{integer acc_get_device_num}
  2016. @end multitable
  2017. @item @emph{Reference}:
  2018. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2019. 3.2.5.
  2020. @end table
  2021. @node acc_get_property
  2022. @section @code{acc_get_property} -- Get device property.
  2023. @cindex acc_get_property
  2024. @cindex acc_get_property_string
  2025. @table @asis
  2026. @item @emph{Description}
  2027. These routines return the value of the specified @var{property} for the
  2028. device being queried according to @var{devicenum} and @var{devicetype}.
  2029. Integer-valued and string-valued properties are returned by
  2030. @code{acc_get_property} and @code{acc_get_property_string} respectively.
  2031. The Fortran @code{acc_get_property_string} subroutine returns the string
  2032. retrieved in its fourth argument while the remaining entry points are
  2033. functions, which pass the return value as their result.
  2034. Note for Fortran, only: the OpenACC technical committee corrected and, hence,
  2035. modified the interface introduced in OpenACC 2.6. The kind-value parameter
  2036. @code{acc_device_property} has been renamed to @code{acc_device_property_kind}
  2037. for consistency and the return type of the @code{acc_get_property} function is
  2038. now a @code{c_size_t} integer instead of a @code{acc_device_property} integer.
  2039. The parameter @code{acc_device_property} will continue to be provided,
  2040. but might be removed in a future version of GCC.
  2041. @item @emph{C/C++}:
  2042. @multitable @columnfractions .20 .80
  2043. @item @emph{Prototype}: @tab @code{size_t acc_get_property(int devicenum, acc_device_t devicetype, acc_device_property_t property);}
  2044. @item @emph{Prototype}: @tab @code{const char *acc_get_property_string(int devicenum, acc_device_t devicetype, acc_device_property_t property);}
  2045. @end multitable
  2046. @item @emph{Fortran}:
  2047. @multitable @columnfractions .20 .80
  2048. @item @emph{Interface}: @tab @code{function acc_get_property(devicenum, devicetype, property)}
  2049. @item @emph{Interface}: @tab @code{subroutine acc_get_property_string(devicenum, devicetype, property, string)}
  2050. @item @tab @code{use ISO_C_Binding, only: c_size_t}
  2051. @item @tab @code{integer devicenum}
  2052. @item @tab @code{integer(kind=acc_device_kind) devicetype}
  2053. @item @tab @code{integer(kind=acc_device_property_kind) property}
  2054. @item @tab @code{integer(kind=c_size_t) acc_get_property}
  2055. @item @tab @code{character(*) string}
  2056. @end multitable
  2057. @item @emph{Reference}:
  2058. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2059. 3.2.6.
  2060. @end table
  2061. @node acc_async_test
  2062. @section @code{acc_async_test} -- Test for completion of a specific asynchronous operation.
  2063. @table @asis
  2064. @item @emph{Description}
  2065. This function tests for completion of the asynchronous operation specified
  2066. in @var{arg}. In C/C++, a non-zero value will be returned to indicate
  2067. the specified asynchronous operation has completed. While Fortran will return
  2068. a @code{true}. If the asynchronous operation has not completed, C/C++ returns
  2069. a zero and Fortran returns a @code{false}.
  2070. @item @emph{C/C++}:
  2071. @multitable @columnfractions .20 .80
  2072. @item @emph{Prototype}: @tab @code{int acc_async_test(int arg);}
  2073. @end multitable
  2074. @item @emph{Fortran}:
  2075. @multitable @columnfractions .20 .80
  2076. @item @emph{Interface}: @tab @code{function acc_async_test(arg)}
  2077. @item @tab @code{integer(kind=acc_handle_kind) arg}
  2078. @item @tab @code{logical acc_async_test}
  2079. @end multitable
  2080. @item @emph{Reference}:
  2081. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2082. 3.2.9.
  2083. @end table
  2084. @node acc_async_test_all
  2085. @section @code{acc_async_test_all} -- Tests for completion of all asynchronous operations.
  2086. @table @asis
  2087. @item @emph{Description}
  2088. This function tests for completion of all asynchronous operations.
  2089. In C/C++, a non-zero value will be returned to indicate all asynchronous
  2090. operations have completed. While Fortran will return a @code{true}. If
  2091. any asynchronous operation has not completed, C/C++ returns a zero and
  2092. Fortran returns a @code{false}.
  2093. @item @emph{C/C++}:
  2094. @multitable @columnfractions .20 .80
  2095. @item @emph{Prototype}: @tab @code{int acc_async_test_all(void);}
  2096. @end multitable
  2097. @item @emph{Fortran}:
  2098. @multitable @columnfractions .20 .80
  2099. @item @emph{Interface}: @tab @code{function acc_async_test()}
  2100. @item @tab @code{logical acc_get_device_num}
  2101. @end multitable
  2102. @item @emph{Reference}:
  2103. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2104. 3.2.10.
  2105. @end table
  2106. @node acc_wait
  2107. @section @code{acc_wait} -- Wait for completion of a specific asynchronous operation.
  2108. @table @asis
  2109. @item @emph{Description}
  2110. This function waits for completion of the asynchronous operation
  2111. specified in @var{arg}.
  2112. @item @emph{C/C++}:
  2113. @multitable @columnfractions .20 .80
  2114. @item @emph{Prototype}: @tab @code{acc_wait(arg);}
  2115. @item @emph{Prototype (OpenACC 1.0 compatibility)}: @tab @code{acc_async_wait(arg);}
  2116. @end multitable
  2117. @item @emph{Fortran}:
  2118. @multitable @columnfractions .20 .80
  2119. @item @emph{Interface}: @tab @code{subroutine acc_wait(arg)}
  2120. @item @tab @code{integer(acc_handle_kind) arg}
  2121. @item @emph{Interface (OpenACC 1.0 compatibility)}: @tab @code{subroutine acc_async_wait(arg)}
  2122. @item @tab @code{integer(acc_handle_kind) arg}
  2123. @end multitable
  2124. @item @emph{Reference}:
  2125. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2126. 3.2.11.
  2127. @end table
  2128. @node acc_wait_all
  2129. @section @code{acc_wait_all} -- Waits for completion of all asynchronous operations.
  2130. @table @asis
  2131. @item @emph{Description}
  2132. This function waits for the completion of all asynchronous operations.
  2133. @item @emph{C/C++}:
  2134. @multitable @columnfractions .20 .80
  2135. @item @emph{Prototype}: @tab @code{acc_wait_all(void);}
  2136. @item @emph{Prototype (OpenACC 1.0 compatibility)}: @tab @code{acc_async_wait_all(void);}
  2137. @end multitable
  2138. @item @emph{Fortran}:
  2139. @multitable @columnfractions .20 .80
  2140. @item @emph{Interface}: @tab @code{subroutine acc_wait_all()}
  2141. @item @emph{Interface (OpenACC 1.0 compatibility)}: @tab @code{subroutine acc_async_wait_all()}
  2142. @end multitable
  2143. @item @emph{Reference}:
  2144. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2145. 3.2.13.
  2146. @end table
  2147. @node acc_wait_all_async
  2148. @section @code{acc_wait_all_async} -- Wait for completion of all asynchronous operations.
  2149. @table @asis
  2150. @item @emph{Description}
  2151. This function enqueues a wait operation on the queue @var{async} for any
  2152. and all asynchronous operations that have been previously enqueued on
  2153. any queue.
  2154. @item @emph{C/C++}:
  2155. @multitable @columnfractions .20 .80
  2156. @item @emph{Prototype}: @tab @code{acc_wait_all_async(int async);}
  2157. @end multitable
  2158. @item @emph{Fortran}:
  2159. @multitable @columnfractions .20 .80
  2160. @item @emph{Interface}: @tab @code{subroutine acc_wait_all_async(async)}
  2161. @item @tab @code{integer(acc_handle_kind) async}
  2162. @end multitable
  2163. @item @emph{Reference}:
  2164. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2165. 3.2.14.
  2166. @end table
  2167. @node acc_wait_async
  2168. @section @code{acc_wait_async} -- Wait for completion of asynchronous operations.
  2169. @table @asis
  2170. @item @emph{Description}
  2171. This function enqueues a wait operation on queue @var{async} for any and all
  2172. asynchronous operations enqueued on queue @var{arg}.
  2173. @item @emph{C/C++}:
  2174. @multitable @columnfractions .20 .80
  2175. @item @emph{Prototype}: @tab @code{acc_wait_async(int arg, int async);}
  2176. @end multitable
  2177. @item @emph{Fortran}:
  2178. @multitable @columnfractions .20 .80
  2179. @item @emph{Interface}: @tab @code{subroutine acc_wait_async(arg, async)}
  2180. @item @tab @code{integer(acc_handle_kind) arg, async}
  2181. @end multitable
  2182. @item @emph{Reference}:
  2183. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2184. 3.2.12.
  2185. @end table
  2186. @node acc_init
  2187. @section @code{acc_init} -- Initialize runtime for a specific device type.
  2188. @table @asis
  2189. @item @emph{Description}
  2190. This function initializes the runtime for the device type specified in
  2191. @var{devicetype}.
  2192. @item @emph{C/C++}:
  2193. @multitable @columnfractions .20 .80
  2194. @item @emph{Prototype}: @tab @code{acc_init(acc_device_t devicetype);}
  2195. @end multitable
  2196. @item @emph{Fortran}:
  2197. @multitable @columnfractions .20 .80
  2198. @item @emph{Interface}: @tab @code{subroutine acc_init(devicetype)}
  2199. @item @tab @code{integer(acc_device_kind) devicetype}
  2200. @end multitable
  2201. @item @emph{Reference}:
  2202. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2203. 3.2.7.
  2204. @end table
  2205. @node acc_shutdown
  2206. @section @code{acc_shutdown} -- Shuts down the runtime for a specific device type.
  2207. @table @asis
  2208. @item @emph{Description}
  2209. This function shuts down the runtime for the device type specified in
  2210. @var{devicetype}.
  2211. @item @emph{C/C++}:
  2212. @multitable @columnfractions .20 .80
  2213. @item @emph{Prototype}: @tab @code{acc_shutdown(acc_device_t devicetype);}
  2214. @end multitable
  2215. @item @emph{Fortran}:
  2216. @multitable @columnfractions .20 .80
  2217. @item @emph{Interface}: @tab @code{subroutine acc_shutdown(devicetype)}
  2218. @item @tab @code{integer(acc_device_kind) devicetype}
  2219. @end multitable
  2220. @item @emph{Reference}:
  2221. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2222. 3.2.8.
  2223. @end table
  2224. @node acc_on_device
  2225. @section @code{acc_on_device} -- Whether executing on a particular device
  2226. @table @asis
  2227. @item @emph{Description}:
  2228. This function returns whether the program is executing on a particular
  2229. device specified in @var{devicetype}. In C/C++ a non-zero value is
  2230. returned to indicate the device is executing on the specified device type.
  2231. In Fortran, @code{true} will be returned. If the program is not executing
  2232. on the specified device type C/C++ will return a zero, while Fortran will
  2233. return @code{false}.
  2234. @item @emph{C/C++}:
  2235. @multitable @columnfractions .20 .80
  2236. @item @emph{Prototype}: @tab @code{acc_on_device(acc_device_t devicetype);}
  2237. @end multitable
  2238. @item @emph{Fortran}:
  2239. @multitable @columnfractions .20 .80
  2240. @item @emph{Interface}: @tab @code{function acc_on_device(devicetype)}
  2241. @item @tab @code{integer(acc_device_kind) devicetype}
  2242. @item @tab @code{logical acc_on_device}
  2243. @end multitable
  2244. @item @emph{Reference}:
  2245. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2246. 3.2.17.
  2247. @end table
  2248. @node acc_malloc
  2249. @section @code{acc_malloc} -- Allocate device memory.
  2250. @table @asis
  2251. @item @emph{Description}
  2252. This function allocates @var{len} bytes of device memory. It returns
  2253. the device address of the allocated memory.
  2254. @item @emph{C/C++}:
  2255. @multitable @columnfractions .20 .80
  2256. @item @emph{Prototype}: @tab @code{d_void* acc_malloc(size_t len);}
  2257. @end multitable
  2258. @item @emph{Reference}:
  2259. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2260. 3.2.18.
  2261. @end table
  2262. @node acc_free
  2263. @section @code{acc_free} -- Free device memory.
  2264. @table @asis
  2265. @item @emph{Description}
  2266. Free previously allocated device memory at the device address @code{a}.
  2267. @item @emph{C/C++}:
  2268. @multitable @columnfractions .20 .80
  2269. @item @emph{Prototype}: @tab @code{acc_free(d_void *a);}
  2270. @end multitable
  2271. @item @emph{Reference}:
  2272. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2273. 3.2.19.
  2274. @end table
  2275. @node acc_copyin
  2276. @section @code{acc_copyin} -- Allocate device memory and copy host memory to it.
  2277. @table @asis
  2278. @item @emph{Description}
  2279. In C/C++, this function allocates @var{len} bytes of device memory
  2280. and maps it to the specified host address in @var{a}. The device
  2281. address of the newly allocated device memory is returned.
  2282. In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
  2283. a contiguous array section. The second form @var{a} specifies a
  2284. variable or array element and @var{len} specifies the length in bytes.
  2285. @item @emph{C/C++}:
  2286. @multitable @columnfractions .20 .80
  2287. @item @emph{Prototype}: @tab @code{void *acc_copyin(h_void *a, size_t len);}
  2288. @item @emph{Prototype}: @tab @code{void *acc_copyin_async(h_void *a, size_t len, int async);}
  2289. @end multitable
  2290. @item @emph{Fortran}:
  2291. @multitable @columnfractions .20 .80
  2292. @item @emph{Interface}: @tab @code{subroutine acc_copyin(a)}
  2293. @item @tab @code{type, dimension(:[,:]...) :: a}
  2294. @item @emph{Interface}: @tab @code{subroutine acc_copyin(a, len)}
  2295. @item @tab @code{type, dimension(:[,:]...) :: a}
  2296. @item @tab @code{integer len}
  2297. @item @emph{Interface}: @tab @code{subroutine acc_copyin_async(a, async)}
  2298. @item @tab @code{type, dimension(:[,:]...) :: a}
  2299. @item @tab @code{integer(acc_handle_kind) :: async}
  2300. @item @emph{Interface}: @tab @code{subroutine acc_copyin_async(a, len, async)}
  2301. @item @tab @code{type, dimension(:[,:]...) :: a}
  2302. @item @tab @code{integer len}
  2303. @item @tab @code{integer(acc_handle_kind) :: async}
  2304. @end multitable
  2305. @item @emph{Reference}:
  2306. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2307. 3.2.20.
  2308. @end table
  2309. @node acc_present_or_copyin
  2310. @section @code{acc_present_or_copyin} -- If the data is not present on the device, allocate device memory and copy from host memory.
  2311. @table @asis
  2312. @item @emph{Description}
  2313. This function tests if the host data specified by @var{a} and of length
  2314. @var{len} is present or not. If it is not present, then device memory
  2315. will be allocated and the host memory copied. The device address of
  2316. the newly allocated device memory is returned.
  2317. In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
  2318. a contiguous array section. The second form @var{a} specifies a variable or
  2319. array element and @var{len} specifies the length in bytes.
  2320. Note that @code{acc_present_or_copyin} and @code{acc_pcopyin} exist for
  2321. backward compatibility with OpenACC 2.0; use @ref{acc_copyin} instead.
  2322. @item @emph{C/C++}:
  2323. @multitable @columnfractions .20 .80
  2324. @item @emph{Prototype}: @tab @code{void *acc_present_or_copyin(h_void *a, size_t len);}
  2325. @item @emph{Prototype}: @tab @code{void *acc_pcopyin(h_void *a, size_t len);}
  2326. @end multitable
  2327. @item @emph{Fortran}:
  2328. @multitable @columnfractions .20 .80
  2329. @item @emph{Interface}: @tab @code{subroutine acc_present_or_copyin(a)}
  2330. @item @tab @code{type, dimension(:[,:]...) :: a}
  2331. @item @emph{Interface}: @tab @code{subroutine acc_present_or_copyin(a, len)}
  2332. @item @tab @code{type, dimension(:[,:]...) :: a}
  2333. @item @tab @code{integer len}
  2334. @item @emph{Interface}: @tab @code{subroutine acc_pcopyin(a)}
  2335. @item @tab @code{type, dimension(:[,:]...) :: a}
  2336. @item @emph{Interface}: @tab @code{subroutine acc_pcopyin(a, len)}
  2337. @item @tab @code{type, dimension(:[,:]...) :: a}
  2338. @item @tab @code{integer len}
  2339. @end multitable
  2340. @item @emph{Reference}:
  2341. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2342. 3.2.20.
  2343. @end table
  2344. @node acc_create
  2345. @section @code{acc_create} -- Allocate device memory and map it to host memory.
  2346. @table @asis
  2347. @item @emph{Description}
  2348. This function allocates device memory and maps it to host memory specified
  2349. by the host address @var{a} with a length of @var{len} bytes. In C/C++,
  2350. the function returns the device address of the allocated device memory.
  2351. In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
  2352. a contiguous array section. The second form @var{a} specifies a variable or
  2353. array element and @var{len} specifies the length in bytes.
  2354. @item @emph{C/C++}:
  2355. @multitable @columnfractions .20 .80
  2356. @item @emph{Prototype}: @tab @code{void *acc_create(h_void *a, size_t len);}
  2357. @item @emph{Prototype}: @tab @code{void *acc_create_async(h_void *a, size_t len, int async);}
  2358. @end multitable
  2359. @item @emph{Fortran}:
  2360. @multitable @columnfractions .20 .80
  2361. @item @emph{Interface}: @tab @code{subroutine acc_create(a)}
  2362. @item @tab @code{type, dimension(:[,:]...) :: a}
  2363. @item @emph{Interface}: @tab @code{subroutine acc_create(a, len)}
  2364. @item @tab @code{type, dimension(:[,:]...) :: a}
  2365. @item @tab @code{integer len}
  2366. @item @emph{Interface}: @tab @code{subroutine acc_create_async(a, async)}
  2367. @item @tab @code{type, dimension(:[,:]...) :: a}
  2368. @item @tab @code{integer(acc_handle_kind) :: async}
  2369. @item @emph{Interface}: @tab @code{subroutine acc_create_async(a, len, async)}
  2370. @item @tab @code{type, dimension(:[,:]...) :: a}
  2371. @item @tab @code{integer len}
  2372. @item @tab @code{integer(acc_handle_kind) :: async}
  2373. @end multitable
  2374. @item @emph{Reference}:
  2375. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2376. 3.2.21.
  2377. @end table
  2378. @node acc_present_or_create
  2379. @section @code{acc_present_or_create} -- If the data is not present on the device, allocate device memory and map it to host memory.
  2380. @table @asis
  2381. @item @emph{Description}
  2382. This function tests if the host data specified by @var{a} and of length
  2383. @var{len} is present or not. If it is not present, then device memory
  2384. will be allocated and mapped to host memory. In C/C++, the device address
  2385. of the newly allocated device memory is returned.
  2386. In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
  2387. a contiguous array section. The second form @var{a} specifies a variable or
  2388. array element and @var{len} specifies the length in bytes.
  2389. Note that @code{acc_present_or_create} and @code{acc_pcreate} exist for
  2390. backward compatibility with OpenACC 2.0; use @ref{acc_create} instead.
  2391. @item @emph{C/C++}:
  2392. @multitable @columnfractions .20 .80
  2393. @item @emph{Prototype}: @tab @code{void *acc_present_or_create(h_void *a, size_t len)}
  2394. @item @emph{Prototype}: @tab @code{void *acc_pcreate(h_void *a, size_t len)}
  2395. @end multitable
  2396. @item @emph{Fortran}:
  2397. @multitable @columnfractions .20 .80
  2398. @item @emph{Interface}: @tab @code{subroutine acc_present_or_create(a)}
  2399. @item @tab @code{type, dimension(:[,:]...) :: a}
  2400. @item @emph{Interface}: @tab @code{subroutine acc_present_or_create(a, len)}
  2401. @item @tab @code{type, dimension(:[,:]...) :: a}
  2402. @item @tab @code{integer len}
  2403. @item @emph{Interface}: @tab @code{subroutine acc_pcreate(a)}
  2404. @item @tab @code{type, dimension(:[,:]...) :: a}
  2405. @item @emph{Interface}: @tab @code{subroutine acc_pcreate(a, len)}
  2406. @item @tab @code{type, dimension(:[,:]...) :: a}
  2407. @item @tab @code{integer len}
  2408. @end multitable
  2409. @item @emph{Reference}:
  2410. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2411. 3.2.21.
  2412. @end table
  2413. @node acc_copyout
  2414. @section @code{acc_copyout} -- Copy device memory to host memory.
  2415. @table @asis
  2416. @item @emph{Description}
  2417. This function copies mapped device memory to host memory which is specified
  2418. by host address @var{a} for a length @var{len} bytes in C/C++.
  2419. In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
  2420. a contiguous array section. The second form @var{a} specifies a variable or
  2421. array element and @var{len} specifies the length in bytes.
  2422. @item @emph{C/C++}:
  2423. @multitable @columnfractions .20 .80
  2424. @item @emph{Prototype}: @tab @code{acc_copyout(h_void *a, size_t len);}
  2425. @item @emph{Prototype}: @tab @code{acc_copyout_async(h_void *a, size_t len, int async);}
  2426. @item @emph{Prototype}: @tab @code{acc_copyout_finalize(h_void *a, size_t len);}
  2427. @item @emph{Prototype}: @tab @code{acc_copyout_finalize_async(h_void *a, size_t len, int async);}
  2428. @end multitable
  2429. @item @emph{Fortran}:
  2430. @multitable @columnfractions .20 .80
  2431. @item @emph{Interface}: @tab @code{subroutine acc_copyout(a)}
  2432. @item @tab @code{type, dimension(:[,:]...) :: a}
  2433. @item @emph{Interface}: @tab @code{subroutine acc_copyout(a, len)}
  2434. @item @tab @code{type, dimension(:[,:]...) :: a}
  2435. @item @tab @code{integer len}
  2436. @item @emph{Interface}: @tab @code{subroutine acc_copyout_async(a, async)}
  2437. @item @tab @code{type, dimension(:[,:]...) :: a}
  2438. @item @tab @code{integer(acc_handle_kind) :: async}
  2439. @item @emph{Interface}: @tab @code{subroutine acc_copyout_async(a, len, async)}
  2440. @item @tab @code{type, dimension(:[,:]...) :: a}
  2441. @item @tab @code{integer len}
  2442. @item @tab @code{integer(acc_handle_kind) :: async}
  2443. @item @emph{Interface}: @tab @code{subroutine acc_copyout_finalize(a)}
  2444. @item @tab @code{type, dimension(:[,:]...) :: a}
  2445. @item @emph{Interface}: @tab @code{subroutine acc_copyout_finalize(a, len)}
  2446. @item @tab @code{type, dimension(:[,:]...) :: a}
  2447. @item @tab @code{integer len}
  2448. @item @emph{Interface}: @tab @code{subroutine acc_copyout_finalize_async(a, async)}
  2449. @item @tab @code{type, dimension(:[,:]...) :: a}
  2450. @item @tab @code{integer(acc_handle_kind) :: async}
  2451. @item @emph{Interface}: @tab @code{subroutine acc_copyout_finalize_async(a, len, async)}
  2452. @item @tab @code{type, dimension(:[,:]...) :: a}
  2453. @item @tab @code{integer len}
  2454. @item @tab @code{integer(acc_handle_kind) :: async}
  2455. @end multitable
  2456. @item @emph{Reference}:
  2457. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2458. 3.2.22.
  2459. @end table
  2460. @node acc_delete
  2461. @section @code{acc_delete} -- Free device memory.
  2462. @table @asis
  2463. @item @emph{Description}
  2464. This function frees previously allocated device memory specified by
  2465. the device address @var{a} and the length of @var{len} bytes.
  2466. In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
  2467. a contiguous array section. The second form @var{a} specifies a variable or
  2468. array element and @var{len} specifies the length in bytes.
  2469. @item @emph{C/C++}:
  2470. @multitable @columnfractions .20 .80
  2471. @item @emph{Prototype}: @tab @code{acc_delete(h_void *a, size_t len);}
  2472. @item @emph{Prototype}: @tab @code{acc_delete_async(h_void *a, size_t len, int async);}
  2473. @item @emph{Prototype}: @tab @code{acc_delete_finalize(h_void *a, size_t len);}
  2474. @item @emph{Prototype}: @tab @code{acc_delete_finalize_async(h_void *a, size_t len, int async);}
  2475. @end multitable
  2476. @item @emph{Fortran}:
  2477. @multitable @columnfractions .20 .80
  2478. @item @emph{Interface}: @tab @code{subroutine acc_delete(a)}
  2479. @item @tab @code{type, dimension(:[,:]...) :: a}
  2480. @item @emph{Interface}: @tab @code{subroutine acc_delete(a, len)}
  2481. @item @tab @code{type, dimension(:[,:]...) :: a}
  2482. @item @tab @code{integer len}
  2483. @item @emph{Interface}: @tab @code{subroutine acc_delete_async(a, async)}
  2484. @item @tab @code{type, dimension(:[,:]...) :: a}
  2485. @item @tab @code{integer(acc_handle_kind) :: async}
  2486. @item @emph{Interface}: @tab @code{subroutine acc_delete_async(a, len, async)}
  2487. @item @tab @code{type, dimension(:[,:]...) :: a}
  2488. @item @tab @code{integer len}
  2489. @item @tab @code{integer(acc_handle_kind) :: async}
  2490. @item @emph{Interface}: @tab @code{subroutine acc_delete_finalize(a)}
  2491. @item @tab @code{type, dimension(:[,:]...) :: a}
  2492. @item @emph{Interface}: @tab @code{subroutine acc_delete_finalize(a, len)}
  2493. @item @tab @code{type, dimension(:[,:]...) :: a}
  2494. @item @tab @code{integer len}
  2495. @item @emph{Interface}: @tab @code{subroutine acc_delete_async_finalize(a, async)}
  2496. @item @tab @code{type, dimension(:[,:]...) :: a}
  2497. @item @tab @code{integer(acc_handle_kind) :: async}
  2498. @item @emph{Interface}: @tab @code{subroutine acc_delete_async_finalize(a, len, async)}
  2499. @item @tab @code{type, dimension(:[,:]...) :: a}
  2500. @item @tab @code{integer len}
  2501. @item @tab @code{integer(acc_handle_kind) :: async}
  2502. @end multitable
  2503. @item @emph{Reference}:
  2504. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2505. 3.2.23.
  2506. @end table
  2507. @node acc_update_device
  2508. @section @code{acc_update_device} -- Update device memory from mapped host memory.
  2509. @table @asis
  2510. @item @emph{Description}
  2511. This function updates the device copy from the previously mapped host memory.
  2512. The host memory is specified with the host address @var{a} and a length of
  2513. @var{len} bytes.
  2514. In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
  2515. a contiguous array section. The second form @var{a} specifies a variable or
  2516. array element and @var{len} specifies the length in bytes.
  2517. @item @emph{C/C++}:
  2518. @multitable @columnfractions .20 .80
  2519. @item @emph{Prototype}: @tab @code{acc_update_device(h_void *a, size_t len);}
  2520. @item @emph{Prototype}: @tab @code{acc_update_device(h_void *a, size_t len, async);}
  2521. @end multitable
  2522. @item @emph{Fortran}:
  2523. @multitable @columnfractions .20 .80
  2524. @item @emph{Interface}: @tab @code{subroutine acc_update_device(a)}
  2525. @item @tab @code{type, dimension(:[,:]...) :: a}
  2526. @item @emph{Interface}: @tab @code{subroutine acc_update_device(a, len)}
  2527. @item @tab @code{type, dimension(:[,:]...) :: a}
  2528. @item @tab @code{integer len}
  2529. @item @emph{Interface}: @tab @code{subroutine acc_update_device_async(a, async)}
  2530. @item @tab @code{type, dimension(:[,:]...) :: a}
  2531. @item @tab @code{integer(acc_handle_kind) :: async}
  2532. @item @emph{Interface}: @tab @code{subroutine acc_update_device_async(a, len, async)}
  2533. @item @tab @code{type, dimension(:[,:]...) :: a}
  2534. @item @tab @code{integer len}
  2535. @item @tab @code{integer(acc_handle_kind) :: async}
  2536. @end multitable
  2537. @item @emph{Reference}:
  2538. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2539. 3.2.24.
  2540. @end table
  2541. @node acc_update_self
  2542. @section @code{acc_update_self} -- Update host memory from mapped device memory.
  2543. @table @asis
  2544. @item @emph{Description}
  2545. This function updates the host copy from the previously mapped device memory.
  2546. The host memory is specified with the host address @var{a} and a length of
  2547. @var{len} bytes.
  2548. In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
  2549. a contiguous array section. The second form @var{a} specifies a variable or
  2550. array element and @var{len} specifies the length in bytes.
  2551. @item @emph{C/C++}:
  2552. @multitable @columnfractions .20 .80
  2553. @item @emph{Prototype}: @tab @code{acc_update_self(h_void *a, size_t len);}
  2554. @item @emph{Prototype}: @tab @code{acc_update_self_async(h_void *a, size_t len, int async);}
  2555. @end multitable
  2556. @item @emph{Fortran}:
  2557. @multitable @columnfractions .20 .80
  2558. @item @emph{Interface}: @tab @code{subroutine acc_update_self(a)}
  2559. @item @tab @code{type, dimension(:[,:]...) :: a}
  2560. @item @emph{Interface}: @tab @code{subroutine acc_update_self(a, len)}
  2561. @item @tab @code{type, dimension(:[,:]...) :: a}
  2562. @item @tab @code{integer len}
  2563. @item @emph{Interface}: @tab @code{subroutine acc_update_self_async(a, async)}
  2564. @item @tab @code{type, dimension(:[,:]...) :: a}
  2565. @item @tab @code{integer(acc_handle_kind) :: async}
  2566. @item @emph{Interface}: @tab @code{subroutine acc_update_self_async(a, len, async)}
  2567. @item @tab @code{type, dimension(:[,:]...) :: a}
  2568. @item @tab @code{integer len}
  2569. @item @tab @code{integer(acc_handle_kind) :: async}
  2570. @end multitable
  2571. @item @emph{Reference}:
  2572. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2573. 3.2.25.
  2574. @end table
  2575. @node acc_map_data
  2576. @section @code{acc_map_data} -- Map previously allocated device memory to host memory.
  2577. @table @asis
  2578. @item @emph{Description}
  2579. This function maps previously allocated device and host memory. The device
  2580. memory is specified with the device address @var{d}. The host memory is
  2581. specified with the host address @var{h} and a length of @var{len}.
  2582. @item @emph{C/C++}:
  2583. @multitable @columnfractions .20 .80
  2584. @item @emph{Prototype}: @tab @code{acc_map_data(h_void *h, d_void *d, size_t len);}
  2585. @end multitable
  2586. @item @emph{Reference}:
  2587. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2588. 3.2.26.
  2589. @end table
  2590. @node acc_unmap_data
  2591. @section @code{acc_unmap_data} -- Unmap device memory from host memory.
  2592. @table @asis
  2593. @item @emph{Description}
  2594. This function unmaps previously mapped device and host memory. The latter
  2595. specified by @var{h}.
  2596. @item @emph{C/C++}:
  2597. @multitable @columnfractions .20 .80
  2598. @item @emph{Prototype}: @tab @code{acc_unmap_data(h_void *h);}
  2599. @end multitable
  2600. @item @emph{Reference}:
  2601. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2602. 3.2.27.
  2603. @end table
  2604. @node acc_deviceptr
  2605. @section @code{acc_deviceptr} -- Get device pointer associated with specific host address.
  2606. @table @asis
  2607. @item @emph{Description}
  2608. This function returns the device address that has been mapped to the
  2609. host address specified by @var{h}.
  2610. @item @emph{C/C++}:
  2611. @multitable @columnfractions .20 .80
  2612. @item @emph{Prototype}: @tab @code{void *acc_deviceptr(h_void *h);}
  2613. @end multitable
  2614. @item @emph{Reference}:
  2615. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2616. 3.2.28.
  2617. @end table
  2618. @node acc_hostptr
  2619. @section @code{acc_hostptr} -- Get host pointer associated with specific device address.
  2620. @table @asis
  2621. @item @emph{Description}
  2622. This function returns the host address that has been mapped to the
  2623. device address specified by @var{d}.
  2624. @item @emph{C/C++}:
  2625. @multitable @columnfractions .20 .80
  2626. @item @emph{Prototype}: @tab @code{void *acc_hostptr(d_void *d);}
  2627. @end multitable
  2628. @item @emph{Reference}:
  2629. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2630. 3.2.29.
  2631. @end table
  2632. @node acc_is_present
  2633. @section @code{acc_is_present} -- Indicate whether host variable / array is present on device.
  2634. @table @asis
  2635. @item @emph{Description}
  2636. This function indicates whether the specified host address in @var{a} and a
  2637. length of @var{len} bytes is present on the device. In C/C++, a non-zero
  2638. value is returned to indicate the presence of the mapped memory on the
  2639. device. A zero is returned to indicate the memory is not mapped on the
  2640. device.
  2641. In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
  2642. a contiguous array section. The second form @var{a} specifies a variable or
  2643. array element and @var{len} specifies the length in bytes. If the host
  2644. memory is mapped to device memory, then a @code{true} is returned. Otherwise,
  2645. a @code{false} is return to indicate the mapped memory is not present.
  2646. @item @emph{C/C++}:
  2647. @multitable @columnfractions .20 .80
  2648. @item @emph{Prototype}: @tab @code{int acc_is_present(h_void *a, size_t len);}
  2649. @end multitable
  2650. @item @emph{Fortran}:
  2651. @multitable @columnfractions .20 .80
  2652. @item @emph{Interface}: @tab @code{function acc_is_present(a)}
  2653. @item @tab @code{type, dimension(:[,:]...) :: a}
  2654. @item @tab @code{logical acc_is_present}
  2655. @item @emph{Interface}: @tab @code{function acc_is_present(a, len)}
  2656. @item @tab @code{type, dimension(:[,:]...) :: a}
  2657. @item @tab @code{integer len}
  2658. @item @tab @code{logical acc_is_present}
  2659. @end multitable
  2660. @item @emph{Reference}:
  2661. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2662. 3.2.30.
  2663. @end table
  2664. @node acc_memcpy_to_device
  2665. @section @code{acc_memcpy_to_device} -- Copy host memory to device memory.
  2666. @table @asis
  2667. @item @emph{Description}
  2668. This function copies host memory specified by host address of @var{src} to
  2669. device memory specified by the device address @var{dest} for a length of
  2670. @var{bytes} bytes.
  2671. @item @emph{C/C++}:
  2672. @multitable @columnfractions .20 .80
  2673. @item @emph{Prototype}: @tab @code{acc_memcpy_to_device(d_void *dest, h_void *src, size_t bytes);}
  2674. @end multitable
  2675. @item @emph{Reference}:
  2676. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2677. 3.2.31.
  2678. @end table
  2679. @node acc_memcpy_from_device
  2680. @section @code{acc_memcpy_from_device} -- Copy device memory to host memory.
  2681. @table @asis
  2682. @item @emph{Description}
  2683. This function copies host memory specified by host address of @var{src} from
  2684. device memory specified by the device address @var{dest} for a length of
  2685. @var{bytes} bytes.
  2686. @item @emph{C/C++}:
  2687. @multitable @columnfractions .20 .80
  2688. @item @emph{Prototype}: @tab @code{acc_memcpy_from_device(d_void *dest, h_void *src, size_t bytes);}
  2689. @end multitable
  2690. @item @emph{Reference}:
  2691. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2692. 3.2.32.
  2693. @end table
  2694. @node acc_attach
  2695. @section @code{acc_attach} -- Let device pointer point to device-pointer target.
  2696. @table @asis
  2697. @item @emph{Description}
  2698. This function updates a pointer on the device from pointing to a host-pointer
  2699. address to pointing to the corresponding device data.
  2700. @item @emph{C/C++}:
  2701. @multitable @columnfractions .20 .80
  2702. @item @emph{Prototype}: @tab @code{acc_attach(h_void **ptr);}
  2703. @item @emph{Prototype}: @tab @code{acc_attach_async(h_void **ptr, int async);}
  2704. @end multitable
  2705. @item @emph{Reference}:
  2706. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2707. 3.2.34.
  2708. @end table
  2709. @node acc_detach
  2710. @section @code{acc_detach} -- Let device pointer point to host-pointer target.
  2711. @table @asis
  2712. @item @emph{Description}
  2713. This function updates a pointer on the device from pointing to a device-pointer
  2714. address to pointing to the corresponding host data.
  2715. @item @emph{C/C++}:
  2716. @multitable @columnfractions .20 .80
  2717. @item @emph{Prototype}: @tab @code{acc_detach(h_void **ptr);}
  2718. @item @emph{Prototype}: @tab @code{acc_detach_async(h_void **ptr, int async);}
  2719. @item @emph{Prototype}: @tab @code{acc_detach_finalize(h_void **ptr);}
  2720. @item @emph{Prototype}: @tab @code{acc_detach_finalize_async(h_void **ptr, int async);}
  2721. @end multitable
  2722. @item @emph{Reference}:
  2723. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2724. 3.2.35.
  2725. @end table
  2726. @node acc_get_current_cuda_device
  2727. @section @code{acc_get_current_cuda_device} -- Get CUDA device handle.
  2728. @table @asis
  2729. @item @emph{Description}
  2730. This function returns the CUDA device handle. This handle is the same
  2731. as used by the CUDA Runtime or Driver API's.
  2732. @item @emph{C/C++}:
  2733. @multitable @columnfractions .20 .80
  2734. @item @emph{Prototype}: @tab @code{void *acc_get_current_cuda_device(void);}
  2735. @end multitable
  2736. @item @emph{Reference}:
  2737. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2738. A.2.1.1.
  2739. @end table
  2740. @node acc_get_current_cuda_context
  2741. @section @code{acc_get_current_cuda_context} -- Get CUDA context handle.
  2742. @table @asis
  2743. @item @emph{Description}
  2744. This function returns the CUDA context handle. This handle is the same
  2745. as used by the CUDA Runtime or Driver API's.
  2746. @item @emph{C/C++}:
  2747. @multitable @columnfractions .20 .80
  2748. @item @emph{Prototype}: @tab @code{void *acc_get_current_cuda_context(void);}
  2749. @end multitable
  2750. @item @emph{Reference}:
  2751. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2752. A.2.1.2.
  2753. @end table
  2754. @node acc_get_cuda_stream
  2755. @section @code{acc_get_cuda_stream} -- Get CUDA stream handle.
  2756. @table @asis
  2757. @item @emph{Description}
  2758. This function returns the CUDA stream handle for the queue @var{async}.
  2759. This handle is the same as used by the CUDA Runtime or Driver API's.
  2760. @item @emph{C/C++}:
  2761. @multitable @columnfractions .20 .80
  2762. @item @emph{Prototype}: @tab @code{void *acc_get_cuda_stream(int async);}
  2763. @end multitable
  2764. @item @emph{Reference}:
  2765. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2766. A.2.1.3.
  2767. @end table
  2768. @node acc_set_cuda_stream
  2769. @section @code{acc_set_cuda_stream} -- Set CUDA stream handle.
  2770. @table @asis
  2771. @item @emph{Description}
  2772. This function associates the stream handle specified by @var{stream} with
  2773. the queue @var{async}.
  2774. This cannot be used to change the stream handle associated with
  2775. @code{acc_async_sync}.
  2776. The return value is not specified.
  2777. @item @emph{C/C++}:
  2778. @multitable @columnfractions .20 .80
  2779. @item @emph{Prototype}: @tab @code{int acc_set_cuda_stream(int async, void *stream);}
  2780. @end multitable
  2781. @item @emph{Reference}:
  2782. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2783. A.2.1.4.
  2784. @end table
  2785. @node acc_prof_register
  2786. @section @code{acc_prof_register} -- Register callbacks.
  2787. @table @asis
  2788. @item @emph{Description}:
  2789. This function registers callbacks.
  2790. @item @emph{C/C++}:
  2791. @multitable @columnfractions .20 .80
  2792. @item @emph{Prototype}: @tab @code{void acc_prof_register (acc_event_t, acc_prof_callback, acc_register_t);}
  2793. @end multitable
  2794. @item @emph{See also}:
  2795. @ref{OpenACC Profiling Interface}
  2796. @item @emph{Reference}:
  2797. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2798. 5.3.
  2799. @end table
  2800. @node acc_prof_unregister
  2801. @section @code{acc_prof_unregister} -- Unregister callbacks.
  2802. @table @asis
  2803. @item @emph{Description}:
  2804. This function unregisters callbacks.
  2805. @item @emph{C/C++}:
  2806. @multitable @columnfractions .20 .80
  2807. @item @emph{Prototype}: @tab @code{void acc_prof_unregister (acc_event_t, acc_prof_callback, acc_register_t);}
  2808. @end multitable
  2809. @item @emph{See also}:
  2810. @ref{OpenACC Profiling Interface}
  2811. @item @emph{Reference}:
  2812. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2813. 5.3.
  2814. @end table
  2815. @node acc_prof_lookup
  2816. @section @code{acc_prof_lookup} -- Obtain inquiry functions.
  2817. @table @asis
  2818. @item @emph{Description}:
  2819. Function to obtain inquiry functions.
  2820. @item @emph{C/C++}:
  2821. @multitable @columnfractions .20 .80
  2822. @item @emph{Prototype}: @tab @code{acc_query_fn acc_prof_lookup (const char *);}
  2823. @end multitable
  2824. @item @emph{See also}:
  2825. @ref{OpenACC Profiling Interface}
  2826. @item @emph{Reference}:
  2827. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2828. 5.3.
  2829. @end table
  2830. @node acc_register_library
  2831. @section @code{acc_register_library} -- Library registration.
  2832. @table @asis
  2833. @item @emph{Description}:
  2834. Function for library registration.
  2835. @item @emph{C/C++}:
  2836. @multitable @columnfractions .20 .80
  2837. @item @emph{Prototype}: @tab @code{void acc_register_library (acc_prof_reg, acc_prof_reg, acc_prof_lookup_func);}
  2838. @end multitable
  2839. @item @emph{See also}:
  2840. @ref{OpenACC Profiling Interface}, @ref{ACC_PROFLIB}
  2841. @item @emph{Reference}:
  2842. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2843. 5.3.
  2844. @end table
  2845. @c ---------------------------------------------------------------------
  2846. @c OpenACC Environment Variables
  2847. @c ---------------------------------------------------------------------
  2848. @node OpenACC Environment Variables
  2849. @chapter OpenACC Environment Variables
  2850. The variables @env{ACC_DEVICE_TYPE} and @env{ACC_DEVICE_NUM}
  2851. are defined by section 4 of the OpenACC specification in version 2.0.
  2852. The variable @env{ACC_PROFLIB}
  2853. is defined by section 4 of the OpenACC specification in version 2.6.
  2854. The variable @env{GCC_ACC_NOTIFY} is used for diagnostic purposes.
  2855. @menu
  2856. * ACC_DEVICE_TYPE::
  2857. * ACC_DEVICE_NUM::
  2858. * ACC_PROFLIB::
  2859. * GCC_ACC_NOTIFY::
  2860. @end menu
  2861. @node ACC_DEVICE_TYPE
  2862. @section @code{ACC_DEVICE_TYPE}
  2863. @table @asis
  2864. @item @emph{Reference}:
  2865. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2866. 4.1.
  2867. @end table
  2868. @node ACC_DEVICE_NUM
  2869. @section @code{ACC_DEVICE_NUM}
  2870. @table @asis
  2871. @item @emph{Reference}:
  2872. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2873. 4.2.
  2874. @end table
  2875. @node ACC_PROFLIB
  2876. @section @code{ACC_PROFLIB}
  2877. @table @asis
  2878. @item @emph{See also}:
  2879. @ref{acc_register_library}, @ref{OpenACC Profiling Interface}
  2880. @item @emph{Reference}:
  2881. @uref{https://www.openacc.org, OpenACC specification v2.6}, section
  2882. 4.3.
  2883. @end table
  2884. @node GCC_ACC_NOTIFY
  2885. @section @code{GCC_ACC_NOTIFY}
  2886. @table @asis
  2887. @item @emph{Description}:
  2888. Print debug information pertaining to the accelerator.
  2889. @end table
  2890. @c ---------------------------------------------------------------------
  2891. @c CUDA Streams Usage
  2892. @c ---------------------------------------------------------------------
  2893. @node CUDA Streams Usage
  2894. @chapter CUDA Streams Usage
  2895. This applies to the @code{nvptx} plugin only.
  2896. The library provides elements that perform asynchronous movement of
  2897. data and asynchronous operation of computing constructs. This
  2898. asynchronous functionality is implemented by making use of CUDA
  2899. streams@footnote{See "Stream Management" in "CUDA Driver API",
  2900. TRM-06703-001, Version 5.5, for additional information}.
  2901. The primary means by that the asynchronous functionality is accessed
  2902. is through the use of those OpenACC directives which make use of the
  2903. @code{async} and @code{wait} clauses. When the @code{async} clause is
  2904. first used with a directive, it creates a CUDA stream. If an
  2905. @code{async-argument} is used with the @code{async} clause, then the
  2906. stream is associated with the specified @code{async-argument}.
  2907. Following the creation of an association between a CUDA stream and the
  2908. @code{async-argument} of an @code{async} clause, both the @code{wait}
  2909. clause and the @code{wait} directive can be used. When either the
  2910. clause or directive is used after stream creation, it creates a
  2911. rendezvous point whereby execution waits until all operations
  2912. associated with the @code{async-argument}, that is, stream, have
  2913. completed.
  2914. Normally, the management of the streams that are created as a result of
  2915. using the @code{async} clause, is done without any intervention by the
  2916. caller. This implies the association between the @code{async-argument}
  2917. and the CUDA stream will be maintained for the lifetime of the program.
  2918. However, this association can be changed through the use of the library
  2919. function @code{acc_set_cuda_stream}. When the function
  2920. @code{acc_set_cuda_stream} is called, the CUDA stream that was
  2921. originally associated with the @code{async} clause will be destroyed.
  2922. Caution should be taken when changing the association as subsequent
  2923. references to the @code{async-argument} refer to a different
  2924. CUDA stream.
  2925. @c ---------------------------------------------------------------------
  2926. @c OpenACC Library Interoperability
  2927. @c ---------------------------------------------------------------------
  2928. @node OpenACC Library Interoperability
  2929. @chapter OpenACC Library Interoperability
  2930. @section Introduction
  2931. The OpenACC library uses the CUDA Driver API, and may interact with
  2932. programs that use the Runtime library directly, or another library
  2933. based on the Runtime library, e.g., CUBLAS@footnote{See section 2.26,
  2934. "Interactions with the CUDA Driver API" in
  2935. "CUDA Runtime API", Version 5.5, and section 2.27, "VDPAU
  2936. Interoperability", in "CUDA Driver API", TRM-06703-001, Version 5.5,
  2937. for additional information on library interoperability.}.
  2938. This chapter describes the use cases and what changes are
  2939. required in order to use both the OpenACC library and the CUBLAS and Runtime
  2940. libraries within a program.
  2941. @section First invocation: NVIDIA CUBLAS library API
  2942. In this first use case (see below), a function in the CUBLAS library is called
  2943. prior to any of the functions in the OpenACC library. More specifically, the
  2944. function @code{cublasCreate()}.
  2945. When invoked, the function initializes the library and allocates the
  2946. hardware resources on the host and the device on behalf of the caller. Once
  2947. the initialization and allocation has completed, a handle is returned to the
  2948. caller. The OpenACC library also requires initialization and allocation of
  2949. hardware resources. Since the CUBLAS library has already allocated the
  2950. hardware resources for the device, all that is left to do is to initialize
  2951. the OpenACC library and acquire the hardware resources on the host.
  2952. Prior to calling the OpenACC function that initializes the library and
  2953. allocate the host hardware resources, you need to acquire the device number
  2954. that was allocated during the call to @code{cublasCreate()}. The invoking of the
  2955. runtime library function @code{cudaGetDevice()} accomplishes this. Once
  2956. acquired, the device number is passed along with the device type as
  2957. parameters to the OpenACC library function @code{acc_set_device_num()}.
  2958. Once the call to @code{acc_set_device_num()} has completed, the OpenACC
  2959. library uses the context that was created during the call to
  2960. @code{cublasCreate()}. In other words, both libraries will be sharing the
  2961. same context.
  2962. @smallexample
  2963. /* Create the handle */
  2964. s = cublasCreate(&h);
  2965. if (s != CUBLAS_STATUS_SUCCESS)
  2966. @{
  2967. fprintf(stderr, "cublasCreate failed %d\n", s);
  2968. exit(EXIT_FAILURE);
  2969. @}
  2970. /* Get the device number */
  2971. e = cudaGetDevice(&dev);
  2972. if (e != cudaSuccess)
  2973. @{
  2974. fprintf(stderr, "cudaGetDevice failed %d\n", e);
  2975. exit(EXIT_FAILURE);
  2976. @}
  2977. /* Initialize OpenACC library and use device 'dev' */
  2978. acc_set_device_num(dev, acc_device_nvidia);
  2979. @end smallexample
  2980. @center Use Case 1
  2981. @section First invocation: OpenACC library API
  2982. In this second use case (see below), a function in the OpenACC library is
  2983. called prior to any of the functions in the CUBLAS library. More specificially,
  2984. the function @code{acc_set_device_num()}.
  2985. In the use case presented here, the function @code{acc_set_device_num()}
  2986. is used to both initialize the OpenACC library and allocate the hardware
  2987. resources on the host and the device. In the call to the function, the
  2988. call parameters specify which device to use and what device
  2989. type to use, i.e., @code{acc_device_nvidia}. It should be noted that this
  2990. is but one method to initialize the OpenACC library and allocate the
  2991. appropriate hardware resources. Other methods are available through the
  2992. use of environment variables and these will be discussed in the next section.
  2993. Once the call to @code{acc_set_device_num()} has completed, other OpenACC
  2994. functions can be called as seen with multiple calls being made to
  2995. @code{acc_copyin()}. In addition, calls can be made to functions in the
  2996. CUBLAS library. In the use case a call to @code{cublasCreate()} is made
  2997. subsequent to the calls to @code{acc_copyin()}.
  2998. As seen in the previous use case, a call to @code{cublasCreate()}
  2999. initializes the CUBLAS library and allocates the hardware resources on the
  3000. host and the device. However, since the device has already been allocated,
  3001. @code{cublasCreate()} will only initialize the CUBLAS library and allocate
  3002. the appropriate hardware resources on the host. The context that was created
  3003. as part of the OpenACC initialization is shared with the CUBLAS library,
  3004. similarly to the first use case.
  3005. @smallexample
  3006. dev = 0;
  3007. acc_set_device_num(dev, acc_device_nvidia);
  3008. /* Copy the first set to the device */
  3009. d_X = acc_copyin(&h_X[0], N * sizeof (float));
  3010. if (d_X == NULL)
  3011. @{
  3012. fprintf(stderr, "copyin error h_X\n");
  3013. exit(EXIT_FAILURE);
  3014. @}
  3015. /* Copy the second set to the device */
  3016. d_Y = acc_copyin(&h_Y1[0], N * sizeof (float));
  3017. if (d_Y == NULL)
  3018. @{
  3019. fprintf(stderr, "copyin error h_Y1\n");
  3020. exit(EXIT_FAILURE);
  3021. @}
  3022. /* Create the handle */
  3023. s = cublasCreate(&h);
  3024. if (s != CUBLAS_STATUS_SUCCESS)
  3025. @{
  3026. fprintf(stderr, "cublasCreate failed %d\n", s);
  3027. exit(EXIT_FAILURE);
  3028. @}
  3029. /* Perform saxpy using CUBLAS library function */
  3030. s = cublasSaxpy(h, N, &alpha, d_X, 1, d_Y, 1);
  3031. if (s != CUBLAS_STATUS_SUCCESS)
  3032. @{
  3033. fprintf(stderr, "cublasSaxpy failed %d\n", s);
  3034. exit(EXIT_FAILURE);
  3035. @}
  3036. /* Copy the results from the device */
  3037. acc_memcpy_from_device(&h_Y1[0], d_Y, N * sizeof (float));
  3038. @end smallexample
  3039. @center Use Case 2
  3040. @section OpenACC library and environment variables
  3041. There are two environment variables associated with the OpenACC library
  3042. that may be used to control the device type and device number:
  3043. @env{ACC_DEVICE_TYPE} and @env{ACC_DEVICE_NUM}, respectively. These two
  3044. environment variables can be used as an alternative to calling
  3045. @code{acc_set_device_num()}. As seen in the second use case, the device
  3046. type and device number were specified using @code{acc_set_device_num()}.
  3047. If however, the aforementioned environment variables were set, then the
  3048. call to @code{acc_set_device_num()} would not be required.
  3049. The use of the environment variables is only relevant when an OpenACC function
  3050. is called prior to a call to @code{cudaCreate()}. If @code{cudaCreate()}
  3051. is called prior to a call to an OpenACC function, then you must call
  3052. @code{acc_set_device_num()}@footnote{More complete information
  3053. about @env{ACC_DEVICE_TYPE} and @env{ACC_DEVICE_NUM} can be found in
  3054. sections 4.1 and 4.2 of the @uref{https://www.openacc.org, OpenACC}
  3055. Application Programming Interface”, Version 2.6.}
  3056. @c ---------------------------------------------------------------------
  3057. @c OpenACC Profiling Interface
  3058. @c ---------------------------------------------------------------------
  3059. @node OpenACC Profiling Interface
  3060. @chapter OpenACC Profiling Interface
  3061. @section Implementation Status and Implementation-Defined Behavior
  3062. We're implementing the OpenACC Profiling Interface as defined by the
  3063. OpenACC 2.6 specification. We're clarifying some aspects here as
  3064. @emph{implementation-defined behavior}, while they're still under
  3065. discussion within the OpenACC Technical Committee.
  3066. This implementation is tuned to keep the performance impact as low as
  3067. possible for the (very common) case that the Profiling Interface is
  3068. not enabled. This is relevant, as the Profiling Interface affects all
  3069. the @emph{hot} code paths (in the target code, not in the offloaded
  3070. code). Users of the OpenACC Profiling Interface can be expected to
  3071. understand that performance will be impacted to some degree once the
  3072. Profiling Interface has gotten enabled: for example, because of the
  3073. @emph{runtime} (libgomp) calling into a third-party @emph{library} for
  3074. every event that has been registered.
  3075. We're not yet accounting for the fact that @cite{OpenACC events may
  3076. occur during event processing}.
  3077. We just handle one case specially, as required by CUDA 9.0
  3078. @command{nvprof}, that @code{acc_get_device_type}
  3079. (@ref{acc_get_device_type})) may be called from
  3080. @code{acc_ev_device_init_start}, @code{acc_ev_device_init_end}
  3081. callbacks.
  3082. We're not yet implementing initialization via a
  3083. @code{acc_register_library} function that is either statically linked
  3084. in, or dynamically via @env{LD_PRELOAD}.
  3085. Initialization via @code{acc_register_library} functions dynamically
  3086. loaded via the @env{ACC_PROFLIB} environment variable does work, as
  3087. does directly calling @code{acc_prof_register},
  3088. @code{acc_prof_unregister}, @code{acc_prof_lookup}.
  3089. As currently there are no inquiry functions defined, calls to
  3090. @code{acc_prof_lookup} will always return @code{NULL}.
  3091. There aren't separate @emph{start}, @emph{stop} events defined for the
  3092. event types @code{acc_ev_create}, @code{acc_ev_delete},
  3093. @code{acc_ev_alloc}, @code{acc_ev_free}. It's not clear if these
  3094. should be triggered before or after the actual device-specific call is
  3095. made. We trigger them after.
  3096. Remarks about data provided to callbacks:
  3097. @table @asis
  3098. @item @code{acc_prof_info.event_type}
  3099. It's not clear if for @emph{nested} event callbacks (for example,
  3100. @code{acc_ev_enqueue_launch_start} as part of a parent compute
  3101. construct), this should be set for the nested event
  3102. (@code{acc_ev_enqueue_launch_start}), or if the value of the parent
  3103. construct should remain (@code{acc_ev_compute_construct_start}). In
  3104. this implementation, the value will generally correspond to the
  3105. innermost nested event type.
  3106. @item @code{acc_prof_info.device_type}
  3107. @itemize
  3108. @item
  3109. For @code{acc_ev_compute_construct_start}, and in presence of an
  3110. @code{if} clause with @emph{false} argument, this will still refer to
  3111. the offloading device type.
  3112. It's not clear if that's the expected behavior.
  3113. @item
  3114. Complementary to the item before, for
  3115. @code{acc_ev_compute_construct_end}, this is set to
  3116. @code{acc_device_host} in presence of an @code{if} clause with
  3117. @emph{false} argument.
  3118. It's not clear if that's the expected behavior.
  3119. @end itemize
  3120. @item @code{acc_prof_info.thread_id}
  3121. Always @code{-1}; not yet implemented.
  3122. @item @code{acc_prof_info.async}
  3123. @itemize
  3124. @item
  3125. Not yet implemented correctly for
  3126. @code{acc_ev_compute_construct_start}.
  3127. @item
  3128. In a compute construct, for host-fallback
  3129. execution/@code{acc_device_host} it will always be
  3130. @code{acc_async_sync}.
  3131. It's not clear if that's the expected behavior.
  3132. @item
  3133. For @code{acc_ev_device_init_start} and @code{acc_ev_device_init_end},
  3134. it will always be @code{acc_async_sync}.
  3135. It's not clear if that's the expected behavior.
  3136. @end itemize
  3137. @item @code{acc_prof_info.async_queue}
  3138. There is no @cite{limited number of asynchronous queues} in libgomp.
  3139. This will always have the same value as @code{acc_prof_info.async}.
  3140. @item @code{acc_prof_info.src_file}
  3141. Always @code{NULL}; not yet implemented.
  3142. @item @code{acc_prof_info.func_name}
  3143. Always @code{NULL}; not yet implemented.
  3144. @item @code{acc_prof_info.line_no}
  3145. Always @code{-1}; not yet implemented.
  3146. @item @code{acc_prof_info.end_line_no}
  3147. Always @code{-1}; not yet implemented.
  3148. @item @code{acc_prof_info.func_line_no}
  3149. Always @code{-1}; not yet implemented.
  3150. @item @code{acc_prof_info.func_end_line_no}
  3151. Always @code{-1}; not yet implemented.
  3152. @item @code{acc_event_info.event_type}, @code{acc_event_info.*.event_type}
  3153. Relating to @code{acc_prof_info.event_type} discussed above, in this
  3154. implementation, this will always be the same value as
  3155. @code{acc_prof_info.event_type}.
  3156. @item @code{acc_event_info.*.parent_construct}
  3157. @itemize
  3158. @item
  3159. Will be @code{acc_construct_parallel} for all OpenACC compute
  3160. constructs as well as many OpenACC Runtime API calls; should be the
  3161. one matching the actual construct, or
  3162. @code{acc_construct_runtime_api}, respectively.
  3163. @item
  3164. Will be @code{acc_construct_enter_data} or
  3165. @code{acc_construct_exit_data} when processing variable mappings
  3166. specified in OpenACC @emph{declare} directives; should be
  3167. @code{acc_construct_declare}.
  3168. @item
  3169. For implicit @code{acc_ev_device_init_start},
  3170. @code{acc_ev_device_init_end}, and explicit as well as implicit
  3171. @code{acc_ev_alloc}, @code{acc_ev_free},
  3172. @code{acc_ev_enqueue_upload_start}, @code{acc_ev_enqueue_upload_end},
  3173. @code{acc_ev_enqueue_download_start}, and
  3174. @code{acc_ev_enqueue_download_end}, will be
  3175. @code{acc_construct_parallel}; should reflect the real parent
  3176. construct.
  3177. @end itemize
  3178. @item @code{acc_event_info.*.implicit}
  3179. For @code{acc_ev_alloc}, @code{acc_ev_free},
  3180. @code{acc_ev_enqueue_upload_start}, @code{acc_ev_enqueue_upload_end},
  3181. @code{acc_ev_enqueue_download_start}, and
  3182. @code{acc_ev_enqueue_download_end}, this currently will be @code{1}
  3183. also for explicit usage.
  3184. @item @code{acc_event_info.data_event.var_name}
  3185. Always @code{NULL}; not yet implemented.
  3186. @item @code{acc_event_info.data_event.host_ptr}
  3187. For @code{acc_ev_alloc}, and @code{acc_ev_free}, this is always
  3188. @code{NULL}.
  3189. @item @code{typedef union acc_api_info}
  3190. @dots{} as printed in @cite{5.2.3. Third Argument: API-Specific
  3191. Information}. This should obviously be @code{typedef @emph{struct}
  3192. acc_api_info}.
  3193. @item @code{acc_api_info.device_api}
  3194. Possibly not yet implemented correctly for
  3195. @code{acc_ev_compute_construct_start},
  3196. @code{acc_ev_device_init_start}, @code{acc_ev_device_init_end}:
  3197. will always be @code{acc_device_api_none} for these event types.
  3198. For @code{acc_ev_enter_data_start}, it will be
  3199. @code{acc_device_api_none} in some cases.
  3200. @item @code{acc_api_info.device_type}
  3201. Always the same as @code{acc_prof_info.device_type}.
  3202. @item @code{acc_api_info.vendor}
  3203. Always @code{-1}; not yet implemented.
  3204. @item @code{acc_api_info.device_handle}
  3205. Always @code{NULL}; not yet implemented.
  3206. @item @code{acc_api_info.context_handle}
  3207. Always @code{NULL}; not yet implemented.
  3208. @item @code{acc_api_info.async_handle}
  3209. Always @code{NULL}; not yet implemented.
  3210. @end table
  3211. Remarks about certain event types:
  3212. @table @asis
  3213. @item @code{acc_ev_device_init_start}, @code{acc_ev_device_init_end}
  3214. @itemize
  3215. @item
  3216. @c See 'DEVICE_INIT_INSIDE_COMPUTE_CONSTRUCT' in
  3217. @c 'libgomp.oacc-c-c++-common/acc_prof-kernels-1.c',
  3218. @c 'libgomp.oacc-c-c++-common/acc_prof-parallel-1.c'.
  3219. When a compute construct triggers implicit
  3220. @code{acc_ev_device_init_start} and @code{acc_ev_device_init_end}
  3221. events, they currently aren't @emph{nested within} the corresponding
  3222. @code{acc_ev_compute_construct_start} and
  3223. @code{acc_ev_compute_construct_end}, but they're currently observed
  3224. @emph{before} @code{acc_ev_compute_construct_start}.
  3225. It's not clear what to do: the standard asks us provide a lot of
  3226. details to the @code{acc_ev_compute_construct_start} callback, without
  3227. (implicitly) initializing a device before?
  3228. @item
  3229. Callbacks for these event types will not be invoked for calls to the
  3230. @code{acc_set_device_type} and @code{acc_set_device_num} functions.
  3231. It's not clear if they should be.
  3232. @end itemize
  3233. @item @code{acc_ev_enter_data_start}, @code{acc_ev_enter_data_end}, @code{acc_ev_exit_data_start}, @code{acc_ev_exit_data_end}
  3234. @itemize
  3235. @item
  3236. Callbacks for these event types will also be invoked for OpenACC
  3237. @emph{host_data} constructs.
  3238. It's not clear if they should be.
  3239. @item
  3240. Callbacks for these event types will also be invoked when processing
  3241. variable mappings specified in OpenACC @emph{declare} directives.
  3242. It's not clear if they should be.
  3243. @end itemize
  3244. @end table
  3245. Callbacks for the following event types will be invoked, but dispatch
  3246. and information provided therein has not yet been thoroughly reviewed:
  3247. @itemize
  3248. @item @code{acc_ev_alloc}
  3249. @item @code{acc_ev_free}
  3250. @item @code{acc_ev_update_start}, @code{acc_ev_update_end}
  3251. @item @code{acc_ev_enqueue_upload_start}, @code{acc_ev_enqueue_upload_end}
  3252. @item @code{acc_ev_enqueue_download_start}, @code{acc_ev_enqueue_download_end}
  3253. @end itemize
  3254. During device initialization, and finalization, respectively,
  3255. callbacks for the following event types will not yet be invoked:
  3256. @itemize
  3257. @item @code{acc_ev_alloc}
  3258. @item @code{acc_ev_free}
  3259. @end itemize
  3260. Callbacks for the following event types have not yet been implemented,
  3261. so currently won't be invoked:
  3262. @itemize
  3263. @item @code{acc_ev_device_shutdown_start}, @code{acc_ev_device_shutdown_end}
  3264. @item @code{acc_ev_runtime_shutdown}
  3265. @item @code{acc_ev_create}, @code{acc_ev_delete}
  3266. @item @code{acc_ev_wait_start}, @code{acc_ev_wait_end}
  3267. @end itemize
  3268. For the following runtime library functions, not all expected
  3269. callbacks will be invoked (mostly concerning implicit device
  3270. initialization):
  3271. @itemize
  3272. @item @code{acc_get_num_devices}
  3273. @item @code{acc_set_device_type}
  3274. @item @code{acc_get_device_type}
  3275. @item @code{acc_set_device_num}
  3276. @item @code{acc_get_device_num}
  3277. @item @code{acc_init}
  3278. @item @code{acc_shutdown}
  3279. @end itemize
  3280. Aside from implicit device initialization, for the following runtime
  3281. library functions, no callbacks will be invoked for shared-memory
  3282. offloading devices (it's not clear if they should be):
  3283. @itemize
  3284. @item @code{acc_malloc}
  3285. @item @code{acc_free}
  3286. @item @code{acc_copyin}, @code{acc_present_or_copyin}, @code{acc_copyin_async}
  3287. @item @code{acc_create}, @code{acc_present_or_create}, @code{acc_create_async}
  3288. @item @code{acc_copyout}, @code{acc_copyout_async}, @code{acc_copyout_finalize}, @code{acc_copyout_finalize_async}
  3289. @item @code{acc_delete}, @code{acc_delete_async}, @code{acc_delete_finalize}, @code{acc_delete_finalize_async}
  3290. @item @code{acc_update_device}, @code{acc_update_device_async}
  3291. @item @code{acc_update_self}, @code{acc_update_self_async}
  3292. @item @code{acc_map_data}, @code{acc_unmap_data}
  3293. @item @code{acc_memcpy_to_device}, @code{acc_memcpy_to_device_async}
  3294. @item @code{acc_memcpy_from_device}, @code{acc_memcpy_from_device_async}
  3295. @end itemize
  3296. @c ---------------------------------------------------------------------
  3297. @c The libgomp ABI
  3298. @c ---------------------------------------------------------------------
  3299. @node The libgomp ABI
  3300. @chapter The libgomp ABI
  3301. The following sections present notes on the external ABI as
  3302. presented by libgomp. Only maintainers should need them.
  3303. @menu
  3304. * Implementing MASTER construct::
  3305. * Implementing CRITICAL construct::
  3306. * Implementing ATOMIC construct::
  3307. * Implementing FLUSH construct::
  3308. * Implementing BARRIER construct::
  3309. * Implementing THREADPRIVATE construct::
  3310. * Implementing PRIVATE clause::
  3311. * Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses::
  3312. * Implementing REDUCTION clause::
  3313. * Implementing PARALLEL construct::
  3314. * Implementing FOR construct::
  3315. * Implementing ORDERED construct::
  3316. * Implementing SECTIONS construct::
  3317. * Implementing SINGLE construct::
  3318. * Implementing OpenACC's PARALLEL construct::
  3319. @end menu
  3320. @node Implementing MASTER construct
  3321. @section Implementing MASTER construct
  3322. @smallexample
  3323. if (omp_get_thread_num () == 0)
  3324. block
  3325. @end smallexample
  3326. Alternately, we generate two copies of the parallel subfunction
  3327. and only include this in the version run by the primary thread.
  3328. Surely this is not worthwhile though...
  3329. @node Implementing CRITICAL construct
  3330. @section Implementing CRITICAL construct
  3331. Without a specified name,
  3332. @smallexample
  3333. void GOMP_critical_start (void);
  3334. void GOMP_critical_end (void);
  3335. @end smallexample
  3336. so that we don't get COPY relocations from libgomp to the main
  3337. application.
  3338. With a specified name, use omp_set_lock and omp_unset_lock with
  3339. name being transformed into a variable declared like
  3340. @smallexample
  3341. omp_lock_t gomp_critical_user_<name> __attribute__((common))
  3342. @end smallexample
  3343. Ideally the ABI would specify that all zero is a valid unlocked
  3344. state, and so we wouldn't need to initialize this at
  3345. startup.
  3346. @node Implementing ATOMIC construct
  3347. @section Implementing ATOMIC construct
  3348. The target should implement the @code{__sync} builtins.
  3349. Failing that we could add
  3350. @smallexample
  3351. void GOMP_atomic_enter (void)
  3352. void GOMP_atomic_exit (void)
  3353. @end smallexample
  3354. which reuses the regular lock code, but with yet another lock
  3355. object private to the library.
  3356. @node Implementing FLUSH construct
  3357. @section Implementing FLUSH construct
  3358. Expands to the @code{__sync_synchronize} builtin.
  3359. @node Implementing BARRIER construct
  3360. @section Implementing BARRIER construct
  3361. @smallexample
  3362. void GOMP_barrier (void)
  3363. @end smallexample
  3364. @node Implementing THREADPRIVATE construct
  3365. @section Implementing THREADPRIVATE construct
  3366. In _most_ cases we can map this directly to @code{__thread}. Except
  3367. that OMP allows constructors for C++ objects. We can either
  3368. refuse to support this (how often is it used?) or we can
  3369. implement something akin to .ctors.
  3370. Even more ideally, this ctor feature is handled by extensions
  3371. to the main pthreads library. Failing that, we can have a set
  3372. of entry points to register ctor functions to be called.
  3373. @node Implementing PRIVATE clause
  3374. @section Implementing PRIVATE clause
  3375. In association with a PARALLEL, or within the lexical extent
  3376. of a PARALLEL block, the variable becomes a local variable in
  3377. the parallel subfunction.
  3378. In association with FOR or SECTIONS blocks, create a new
  3379. automatic variable within the current function. This preserves
  3380. the semantic of new variable creation.
  3381. @node Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses
  3382. @section Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses
  3383. This seems simple enough for PARALLEL blocks. Create a private
  3384. struct for communicating between the parent and subfunction.
  3385. In the parent, copy in values for scalar and "small" structs;
  3386. copy in addresses for others TREE_ADDRESSABLE types. In the
  3387. subfunction, copy the value into the local variable.
  3388. It is not clear what to do with bare FOR or SECTION blocks.
  3389. The only thing I can figure is that we do something like:
  3390. @smallexample
  3391. #pragma omp for firstprivate(x) lastprivate(y)
  3392. for (int i = 0; i < n; ++i)
  3393. body;
  3394. @end smallexample
  3395. which becomes
  3396. @smallexample
  3397. @{
  3398. int x = x, y;
  3399. // for stuff
  3400. if (i == n)
  3401. y = y;
  3402. @}
  3403. @end smallexample
  3404. where the "x=x" and "y=y" assignments actually have different
  3405. uids for the two variables, i.e. not something you could write
  3406. directly in C. Presumably this only makes sense if the "outer"
  3407. x and y are global variables.
  3408. COPYPRIVATE would work the same way, except the structure
  3409. broadcast would have to happen via SINGLE machinery instead.
  3410. @node Implementing REDUCTION clause
  3411. @section Implementing REDUCTION clause
  3412. The private struct mentioned in the previous section should have
  3413. a pointer to an array of the type of the variable, indexed by the
  3414. thread's @var{team_id}. The thread stores its final value into the
  3415. array, and after the barrier, the primary thread iterates over the
  3416. array to collect the values.
  3417. @node Implementing PARALLEL construct
  3418. @section Implementing PARALLEL construct
  3419. @smallexample
  3420. #pragma omp parallel
  3421. @{
  3422. body;
  3423. @}
  3424. @end smallexample
  3425. becomes
  3426. @smallexample
  3427. void subfunction (void *data)
  3428. @{
  3429. use data;
  3430. body;
  3431. @}
  3432. setup data;
  3433. GOMP_parallel_start (subfunction, &data, num_threads);
  3434. subfunction (&data);
  3435. GOMP_parallel_end ();
  3436. @end smallexample
  3437. @smallexample
  3438. void GOMP_parallel_start (void (*fn)(void *), void *data, unsigned num_threads)
  3439. @end smallexample
  3440. The @var{FN} argument is the subfunction to be run in parallel.
  3441. The @var{DATA} argument is a pointer to a structure used to
  3442. communicate data in and out of the subfunction, as discussed
  3443. above with respect to FIRSTPRIVATE et al.
  3444. The @var{NUM_THREADS} argument is 1 if an IF clause is present
  3445. and false, or the value of the NUM_THREADS clause, if
  3446. present, or 0.
  3447. The function needs to create the appropriate number of
  3448. threads and/or launch them from the dock. It needs to
  3449. create the team structure and assign team ids.
  3450. @smallexample
  3451. void GOMP_parallel_end (void)
  3452. @end smallexample
  3453. Tears down the team and returns us to the previous @code{omp_in_parallel()} state.
  3454. @node Implementing FOR construct
  3455. @section Implementing FOR construct
  3456. @smallexample
  3457. #pragma omp parallel for
  3458. for (i = lb; i <= ub; i++)
  3459. body;
  3460. @end smallexample
  3461. becomes
  3462. @smallexample
  3463. void subfunction (void *data)
  3464. @{
  3465. long _s0, _e0;
  3466. while (GOMP_loop_static_next (&_s0, &_e0))
  3467. @{
  3468. long _e1 = _e0, i;
  3469. for (i = _s0; i < _e1; i++)
  3470. body;
  3471. @}
  3472. GOMP_loop_end_nowait ();
  3473. @}
  3474. GOMP_parallel_loop_static (subfunction, NULL, 0, lb, ub+1, 1, 0);
  3475. subfunction (NULL);
  3476. GOMP_parallel_end ();
  3477. @end smallexample
  3478. @smallexample
  3479. #pragma omp for schedule(runtime)
  3480. for (i = 0; i < n; i++)
  3481. body;
  3482. @end smallexample
  3483. becomes
  3484. @smallexample
  3485. @{
  3486. long i, _s0, _e0;
  3487. if (GOMP_loop_runtime_start (0, n, 1, &_s0, &_e0))
  3488. do @{
  3489. long _e1 = _e0;
  3490. for (i = _s0, i < _e0; i++)
  3491. body;
  3492. @} while (GOMP_loop_runtime_next (&_s0, _&e0));
  3493. GOMP_loop_end ();
  3494. @}
  3495. @end smallexample
  3496. Note that while it looks like there is trickiness to propagating
  3497. a non-constant STEP, there isn't really. We're explicitly allowed
  3498. to evaluate it as many times as we want, and any variables involved
  3499. should automatically be handled as PRIVATE or SHARED like any other
  3500. variables. So the expression should remain evaluable in the
  3501. subfunction. We can also pull it into a local variable if we like,
  3502. but since its supposed to remain unchanged, we can also not if we like.
  3503. If we have SCHEDULE(STATIC), and no ORDERED, then we ought to be
  3504. able to get away with no work-sharing context at all, since we can
  3505. simply perform the arithmetic directly in each thread to divide up
  3506. the iterations. Which would mean that we wouldn't need to call any
  3507. of these routines.
  3508. There are separate routines for handling loops with an ORDERED
  3509. clause. Bookkeeping for that is non-trivial...
  3510. @node Implementing ORDERED construct
  3511. @section Implementing ORDERED construct
  3512. @smallexample
  3513. void GOMP_ordered_start (void)
  3514. void GOMP_ordered_end (void)
  3515. @end smallexample
  3516. @node Implementing SECTIONS construct
  3517. @section Implementing SECTIONS construct
  3518. A block as
  3519. @smallexample
  3520. #pragma omp sections
  3521. @{
  3522. #pragma omp section
  3523. stmt1;
  3524. #pragma omp section
  3525. stmt2;
  3526. #pragma omp section
  3527. stmt3;
  3528. @}
  3529. @end smallexample
  3530. becomes
  3531. @smallexample
  3532. for (i = GOMP_sections_start (3); i != 0; i = GOMP_sections_next ())
  3533. switch (i)
  3534. @{
  3535. case 1:
  3536. stmt1;
  3537. break;
  3538. case 2:
  3539. stmt2;
  3540. break;
  3541. case 3:
  3542. stmt3;
  3543. break;
  3544. @}
  3545. GOMP_barrier ();
  3546. @end smallexample
  3547. @node Implementing SINGLE construct
  3548. @section Implementing SINGLE construct
  3549. A block like
  3550. @smallexample
  3551. #pragma omp single
  3552. @{
  3553. body;
  3554. @}
  3555. @end smallexample
  3556. becomes
  3557. @smallexample
  3558. if (GOMP_single_start ())
  3559. body;
  3560. GOMP_barrier ();
  3561. @end smallexample
  3562. while
  3563. @smallexample
  3564. #pragma omp single copyprivate(x)
  3565. body;
  3566. @end smallexample
  3567. becomes
  3568. @smallexample
  3569. datap = GOMP_single_copy_start ();
  3570. if (datap == NULL)
  3571. @{
  3572. body;
  3573. data.x = x;
  3574. GOMP_single_copy_end (&data);
  3575. @}
  3576. else
  3577. x = datap->x;
  3578. GOMP_barrier ();
  3579. @end smallexample
  3580. @node Implementing OpenACC's PARALLEL construct
  3581. @section Implementing OpenACC's PARALLEL construct
  3582. @smallexample
  3583. void GOACC_parallel ()
  3584. @end smallexample
  3585. @c ---------------------------------------------------------------------
  3586. @c Reporting Bugs
  3587. @c ---------------------------------------------------------------------
  3588. @node Reporting Bugs
  3589. @chapter Reporting Bugs
  3590. Bugs in the GNU Offloading and Multi Processing Runtime Library should
  3591. be reported via @uref{https://gcc.gnu.org/bugzilla/, Bugzilla}. Please add
  3592. "openacc", or "openmp", or both to the keywords field in the bug
  3593. report, as appropriate.
  3594. @c ---------------------------------------------------------------------
  3595. @c GNU General Public License
  3596. @c ---------------------------------------------------------------------
  3597. @include gpl_v3.texi
  3598. @c ---------------------------------------------------------------------
  3599. @c GNU Free Documentation License
  3600. @c ---------------------------------------------------------------------
  3601. @include fdl.texi
  3602. @c ---------------------------------------------------------------------
  3603. @c Funding Free Software
  3604. @c ---------------------------------------------------------------------
  3605. @include funding.texi
  3606. @c ---------------------------------------------------------------------
  3607. @c Index
  3608. @c ---------------------------------------------------------------------
  3609. @node Library Index
  3610. @unnumbered Library Index
  3611. @printindex cp
  3612. @bye