]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgomp/libgomp.texi
libgomp.texi: Improve "OpenACC Environment Variables"
[thirdparty/gcc.git] / libgomp / libgomp.texi
CommitLineData
d77de738
ML
1\input texinfo @c -*-texinfo-*-
2
3@c %**start of header
4@setfilename libgomp.info
5@settitle GNU libgomp
6@c %**end of header
7
8
9@copying
74d5206f 10Copyright @copyright{} 2006-2023 Free Software Foundation, Inc.
d77de738
ML
11
12Permission is granted to copy, distribute and/or modify this document
13under the terms of the GNU Free Documentation License, Version 1.3 or
14any later version published by the Free Software Foundation; with the
15Invariant Sections being ``Funding Free Software'', the Front-Cover
16texts being (a) (see below), and with the Back-Cover Texts being (b)
17(see below). A copy of the license is included in the section entitled
18``GNU Free Documentation License''.
19
20(a) The FSF's Front-Cover Text is:
21
22 A GNU Manual
23
24(b) The FSF's Back-Cover Text is:
25
26 You have freedom to copy and modify this GNU Manual, like GNU
27 software. Copies published by the Free Software Foundation raise
28 funds for GNU development.
29@end copying
30
31@ifinfo
32@dircategory GNU Libraries
33@direntry
34* libgomp: (libgomp). GNU Offloading and Multi Processing Runtime Library.
35@end direntry
36
37This manual documents libgomp, the GNU Offloading and Multi Processing
38Runtime library. This is the GNU implementation of the OpenMP and
39OpenACC APIs for parallel and accelerator programming in C/C++ and
40Fortran.
41
42Published by the Free Software Foundation
4351 Franklin Street, Fifth Floor
44Boston, MA 02110-1301 USA
45
46@insertcopying
47@end ifinfo
48
49
50@setchapternewpage odd
51
52@titlepage
53@title GNU Offloading and Multi Processing Runtime Library
54@subtitle The GNU OpenMP and OpenACC Implementation
55@page
56@vskip 0pt plus 1filll
57@comment For the @value{version-GCC} Version*
58@sp 1
59Published by the Free Software Foundation @*
6051 Franklin Street, Fifth Floor@*
61Boston, MA 02110-1301, USA@*
62@sp 1
63@insertcopying
64@end titlepage
65
66@summarycontents
67@contents
68@page
69
70
71@node Top, Enabling OpenMP
72@top Introduction
73@cindex Introduction
74
75This manual documents the usage of libgomp, the GNU Offloading and
76Multi Processing Runtime Library. This includes the GNU
77implementation of the @uref{https://www.openmp.org, OpenMP} Application
78Programming Interface (API) for multi-platform shared-memory parallel
79programming in C/C++ and Fortran, and the GNU implementation of the
80@uref{https://www.openacc.org, OpenACC} Application Programming
81Interface (API) for offloading of code to accelerator devices in C/C++
82and Fortran.
83
84Originally, libgomp implemented the GNU OpenMP Runtime Library. Based
85on this, support for OpenACC and offloading (both OpenACC and OpenMP
864's target construct) has been added later on, and the library's name
87changed to GNU Offloading and Multi Processing Runtime Library.
88
89
90
91@comment
92@comment When you add a new menu item, please keep the right hand
93@comment aligned to the same column. Do not use tabs. This provides
94@comment better formatting.
95@comment
96@menu
97* Enabling OpenMP:: How to enable OpenMP for your applications.
98* OpenMP Implementation Status:: List of implemented features by OpenMP version
99* OpenMP Runtime Library Routines: Runtime Library Routines.
100 The OpenMP runtime application programming
101 interface.
102* OpenMP Environment Variables: Environment Variables.
103 Influencing OpenMP runtime behavior with
104 environment variables.
105* Enabling OpenACC:: How to enable OpenACC for your
106 applications.
107* OpenACC Runtime Library Routines:: The OpenACC runtime application
108 programming interface.
109* OpenACC Environment Variables:: Influencing OpenACC runtime behavior with
110 environment variables.
111* CUDA Streams Usage:: Notes on the implementation of
112 asynchronous operations.
113* OpenACC Library Interoperability:: OpenACC library interoperability with the
114 NVIDIA CUBLAS library.
115* OpenACC Profiling Interface::
116* OpenMP-Implementation Specifics:: Notes specifics of this OpenMP
117 implementation
118* Offload-Target Specifics:: Notes on offload-target specific internals
119* The libgomp ABI:: Notes on the external ABI presented by libgomp.
120* Reporting Bugs:: How to report bugs in the GNU Offloading and
121 Multi Processing Runtime Library.
122* Copying:: GNU general public license says
123 how you can copy and share libgomp.
124* GNU Free Documentation License::
125 How you can copy and share this manual.
126* Funding:: How to help assure continued work for free
127 software.
128* Library Index:: Index of this documentation.
129@end menu
130
131
132@c ---------------------------------------------------------------------
133@c Enabling OpenMP
134@c ---------------------------------------------------------------------
135
136@node Enabling OpenMP
137@chapter Enabling OpenMP
138
139To activate the OpenMP extensions for C/C++ and Fortran, the compile-time
140flag @command{-fopenmp} must be specified. This enables the OpenMP directive
141@code{#pragma omp} in C/C++ and @code{!$omp} directives in free form,
142@code{c$omp}, @code{*$omp} and @code{!$omp} directives in fixed form,
143@code{!$} conditional compilation sentinels in free form and @code{c$},
144@code{*$} and @code{!$} sentinels in fixed form, for Fortran. The flag also
145arranges for automatic linking of the OpenMP runtime library
146(@ref{Runtime Library Routines}).
147
148A complete description of all OpenMP directives may be found in the
149@uref{https://www.openmp.org, OpenMP Application Program Interface} manuals.
150See also @ref{OpenMP Implementation Status}.
151
152
153@c ---------------------------------------------------------------------
154@c OpenMP Implementation Status
155@c ---------------------------------------------------------------------
156
157@node OpenMP Implementation Status
158@chapter OpenMP Implementation Status
159
160@menu
161* OpenMP 4.5:: Feature completion status to 4.5 specification
162* OpenMP 5.0:: Feature completion status to 5.0 specification
163* OpenMP 5.1:: Feature completion status to 5.1 specification
164* OpenMP 5.2:: Feature completion status to 5.2 specification
c16e85d7 165* OpenMP Technical Report 11:: Feature completion status to first 6.0 preview
d77de738
ML
166@end menu
167
168The @code{_OPENMP} preprocessor macro and Fortran's @code{openmp_version}
169parameter, provided by @code{omp_lib.h} and the @code{omp_lib} module, have
170the value @code{201511} (i.e. OpenMP 4.5).
171
172@node OpenMP 4.5
173@section OpenMP 4.5
174
175The OpenMP 4.5 specification is fully supported.
176
177@node OpenMP 5.0
178@section OpenMP 5.0
179
180@unnumberedsubsec New features listed in Appendix B of the OpenMP specification
181@c This list is sorted as in OpenMP 5.1's B.3 not as in OpenMP 5.0's B.2
182
183@multitable @columnfractions .60 .10 .25
184@headitem Description @tab Status @tab Comments
185@item Array shaping @tab N @tab
186@item Array sections with non-unit strides in C and C++ @tab N @tab
187@item Iterators @tab Y @tab
188@item @code{metadirective} directive @tab N @tab
189@item @code{declare variant} directive
190 @tab P @tab @emph{simd} traits not handled correctly
2cd0689a 191@item @var{target-offload-var} ICV and @code{OMP_TARGET_OFFLOAD}
d77de738 192 env variable @tab Y @tab
2cd0689a 193@item Nested-parallel changes to @var{max-active-levels-var} ICV @tab Y @tab
d77de738 194@item @code{requires} directive @tab P
8c2fc744 195 @tab complete but no non-host device provides @code{unified_shared_memory}
d77de738 196@item @code{teams} construct outside an enclosing target region @tab Y @tab
85da0b40
TB
197@item Non-rectangular loop nests @tab P
198 @tab Full support for C/C++, partial for Fortran
199 (@uref{https://gcc.gnu.org/PR110735,PR110735})
d77de738
ML
200@item @code{!=} as relational-op in canonical loop form for C/C++ @tab Y @tab
201@item @code{nonmonotonic} as default loop schedule modifier for worksharing-loop
202 constructs @tab Y @tab
87f9b6c2 203@item Collapse of associated loops that are imperfectly nested loops @tab Y @tab
d77de738
ML
204@item Clauses @code{if}, @code{nontemporal} and @code{order(concurrent)} in
205 @code{simd} construct @tab Y @tab
206@item @code{atomic} constructs in @code{simd} @tab Y @tab
207@item @code{loop} construct @tab Y @tab
208@item @code{order(concurrent)} clause @tab Y @tab
209@item @code{scan} directive and @code{in_scan} modifier for the
210 @code{reduction} clause @tab Y @tab
211@item @code{in_reduction} clause on @code{task} constructs @tab Y @tab
212@item @code{in_reduction} clause on @code{target} constructs @tab P
213 @tab @code{nowait} only stub
214@item @code{task_reduction} clause with @code{taskgroup} @tab Y @tab
215@item @code{task} modifier to @code{reduction} clause @tab Y @tab
216@item @code{affinity} clause to @code{task} construct @tab Y @tab Stub only
217@item @code{detach} clause to @code{task} construct @tab Y @tab
218@item @code{omp_fulfill_event} runtime routine @tab Y @tab
219@item @code{reduction} and @code{in_reduction} clauses on @code{taskloop}
220 and @code{taskloop simd} constructs @tab Y @tab
221@item @code{taskloop} construct cancelable by @code{cancel} construct
222 @tab Y @tab
223@item @code{mutexinoutset} @emph{dependence-type} for @code{depend} clause
224 @tab Y @tab
225@item Predefined memory spaces, memory allocators, allocator traits
13c3e29d 226 @tab Y @tab See also @ref{Memory allocation}
d77de738 227@item Memory management routines @tab Y @tab
969f5c3e 228@item @code{allocate} directive @tab P @tab Only C and Fortran, only stack variables
d77de738
ML
229@item @code{allocate} clause @tab P @tab Initial support
230@item @code{use_device_addr} clause on @code{target data} @tab Y @tab
f84fdb13 231@item @code{ancestor} modifier on @code{device} clause @tab Y @tab
d77de738
ML
232@item Implicit declare target directive @tab Y @tab
233@item Discontiguous array section with @code{target update} construct
234 @tab N @tab
235@item C/C++'s lvalue expressions in @code{to}, @code{from}
236 and @code{map} clauses @tab N @tab
237@item C/C++'s lvalue expressions in @code{depend} clauses @tab Y @tab
238@item Nested @code{declare target} directive @tab Y @tab
239@item Combined @code{master} constructs @tab Y @tab
240@item @code{depend} clause on @code{taskwait} @tab Y @tab
241@item Weak memory ordering clauses on @code{atomic} and @code{flush} construct
242 @tab Y @tab
243@item @code{hint} clause on the @code{atomic} construct @tab Y @tab Stub only
244@item @code{depobj} construct and depend objects @tab Y @tab
245@item Lock hints were renamed to synchronization hints @tab Y @tab
246@item @code{conditional} modifier to @code{lastprivate} clause @tab Y @tab
247@item Map-order clarifications @tab P @tab
248@item @code{close} @emph{map-type-modifier} @tab Y @tab
249@item Mapping C/C++ pointer variables and to assign the address of
250 device memory mapped by an array section @tab P @tab
251@item Mapping of Fortran pointer and allocatable variables, including pointer
252 and allocatable components of variables
253 @tab P @tab Mapping of vars with allocatable components unsupported
254@item @code{defaultmap} extensions @tab Y @tab
255@item @code{declare mapper} directive @tab N @tab
256@item @code{omp_get_supported_active_levels} routine @tab Y @tab
257@item Runtime routines and environment variables to display runtime thread
258 affinity information @tab Y @tab
259@item @code{omp_pause_resource} and @code{omp_pause_resource_all} runtime
260 routines @tab Y @tab
261@item @code{omp_get_device_num} runtime routine @tab Y @tab
262@item OMPT interface @tab N @tab
263@item OMPD interface @tab N @tab
264@end multitable
265
266@unnumberedsubsec Other new OpenMP 5.0 features
267
268@multitable @columnfractions .60 .10 .25
269@headitem Description @tab Status @tab Comments
270@item Supporting C++'s range-based for loop @tab Y @tab
271@end multitable
272
273
274@node OpenMP 5.1
275@section OpenMP 5.1
276
277@unnumberedsubsec New features listed in Appendix B of the OpenMP specification
278
279@multitable @columnfractions .60 .10 .25
280@headitem Description @tab Status @tab Comments
281@item OpenMP directive as C++ attribute specifiers @tab Y @tab
282@item @code{omp_all_memory} reserved locator @tab Y @tab
283@item @emph{target_device trait} in OpenMP Context @tab N @tab
284@item @code{target_device} selector set in context selectors @tab N @tab
285@item C/C++'s @code{declare variant} directive: elision support of
286 preprocessed code @tab N @tab
287@item @code{declare variant}: new clauses @code{adjust_args} and
288 @code{append_args} @tab N @tab
289@item @code{dispatch} construct @tab N @tab
290@item device-specific ICV settings with environment variables @tab Y @tab
eda38850 291@item @code{assume} and @code{assumes} directives @tab Y @tab
d77de738
ML
292@item @code{nothing} directive @tab Y @tab
293@item @code{error} directive @tab Y @tab
294@item @code{masked} construct @tab Y @tab
295@item @code{scope} directive @tab Y @tab
296@item Loop transformation constructs @tab N @tab
297@item @code{strict} modifier in the @code{grainsize} and @code{num_tasks}
298 clauses of the @code{taskloop} construct @tab Y @tab
1a554a2c 299@item @code{align} clause in @code{allocate} directive @tab P
969f5c3e 300 @tab Only C and Fortran (and only stack variables)
b2e1c49b 301@item @code{align} modifier in @code{allocate} clause @tab Y @tab
d77de738
ML
302@item @code{thread_limit} clause to @code{target} construct @tab Y @tab
303@item @code{has_device_addr} clause to @code{target} construct @tab Y @tab
304@item Iterators in @code{target update} motion clauses and @code{map}
305 clauses @tab N @tab
306@item Indirect calls to the device version of a procedure or function in
307 @code{target} regions @tab N @tab
308@item @code{interop} directive @tab N @tab
309@item @code{omp_interop_t} object support in runtime routines @tab N @tab
310@item @code{nowait} clause in @code{taskwait} directive @tab Y @tab
311@item Extensions to the @code{atomic} directive @tab Y @tab
312@item @code{seq_cst} clause on a @code{flush} construct @tab Y @tab
313@item @code{inoutset} argument to the @code{depend} clause @tab Y @tab
314@item @code{private} and @code{firstprivate} argument to @code{default}
315 clause in C and C++ @tab Y @tab
4ede915d 316@item @code{present} argument to @code{defaultmap} clause @tab Y @tab
d77de738
ML
317@item @code{omp_set_num_teams}, @code{omp_set_teams_thread_limit},
318 @code{omp_get_max_teams}, @code{omp_get_teams_thread_limit} runtime
319 routines @tab Y @tab
320@item @code{omp_target_is_accessible} runtime routine @tab Y @tab
321@item @code{omp_target_memcpy_async} and @code{omp_target_memcpy_rect_async}
322 runtime routines @tab Y @tab
323@item @code{omp_get_mapped_ptr} runtime routine @tab Y @tab
324@item @code{omp_calloc}, @code{omp_realloc}, @code{omp_aligned_alloc} and
325 @code{omp_aligned_calloc} runtime routines @tab Y @tab
326@item @code{omp_alloctrait_key_t} enum: @code{omp_atv_serialized} added,
327 @code{omp_atv_default} changed @tab Y @tab
328@item @code{omp_display_env} runtime routine @tab Y @tab
329@item @code{ompt_scope_endpoint_t} enum: @code{ompt_scope_beginend} @tab N @tab
330@item @code{ompt_sync_region_t} enum additions @tab N @tab
331@item @code{ompt_state_t} enum: @code{ompt_state_wait_barrier_implementation}
332 and @code{ompt_state_wait_barrier_teams} @tab N @tab
333@item @code{ompt_callback_target_data_op_emi_t},
334 @code{ompt_callback_target_emi_t}, @code{ompt_callback_target_map_emi_t}
335 and @code{ompt_callback_target_submit_emi_t} @tab N @tab
336@item @code{ompt_callback_error_t} type @tab N @tab
337@item @code{OMP_PLACES} syntax extensions @tab Y @tab
338@item @code{OMP_NUM_TEAMS} and @code{OMP_TEAMS_THREAD_LIMIT} environment
339 variables @tab Y @tab
340@end multitable
341
342@unnumberedsubsec Other new OpenMP 5.1 features
343
344@multitable @columnfractions .60 .10 .25
345@headitem Description @tab Status @tab Comments
346@item Support of strictly structured blocks in Fortran @tab Y @tab
347@item Support of structured block sequences in C/C++ @tab Y @tab
348@item @code{unconstrained} and @code{reproducible} modifiers on @code{order}
349 clause @tab Y @tab
350@item Support @code{begin/end declare target} syntax in C/C++ @tab Y @tab
351@item Pointer predetermined firstprivate getting initialized
352to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
353@item For Fortran, diagnose placing declarative before/between @code{USE},
354 @code{IMPORT}, and @code{IMPLICIT} as invalid @tab N @tab
eda38850 355@item Optional comma between directive and clause in the @code{#pragma} form @tab Y @tab
c16e85d7
TB
356@item @code{indirect} clause in @code{declare target} @tab N @tab
357@item @code{device_type(nohost)}/@code{device_type(host)} for variables @tab N @tab
4ede915d
TB
358@item @code{present} modifier to the @code{map}, @code{to} and @code{from}
359 clauses @tab Y @tab
d77de738
ML
360@end multitable
361
362
363@node OpenMP 5.2
364@section OpenMP 5.2
365
366@unnumberedsubsec New features listed in Appendix B of the OpenMP specification
367
368@multitable @columnfractions .60 .10 .25
369@headitem Description @tab Status @tab Comments
2cd0689a 370@item @code{omp_in_explicit_task} routine and @var{explicit-task-var} ICV
d77de738
ML
371 @tab Y @tab
372@item @code{omp}/@code{ompx}/@code{omx} sentinels and @code{omp_}/@code{ompx_}
373 namespaces @tab N/A
374 @tab warning for @code{ompx/omx} sentinels@footnote{The @code{ompx}
375 sentinel as C/C++ pragma and C++ attributes are warned for with
376 @code{-Wunknown-pragmas} (implied by @code{-Wall}) and @code{-Wattributes}
377 (enabled by default), respectively; for Fortran free-source code, there is
378 a warning enabled by default and, for fixed-source code, the @code{omx}
379 sentinel is warned for with with @code{-Wsurprising} (enabled by
380 @code{-Wall}). Unknown clauses are always rejected with an error.}
091b6dbc 381@item Clauses on @code{end} directive can be on directive @tab Y @tab
0698c9fd
TB
382@item @code{destroy} clause with destroy-var argument on @code{depobj}
383 @tab N @tab
d77de738
ML
384@item Deprecation of no-argument @code{destroy} clause on @code{depobj}
385 @tab N @tab
386@item @code{linear} clause syntax changes and @code{step} modifier @tab Y @tab
387@item Deprecation of minus operator for reductions @tab N @tab
388@item Deprecation of separating @code{map} modifiers without comma @tab N @tab
389@item @code{declare mapper} with iterator and @code{present} modifiers
390 @tab N @tab
391@item If a matching mapped list item is not found in the data environment, the
b25ea7ab 392 pointer retains its original value @tab Y @tab
d77de738
ML
393@item New @code{enter} clause as alias for @code{to} on declare target directive
394 @tab Y @tab
395@item Deprecation of @code{to} clause on declare target directive @tab N @tab
396@item Extended list of directives permitted in Fortran pure procedures
2df7e451 397 @tab Y @tab
d77de738
ML
398@item New @code{allocators} directive for Fortran @tab N @tab
399@item Deprecation of @code{allocate} directive for Fortran
400 allocatables/pointers @tab N @tab
401@item Optional paired @code{end} directive with @code{dispatch} @tab N @tab
402@item New @code{memspace} and @code{traits} modifiers for @code{uses_allocators}
403 @tab N @tab
404@item Deprecation of traits array following the allocator_handle expression in
405 @code{uses_allocators} @tab N @tab
406@item New @code{otherwise} clause as alias for @code{default} on metadirectives
407 @tab N @tab
408@item Deprecation of @code{default} clause on metadirectives @tab N @tab
409@item Deprecation of delimited form of @code{declare target} @tab N @tab
410@item Reproducible semantics changed for @code{order(concurrent)} @tab N @tab
411@item @code{allocate} and @code{firstprivate} clauses on @code{scope}
412 @tab Y @tab
413@item @code{ompt_callback_work} @tab N @tab
9f80367e 414@item Default map-type for the @code{map} clause in @code{target enter/exit data}
d77de738
ML
415 @tab Y @tab
416@item New @code{doacross} clause as alias for @code{depend} with
417 @code{source}/@code{sink} modifier @tab Y @tab
418@item Deprecation of @code{depend} with @code{source}/@code{sink} modifier
419 @tab N @tab
420@item @code{omp_cur_iteration} keyword @tab Y @tab
421@end multitable
422
423@unnumberedsubsec Other new OpenMP 5.2 features
424
425@multitable @columnfractions .60 .10 .25
426@headitem Description @tab Status @tab Comments
427@item For Fortran, optional comma between directive and clause @tab N @tab
428@item Conforming device numbers and @code{omp_initial_device} and
429 @code{omp_invalid_device} enum/PARAMETER @tab Y @tab
2cd0689a 430@item Initial value of @var{default-device-var} ICV with
18c8b56c 431 @code{OMP_TARGET_OFFLOAD=mandatory} @tab Y @tab
0698c9fd 432@item @code{all} as @emph{implicit-behavior} for @code{defaultmap} @tab Y @tab
d77de738
ML
433@item @emph{interop_types} in any position of the modifier list for the @code{init} clause
434 of the @code{interop} construct @tab N @tab
435@end multitable
436
437
c16e85d7
TB
438@node OpenMP Technical Report 11
439@section OpenMP Technical Report 11
440
441Technical Report (TR) 11 is the first preview for OpenMP 6.0.
442
443@unnumberedsubsec New features listed in Appendix B of the OpenMP specification
444@multitable @columnfractions .60 .10 .25
445@item Features deprecated in versions 5.2, 5.1 and 5.0 were removed
446 @tab N/A @tab Backward compatibility
447@item The @code{decl} attribute was added to the C++ attribute syntax
04b2fb5b 448 @tab Y @tab
c16e85d7
TB
449@item @code{_ALL} suffix to the device-scope environment variables
450 @tab P @tab Host device number wrongly accepted
451@item For Fortran, @emph{locator list} can be also function reference with
452 data pointer result @tab N @tab
453@item Ref-count change for @code{use_device_ptr}/@code{use_device_addr}
454 @tab N @tab
455@item Implicit reduction identifiers of C++ classes
456 @tab N @tab
457@item Change of the @emph{map-type} property from @emph{ultimate} to
458 @emph{default} @tab N @tab
459@item Concept of @emph{assumed-size arrays} in C and C++
460 @tab N @tab
461@item Mapping of @emph{assumed-size arrays} in C, C++ and Fortran
462 @tab N @tab
463@item @code{groupprivate} directive @tab N @tab
464@item @code{local} clause to declare target directive @tab N @tab
465@item @code{part_size} allocator trait @tab N @tab
466@item @code{pin_device}, @code{preferred_device} and @code{target_access}
467 allocator traits
468 @tab N @tab
469@item @code{access} allocator trait changes @tab N @tab
470@item Extension of @code{interop} operation of @code{append_args}, allowing all
471 modifiers of the @code{init} clause
9f80367e 472 @tab N @tab
c16e85d7
TB
473@item @code{interop} clause to @code{dispatch} @tab N @tab
474@item @code{apply} code to loop-transforming constructs @tab N @tab
475@item @code{omp_curr_progress_width} identifier @tab N @tab
476@item @code{safesync} clause to the @code{parallel} construct @tab N @tab
477@item @code{omp_get_max_progress_width} runtime routine @tab N @tab
8da7476c 478@item @code{strict} modifier keyword to @code{num_threads} @tab N @tab
c16e85d7
TB
479@item @code{memscope} clause to @code{atomic} and @code{flush} @tab N @tab
480@item Routines for obtaining memory spaces/allocators for shared/device memory
481 @tab N @tab
482@item @code{omp_get_memspace_num_resources} routine @tab N @tab
483@item @code{omp_get_submemspace} routine @tab N @tab
484@item @code{ompt_get_buffer_limits} OMPT routine @tab N @tab
485@item Extension of @code{OMP_DEFAULT_DEVICE} and new
486 @code{OMP_AVAILABLE_DEVICES} environment vars @tab N @tab
487@item Supporting increments with abstract names in @code{OMP_PLACES} @tab N @tab
488@end multitable
489
490@unnumberedsubsec Other new TR 11 features
491@multitable @columnfractions .60 .10 .25
492@item Relaxed Fortran restrictions to the @code{aligned} clause @tab N @tab
493@item Mapping lambda captures @tab N @tab
494@item For Fortran, atomic compare with storing the comparison result
495 @tab N @tab
c16e85d7
TB
496@end multitable
497
498
499
d77de738
ML
500@c ---------------------------------------------------------------------
501@c OpenMP Runtime Library Routines
502@c ---------------------------------------------------------------------
503
504@node Runtime Library Routines
505@chapter OpenMP Runtime Library Routines
506
506f068e
TB
507The runtime routines described here are defined by Section 18 of the OpenMP
508specification in version 5.2.
d77de738
ML
509
510@menu
506f068e
TB
511* Thread Team Routines::
512* Thread Affinity Routines::
513* Teams Region Routines::
514* Tasking Routines::
515@c * Resource Relinquishing Routines::
516* Device Information Routines::
e0786ba6 517* Device Memory Routines::
506f068e
TB
518* Lock Routines::
519* Timing Routines::
520* Event Routine::
521@c * Interoperability Routines::
971f119f 522* Memory Management Routines::
506f068e
TB
523@c * Tool Control Routine::
524@c * Environment Display Routine::
525@end menu
d77de738 526
506f068e
TB
527
528
529@node Thread Team Routines
530@section Thread Team Routines
531
532Routines controlling threads in the current contention group.
533They have C linkage and do not throw exceptions.
534
535@menu
536* omp_set_num_threads:: Set upper team size limit
d77de738 537* omp_get_num_threads:: Size of the active team
506f068e 538* omp_get_max_threads:: Maximum number of threads of parallel region
d77de738
ML
539* omp_get_thread_num:: Current thread ID
540* omp_in_parallel:: Whether a parallel region is active
d77de738 541* omp_set_dynamic:: Enable/disable dynamic teams
506f068e
TB
542* omp_get_dynamic:: Dynamic teams setting
543* omp_get_cancellation:: Whether cancellation support is enabled
d77de738 544* omp_set_nested:: Enable/disable nested parallel regions
506f068e 545* omp_get_nested:: Nested parallel regions
d77de738 546* omp_set_schedule:: Set the runtime scheduling method
506f068e
TB
547* omp_get_schedule:: Obtain the runtime scheduling method
548* omp_get_teams_thread_limit:: Maximum number of threads imposed by teams
549* omp_get_supported_active_levels:: Maximum number of active regions supported
550* omp_set_max_active_levels:: Limits the number of active parallel regions
551* omp_get_max_active_levels:: Current maximum number of active regions
552* omp_get_level:: Number of parallel regions
553* omp_get_ancestor_thread_num:: Ancestor thread ID
554* omp_get_team_size:: Number of threads in a team
555* omp_get_active_level:: Number of active parallel regions
556@end menu
d77de738 557
d77de738 558
d77de738 559
506f068e
TB
560@node omp_set_num_threads
561@subsection @code{omp_set_num_threads} -- Set upper team size limit
562@table @asis
563@item @emph{Description}:
564Specifies the number of threads used by default in subsequent parallel
565sections, if those do not specify a @code{num_threads} clause. The
566argument of @code{omp_set_num_threads} shall be a positive integer.
d77de738 567
506f068e
TB
568@item @emph{C/C++}:
569@multitable @columnfractions .20 .80
570@item @emph{Prototype}: @tab @code{void omp_set_num_threads(int num_threads);}
571@end multitable
d77de738 572
506f068e
TB
573@item @emph{Fortran}:
574@multitable @columnfractions .20 .80
575@item @emph{Interface}: @tab @code{subroutine omp_set_num_threads(num_threads)}
576@item @tab @code{integer, intent(in) :: num_threads}
577@end multitable
d77de738 578
506f068e
TB
579@item @emph{See also}:
580@ref{OMP_NUM_THREADS}, @ref{omp_get_num_threads}, @ref{omp_get_max_threads}
d77de738 581
506f068e
TB
582@item @emph{Reference}:
583@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.1.
584@end table
d77de738
ML
585
586
506f068e
TB
587
588@node omp_get_num_threads
589@subsection @code{omp_get_num_threads} -- Size of the active team
d77de738
ML
590@table @asis
591@item @emph{Description}:
506f068e
TB
592Returns the number of threads in the current team. In a sequential section of
593the program @code{omp_get_num_threads} returns 1.
d77de738 594
506f068e
TB
595The default team size may be initialized at startup by the
596@env{OMP_NUM_THREADS} environment variable. At runtime, the size
597of the current team may be set either by the @code{NUM_THREADS}
598clause or by @code{omp_set_num_threads}. If none of the above were
599used to define a specific value and @env{OMP_DYNAMIC} is disabled,
600one thread per CPU online is used.
601
602@item @emph{C/C++}:
d77de738 603@multitable @columnfractions .20 .80
506f068e 604@item @emph{Prototype}: @tab @code{int omp_get_num_threads(void);}
d77de738
ML
605@end multitable
606
607@item @emph{Fortran}:
608@multitable @columnfractions .20 .80
506f068e 609@item @emph{Interface}: @tab @code{integer function omp_get_num_threads()}
d77de738
ML
610@end multitable
611
612@item @emph{See also}:
506f068e 613@ref{omp_get_max_threads}, @ref{omp_set_num_threads}, @ref{OMP_NUM_THREADS}
d77de738
ML
614
615@item @emph{Reference}:
506f068e 616@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.2.
d77de738
ML
617@end table
618
619
620
506f068e
TB
621@node omp_get_max_threads
622@subsection @code{omp_get_max_threads} -- Maximum number of threads of parallel region
d77de738
ML
623@table @asis
624@item @emph{Description}:
506f068e
TB
625Return the maximum number of threads used for the current parallel region
626that does not use the clause @code{num_threads}.
d77de738 627
506f068e 628@item @emph{C/C++}:
d77de738 629@multitable @columnfractions .20 .80
506f068e 630@item @emph{Prototype}: @tab @code{int omp_get_max_threads(void);}
d77de738
ML
631@end multitable
632
633@item @emph{Fortran}:
634@multitable @columnfractions .20 .80
506f068e 635@item @emph{Interface}: @tab @code{integer function omp_get_max_threads()}
d77de738
ML
636@end multitable
637
638@item @emph{See also}:
506f068e 639@ref{omp_set_num_threads}, @ref{omp_set_dynamic}, @ref{omp_get_thread_limit}
d77de738
ML
640
641@item @emph{Reference}:
506f068e 642@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.3.
d77de738
ML
643@end table
644
645
646
506f068e
TB
647@node omp_get_thread_num
648@subsection @code{omp_get_thread_num} -- Current thread ID
d77de738
ML
649@table @asis
650@item @emph{Description}:
506f068e
TB
651Returns a unique thread identification number within the current team.
652In a sequential parts of the program, @code{omp_get_thread_num}
653always returns 0. In parallel regions the return value varies
654from 0 to @code{omp_get_num_threads}-1 inclusive. The return
655value of the primary thread of a team is always 0.
d77de738
ML
656
657@item @emph{C/C++}:
658@multitable @columnfractions .20 .80
506f068e 659@item @emph{Prototype}: @tab @code{int omp_get_thread_num(void);}
d77de738
ML
660@end multitable
661
662@item @emph{Fortran}:
663@multitable @columnfractions .20 .80
506f068e 664@item @emph{Interface}: @tab @code{integer function omp_get_thread_num()}
d77de738
ML
665@end multitable
666
667@item @emph{See also}:
506f068e 668@ref{omp_get_num_threads}, @ref{omp_get_ancestor_thread_num}
d77de738
ML
669
670@item @emph{Reference}:
506f068e 671@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.4.
d77de738
ML
672@end table
673
674
675
506f068e
TB
676@node omp_in_parallel
677@subsection @code{omp_in_parallel} -- Whether a parallel region is active
d77de738
ML
678@table @asis
679@item @emph{Description}:
506f068e
TB
680This function returns @code{true} if currently running in parallel,
681@code{false} otherwise. Here, @code{true} and @code{false} represent
682their language-specific counterparts.
d77de738
ML
683
684@item @emph{C/C++}:
685@multitable @columnfractions .20 .80
506f068e 686@item @emph{Prototype}: @tab @code{int omp_in_parallel(void);}
d77de738
ML
687@end multitable
688
689@item @emph{Fortran}:
690@multitable @columnfractions .20 .80
506f068e 691@item @emph{Interface}: @tab @code{logical function omp_in_parallel()}
d77de738
ML
692@end multitable
693
d77de738 694@item @emph{Reference}:
506f068e 695@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.6.
d77de738
ML
696@end table
697
698
506f068e
TB
699@node omp_set_dynamic
700@subsection @code{omp_set_dynamic} -- Enable/disable dynamic teams
d77de738
ML
701@table @asis
702@item @emph{Description}:
506f068e
TB
703Enable or disable the dynamic adjustment of the number of threads
704within a team. The function takes the language-specific equivalent
705of @code{true} and @code{false}, where @code{true} enables dynamic
706adjustment of team sizes and @code{false} disables it.
d77de738 707
506f068e 708@item @emph{C/C++}:
d77de738 709@multitable @columnfractions .20 .80
506f068e 710@item @emph{Prototype}: @tab @code{void omp_set_dynamic(int dynamic_threads);}
d77de738
ML
711@end multitable
712
713@item @emph{Fortran}:
714@multitable @columnfractions .20 .80
506f068e
TB
715@item @emph{Interface}: @tab @code{subroutine omp_set_dynamic(dynamic_threads)}
716@item @tab @code{logical, intent(in) :: dynamic_threads}
d77de738
ML
717@end multitable
718
719@item @emph{See also}:
506f068e 720@ref{OMP_DYNAMIC}, @ref{omp_get_dynamic}
d77de738
ML
721
722@item @emph{Reference}:
506f068e 723@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.7.
d77de738
ML
724@end table
725
726
727
728@node omp_get_dynamic
506f068e 729@subsection @code{omp_get_dynamic} -- Dynamic teams setting
d77de738
ML
730@table @asis
731@item @emph{Description}:
732This function returns @code{true} if enabled, @code{false} otherwise.
733Here, @code{true} and @code{false} represent their language-specific
734counterparts.
735
736The dynamic team setting may be initialized at startup by the
737@env{OMP_DYNAMIC} environment variable or at runtime using
738@code{omp_set_dynamic}. If undefined, dynamic adjustment is
739disabled by default.
740
741@item @emph{C/C++}:
742@multitable @columnfractions .20 .80
743@item @emph{Prototype}: @tab @code{int omp_get_dynamic(void);}
744@end multitable
745
746@item @emph{Fortran}:
747@multitable @columnfractions .20 .80
748@item @emph{Interface}: @tab @code{logical function omp_get_dynamic()}
749@end multitable
750
751@item @emph{See also}:
752@ref{omp_set_dynamic}, @ref{OMP_DYNAMIC}
753
754@item @emph{Reference}:
755@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.8.
756@end table
757
758
759
506f068e
TB
760@node omp_get_cancellation
761@subsection @code{omp_get_cancellation} -- Whether cancellation support is enabled
d77de738
ML
762@table @asis
763@item @emph{Description}:
506f068e
TB
764This function returns @code{true} if cancellation is activated, @code{false}
765otherwise. Here, @code{true} and @code{false} represent their language-specific
766counterparts. Unless @env{OMP_CANCELLATION} is set true, cancellations are
767deactivated.
d77de738 768
506f068e 769@item @emph{C/C++}:
d77de738 770@multitable @columnfractions .20 .80
506f068e 771@item @emph{Prototype}: @tab @code{int omp_get_cancellation(void);}
d77de738
ML
772@end multitable
773
774@item @emph{Fortran}:
775@multitable @columnfractions .20 .80
506f068e 776@item @emph{Interface}: @tab @code{logical function omp_get_cancellation()}
d77de738
ML
777@end multitable
778
779@item @emph{See also}:
506f068e 780@ref{OMP_CANCELLATION}
d77de738
ML
781
782@item @emph{Reference}:
506f068e 783@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.9.
d77de738
ML
784@end table
785
786
787
506f068e
TB
788@node omp_set_nested
789@subsection @code{omp_set_nested} -- Enable/disable nested parallel regions
d77de738
ML
790@table @asis
791@item @emph{Description}:
506f068e
TB
792Enable or disable nested parallel regions, i.e., whether team members
793are allowed to create new teams. The function takes the language-specific
794equivalent of @code{true} and @code{false}, where @code{true} enables
795dynamic adjustment of team sizes and @code{false} disables it.
d77de738 796
15886c03 797Enabling nested parallel regions also sets the maximum number of
506f068e 798active nested regions to the maximum supported. Disabling nested parallel
15886c03 799regions sets the maximum number of active nested regions to one.
506f068e
TB
800
801Note that the @code{omp_set_nested} API routine was deprecated
802in the OpenMP specification 5.2 in favor of @code{omp_set_max_active_levels}.
803
804@item @emph{C/C++}:
d77de738 805@multitable @columnfractions .20 .80
506f068e 806@item @emph{Prototype}: @tab @code{void omp_set_nested(int nested);}
d77de738
ML
807@end multitable
808
809@item @emph{Fortran}:
810@multitable @columnfractions .20 .80
506f068e
TB
811@item @emph{Interface}: @tab @code{subroutine omp_set_nested(nested)}
812@item @tab @code{logical, intent(in) :: nested}
d77de738
ML
813@end multitable
814
815@item @emph{See also}:
506f068e
TB
816@ref{omp_get_nested}, @ref{omp_set_max_active_levels},
817@ref{OMP_MAX_ACTIVE_LEVELS}, @ref{OMP_NESTED}
d77de738
ML
818
819@item @emph{Reference}:
506f068e 820@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.10.
d77de738
ML
821@end table
822
823
824
506f068e
TB
825@node omp_get_nested
826@subsection @code{omp_get_nested} -- Nested parallel regions
d77de738
ML
827@table @asis
828@item @emph{Description}:
506f068e
TB
829This function returns @code{true} if nested parallel regions are
830enabled, @code{false} otherwise. Here, @code{true} and @code{false}
831represent their language-specific counterparts.
832
833The state of nested parallel regions at startup depends on several
834environment variables. If @env{OMP_MAX_ACTIVE_LEVELS} is defined
835and is set to greater than one, then nested parallel regions will be
836enabled. If not defined, then the value of the @env{OMP_NESTED}
837environment variable will be followed if defined. If neither are
838defined, then if either @env{OMP_NUM_THREADS} or @env{OMP_PROC_BIND}
839are defined with a list of more than one value, then nested parallel
840regions are enabled. If none of these are defined, then nested parallel
841regions are disabled by default.
842
843Nested parallel regions can be enabled or disabled at runtime using
844@code{omp_set_nested}, or by setting the maximum number of nested
845regions with @code{omp_set_max_active_levels} to one to disable, or
846above one to enable.
847
848Note that the @code{omp_get_nested} API routine was deprecated
849in the OpenMP specification 5.2 in favor of @code{omp_get_max_active_levels}.
850
851@item @emph{C/C++}:
852@multitable @columnfractions .20 .80
853@item @emph{Prototype}: @tab @code{int omp_get_nested(void);}
854@end multitable
855
856@item @emph{Fortran}:
857@multitable @columnfractions .20 .80
858@item @emph{Interface}: @tab @code{logical function omp_get_nested()}
859@end multitable
860
861@item @emph{See also}:
862@ref{omp_get_max_active_levels}, @ref{omp_set_nested},
863@ref{OMP_MAX_ACTIVE_LEVELS}, @ref{OMP_NESTED}
864
865@item @emph{Reference}:
866@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.11.
867@end table
868
869
870
871@node omp_set_schedule
872@subsection @code{omp_set_schedule} -- Set the runtime scheduling method
873@table @asis
874@item @emph{Description}:
875Sets the runtime scheduling method. The @var{kind} argument can have the
876value @code{omp_sched_static}, @code{omp_sched_dynamic},
877@code{omp_sched_guided} or @code{omp_sched_auto}. Except for
878@code{omp_sched_auto}, the chunk size is set to the value of
879@var{chunk_size} if positive, or to the default value if zero or negative.
880For @code{omp_sched_auto} the @var{chunk_size} argument is ignored.
d77de738
ML
881
882@item @emph{C/C++}
883@multitable @columnfractions .20 .80
506f068e 884@item @emph{Prototype}: @tab @code{void omp_set_schedule(omp_sched_t kind, int chunk_size);}
d77de738
ML
885@end multitable
886
887@item @emph{Fortran}:
888@multitable @columnfractions .20 .80
506f068e
TB
889@item @emph{Interface}: @tab @code{subroutine omp_set_schedule(kind, chunk_size)}
890@item @tab @code{integer(kind=omp_sched_kind) kind}
891@item @tab @code{integer chunk_size}
d77de738
ML
892@end multitable
893
894@item @emph{See also}:
506f068e
TB
895@ref{omp_get_schedule}
896@ref{OMP_SCHEDULE}
d77de738
ML
897
898@item @emph{Reference}:
506f068e 899@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.12.
d77de738
ML
900@end table
901
902
506f068e
TB
903
904@node omp_get_schedule
905@subsection @code{omp_get_schedule} -- Obtain the runtime scheduling method
d77de738
ML
906@table @asis
907@item @emph{Description}:
15886c03
TB
908Obtain the runtime scheduling method. The @var{kind} argument is set to
909@code{omp_sched_static}, @code{omp_sched_dynamic},
506f068e
TB
910@code{omp_sched_guided} or @code{omp_sched_auto}. The second argument,
911@var{chunk_size}, is set to the chunk size.
d77de738
ML
912
913@item @emph{C/C++}
914@multitable @columnfractions .20 .80
506f068e 915@item @emph{Prototype}: @tab @code{void omp_get_schedule(omp_sched_t *kind, int *chunk_size);}
d77de738
ML
916@end multitable
917
918@item @emph{Fortran}:
919@multitable @columnfractions .20 .80
506f068e
TB
920@item @emph{Interface}: @tab @code{subroutine omp_get_schedule(kind, chunk_size)}
921@item @tab @code{integer(kind=omp_sched_kind) kind}
922@item @tab @code{integer chunk_size}
d77de738
ML
923@end multitable
924
506f068e
TB
925@item @emph{See also}:
926@ref{omp_set_schedule}, @ref{OMP_SCHEDULE}
927
d77de738 928@item @emph{Reference}:
506f068e 929@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.13.
d77de738
ML
930@end table
931
932
506f068e
TB
933@node omp_get_teams_thread_limit
934@subsection @code{omp_get_teams_thread_limit} -- Maximum number of threads imposed by teams
d77de738
ML
935@table @asis
936@item @emph{Description}:
15886c03 937Return the maximum number of threads that are able to participate in
506f068e 938each team created by a teams construct.
d77de738
ML
939
940@item @emph{C/C++}:
941@multitable @columnfractions .20 .80
506f068e 942@item @emph{Prototype}: @tab @code{int omp_get_teams_thread_limit(void);}
d77de738
ML
943@end multitable
944
945@item @emph{Fortran}:
946@multitable @columnfractions .20 .80
506f068e 947@item @emph{Interface}: @tab @code{integer function omp_get_teams_thread_limit()}
d77de738
ML
948@end multitable
949
950@item @emph{See also}:
506f068e 951@ref{omp_set_teams_thread_limit}, @ref{OMP_TEAMS_THREAD_LIMIT}
d77de738
ML
952
953@item @emph{Reference}:
506f068e 954@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.4.6.
d77de738
ML
955@end table
956
957
958
506f068e
TB
959@node omp_get_supported_active_levels
960@subsection @code{omp_get_supported_active_levels} -- Maximum number of active regions supported
d77de738
ML
961@table @asis
962@item @emph{Description}:
506f068e
TB
963This function returns the maximum number of nested, active parallel regions
964supported by this implementation.
d77de738 965
506f068e 966@item @emph{C/C++}
d77de738 967@multitable @columnfractions .20 .80
506f068e 968@item @emph{Prototype}: @tab @code{int omp_get_supported_active_levels(void);}
d77de738
ML
969@end multitable
970
971@item @emph{Fortran}:
972@multitable @columnfractions .20 .80
506f068e 973@item @emph{Interface}: @tab @code{integer function omp_get_supported_active_levels()}
d77de738
ML
974@end multitable
975
976@item @emph{See also}:
506f068e 977@ref{omp_get_max_active_levels}, @ref{omp_set_max_active_levels}
d77de738
ML
978
979@item @emph{Reference}:
506f068e 980@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.2.15.
d77de738
ML
981@end table
982
983
984
506f068e
TB
985@node omp_set_max_active_levels
986@subsection @code{omp_set_max_active_levels} -- Limits the number of active parallel regions
d77de738
ML
987@table @asis
988@item @emph{Description}:
506f068e
TB
989This function limits the maximum allowed number of nested, active
990parallel regions. @var{max_levels} must be less or equal to
991the value returned by @code{omp_get_supported_active_levels}.
d77de738 992
506f068e
TB
993@item @emph{C/C++}
994@multitable @columnfractions .20 .80
995@item @emph{Prototype}: @tab @code{void omp_set_max_active_levels(int max_levels);}
996@end multitable
d77de738 997
506f068e
TB
998@item @emph{Fortran}:
999@multitable @columnfractions .20 .80
1000@item @emph{Interface}: @tab @code{subroutine omp_set_max_active_levels(max_levels)}
1001@item @tab @code{integer max_levels}
1002@end multitable
d77de738 1003
506f068e
TB
1004@item @emph{See also}:
1005@ref{omp_get_max_active_levels}, @ref{omp_get_active_level},
1006@ref{omp_get_supported_active_levels}
2cd0689a 1007
506f068e
TB
1008@item @emph{Reference}:
1009@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.15.
1010@end table
1011
1012
1013
1014@node omp_get_max_active_levels
1015@subsection @code{omp_get_max_active_levels} -- Current maximum number of active regions
1016@table @asis
1017@item @emph{Description}:
1018This function obtains the maximum allowed number of nested, active parallel regions.
1019
1020@item @emph{C/C++}
d77de738 1021@multitable @columnfractions .20 .80
506f068e 1022@item @emph{Prototype}: @tab @code{int omp_get_max_active_levels(void);}
d77de738
ML
1023@end multitable
1024
1025@item @emph{Fortran}:
1026@multitable @columnfractions .20 .80
506f068e 1027@item @emph{Interface}: @tab @code{integer function omp_get_max_active_levels()}
d77de738
ML
1028@end multitable
1029
1030@item @emph{See also}:
506f068e 1031@ref{omp_set_max_active_levels}, @ref{omp_get_active_level}
d77de738
ML
1032
1033@item @emph{Reference}:
506f068e 1034@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.16.
d77de738
ML
1035@end table
1036
1037
506f068e
TB
1038@node omp_get_level
1039@subsection @code{omp_get_level} -- Obtain the current nesting level
d77de738
ML
1040@table @asis
1041@item @emph{Description}:
506f068e
TB
1042This function returns the nesting level for the parallel blocks,
1043which enclose the calling call.
d77de738 1044
506f068e 1045@item @emph{C/C++}
d77de738 1046@multitable @columnfractions .20 .80
506f068e 1047@item @emph{Prototype}: @tab @code{int omp_get_level(void);}
d77de738
ML
1048@end multitable
1049
1050@item @emph{Fortran}:
1051@multitable @columnfractions .20 .80
506f068e 1052@item @emph{Interface}: @tab @code{integer function omp_level()}
d77de738
ML
1053@end multitable
1054
506f068e
TB
1055@item @emph{See also}:
1056@ref{omp_get_active_level}
1057
d77de738 1058@item @emph{Reference}:
506f068e 1059@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.17.
d77de738
ML
1060@end table
1061
1062
1063
506f068e
TB
1064@node omp_get_ancestor_thread_num
1065@subsection @code{omp_get_ancestor_thread_num} -- Ancestor thread ID
d77de738
ML
1066@table @asis
1067@item @emph{Description}:
506f068e
TB
1068This function returns the thread identification number for the given
1069nesting level of the current thread. For values of @var{level} outside
1070zero to @code{omp_get_level} -1 is returned; if @var{level} is
1071@code{omp_get_level} the result is identical to @code{omp_get_thread_num}.
d77de738 1072
506f068e 1073@item @emph{C/C++}
d77de738 1074@multitable @columnfractions .20 .80
506f068e 1075@item @emph{Prototype}: @tab @code{int omp_get_ancestor_thread_num(int level);}
d77de738
ML
1076@end multitable
1077
1078@item @emph{Fortran}:
1079@multitable @columnfractions .20 .80
506f068e
TB
1080@item @emph{Interface}: @tab @code{integer function omp_get_ancestor_thread_num(level)}
1081@item @tab @code{integer level}
d77de738
ML
1082@end multitable
1083
506f068e
TB
1084@item @emph{See also}:
1085@ref{omp_get_level}, @ref{omp_get_thread_num}, @ref{omp_get_team_size}
1086
d77de738 1087@item @emph{Reference}:
506f068e 1088@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.18.
d77de738
ML
1089@end table
1090
1091
1092
506f068e
TB
1093@node omp_get_team_size
1094@subsection @code{omp_get_team_size} -- Number of threads in a team
d77de738
ML
1095@table @asis
1096@item @emph{Description}:
506f068e
TB
1097This function returns the number of threads in a thread team to which
1098either the current thread or its ancestor belongs. For values of @var{level}
1099outside zero to @code{omp_get_level}, -1 is returned; if @var{level} is zero,
11001 is returned, and for @code{omp_get_level}, the result is identical
1101to @code{omp_get_num_threads}.
d77de738
ML
1102
1103@item @emph{C/C++}:
1104@multitable @columnfractions .20 .80
506f068e 1105@item @emph{Prototype}: @tab @code{int omp_get_team_size(int level);}
d77de738
ML
1106@end multitable
1107
1108@item @emph{Fortran}:
1109@multitable @columnfractions .20 .80
506f068e
TB
1110@item @emph{Interface}: @tab @code{integer function omp_get_team_size(level)}
1111@item @tab @code{integer level}
d77de738
ML
1112@end multitable
1113
506f068e
TB
1114@item @emph{See also}:
1115@ref{omp_get_num_threads}, @ref{omp_get_level}, @ref{omp_get_ancestor_thread_num}
1116
d77de738 1117@item @emph{Reference}:
506f068e 1118@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.19.
d77de738
ML
1119@end table
1120
1121
1122
506f068e
TB
1123@node omp_get_active_level
1124@subsection @code{omp_get_active_level} -- Number of parallel regions
d77de738
ML
1125@table @asis
1126@item @emph{Description}:
506f068e
TB
1127This function returns the nesting level for the active parallel blocks,
1128which enclose the calling call.
d77de738 1129
506f068e 1130@item @emph{C/C++}
d77de738 1131@multitable @columnfractions .20 .80
506f068e 1132@item @emph{Prototype}: @tab @code{int omp_get_active_level(void);}
d77de738
ML
1133@end multitable
1134
1135@item @emph{Fortran}:
1136@multitable @columnfractions .20 .80
506f068e 1137@item @emph{Interface}: @tab @code{integer function omp_get_active_level()}
d77de738
ML
1138@end multitable
1139
1140@item @emph{See also}:
506f068e 1141@ref{omp_get_level}, @ref{omp_get_max_active_levels}, @ref{omp_set_max_active_levels}
d77de738
ML
1142
1143@item @emph{Reference}:
506f068e 1144@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.20.
d77de738
ML
1145@end table
1146
1147
1148
506f068e
TB
1149@node Thread Affinity Routines
1150@section Thread Affinity Routines
1151
1152Routines controlling and accessing thread-affinity policies.
1153They have C linkage and do not throw exceptions.
1154
1155@menu
1156* omp_get_proc_bind:: Whether threads may be moved between CPUs
1157@c * omp_get_num_places:: <fixme>
1158@c * omp_get_place_num_procs:: <fixme>
1159@c * omp_get_place_proc_ids:: <fixme>
1160@c * omp_get_place_num:: <fixme>
1161@c * omp_get_partition_num_places:: <fixme>
1162@c * omp_get_partition_place_nums:: <fixme>
1163@c * omp_set_affinity_format:: <fixme>
1164@c * omp_get_affinity_format:: <fixme>
1165@c * omp_display_affinity:: <fixme>
1166@c * omp_capture_affinity:: <fixme>
1167@end menu
1168
1169
1170
d77de738 1171@node omp_get_proc_bind
506f068e 1172@subsection @code{omp_get_proc_bind} -- Whether threads may be moved between CPUs
d77de738
ML
1173@table @asis
1174@item @emph{Description}:
1175This functions returns the currently active thread affinity policy, which is
1176set via @env{OMP_PROC_BIND}. Possible values are @code{omp_proc_bind_false},
1177@code{omp_proc_bind_true}, @code{omp_proc_bind_primary},
1178@code{omp_proc_bind_master}, @code{omp_proc_bind_close} and @code{omp_proc_bind_spread},
1179where @code{omp_proc_bind_master} is an alias for @code{omp_proc_bind_primary}.
1180
1181@item @emph{C/C++}:
1182@multitable @columnfractions .20 .80
1183@item @emph{Prototype}: @tab @code{omp_proc_bind_t omp_get_proc_bind(void);}
1184@end multitable
1185
1186@item @emph{Fortran}:
1187@multitable @columnfractions .20 .80
1188@item @emph{Interface}: @tab @code{integer(kind=omp_proc_bind_kind) function omp_get_proc_bind()}
1189@end multitable
1190
1191@item @emph{See also}:
1192@ref{OMP_PROC_BIND}, @ref{OMP_PLACES}, @ref{GOMP_CPU_AFFINITY},
1193
1194@item @emph{Reference}:
1195@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.22.
1196@end table
1197
1198
1199
506f068e
TB
1200@node Teams Region Routines
1201@section Teams Region Routines
d77de738 1202
506f068e
TB
1203Routines controlling the league of teams that are executed in a @code{teams}
1204region. They have C linkage and do not throw exceptions.
d77de738 1205
506f068e
TB
1206@menu
1207* omp_get_num_teams:: Number of teams
1208* omp_get_team_num:: Get team number
1209* omp_set_num_teams:: Set upper teams limit for teams region
1210* omp_get_max_teams:: Maximum number of teams for teams region
1211* omp_set_teams_thread_limit:: Set upper thread limit for teams construct
1212* omp_get_thread_limit:: Maximum number of threads
1213@end menu
d77de738 1214
d77de738
ML
1215
1216
506f068e
TB
1217@node omp_get_num_teams
1218@subsection @code{omp_get_num_teams} -- Number of teams
d77de738
ML
1219@table @asis
1220@item @emph{Description}:
506f068e 1221Returns the number of teams in the current team region.
d77de738 1222
506f068e 1223@item @emph{C/C++}:
d77de738 1224@multitable @columnfractions .20 .80
506f068e 1225@item @emph{Prototype}: @tab @code{int omp_get_num_teams(void);}
d77de738
ML
1226@end multitable
1227
1228@item @emph{Fortran}:
1229@multitable @columnfractions .20 .80
506f068e 1230@item @emph{Interface}: @tab @code{integer function omp_get_num_teams()}
d77de738
ML
1231@end multitable
1232
d77de738 1233@item @emph{Reference}:
506f068e 1234@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.32.
d77de738
ML
1235@end table
1236
1237
1238
1239@node omp_get_team_num
506f068e 1240@subsection @code{omp_get_team_num} -- Get team number
d77de738
ML
1241@table @asis
1242@item @emph{Description}:
1243Returns the team number of the calling thread.
1244
1245@item @emph{C/C++}:
1246@multitable @columnfractions .20 .80
1247@item @emph{Prototype}: @tab @code{int omp_get_team_num(void);}
1248@end multitable
1249
1250@item @emph{Fortran}:
1251@multitable @columnfractions .20 .80
1252@item @emph{Interface}: @tab @code{integer function omp_get_team_num()}
1253@end multitable
1254
1255@item @emph{Reference}:
1256@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.33.
1257@end table
1258
1259
1260
506f068e
TB
1261@node omp_set_num_teams
1262@subsection @code{omp_set_num_teams} -- Set upper teams limit for teams construct
d77de738
ML
1263@table @asis
1264@item @emph{Description}:
506f068e
TB
1265Specifies the upper bound for number of teams created by the teams construct
1266which does not specify a @code{num_teams} clause. The
1267argument of @code{omp_set_num_teams} shall be a positive integer.
d77de738
ML
1268
1269@item @emph{C/C++}:
1270@multitable @columnfractions .20 .80
506f068e 1271@item @emph{Prototype}: @tab @code{void omp_set_num_teams(int num_teams);}
d77de738
ML
1272@end multitable
1273
1274@item @emph{Fortran}:
1275@multitable @columnfractions .20 .80
506f068e
TB
1276@item @emph{Interface}: @tab @code{subroutine omp_set_num_teams(num_teams)}
1277@item @tab @code{integer, intent(in) :: num_teams}
d77de738
ML
1278@end multitable
1279
1280@item @emph{See also}:
506f068e 1281@ref{OMP_NUM_TEAMS}, @ref{omp_get_num_teams}, @ref{omp_get_max_teams}
d77de738
ML
1282
1283@item @emph{Reference}:
506f068e 1284@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.4.3.
d77de738
ML
1285@end table
1286
1287
1288
506f068e
TB
1289@node omp_get_max_teams
1290@subsection @code{omp_get_max_teams} -- Maximum number of teams of teams region
d77de738
ML
1291@table @asis
1292@item @emph{Description}:
506f068e
TB
1293Return the maximum number of teams used for the teams region
1294that does not use the clause @code{num_teams}.
d77de738
ML
1295
1296@item @emph{C/C++}:
1297@multitable @columnfractions .20 .80
506f068e 1298@item @emph{Prototype}: @tab @code{int omp_get_max_teams(void);}
d77de738
ML
1299@end multitable
1300
1301@item @emph{Fortran}:
1302@multitable @columnfractions .20 .80
506f068e 1303@item @emph{Interface}: @tab @code{integer function omp_get_max_teams()}
d77de738
ML
1304@end multitable
1305
1306@item @emph{See also}:
506f068e 1307@ref{omp_set_num_teams}, @ref{omp_get_num_teams}
d77de738
ML
1308
1309@item @emph{Reference}:
506f068e 1310@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.4.4.
d77de738
ML
1311@end table
1312
1313
1314
506f068e
TB
1315@node omp_set_teams_thread_limit
1316@subsection @code{omp_set_teams_thread_limit} -- Set upper thread limit for teams construct
d77de738
ML
1317@table @asis
1318@item @emph{Description}:
15886c03 1319Specifies the upper bound for number of threads that are available
506f068e
TB
1320for each team created by the teams construct which does not specify a
1321@code{thread_limit} clause. The argument of
1322@code{omp_set_teams_thread_limit} shall be a positive integer.
d77de738
ML
1323
1324@item @emph{C/C++}:
1325@multitable @columnfractions .20 .80
506f068e 1326@item @emph{Prototype}: @tab @code{void omp_set_teams_thread_limit(int thread_limit);}
d77de738
ML
1327@end multitable
1328
1329@item @emph{Fortran}:
1330@multitable @columnfractions .20 .80
506f068e
TB
1331@item @emph{Interface}: @tab @code{subroutine omp_set_teams_thread_limit(thread_limit)}
1332@item @tab @code{integer, intent(in) :: thread_limit}
d77de738
ML
1333@end multitable
1334
1335@item @emph{See also}:
506f068e 1336@ref{OMP_TEAMS_THREAD_LIMIT}, @ref{omp_get_teams_thread_limit}, @ref{omp_get_thread_limit}
d77de738
ML
1337
1338@item @emph{Reference}:
506f068e 1339@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.4.5.
d77de738
ML
1340@end table
1341
1342
1343
506f068e
TB
1344@node omp_get_thread_limit
1345@subsection @code{omp_get_thread_limit} -- Maximum number of threads
d77de738
ML
1346@table @asis
1347@item @emph{Description}:
506f068e 1348Return the maximum number of threads of the program.
d77de738
ML
1349
1350@item @emph{C/C++}:
1351@multitable @columnfractions .20 .80
506f068e 1352@item @emph{Prototype}: @tab @code{int omp_get_thread_limit(void);}
d77de738
ML
1353@end multitable
1354
1355@item @emph{Fortran}:
1356@multitable @columnfractions .20 .80
506f068e 1357@item @emph{Interface}: @tab @code{integer function omp_get_thread_limit()}
d77de738
ML
1358@end multitable
1359
1360@item @emph{See also}:
506f068e 1361@ref{omp_get_max_threads}, @ref{OMP_THREAD_LIMIT}
d77de738
ML
1362
1363@item @emph{Reference}:
506f068e 1364@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.14.
d77de738
ML
1365@end table
1366
1367
1368
506f068e
TB
1369@node Tasking Routines
1370@section Tasking Routines
1371
1372Routines relating to explicit tasks.
1373They have C linkage and do not throw exceptions.
1374
1375@menu
1376* omp_get_max_task_priority:: Maximum task priority value that can be set
819f3d36 1377* omp_in_explicit_task:: Whether a given task is an explicit task
506f068e
TB
1378* omp_in_final:: Whether in final or included task region
1379@end menu
1380
1381
1382
1383@node omp_get_max_task_priority
1384@subsection @code{omp_get_max_task_priority} -- Maximum priority value
1385that can be set for tasks.
d77de738
ML
1386@table @asis
1387@item @emph{Description}:
506f068e 1388This function obtains the maximum allowed priority number for tasks.
d77de738 1389
506f068e 1390@item @emph{C/C++}
d77de738 1391@multitable @columnfractions .20 .80
506f068e 1392@item @emph{Prototype}: @tab @code{int omp_get_max_task_priority(void);}
d77de738
ML
1393@end multitable
1394
1395@item @emph{Fortran}:
1396@multitable @columnfractions .20 .80
506f068e 1397@item @emph{Interface}: @tab @code{integer function omp_get_max_task_priority()}
d77de738
ML
1398@end multitable
1399
1400@item @emph{Reference}:
506f068e 1401@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.29.
d77de738
ML
1402@end table
1403
1404
506f068e 1405
819f3d36
TB
1406@node omp_in_explicit_task
1407@subsection @code{omp_in_explicit_task} -- Whether a given task is an explicit task
1408@table @asis
1409@item @emph{Description}:
1410The function returns the @var{explicit-task-var} ICV; it returns true when the
1411encountering task was generated by a task-generating construct such as
1412@code{target}, @code{task} or @code{taskloop}. Otherwise, the encountering task
1413is in an implicit task region such as generated by the implicit or explicit
1414@code{parallel} region and @code{omp_in_explicit_task} returns false.
1415
1416@item @emph{C/C++}
1417@multitable @columnfractions .20 .80
1418@item @emph{Prototype}: @tab @code{int omp_in_explicit_task(void);}
1419@end multitable
1420
1421@item @emph{Fortran}:
1422@multitable @columnfractions .20 .80
1423@item @emph{Interface}: @tab @code{logical function omp_in_explicit_task()}
1424@end multitable
1425
1426@item @emph{Reference}:
1427@uref{https://www.openmp.org, OpenMP specification v5.2}, Section 18.5.2.
1428@end table
1429
1430
1431
d77de738 1432@node omp_in_final
506f068e 1433@subsection @code{omp_in_final} -- Whether in final or included task region
d77de738
ML
1434@table @asis
1435@item @emph{Description}:
1436This function returns @code{true} if currently running in a final
1437or included task region, @code{false} otherwise. Here, @code{true}
1438and @code{false} represent their language-specific counterparts.
1439
1440@item @emph{C/C++}:
1441@multitable @columnfractions .20 .80
1442@item @emph{Prototype}: @tab @code{int omp_in_final(void);}
1443@end multitable
1444
1445@item @emph{Fortran}:
1446@multitable @columnfractions .20 .80
1447@item @emph{Interface}: @tab @code{logical function omp_in_final()}
1448@end multitable
1449
1450@item @emph{Reference}:
1451@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.21.
1452@end table
1453
1454
1455
506f068e
TB
1456@c @node Resource Relinquishing Routines
1457@c @section Resource Relinquishing Routines
1458@c
1459@c Routines releasing resources used by the OpenMP runtime.
1460@c They have C linkage and do not throw exceptions.
1461@c
1462@c @menu
1463@c * omp_pause_resource:: <fixme>
1464@c * omp_pause_resource_all:: <fixme>
1465@c @end menu
1466
1467@node Device Information Routines
1468@section Device Information Routines
1469
1470Routines related to devices available to an OpenMP program.
1471They have C linkage and do not throw exceptions.
1472
1473@menu
1474* omp_get_num_procs:: Number of processors online
1475@c * omp_get_max_progress_width:: <fixme>/TR11
1476* omp_set_default_device:: Set the default device for target regions
1477* omp_get_default_device:: Get the default device for target regions
1478* omp_get_num_devices:: Number of target devices
1479* omp_get_device_num:: Get device that current thread is running on
1480* omp_is_initial_device:: Whether executing on the host device
1481* omp_get_initial_device:: Device number of host device
1482@end menu
1483
1484
1485
1486@node omp_get_num_procs
1487@subsection @code{omp_get_num_procs} -- Number of processors online
d77de738
ML
1488@table @asis
1489@item @emph{Description}:
506f068e 1490Returns the number of processors online on that device.
d77de738
ML
1491
1492@item @emph{C/C++}:
1493@multitable @columnfractions .20 .80
506f068e 1494@item @emph{Prototype}: @tab @code{int omp_get_num_procs(void);}
d77de738
ML
1495@end multitable
1496
1497@item @emph{Fortran}:
1498@multitable @columnfractions .20 .80
506f068e 1499@item @emph{Interface}: @tab @code{integer function omp_get_num_procs()}
d77de738
ML
1500@end multitable
1501
1502@item @emph{Reference}:
506f068e 1503@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.5.
d77de738
ML
1504@end table
1505
1506
1507
1508@node omp_set_default_device
506f068e 1509@subsection @code{omp_set_default_device} -- Set the default device for target regions
d77de738
ML
1510@table @asis
1511@item @emph{Description}:
1512Set the default device for target regions without device clause. The argument
1513shall be a nonnegative device number.
1514
1515@item @emph{C/C++}:
1516@multitable @columnfractions .20 .80
1517@item @emph{Prototype}: @tab @code{void omp_set_default_device(int device_num);}
1518@end multitable
1519
1520@item @emph{Fortran}:
1521@multitable @columnfractions .20 .80
1522@item @emph{Interface}: @tab @code{subroutine omp_set_default_device(device_num)}
1523@item @tab @code{integer device_num}
1524@end multitable
1525
1526@item @emph{See also}:
1527@ref{OMP_DEFAULT_DEVICE}, @ref{omp_get_default_device}
1528
1529@item @emph{Reference}:
1530@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.29.
1531@end table
1532
1533
1534
506f068e
TB
1535@node omp_get_default_device
1536@subsection @code{omp_get_default_device} -- Get the default device for target regions
d77de738
ML
1537@table @asis
1538@item @emph{Description}:
506f068e 1539Get the default device for target regions without device clause.
2cd0689a 1540
d77de738
ML
1541@item @emph{C/C++}:
1542@multitable @columnfractions .20 .80
506f068e 1543@item @emph{Prototype}: @tab @code{int omp_get_default_device(void);}
d77de738
ML
1544@end multitable
1545
1546@item @emph{Fortran}:
1547@multitable @columnfractions .20 .80
506f068e 1548@item @emph{Interface}: @tab @code{integer function omp_get_default_device()}
d77de738
ML
1549@end multitable
1550
1551@item @emph{See also}:
506f068e 1552@ref{OMP_DEFAULT_DEVICE}, @ref{omp_set_default_device}
d77de738
ML
1553
1554@item @emph{Reference}:
506f068e 1555@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.30.
d77de738
ML
1556@end table
1557
1558
1559
506f068e
TB
1560@node omp_get_num_devices
1561@subsection @code{omp_get_num_devices} -- Number of target devices
d77de738
ML
1562@table @asis
1563@item @emph{Description}:
506f068e 1564Returns the number of target devices.
d77de738
ML
1565
1566@item @emph{C/C++}:
1567@multitable @columnfractions .20 .80
506f068e 1568@item @emph{Prototype}: @tab @code{int omp_get_num_devices(void);}
d77de738
ML
1569@end multitable
1570
1571@item @emph{Fortran}:
1572@multitable @columnfractions .20 .80
506f068e 1573@item @emph{Interface}: @tab @code{integer function omp_get_num_devices()}
d77de738
ML
1574@end multitable
1575
d77de738 1576@item @emph{Reference}:
506f068e 1577@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.31.
d77de738
ML
1578@end table
1579
1580
1581
506f068e
TB
1582@node omp_get_device_num
1583@subsection @code{omp_get_device_num} -- Return device number of current device
d77de738
ML
1584@table @asis
1585@item @emph{Description}:
506f068e
TB
1586This function returns a device number that represents the device that the
1587current thread is executing on. For OpenMP 5.0, this must be equal to the
1588value returned by the @code{omp_get_initial_device} function when called
1589from the host.
d77de738 1590
506f068e 1591@item @emph{C/C++}
d77de738 1592@multitable @columnfractions .20 .80
506f068e 1593@item @emph{Prototype}: @tab @code{int omp_get_device_num(void);}
d77de738
ML
1594@end multitable
1595
1596@item @emph{Fortran}:
506f068e
TB
1597@multitable @columnfractions .20 .80
1598@item @emph{Interface}: @tab @code{integer function omp_get_device_num()}
d77de738
ML
1599@end multitable
1600
1601@item @emph{See also}:
506f068e 1602@ref{omp_get_initial_device}
d77de738
ML
1603
1604@item @emph{Reference}:
506f068e 1605@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.2.37.
d77de738
ML
1606@end table
1607
1608
1609
506f068e
TB
1610@node omp_is_initial_device
1611@subsection @code{omp_is_initial_device} -- Whether executing on the host device
d77de738
ML
1612@table @asis
1613@item @emph{Description}:
506f068e
TB
1614This function returns @code{true} if currently running on the host device,
1615@code{false} otherwise. Here, @code{true} and @code{false} represent
1616their language-specific counterparts.
d77de738 1617
506f068e 1618@item @emph{C/C++}:
d77de738 1619@multitable @columnfractions .20 .80
506f068e 1620@item @emph{Prototype}: @tab @code{int omp_is_initial_device(void);}
d77de738
ML
1621@end multitable
1622
1623@item @emph{Fortran}:
1624@multitable @columnfractions .20 .80
506f068e 1625@item @emph{Interface}: @tab @code{logical function omp_is_initial_device()}
d77de738
ML
1626@end multitable
1627
d77de738 1628@item @emph{Reference}:
506f068e 1629@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.34.
d77de738
ML
1630@end table
1631
1632
1633
506f068e
TB
1634@node omp_get_initial_device
1635@subsection @code{omp_get_initial_device} -- Return device number of initial device
d77de738
ML
1636@table @asis
1637@item @emph{Description}:
506f068e
TB
1638This function returns a device number that represents the host device.
1639For OpenMP 5.1, this must be equal to the value returned by the
1640@code{omp_get_num_devices} function.
d77de738 1641
506f068e 1642@item @emph{C/C++}
d77de738 1643@multitable @columnfractions .20 .80
506f068e 1644@item @emph{Prototype}: @tab @code{int omp_get_initial_device(void);}
d77de738
ML
1645@end multitable
1646
1647@item @emph{Fortran}:
1648@multitable @columnfractions .20 .80
506f068e 1649@item @emph{Interface}: @tab @code{integer function omp_get_initial_device()}
d77de738
ML
1650@end multitable
1651
1652@item @emph{See also}:
506f068e 1653@ref{omp_get_num_devices}
d77de738
ML
1654
1655@item @emph{Reference}:
506f068e 1656@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.35.
d77de738
ML
1657@end table
1658
1659
1660
e0786ba6
TB
1661@node Device Memory Routines
1662@section Device Memory Routines
1663
1664Routines related to memory allocation and managing corresponding
1665pointers on devices. They have C linkage and do not throw exceptions.
1666
1667@menu
1668* omp_target_alloc:: Allocate device memory
1669* omp_target_free:: Free device memory
1670* omp_target_is_present:: Check whether storage is mapped
506f068e
TB
1671@c * omp_target_is_accessible:: <fixme>
1672@c * omp_target_memcpy:: <fixme>
1673@c * omp_target_memcpy_rect:: <fixme>
1674@c * omp_target_memcpy_async:: <fixme>
1675@c * omp_target_memcpy_rect_async:: <fixme>
e0786ba6
TB
1676@c * omp_target_memset:: <fixme>/TR12
1677@c * omp_target_memset_async:: <fixme>/TR12
1678* omp_target_associate_ptr:: Associate a device pointer with a host pointer
1679* omp_target_disassociate_ptr:: Remove device--host pointer association
1680* omp_get_mapped_ptr:: Return device pointer to a host pointer
1681@end menu
1682
1683
1684
1685@node omp_target_alloc
1686@subsection @code{omp_target_alloc} -- Allocate device memory
1687@table @asis
1688@item @emph{Description}:
1689This routine allocates @var{size} bytes of memory in the device environment
1690associated with the device number @var{device_num}. If successful, a device
1691pointer is returned, otherwise a null pointer.
1692
1693In GCC, when the device is the host or the device shares memory with the host,
1694the memory is allocated on the host; in that case, when @var{size} is zero,
1695either NULL or a unique pointer value that can later be successfully passed to
1696@code{omp_target_free} is returned. When the allocation is not performed on
1697the host, a null pointer is returned when @var{size} is zero; in that case,
1698additionally a diagnostic might be printed to standard error (stderr).
1699
1700Running this routine in a @code{target} region except on the initial device
1701is not supported.
1702
1703@item @emph{C/C++}
1704@multitable @columnfractions .20 .80
1705@item @emph{Prototype}: @tab @code{void *omp_target_alloc(size_t size, int device_num)}
1706@end multitable
1707
1708@item @emph{Fortran}:
1709@multitable @columnfractions .20 .80
1710@item @emph{Interface}: @tab @code{type(c_ptr) function omp_target_alloc(size, device_num) bind(C)}
1711@item @tab @code{use, intrinsic :: iso_c_binding, only: c_ptr, c_int, c_size_t}
1712@item @tab @code{integer(c_size_t), value :: size}
1713@item @tab @code{integer(c_int), value :: device_num}
1714@end multitable
1715
1716@item @emph{See also}:
1717@ref{omp_target_free}, @ref{omp_target_associate_ptr}
1718
1719@item @emph{Reference}:
1720@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 18.8.1
1721@end table
1722
1723
1724
1725@node omp_target_free
1726@subsection @code{omp_target_free} -- Free device memory
1727@table @asis
1728@item @emph{Description}:
1729This routine frees memory allocated by the @code{omp_target_alloc} routine.
1730The @var{device_ptr} argument must be either a null pointer or a device pointer
1731returned by @code{omp_target_alloc} for the specified @code{device_num}. The
1732device number @var{device_num} must be a conforming device number.
1733
1734Running this routine in a @code{target} region except on the initial device
1735is not supported.
1736
1737@item @emph{C/C++}
1738@multitable @columnfractions .20 .80
1739@item @emph{Prototype}: @tab @code{void omp_target_free(void *device_ptr, int device_num)}
1740@end multitable
1741
1742@item @emph{Fortran}:
1743@multitable @columnfractions .20 .80
1744@item @emph{Interface}: @tab @code{subroutine omp_target_free(device_ptr, device_num) bind(C)}
1745@item @tab @code{use, intrinsic :: iso_c_binding, only: c_ptr, c_int}
1746@item @tab @code{type(c_ptr), value :: device_ptr}
1747@item @tab @code{integer(c_int), value :: device_num}
1748@end multitable
1749
1750@item @emph{See also}:
1751@ref{omp_target_alloc}, @ref{omp_target_disassociate_ptr}
1752
1753@item @emph{Reference}:
1754@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 18.8.2
1755@end table
1756
1757
1758
1759@node omp_target_is_present
1760@subsection @code{omp_target_is_present} -- Check whether storage is mapped
1761@table @asis
1762@item @emph{Description}:
1763This routine tests whether storage, identified by the host pointer @var{ptr}
1764is mapped to the device specified by @var{device_num}. If so, it returns
1765@emph{true} and otherwise @emph{false}.
1766
1767In GCC, this includes self mapping such that @code{omp_target_is_present}
1768returns @emph{true} when @var{device_num} specifies the host or when the host
1769and the device share memory. If @var{ptr} is a null pointer, @var{true} is
1770returned and if @var{device_num} is an invalid device number, @var{false} is
1771returned.
1772
1773If those conditions do not apply, @emph{true} is returned if the association has
1774been established by an explicit or implicit @code{map} clause, the
1775@code{declare target} directive or a call to the @code{omp_target_associate_ptr}
1776routine.
1777
1778Running this routine in a @code{target} region except on the initial device
1779is not supported.
1780
1781@item @emph{C/C++}
1782@multitable @columnfractions .20 .80
1783@item @emph{Prototype}: @tab @code{int omp_target_is_present(const void *ptr,}
1784@item @tab @code{ int device_num)}
1785@end multitable
1786
1787@item @emph{Fortran}:
1788@multitable @columnfractions .20 .80
1789@item @emph{Interface}: @tab @code{integer(c_int) function omp_target_is_present(ptr, &}
1790@item @tab @code{ device_num) bind(C)}
1791@item @tab @code{use, intrinsic :: iso_c_binding, only: c_ptr, c_int}
1792@item @tab @code{type(c_ptr), value :: ptr}
1793@item @tab @code{integer(c_int), value :: device_num}
1794@end multitable
1795
1796@item @emph{See also}:
1797@ref{omp_target_associate_ptr}
1798
1799@item @emph{Reference}:
1800@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 18.8.3
1801@end table
1802
1803
1804
1805@node omp_target_associate_ptr
1806@subsection @code{omp_target_associate_ptr} -- Associate a device pointer with a host pointer
1807@table @asis
1808@item @emph{Description}:
1809This routine associates storage on the host with storage on a device identified
1810by @var{device_num}. The device pointer is usually obtained by calling
1811@code{omp_target_alloc} or by other means (but not by using the @code{map}
1812clauses or the @code{declare target} directive). The host pointer should point
1813to memory that has a storage size of at least @var{size}.
1814
1815The @var{device_offset} parameter specifies the offset into @var{device_ptr}
1816that is used as the base address for the device side of the mapping; the
1817storage size should be at least @var{device_offset} plus @var{size}.
1818
1819After the association, the host pointer can be used in a @code{map} clause and
1820in the @code{to} and @code{from} clauses of the @code{target update} directive
1821to transfer data between the associated pointers. The reference count of such
1822associated storage is infinite. The association can be removed by calling
1823@code{omp_target_disassociate_ptr} which should be done before the lifetime
1824of either either storage ends.
1825
1826The routine returns nonzero (@code{EINVAL}) when the @var{device_num} invalid,
1827for when the initial device or the associated device shares memory with the
1828host. @code{omp_target_associate_ptr} returns zero if @var{host_ptr} points
1829into already associated storage that is fully inside of a previously associated
1830memory. Otherwise, if the association was successful zero is returned; if none
1831of the cases above apply, nonzero (@code{EINVAL}) is returned.
1832
1833The @code{omp_target_is_present} routine can be used to test whether
1834associated storage for a device pointer exists.
1835
1836Running this routine in a @code{target} region except on the initial device
1837is not supported.
1838
1839@item @emph{C/C++}
1840@multitable @columnfractions .20 .80
1841@item @emph{Prototype}: @tab @code{int omp_target_associate_ptr(const void *host_ptr,}
1842@item @tab @code{ const void *device_ptr,}
1843@item @tab @code{ size_t size,}
1844@item @tab @code{ size_t device_offset,}
1845@item @tab @code{ int device_num)}
1846@end multitable
1847
1848@item @emph{Fortran}:
1849@multitable @columnfractions .20 .80
1850@item @emph{Interface}: @tab @code{integer(c_int) function omp_target_associate_ptr(host_ptr, &}
1851@item @tab @code{ device_ptr, size, device_offset, device_num) bind(C)}
1852@item @tab @code{use, intrinsic :: iso_c_binding, only: c_ptr, c_int, c_size_t}
1853@item @tab @code{type(c_ptr), value :: host_ptr, device_ptr}
1854@item @tab @code{integer(c_size_t), value :: size, device_offset}
1855@item @tab @code{integer(c_int), value :: device_num}
1856@end multitable
1857
1858@item @emph{See also}:
1859@ref{omp_target_disassociate_ptr}, @ref{omp_target_is_present},
1860@ref{omp_target_alloc}
1861
1862@item @emph{Reference}:
1863@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 18.8.9
1864@end table
1865
1866
1867
1868@node omp_target_disassociate_ptr
1869@subsection @code{omp_target_disassociate_ptr} -- Remove device--host pointer association
1870@table @asis
1871@item @emph{Description}:
1872This routine removes the storage association established by calling
1873@code{omp_target_associate_ptr} and sets the reference count to zero,
1874even if @code{omp_target_associate_ptr} was invoked multiple times for
1875for host pointer @code{ptr}. If applicable, the device memory needs
1876to be freed by the user.
1877
1878If an associated device storage location for the @var{device_num} was
1879found and has infinite reference count, the association is removed and
1880zero is returned. In all other cases, nonzero (@code{EINVAL}) is returned
1881and no other action is taken.
1882
1883Note that passing a host pointer where the association to the device pointer
1884was established with the @code{declare target} directive yields undefined
1885behavior.
1886
1887Running this routine in a @code{target} region except on the initial device
1888is not supported.
1889
1890@item @emph{C/C++}
1891@multitable @columnfractions .20 .80
1892@item @emph{Prototype}: @tab @code{int omp_target_disassociate_ptr(const void *ptr,}
1893@item @tab @code{ int device_num)}
1894@end multitable
1895
1896@item @emph{Fortran}:
1897@multitable @columnfractions .20 .80
1898@item @emph{Interface}: @tab @code{integer(c_int) function omp_target_disassociate_ptr(ptr, &}
1899@item @tab @code{ device_num) bind(C)}
1900@item @tab @code{use, intrinsic :: iso_c_binding, only: c_ptr, c_int}
1901@item @tab @code{type(c_ptr), value :: ptr}
1902@item @tab @code{integer(c_int), value :: device_num}
1903@end multitable
1904
1905@item @emph{See also}:
1906@ref{omp_target_associate_ptr}
1907
1908@item @emph{Reference}:
1909@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 18.8.10
1910@end table
1911
1912
1913
1914@node omp_get_mapped_ptr
1915@subsection @code{omp_get_mapped_ptr} -- Return device pointer to a host pointer
1916@table @asis
1917@item @emph{Description}:
1918If the device number is refers to the initial device or to a device with
1919memory accessible from the host (shared memory), the @code{omp_get_mapped_ptr}
bc238c40 1920routines returns the value of the passed @var{ptr}. Otherwise, if associated
e0786ba6
TB
1921storage to the passed host pointer @var{ptr} exists on device associated with
1922@var{device_num}, it returns that pointer. In all other cases and in cases of
1923an error, a null pointer is returned.
1924
1925The association of storage location is established either via an explicit or
1926implicit @code{map} clause, the @code{declare target} directive or the
1927@code{omp_target_associate_ptr} routine.
1928
1929Running this routine in a @code{target} region except on the initial device
1930is not supported.
1931
1932@item @emph{C/C++}
1933@multitable @columnfractions .20 .80
1934@item @emph{Prototype}: @tab @code{void *omp_get_mapped_ptr(const void *ptr, int device_num);}
1935@end multitable
1936
1937@item @emph{Fortran}:
1938@multitable @columnfractions .20 .80
1939@item @emph{Interface}: @tab @code{type(c_ptr) function omp_get_mapped_ptr(ptr, device_num) bind(C)}
1940@item @tab @code{use, intrinsic :: iso_c_binding, only: c_ptr, c_int}
1941@item @tab @code{type(c_ptr), value :: ptr}
1942@item @tab @code{integer(c_int), value :: device_num}
1943@end multitable
1944
1945@item @emph{See also}:
1946@ref{omp_target_associate_ptr}
1947
1948@item @emph{Reference}:
1949@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 18.8.11
1950@end table
1951
1952
506f068e
TB
1953
1954@node Lock Routines
1955@section Lock Routines
1956
1957Initialize, set, test, unset and destroy simple and nested locks.
1958The routines have C linkage and do not throw exceptions.
1959
1960@menu
1961* omp_init_lock:: Initialize simple lock
1962* omp_init_nest_lock:: Initialize nested lock
1963@c * omp_init_lock_with_hint:: <fixme>
1964@c * omp_init_nest_lock_with_hint:: <fixme>
1965* omp_destroy_lock:: Destroy simple lock
1966* omp_destroy_nest_lock:: Destroy nested lock
1967* omp_set_lock:: Wait for and set simple lock
1968* omp_set_nest_lock:: Wait for and set simple lock
1969* omp_unset_lock:: Unset simple lock
1970* omp_unset_nest_lock:: Unset nested lock
1971* omp_test_lock:: Test and set simple lock if available
1972* omp_test_nest_lock:: Test and set nested lock if available
1973@end menu
1974
1975
1976
d77de738 1977@node omp_init_lock
506f068e 1978@subsection @code{omp_init_lock} -- Initialize simple lock
d77de738
ML
1979@table @asis
1980@item @emph{Description}:
1981Initialize a simple lock. After initialization, the lock is in
1982an unlocked state.
1983
1984@item @emph{C/C++}:
1985@multitable @columnfractions .20 .80
1986@item @emph{Prototype}: @tab @code{void omp_init_lock(omp_lock_t *lock);}
1987@end multitable
1988
1989@item @emph{Fortran}:
1990@multitable @columnfractions .20 .80
1991@item @emph{Interface}: @tab @code{subroutine omp_init_lock(svar)}
1992@item @tab @code{integer(omp_lock_kind), intent(out) :: svar}
1993@end multitable
1994
1995@item @emph{See also}:
1996@ref{omp_destroy_lock}
1997
1998@item @emph{Reference}:
1999@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.1.
2000@end table
2001
2002
2003
506f068e
TB
2004@node omp_init_nest_lock
2005@subsection @code{omp_init_nest_lock} -- Initialize nested lock
d77de738
ML
2006@table @asis
2007@item @emph{Description}:
506f068e
TB
2008Initialize a nested lock. After initialization, the lock is in
2009an unlocked state and the nesting count is set to zero.
d77de738
ML
2010
2011@item @emph{C/C++}:
2012@multitable @columnfractions .20 .80
506f068e 2013@item @emph{Prototype}: @tab @code{void omp_init_nest_lock(omp_nest_lock_t *lock);}
d77de738
ML
2014@end multitable
2015
2016@item @emph{Fortran}:
2017@multitable @columnfractions .20 .80
506f068e
TB
2018@item @emph{Interface}: @tab @code{subroutine omp_init_nest_lock(nvar)}
2019@item @tab @code{integer(omp_nest_lock_kind), intent(out) :: nvar}
d77de738
ML
2020@end multitable
2021
2022@item @emph{See also}:
506f068e 2023@ref{omp_destroy_nest_lock}
d77de738 2024
506f068e
TB
2025@item @emph{Reference}:
2026@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.1.
d77de738
ML
2027@end table
2028
2029
2030
506f068e
TB
2031@node omp_destroy_lock
2032@subsection @code{omp_destroy_lock} -- Destroy simple lock
d77de738
ML
2033@table @asis
2034@item @emph{Description}:
506f068e
TB
2035Destroy a simple lock. In order to be destroyed, a simple lock must be
2036in the unlocked state.
d77de738
ML
2037
2038@item @emph{C/C++}:
2039@multitable @columnfractions .20 .80
506f068e 2040@item @emph{Prototype}: @tab @code{void omp_destroy_lock(omp_lock_t *lock);}
d77de738
ML
2041@end multitable
2042
2043@item @emph{Fortran}:
2044@multitable @columnfractions .20 .80
506f068e 2045@item @emph{Interface}: @tab @code{subroutine omp_destroy_lock(svar)}
d77de738
ML
2046@item @tab @code{integer(omp_lock_kind), intent(inout) :: svar}
2047@end multitable
2048
2049@item @emph{See also}:
506f068e 2050@ref{omp_init_lock}
d77de738
ML
2051
2052@item @emph{Reference}:
506f068e 2053@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.3.
d77de738
ML
2054@end table
2055
2056
2057
506f068e
TB
2058@node omp_destroy_nest_lock
2059@subsection @code{omp_destroy_nest_lock} -- Destroy nested lock
d77de738
ML
2060@table @asis
2061@item @emph{Description}:
506f068e
TB
2062Destroy a nested lock. In order to be destroyed, a nested lock must be
2063in the unlocked state and its nesting count must equal zero.
d77de738
ML
2064
2065@item @emph{C/C++}:
2066@multitable @columnfractions .20 .80
506f068e 2067@item @emph{Prototype}: @tab @code{void omp_destroy_nest_lock(omp_nest_lock_t *);}
d77de738
ML
2068@end multitable
2069
2070@item @emph{Fortran}:
2071@multitable @columnfractions .20 .80
506f068e
TB
2072@item @emph{Interface}: @tab @code{subroutine omp_destroy_nest_lock(nvar)}
2073@item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: nvar}
d77de738
ML
2074@end multitable
2075
2076@item @emph{See also}:
506f068e 2077@ref{omp_init_lock}
d77de738
ML
2078
2079@item @emph{Reference}:
506f068e 2080@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.3.
d77de738
ML
2081@end table
2082
2083
2084
506f068e
TB
2085@node omp_set_lock
2086@subsection @code{omp_set_lock} -- Wait for and set simple lock
d77de738
ML
2087@table @asis
2088@item @emph{Description}:
506f068e
TB
2089Before setting a simple lock, the lock variable must be initialized by
2090@code{omp_init_lock}. The calling thread is blocked until the lock
2091is available. If the lock is already held by the current thread,
2092a deadlock occurs.
d77de738
ML
2093
2094@item @emph{C/C++}:
2095@multitable @columnfractions .20 .80
506f068e 2096@item @emph{Prototype}: @tab @code{void omp_set_lock(omp_lock_t *lock);}
d77de738
ML
2097@end multitable
2098
2099@item @emph{Fortran}:
2100@multitable @columnfractions .20 .80
506f068e 2101@item @emph{Interface}: @tab @code{subroutine omp_set_lock(svar)}
d77de738
ML
2102@item @tab @code{integer(omp_lock_kind), intent(inout) :: svar}
2103@end multitable
2104
2105@item @emph{See also}:
506f068e 2106@ref{omp_init_lock}, @ref{omp_test_lock}, @ref{omp_unset_lock}
d77de738
ML
2107
2108@item @emph{Reference}:
506f068e 2109@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.4.
d77de738
ML
2110@end table
2111
2112
2113
d77de738 2114@node omp_set_nest_lock
506f068e 2115@subsection @code{omp_set_nest_lock} -- Wait for and set nested lock
d77de738
ML
2116@table @asis
2117@item @emph{Description}:
2118Before setting a nested lock, the lock variable must be initialized by
2119@code{omp_init_nest_lock}. The calling thread is blocked until the lock
2120is available. If the lock is already held by the current thread, the
2121nesting count for the lock is incremented.
2122
2123@item @emph{C/C++}:
2124@multitable @columnfractions .20 .80
2125@item @emph{Prototype}: @tab @code{void omp_set_nest_lock(omp_nest_lock_t *lock);}
2126@end multitable
2127
2128@item @emph{Fortran}:
2129@multitable @columnfractions .20 .80
2130@item @emph{Interface}: @tab @code{subroutine omp_set_nest_lock(nvar)}
2131@item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: nvar}
2132@end multitable
2133
2134@item @emph{See also}:
2135@ref{omp_init_nest_lock}, @ref{omp_unset_nest_lock}
2136
2137@item @emph{Reference}:
2138@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.4.
2139@end table
2140
2141
2142
506f068e
TB
2143@node omp_unset_lock
2144@subsection @code{omp_unset_lock} -- Unset simple lock
d77de738
ML
2145@table @asis
2146@item @emph{Description}:
506f068e
TB
2147A simple lock about to be unset must have been locked by @code{omp_set_lock}
2148or @code{omp_test_lock} before. In addition, the lock must be held by the
2149thread calling @code{omp_unset_lock}. Then, the lock becomes unlocked. If one
2150or more threads attempted to set the lock before, one of them is chosen to,
2151again, set the lock to itself.
d77de738
ML
2152
2153@item @emph{C/C++}:
2154@multitable @columnfractions .20 .80
506f068e 2155@item @emph{Prototype}: @tab @code{void omp_unset_lock(omp_lock_t *lock);}
d77de738
ML
2156@end multitable
2157
2158@item @emph{Fortran}:
2159@multitable @columnfractions .20 .80
506f068e
TB
2160@item @emph{Interface}: @tab @code{subroutine omp_unset_lock(svar)}
2161@item @tab @code{integer(omp_lock_kind), intent(inout) :: svar}
d77de738
ML
2162@end multitable
2163
d77de738 2164@item @emph{See also}:
506f068e 2165@ref{omp_set_lock}, @ref{omp_test_lock}
d77de738
ML
2166
2167@item @emph{Reference}:
506f068e 2168@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.5.
d77de738
ML
2169@end table
2170
2171
2172
2173@node omp_unset_nest_lock
506f068e 2174@subsection @code{omp_unset_nest_lock} -- Unset nested lock
d77de738
ML
2175@table @asis
2176@item @emph{Description}:
2177A nested lock about to be unset must have been locked by @code{omp_set_nested_lock}
2178or @code{omp_test_nested_lock} before. In addition, the lock must be held by the
2179thread calling @code{omp_unset_nested_lock}. If the nesting count drops to zero, the
2180lock becomes unlocked. If one ore more threads attempted to set the lock before,
2181one of them is chosen to, again, set the lock to itself.
2182
2183@item @emph{C/C++}:
2184@multitable @columnfractions .20 .80
2185@item @emph{Prototype}: @tab @code{void omp_unset_nest_lock(omp_nest_lock_t *lock);}
2186@end multitable
2187
2188@item @emph{Fortran}:
2189@multitable @columnfractions .20 .80
2190@item @emph{Interface}: @tab @code{subroutine omp_unset_nest_lock(nvar)}
2191@item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: nvar}
2192@end multitable
2193
2194@item @emph{See also}:
2195@ref{omp_set_nest_lock}
2196
2197@item @emph{Reference}:
2198@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.5.
2199@end table
2200
2201
2202
506f068e
TB
2203@node omp_test_lock
2204@subsection @code{omp_test_lock} -- Test and set simple lock if available
d77de738
ML
2205@table @asis
2206@item @emph{Description}:
506f068e
TB
2207Before setting a simple lock, the lock variable must be initialized by
2208@code{omp_init_lock}. Contrary to @code{omp_set_lock}, @code{omp_test_lock}
2209does not block if the lock is not available. This function returns
2210@code{true} upon success, @code{false} otherwise. Here, @code{true} and
2211@code{false} represent their language-specific counterparts.
d77de738
ML
2212
2213@item @emph{C/C++}:
2214@multitable @columnfractions .20 .80
506f068e 2215@item @emph{Prototype}: @tab @code{int omp_test_lock(omp_lock_t *lock);}
d77de738
ML
2216@end multitable
2217
2218@item @emph{Fortran}:
2219@multitable @columnfractions .20 .80
506f068e
TB
2220@item @emph{Interface}: @tab @code{logical function omp_test_lock(svar)}
2221@item @tab @code{integer(omp_lock_kind), intent(inout) :: svar}
2222@end multitable
2223
2224@item @emph{See also}:
2225@ref{omp_init_lock}, @ref{omp_set_lock}, @ref{omp_set_lock}
2226
2227@item @emph{Reference}:
2228@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.6.
2229@end table
2230
2231
2232
2233@node omp_test_nest_lock
2234@subsection @code{omp_test_nest_lock} -- Test and set nested lock if available
2235@table @asis
2236@item @emph{Description}:
2237Before setting a nested lock, the lock variable must be initialized by
2238@code{omp_init_nest_lock}. Contrary to @code{omp_set_nest_lock},
2239@code{omp_test_nest_lock} does not block if the lock is not available.
2240If the lock is already held by the current thread, the new nesting count
2241is returned. Otherwise, the return value equals zero.
2242
2243@item @emph{C/C++}:
2244@multitable @columnfractions .20 .80
2245@item @emph{Prototype}: @tab @code{int omp_test_nest_lock(omp_nest_lock_t *lock);}
2246@end multitable
2247
2248@item @emph{Fortran}:
2249@multitable @columnfractions .20 .80
2250@item @emph{Interface}: @tab @code{logical function omp_test_nest_lock(nvar)}
d77de738
ML
2251@item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: nvar}
2252@end multitable
2253
506f068e 2254
d77de738 2255@item @emph{See also}:
506f068e 2256@ref{omp_init_lock}, @ref{omp_set_lock}, @ref{omp_set_lock}
d77de738
ML
2257
2258@item @emph{Reference}:
506f068e 2259@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.6.
d77de738
ML
2260@end table
2261
2262
2263
506f068e
TB
2264@node Timing Routines
2265@section Timing Routines
2266
2267Portable, thread-based, wall clock timer.
2268The routines have C linkage and do not throw exceptions.
2269
2270@menu
2271* omp_get_wtick:: Get timer precision.
2272* omp_get_wtime:: Elapsed wall clock time.
2273@end menu
2274
2275
2276
d77de738 2277@node omp_get_wtick
506f068e 2278@subsection @code{omp_get_wtick} -- Get timer precision
d77de738
ML
2279@table @asis
2280@item @emph{Description}:
2281Gets the timer precision, i.e., the number of seconds between two
2282successive clock ticks.
2283
2284@item @emph{C/C++}:
2285@multitable @columnfractions .20 .80
2286@item @emph{Prototype}: @tab @code{double omp_get_wtick(void);}
2287@end multitable
2288
2289@item @emph{Fortran}:
2290@multitable @columnfractions .20 .80
2291@item @emph{Interface}: @tab @code{double precision function omp_get_wtick()}
2292@end multitable
2293
2294@item @emph{See also}:
2295@ref{omp_get_wtime}
2296
2297@item @emph{Reference}:
2298@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.4.2.
2299@end table
2300
2301
2302
2303@node omp_get_wtime
506f068e 2304@subsection @code{omp_get_wtime} -- Elapsed wall clock time
d77de738
ML
2305@table @asis
2306@item @emph{Description}:
2307Elapsed wall clock time in seconds. The time is measured per thread, no
2308guarantee can be made that two distinct threads measure the same time.
2309Time is measured from some "time in the past", which is an arbitrary time
2310guaranteed not to change during the execution of the program.
2311
2312@item @emph{C/C++}:
2313@multitable @columnfractions .20 .80
2314@item @emph{Prototype}: @tab @code{double omp_get_wtime(void);}
2315@end multitable
2316
2317@item @emph{Fortran}:
2318@multitable @columnfractions .20 .80
2319@item @emph{Interface}: @tab @code{double precision function omp_get_wtime()}
2320@end multitable
2321
2322@item @emph{See also}:
2323@ref{omp_get_wtick}
2324
2325@item @emph{Reference}:
2326@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.4.1.
2327@end table
2328
2329
2330
506f068e
TB
2331@node Event Routine
2332@section Event Routine
2333
2334Support for event objects.
2335The routine has C linkage and do not throw exceptions.
2336
2337@menu
2338* omp_fulfill_event:: Fulfill and destroy an OpenMP event.
2339@end menu
2340
2341
2342
d77de738 2343@node omp_fulfill_event
506f068e 2344@subsection @code{omp_fulfill_event} -- Fulfill and destroy an OpenMP event
d77de738
ML
2345@table @asis
2346@item @emph{Description}:
2347Fulfill the event associated with the event handle argument. Currently, it
2348is only used to fulfill events generated by detach clauses on task
2349constructs - the effect of fulfilling the event is to allow the task to
2350complete.
2351
2352The result of calling @code{omp_fulfill_event} with an event handle other
2353than that generated by a detach clause is undefined. Calling it with an
2354event handle that has already been fulfilled is also undefined.
2355
2356@item @emph{C/C++}:
2357@multitable @columnfractions .20 .80
2358@item @emph{Prototype}: @tab @code{void omp_fulfill_event(omp_event_handle_t event);}
2359@end multitable
2360
2361@item @emph{Fortran}:
2362@multitable @columnfractions .20 .80
2363@item @emph{Interface}: @tab @code{subroutine omp_fulfill_event(event)}
2364@item @tab @code{integer (kind=omp_event_handle_kind) :: event}
2365@end multitable
2366
2367@item @emph{Reference}:
2368@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.5.1.
2369@end table
2370
2371
2372
506f068e
TB
2373@c @node Interoperability Routines
2374@c @section Interoperability Routines
2375@c
2376@c Routines to obtain properties from an @code{omp_interop_t} object.
2377@c They have C linkage and do not throw exceptions.
2378@c
2379@c @menu
2380@c * omp_get_num_interop_properties:: <fixme>
2381@c * omp_get_interop_int:: <fixme>
2382@c * omp_get_interop_ptr:: <fixme>
2383@c * omp_get_interop_str:: <fixme>
2384@c * omp_get_interop_name:: <fixme>
2385@c * omp_get_interop_type_desc:: <fixme>
2386@c * omp_get_interop_rc_desc:: <fixme>
2387@c @end menu
2388
971f119f
TB
2389@node Memory Management Routines
2390@section Memory Management Routines
2391
2392Routines to manage and allocate memory on the current device.
2393They have C linkage and do not throw exceptions.
2394
2395@menu
2396* omp_init_allocator:: Create an allocator
2397* omp_destroy_allocator:: Destroy an allocator
2398* omp_set_default_allocator:: Set the default allocator
2399* omp_get_default_allocator:: Get the default allocator
bc238c40
TB
2400* omp_alloc:: Memory allocation with an allocator
2401* omp_aligned_alloc:: Memory allocation with an allocator and alignment
2402* omp_free:: Freeing memory allocated with OpenMP routines
2403* omp_calloc:: Allocate nullified memory with an allocator
2404* omp_aligned_calloc:: Allocate nullified aligned memory with an allocator
2405* omp_realloc:: Reallocate memory allocated with OpenMP routines
506f068e
TB
2406@c * omp_get_memspace_num_resources:: <fixme>/TR11
2407@c * omp_get_submemspace:: <fixme>/TR11
971f119f
TB
2408@end menu
2409
2410
2411
2412@node omp_init_allocator
2413@subsection @code{omp_init_allocator} -- Create an allocator
2414@table @asis
2415@item @emph{Description}:
2416Create an allocator that uses the specified memory space and has the specified
2417traits; if an allocator that fulfills the requirements cannot be created,
2418@code{omp_null_allocator} is returned.
2419
2420The predefined memory spaces and available traits can be found at
2421@ref{OMP_ALLOCATOR}, where the trait names have to be be prefixed by
2422@code{omp_atk_} (e.g. @code{omp_atk_pinned}) and the named trait values by
2423@code{omp_atv_} (e.g. @code{omp_atv_true}); additionally, @code{omp_atv_default}
2424may be used as trait value to specify that the default value should be used.
2425
2426@item @emph{C/C++}:
2427@multitable @columnfractions .20 .80
2428@item @emph{Prototype}: @tab @code{omp_allocator_handle_t omp_init_allocator(}
2429@item @tab @code{ omp_memspace_handle_t memspace,}
2430@item @tab @code{ int ntraits,}
2431@item @tab @code{ const omp_alloctrait_t traits[]);}
2432@end multitable
2433
2434@item @emph{Fortran}:
2435@multitable @columnfractions .20 .80
2436@item @emph{Interface}: @tab @code{function omp_init_allocator(memspace, ntraits, traits)}
bc238c40
TB
2437@item @tab @code{integer (omp_allocator_handle_kind) :: omp_init_allocator}
2438@item @tab @code{integer (omp_memspace_handle_kind), intent(in) :: memspace}
971f119f
TB
2439@item @tab @code{integer, intent(in) :: ntraits}
2440@item @tab @code{type (omp_alloctrait), intent(in) :: traits(*)}
2441@end multitable
2442
2443@item @emph{See also}:
2444@ref{OMP_ALLOCATOR}, @ref{Memory allocation}, @ref{omp_destroy_allocator}
2445
2446@item @emph{Reference}:
2447@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.7.2
2448@end table
2449
2450
2451
2452@node omp_destroy_allocator
2453@subsection @code{omp_destroy_allocator} -- Destroy an allocator
2454@table @asis
2455@item @emph{Description}:
2456Releases all resources used by a memory allocator, which must not represent
2457a predefined memory allocator. Accessing memory after its allocator has been
2458destroyed has unspecified behavior. Passing @code{omp_null_allocator} to the
15886c03 2459routine is permitted but has no effect.
971f119f
TB
2460
2461
2462@item @emph{C/C++}:
2463@multitable @columnfractions .20 .80
2464@item @emph{Prototype}: @tab @code{void omp_destroy_allocator (omp_allocator_handle_t allocator);}
2465@end multitable
2466
2467@item @emph{Fortran}:
2468@multitable @columnfractions .20 .80
2469@item @emph{Interface}: @tab @code{subroutine omp_destroy_allocator(allocator)}
bc238c40 2470@item @tab @code{integer (omp_allocator_handle_kind), intent(in) :: allocator}
971f119f
TB
2471@end multitable
2472
2473@item @emph{See also}:
2474@ref{omp_init_allocator}
2475
2476@item @emph{Reference}:
2477@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.7.3
2478@end table
2479
2480
2481
2482@node omp_set_default_allocator
2483@subsection @code{omp_set_default_allocator} -- Set the default allocator
2484@table @asis
2485@item @emph{Description}:
2486Sets the default allocator that is used when no allocator has been specified
2487in the @code{allocate} or @code{allocator} clause or if an OpenMP memory
2488routine is invoked with the @code{omp_null_allocator} allocator.
2489
2490@item @emph{C/C++}:
2491@multitable @columnfractions .20 .80
2492@item @emph{Prototype}: @tab @code{void omp_set_default_allocator(omp_allocator_handle_t allocator);}
2493@end multitable
2494
2495@item @emph{Fortran}:
2496@multitable @columnfractions .20 .80
2497@item @emph{Interface}: @tab @code{subroutine omp_set_default_allocator(allocator)}
bc238c40 2498@item @tab @code{integer (omp_allocator_handle_kind), intent(in) :: allocator}
971f119f
TB
2499@end multitable
2500
2501@item @emph{See also}:
2502@ref{omp_get_default_allocator}, @ref{omp_init_allocator}, @ref{OMP_ALLOCATOR},
2503@ref{Memory allocation}
2504
2505@item @emph{Reference}:
2506@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.7.4
2507@end table
2508
2509
2510
2511@node omp_get_default_allocator
2512@subsection @code{omp_get_default_allocator} -- Get the default allocator
2513@table @asis
2514@item @emph{Description}:
2515The routine returns the default allocator that is used when no allocator has
2516been specified in the @code{allocate} or @code{allocator} clause or if an
2517OpenMP memory routine is invoked with the @code{omp_null_allocator} allocator.
2518
2519@item @emph{C/C++}:
2520@multitable @columnfractions .20 .80
2521@item @emph{Prototype}: @tab @code{omp_allocator_handle_t omp_get_default_allocator();}
2522@end multitable
2523
2524@item @emph{Fortran}:
2525@multitable @columnfractions .20 .80
2526@item @emph{Interface}: @tab @code{function omp_get_default_allocator()}
bc238c40 2527@item @tab @code{integer (omp_allocator_handle_kind) :: omp_get_default_allocator}
971f119f
TB
2528@end multitable
2529
2530@item @emph{See also}:
2531@ref{omp_set_default_allocator}, @ref{OMP_ALLOCATOR}
2532
2533@item @emph{Reference}:
2534@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.7.5
2535@end table
2536
2537
506f068e 2538
bc238c40
TB
2539@node omp_alloc
2540@subsection @code{omp_alloc} -- Memory allocation with an allocator
2541@table @asis
2542@item @emph{Description}:
2543Allocate memory with the specified allocator, which can either be a predefined
2544allocator, an allocator handle or @code{omp_null_allocator}. If the allocators
2545is @code{omp_null_allocator}, the allocator specified by the
2546@var{def-allocator-var} ICV is used. @var{size} must be a nonnegative number
2547denoting the number of bytes to be allocated; if @var{size} is zero,
2548@code{omp_alloc} will return a null pointer. If successful, a pointer to the
2549allocated memory is returned, otherwise the @code{fallback} trait of the
2550allocator determines the behavior. The content of the allocated memory is
2551unspecified.
2552
2553In @code{target} regions, either the @code{dynamic_allocators} clause must
2554appear on a @code{requires} directive in the same compilation unit -- or the
2555@var{allocator} argument may only be a constant expression with the value of
2556one of the predefined allocators and may not be @code{omp_null_allocator}.
2557
2558Memory allocated by @code{omp_alloc} must be freed using @code{omp_free}.
2559
2560@item @emph{C}:
2561@multitable @columnfractions .20 .80
2562@item @emph{Prototype}: @tab @code{void* omp_alloc(size_t size,}
2563@item @tab @code{ omp_allocator_handle_t allocator)}
2564@end multitable
2565
2566@item @emph{C++}:
2567@multitable @columnfractions .20 .80
2568@item @emph{Prototype}: @tab @code{void* omp_alloc(size_t size,}
2569@item @tab @code{ omp_allocator_handle_t allocator=omp_null_allocator)}
2570@end multitable
2571
2572@item @emph{Fortran}:
2573@multitable @columnfractions .20 .80
2574@item @emph{Interface}: @tab @code{type(c_ptr) function omp_alloc(size, allocator) bind(C)}
2575@item @tab @code{use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t}
2576@item @tab @code{integer (c_size_t), value :: size}
2577@item @tab @code{integer (omp_allocator_handle_kind), value :: allocator}
2578@end multitable
2579
2580@item @emph{See also}:
2581@ref{OMP_ALLOCATOR}, @ref{Memory allocation}, @ref{omp_set_default_allocator},
2582@ref{omp_free}, @ref{omp_init_allocator}
2583
2584@item @emph{Reference}:
2585@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.7.6
2586@end table
2587
2588
2589
2590@node omp_aligned_alloc
2591@subsection @code{omp_aligned_alloc} -- Memory allocation with an allocator and alignment
2592@table @asis
2593@item @emph{Description}:
2594Allocate memory with the specified allocator, which can either be a predefined
2595allocator, an allocator handle or @code{omp_null_allocator}. If the allocators
2596is @code{omp_null_allocator}, the allocator specified by the
2597@var{def-allocator-var} ICV is used. @var{alignment} must be a positive power
2598of two and @var{size} must be a nonnegative number that is a multiple of the
2599alignment and denotes the number of bytes to be allocated; if @var{size} is
2600zero, @code{omp_aligned_alloc} will return a null pointer. The alignment will
2601be at least the maximal value required by @code{alignment} trait of the
2602allocator and the value of the passed @var{alignment} argument. If successful,
2603a pointer to the allocated memory is returned, otherwise the @code{fallback}
2604trait of the allocator determines the behavior. The content of the allocated
2605memory is unspecified.
2606
2607In @code{target} regions, either the @code{dynamic_allocators} clause must
2608appear on a @code{requires} directive in the same compilation unit -- or the
2609@var{allocator} argument may only be a constant expression with the value of
2610one of the predefined allocators and may not be @code{omp_null_allocator}.
2611
2612Memory allocated by @code{omp_aligned_alloc} must be freed using
2613@code{omp_free}.
2614
2615@item @emph{C}:
2616@multitable @columnfractions .20 .80
2617@item @emph{Prototype}: @tab @code{void* omp_aligned_alloc(size_t alignment,}
2618@item @tab @code{ size_t size,}
2619@item @tab @code{ omp_allocator_handle_t allocator)}
2620@end multitable
2621
2622@item @emph{C++}:
2623@multitable @columnfractions .20 .80
2624@item @emph{Prototype}: @tab @code{void* omp_aligned_alloc(size_t alignment,}
2625@item @tab @code{ size_t size,}
2626@item @tab @code{ omp_allocator_handle_t allocator=omp_null_allocator)}
2627@end multitable
2628
2629@item @emph{Fortran}:
2630@multitable @columnfractions .20 .80
2631@item @emph{Interface}: @tab @code{type(c_ptr) function omp_aligned_alloc(alignment, size, allocator) bind(C)}
2632@item @tab @code{use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t}
2633@item @tab @code{integer (c_size_t), value :: alignment, size}
2634@item @tab @code{integer (omp_allocator_handle_kind), value :: allocator}
2635@end multitable
2636
2637@item @emph{See also}:
2638@ref{OMP_ALLOCATOR}, @ref{Memory allocation}, @ref{omp_set_default_allocator},
2639@ref{omp_free}, @ref{omp_init_allocator}
2640
2641@item @emph{Reference}:
2642@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.13.6
2643@end table
2644
2645
2646
2647@node omp_free
2648@subsection @code{omp_free} -- Freeing memory allocated with OpenMP routines
2649@table @asis
2650@item @emph{Description}:
2651The @code{omp_free} routine deallocates memory previously allocated by an
2652OpenMP memory-management routine. The @var{ptr} argument must point to such
2653memory or be a null pointer; if it is a null pointer, no operation is
2654performed. If specified, the @var{allocator} argument must be either the
2655memory allocator that was used for the allocation or @code{omp_null_allocator};
2656if it is @code{omp_null_allocator}, the implementation will determine the value
2657automatically.
2658
2659Calling @code{omp_free} invokes undefined behavior if the memory
2660was already deallocated or when the used allocator has already been destroyed.
2661
2662@item @emph{C}:
2663@multitable @columnfractions .20 .80
2664@item @emph{Prototype}: @tab @code{void omp_free(void *ptr,}
2665@item @tab @code{ omp_allocator_handle_t allocator)}
2666@end multitable
2667
2668@item @emph{C++}:
2669@multitable @columnfractions .20 .80
2670@item @emph{Prototype}: @tab @code{void omp_free(void *ptr,}
2671@item @tab @code{ omp_allocator_handle_t allocator=omp_null_allocator)}
2672@end multitable
2673
2674@item @emph{Fortran}:
2675@multitable @columnfractions .20 .80
2676@item @emph{Interface}: @tab @code{subroutine omp_free(ptr, allocator) bind(C)}
2677@item @tab @code{use, intrinsic :: iso_c_binding, only : c_ptr}
2678@item @tab @code{type (c_ptr), value :: ptr}
2679@item @tab @code{integer (omp_allocator_handle_kind), value :: allocator}
2680@end multitable
2681
2682@item @emph{See also}:
2683@ref{omp_alloc}, @ref{omp_aligned_alloc}, @ref{omp_calloc},
2684@ref{omp_aligned_calloc}, @ref{omp_realloc}
2685
2686@item @emph{Reference}:
2687@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.7.7
2688@end table
2689
2690
2691
2692@node omp_calloc
2693@subsection @code{omp_calloc} -- Allocate nullified memory with an allocator
2694@table @asis
2695@item @emph{Description}:
2696Allocate zero-initialized memory with the specified allocator, which can either
2697be a predefined allocator, an allocator handle or @code{omp_null_allocator}. If
2698the allocators is @code{omp_null_allocator}, the allocator specified by the
2699@var{def-allocator-var} ICV is used. The to-be allocated memory is for an
2700array with @var{nmemb} elements, each having a size of @var{size} bytes. Both
2701@var{nmemb} and @var{size} must be nonnegative numbers; if either of them is
2702zero, @code{omp_calloc} will return a null pointer. If successful, a pointer to
2703the zero-initialized allocated memory is returned, otherwise the @code{fallback}
2704trait of the allocator determines the behavior.
2705
2706In @code{target} regions, either the @code{dynamic_allocators} clause must
2707appear on a @code{requires} directive in the same compilation unit -- or the
2708@var{allocator} argument may only be a constant expression with the value of
2709one of the predefined allocators and may not be @code{omp_null_allocator}.
2710
2711Memory allocated by @code{omp_calloc} must be freed using @code{omp_free}.
2712
2713@item @emph{C}:
2714@multitable @columnfractions .20 .80
2715@item @emph{Prototype}: @tab @code{void* omp_calloc(size_t nmemb, size_t size,}
2716@item @tab @code{ omp_allocator_handle_t allocator)}
2717@end multitable
2718
2719@item @emph{C++}:
2720@multitable @columnfractions .20 .80
2721@item @emph{Prototype}: @tab @code{void* omp_calloc(size_t nmemb, size_t size,}
2722@item @tab @code{ omp_allocator_handle_t allocator=omp_null_allocator)}
2723@end multitable
2724
2725@item @emph{Fortran}:
2726@multitable @columnfractions .20 .80
2727@item @emph{Interface}: @tab @code{type(c_ptr) function omp_calloc(nmemb, size, allocator) bind(C)}
2728@item @tab @code{use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t}
2729@item @tab @code{integer (c_size_t), value :: nmemb, size}
2730@item @tab @code{integer (omp_allocator_handle_kind), value :: allocator}
2731@end multitable
2732
2733@item @emph{See also}:
2734@ref{OMP_ALLOCATOR}, @ref{Memory allocation}, @ref{omp_set_default_allocator},
2735@ref{omp_free}, @ref{omp_init_allocator}
2736
2737@item @emph{Reference}:
2738@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.13.8
2739@end table
2740
2741
2742
2743@node omp_aligned_calloc
2744@subsection @code{omp_aligned_calloc} -- Allocate aligned nullified memory with an allocator
2745@table @asis
2746@item @emph{Description}:
2747Allocate zero-initialized memory with the specified allocator, which can either
2748be a predefined allocator, an allocator handle or @code{omp_null_allocator}. If
2749the allocators is @code{omp_null_allocator}, the allocator specified by the
2750@var{def-allocator-var} ICV is used. The to-be allocated memory is for an
2751array with @var{nmemb} elements, each having a size of @var{size} bytes. Both
2752@var{nmemb} and @var{size} must be nonnegative numbers; if either of them is
2753zero, @code{omp_aligned_calloc} will return a null pointer. @var{alignment}
2754must be a positive power of two and @var{size} must be a multiple of the
2755alignment; the alignment will be at least the maximal value required by
2756@code{alignment} trait of the allocator and the value of the passed
2757@var{alignment} argument. If successful, a pointer to the zero-initialized
2758allocated memory is returned, otherwise the @code{fallback} trait of the
2759allocator determines the behavior.
2760
2761In @code{target} regions, either the @code{dynamic_allocators} clause must
2762appear on a @code{requires} directive in the same compilation unit -- or the
2763@var{allocator} argument may only be a constant expression with the value of
2764one of the predefined allocators and may not be @code{omp_null_allocator}.
2765
2766Memory allocated by @code{omp_aligned_calloc} must be freed using
2767@code{omp_free}.
2768
2769@item @emph{C}:
2770@multitable @columnfractions .20 .80
2771@item @emph{Prototype}: @tab @code{void* omp_aligned_calloc(size_t nmemb, size_t size,}
2772@item @tab @code{ omp_allocator_handle_t allocator)}
2773@end multitable
2774
2775@item @emph{C++}:
2776@multitable @columnfractions .20 .80
2777@item @emph{Prototype}: @tab @code{void* omp_aligned_calloc(size_t nmemb, size_t size,}
2778@item @tab @code{ omp_allocator_handle_t allocator=omp_null_allocator)}
2779@end multitable
2780
2781@item @emph{Fortran}:
2782@multitable @columnfractions .20 .80
2783@item @emph{Interface}: @tab @code{type(c_ptr) function omp_aligned_calloc(nmemb, size, allocator) bind(C)}
2784@item @tab @code{use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t}
2785@item @tab @code{integer (c_size_t), value :: nmemb, size}
2786@item @tab @code{integer (omp_allocator_handle_kind), value :: allocator}
2787@end multitable
2788
2789@item @emph{See also}:
2790@ref{OMP_ALLOCATOR}, @ref{Memory allocation}, @ref{omp_set_default_allocator},
2791@ref{omp_free}, @ref{omp_init_allocator}
2792
2793@item @emph{Reference}:
2794@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.13.8
2795@end table
2796
2797
2798
2799@node omp_realloc
2800@subsection @code{omp_realloc} -- Reallocate memory allocated with OpenMP routines
2801@table @asis
2802@item @emph{Description}:
2803The @code{omp_realloc} routine deallocates memory to which @var{ptr} points to
2804and allocates new memory with the specified @var{allocator} argument; the
2805new memory will have the content of the old memory up to the minimum of the
2806old size and the new @var{size}, otherwise the content of the returned memory
2807is unspecified. If the new allocator is the same as the old one, the routine
2808tries to resize the existing memory allocation, returning the same address as
2809@var{ptr} if successful. @var{ptr} must point to memory allocated by an OpenMP
2810memory-management routine.
2811
2812The @var{allocator} and @var{free_allocator} arguments must be a predefined
2813allocator, an allocator handle or @code{omp_null_allocator}. If
2814@var{free_allocator} is @code{omp_null_allocator}, the implementation
2815automatically determines the allocator used for the allocation of @var{ptr}.
2816If @var{allocator} is @code{omp_null_allocator} and @var{ptr} is is not a
2817null pointer, the same allocator as @code{free_allocator} is used and
2818when @var{ptr} is a null pointer the allocator specified by the
2819@var{def-allocator-var} ICV is used.
2820
2821The @var{size} must be a nonnegative number denoting the number of bytes to be
2822allocated; if @var{size} is zero, @code{omp_realloc} will return free the
2823memory and return a null pointer. When @var{size} is nonzero: if successful,
2824a pointer to the allocated memory is returned, otherwise the @code{fallback}
2825trait of the allocator determines the behavior.
2826
2827In @code{target} regions, either the @code{dynamic_allocators} clause must
2828appear on a @code{requires} directive in the same compilation unit -- or the
2829@var{free_allocator} and @var{allocator} arguments may only be a constant
2830expression with the value of one of the predefined allocators and may not be
2831@code{omp_null_allocator}.
2832
2833Memory allocated by @code{omp_realloc} must be freed using @code{omp_free}.
2834Calling @code{omp_free} invokes undefined behavior if the memory
2835was already deallocated or when the used allocator has already been destroyed.
2836
2837@item @emph{C}:
2838@multitable @columnfractions .20 .80
2839@item @emph{Prototype}: @tab @code{void* omp_realloc(void *ptr, size_t size,}
2840@item @tab @code{ omp_allocator_handle_t allocator,}
2841@item @tab @code{ omp_allocator_handle_t free_allocator)}
2842@end multitable
2843
2844@item @emph{C++}:
2845@multitable @columnfractions .20 .80
2846@item @emph{Prototype}: @tab @code{void* omp_realloc(void *ptr, size_t size,}
2847@item @tab @code{ omp_allocator_handle_t allocator=omp_null_allocator,}
2848@item @tab @code{ omp_allocator_handle_t free_allocator=omp_null_allocator)}
2849@end multitable
2850
2851@item @emph{Fortran}:
2852@multitable @columnfractions .20 .80
2853@item @emph{Interface}: @tab @code{type(c_ptr) function omp_realloc(ptr, size, allocator, free_allocator) bind(C)}
2854@item @tab @code{use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t}
2855@item @tab @code{type(C_ptr), value :: ptr}
2856@item @tab @code{integer (c_size_t), value :: size}
2857@item @tab @code{integer (omp_allocator_handle_kind), value :: allocator, free_allocator}
2858@end multitable
2859
2860@item @emph{See also}:
2861@ref{OMP_ALLOCATOR}, @ref{Memory allocation}, @ref{omp_set_default_allocator},
2862@ref{omp_free}, @ref{omp_init_allocator}
2863
2864@item @emph{Reference}:
2865@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.7.9
2866@end table
2867
2868
2869
506f068e
TB
2870@c @node Tool Control Routine
2871@c
2872@c FIXME
2873
2874@c @node Environment Display Routine
2875@c @section Environment Display Routine
2876@c
2877@c Routine to display the OpenMP number and the initial value of ICVs.
2878@c It has C linkage and do not throw exceptions.
2879@c
2880@c menu
2881@c * omp_display_env:: <fixme>
2882@c end menu
2883
d77de738
ML
2884@c ---------------------------------------------------------------------
2885@c OpenMP Environment Variables
2886@c ---------------------------------------------------------------------
2887
2888@node Environment Variables
2889@chapter OpenMP Environment Variables
2890
2891The environment variables which beginning with @env{OMP_} are defined by
2cd0689a
TB
2892section 4 of the OpenMP specification in version 4.5 or in a later version
2893of the specification, while those beginning with @env{GOMP_} are GNU extensions.
2894Most @env{OMP_} environment variables have an associated internal control
2895variable (ICV).
2896
2897For any OpenMP environment variable that sets an ICV and is neither
2898@code{OMP_DEFAULT_DEVICE} nor has global ICV scope, associated
2899device-specific environment variables exist. For them, the environment
2900variable without suffix affects the host. The suffix @code{_DEV_} followed
2901by a non-negative device number less that the number of available devices sets
2902the ICV for the corresponding device. The suffix @code{_DEV} sets the ICV
2903of all non-host devices for which a device-specific corresponding environment
2904variable has not been set while the @code{_ALL} suffix sets the ICV of all
2905host and non-host devices for which a more specific corresponding environment
2906variable is not set.
d77de738
ML
2907
2908@menu
73a0d3bf
TB
2909* OMP_ALLOCATOR:: Set the default allocator
2910* OMP_AFFINITY_FORMAT:: Set the format string used for affinity display
d77de738 2911* OMP_CANCELLATION:: Set whether cancellation is activated
73a0d3bf 2912* OMP_DISPLAY_AFFINITY:: Display thread affinity information
d77de738
ML
2913* OMP_DISPLAY_ENV:: Show OpenMP version and environment variables
2914* OMP_DEFAULT_DEVICE:: Set the device used in target regions
2915* OMP_DYNAMIC:: Dynamic adjustment of threads
2916* OMP_MAX_ACTIVE_LEVELS:: Set the maximum number of nested parallel regions
2917* OMP_MAX_TASK_PRIORITY:: Set the maximum task priority value
2918* OMP_NESTED:: Nested parallel regions
2919* OMP_NUM_TEAMS:: Specifies the number of teams to use by teams region
2920* OMP_NUM_THREADS:: Specifies the number of threads to use
0b9bd33d
JJ
2921* OMP_PROC_BIND:: Whether threads may be moved between CPUs
2922* OMP_PLACES:: Specifies on which CPUs the threads should be placed
d77de738
ML
2923* OMP_STACKSIZE:: Set default thread stack size
2924* OMP_SCHEDULE:: How threads are scheduled
bc238c40 2925* OMP_TARGET_OFFLOAD:: Controls offloading behavior
d77de738
ML
2926* OMP_TEAMS_THREAD_LIMIT:: Set the maximum number of threads imposed by teams
2927* OMP_THREAD_LIMIT:: Set the maximum number of threads
2928* OMP_WAIT_POLICY:: How waiting threads are handled
2929* GOMP_CPU_AFFINITY:: Bind threads to specific CPUs
2930* GOMP_DEBUG:: Enable debugging output
2931* GOMP_STACKSIZE:: Set default thread stack size
2932* GOMP_SPINCOUNT:: Set the busy-wait spin count
2933* GOMP_RTEMS_THREAD_POOLS:: Set the RTEMS specific thread pools
2934@end menu
2935
2936
73a0d3bf
TB
2937@node OMP_ALLOCATOR
2938@section @env{OMP_ALLOCATOR} -- Set the default allocator
2939@cindex Environment Variable
2940@table @asis
971f119f 2941@item @emph{ICV:} @var{def-allocator-var}
2cd0689a 2942@item @emph{Scope:} data environment
73a0d3bf
TB
2943@item @emph{Description}:
2944Sets the default allocator that is used when no allocator has been specified
2945in the @code{allocate} or @code{allocator} clause or if an OpenMP memory
2946routine is invoked with the @code{omp_null_allocator} allocator.
2947If unset, @code{omp_default_mem_alloc} is used.
2948
2949The value can either be a predefined allocator or a predefined memory space
2950or a predefined memory space followed by a colon and a comma-separated list
2951of memory trait and value pairs, separated by @code{=}.
2952
2cd0689a
TB
2953Note: The corresponding device environment variables are currently not
2954supported. Therefore, the non-host @var{def-allocator-var} ICVs are always
2955initialized to @code{omp_default_mem_alloc}. However, on all devices,
2956the @code{omp_set_default_allocator} API routine can be used to change
2957value.
2958
73a0d3bf 2959@multitable @columnfractions .45 .45
a85a106c 2960@headitem Predefined allocators @tab Associated predefined memory spaces
73a0d3bf
TB
2961@item omp_default_mem_alloc @tab omp_default_mem_space
2962@item omp_large_cap_mem_alloc @tab omp_large_cap_mem_space
2963@item omp_const_mem_alloc @tab omp_const_mem_space
2964@item omp_high_bw_mem_alloc @tab omp_high_bw_mem_space
2965@item omp_low_lat_mem_alloc @tab omp_low_lat_mem_space
2966@item omp_cgroup_mem_alloc @tab --
2967@item omp_pteam_mem_alloc @tab --
2968@item omp_thread_mem_alloc @tab --
2969@end multitable
2970
a85a106c
TB
2971The predefined allocators use the default values for the traits,
2972as listed below. Except that the last three allocators have the
2973@code{access} trait set to @code{cgroup}, @code{pteam}, and
2974@code{thread}, respectively.
2975
2976@multitable @columnfractions .25 .40 .25
2977@headitem Trait @tab Allowed values @tab Default value
73a0d3bf
TB
2978@item @code{sync_hint} @tab @code{contended}, @code{uncontended},
2979 @code{serialized}, @code{private}
a85a106c 2980 @tab @code{contended}
73a0d3bf 2981@item @code{alignment} @tab Positive integer being a power of two
a85a106c 2982 @tab 1 byte
73a0d3bf
TB
2983@item @code{access} @tab @code{all}, @code{cgroup},
2984 @code{pteam}, @code{thread}
a85a106c 2985 @tab @code{all}
73a0d3bf 2986@item @code{pool_size} @tab Positive integer
a85a106c 2987 @tab See @ref{Memory allocation}
73a0d3bf
TB
2988@item @code{fallback} @tab @code{default_mem_fb}, @code{null_fb},
2989 @code{abort_fb}, @code{allocator_fb}
a85a106c 2990 @tab See below
73a0d3bf 2991@item @code{fb_data} @tab @emph{unsupported as it needs an allocator handle}
a85a106c 2992 @tab (none)
73a0d3bf 2993@item @code{pinned} @tab @code{true}, @code{false}
a85a106c 2994 @tab @code{false}
73a0d3bf
TB
2995@item @code{partition} @tab @code{environment}, @code{nearest},
2996 @code{blocked}, @code{interleaved}
a85a106c 2997 @tab @code{environment}
73a0d3bf
TB
2998@end multitable
2999
a85a106c
TB
3000For the @code{fallback} trait, the default value is @code{null_fb} for the
3001@code{omp_default_mem_alloc} allocator and any allocator that is associated
3002with device memory; for all other other allocators, it is @code{default_mem_fb}
3003by default.
3004
73a0d3bf
TB
3005Examples:
3006@smallexample
3007OMP_ALLOCATOR=omp_high_bw_mem_alloc
3008OMP_ALLOCATOR=omp_large_cap_mem_space
506f068e 3009OMP_ALLOCATOR=omp_low_lat_mem_space:pinned=true,partition=nearest
73a0d3bf
TB
3010@end smallexample
3011
a85a106c 3012@item @emph{See also}:
971f119f
TB
3013@ref{Memory allocation}, @ref{omp_get_default_allocator},
3014@ref{omp_set_default_allocator}
73a0d3bf
TB
3015
3016@item @emph{Reference}:
3017@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 6.21
3018@end table
3019
3020
3021
3022@node OMP_AFFINITY_FORMAT
3023@section @env{OMP_AFFINITY_FORMAT} -- Set the format string used for affinity display
3024@cindex Environment Variable
3025@table @asis
2cd0689a
TB
3026@item @emph{ICV:} @var{affinity-format-var}
3027@item @emph{Scope:} device
73a0d3bf
TB
3028@item @emph{Description}:
3029Sets the format string used when displaying OpenMP thread affinity information.
3030Special values are output using @code{%} followed by an optional size
3031specification and then either the single-character field type or its long
15886c03 3032name enclosed in curly braces; using @code{%%} displays a literal percent.
73a0d3bf 3033The size specification consists of an optional @code{0.} or @code{.} followed
450b05ce 3034by a positive integer, specifying the minimal width of the output. With
73a0d3bf
TB
3035@code{0.} and numerical values, the output is padded with zeros on the left;
3036with @code{.}, the output is padded by spaces on the left; otherwise, the
3037output is padded by spaces on the right. If unset, the value is
3038``@code{level %L thread %i affinity %A}''.
3039
3040Supported field types are:
3041
3042@multitable @columnfractions .10 .25 .60
3043@item t @tab team_num @tab value returned by @code{omp_get_team_num}
3044@item T @tab num_teams @tab value returned by @code{omp_get_num_teams}
3045@item L @tab nesting_level @tab value returned by @code{omp_get_level}
3046@item n @tab thread_num @tab value returned by @code{omp_get_thread_num}
3047@item N @tab num_threads @tab value returned by @code{omp_get_num_threads}
3048@item a @tab ancestor_tnum
3049 @tab value returned by
3050 @code{omp_get_ancestor_thread_num(omp_get_level()-1)}
3051@item H @tab host @tab name of the host that executes the thread
450b05ce
TB
3052@item P @tab process_id @tab process identifier
3053@item i @tab native_thread_id @tab native thread identifier
73a0d3bf
TB
3054@item A @tab thread_affinity
3055 @tab comma separated list of integer values or ranges, representing the
3056 processors on which a process might execute, subject to affinity
3057 mechanisms
3058@end multitable
3059
3060For instance, after setting
3061
3062@smallexample
3063OMP_AFFINITY_FORMAT="%0.2a!%n!%.4L!%N;%.2t;%0.2T;%@{team_num@};%@{num_teams@};%A"
3064@end smallexample
3065
3066with either @code{OMP_DISPLAY_AFFINITY} being set or when calling
3067@code{omp_display_affinity} with @code{NULL} or an empty string, the program
3068might display the following:
3069
3070@smallexample
307100!0! 1!4; 0;01;0;1;0-11
307200!3! 1!4; 0;01;0;1;0-11
307300!2! 1!4; 0;01;0;1;0-11
307400!1! 1!4; 0;01;0;1;0-11
3075@end smallexample
3076
3077@item @emph{See also}:
3078@ref{OMP_DISPLAY_AFFINITY}
3079
3080@item @emph{Reference}:
3081@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 6.14
3082@end table
3083
3084
3085
d77de738
ML
3086@node OMP_CANCELLATION
3087@section @env{OMP_CANCELLATION} -- Set whether cancellation is activated
3088@cindex Environment Variable
3089@table @asis
2cd0689a
TB
3090@item @emph{ICV:} @var{cancel-var}
3091@item @emph{Scope:} global
d77de738
ML
3092@item @emph{Description}:
3093If set to @code{TRUE}, the cancellation is activated. If set to @code{FALSE} or
3094if unset, cancellation is disabled and the @code{cancel} construct is ignored.
3095
3096@item @emph{See also}:
3097@ref{omp_get_cancellation}
3098
3099@item @emph{Reference}:
3100@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.11
3101@end table
3102
3103
3104
73a0d3bf
TB
3105@node OMP_DISPLAY_AFFINITY
3106@section @env{OMP_DISPLAY_AFFINITY} -- Display thread affinity information
3107@cindex Environment Variable
3108@table @asis
2cd0689a
TB
3109@item @emph{ICV:} @var{display-affinity-var}
3110@item @emph{Scope:} global
73a0d3bf
TB
3111@item @emph{Description}:
3112If set to @code{FALSE} or if unset, affinity displaying is disabled.
15886c03 3113If set to @code{TRUE}, the runtime displays affinity information about
73a0d3bf
TB
3114OpenMP threads in a parallel region upon entering the region and every time
3115any change occurs.
3116
3117@item @emph{See also}:
3118@ref{OMP_AFFINITY_FORMAT}
3119
3120@item @emph{Reference}:
3121@uref{https://www.openmp.org, OpenMP specification v5.0}, Section 6.13
3122@end table
3123
3124
3125
3126
d77de738
ML
3127@node OMP_DISPLAY_ENV
3128@section @env{OMP_DISPLAY_ENV} -- Show OpenMP version and environment variables
3129@cindex Environment Variable
3130@table @asis
2cd0689a
TB
3131@item @emph{ICV:} none
3132@item @emph{Scope:} not applicable
d77de738
ML
3133@item @emph{Description}:
3134If set to @code{TRUE}, the OpenMP version number and the values
3135associated with the OpenMP environment variables are printed to @code{stderr}.
3136If set to @code{VERBOSE}, it additionally shows the value of the environment
3137variables which are GNU extensions. If undefined or set to @code{FALSE},
15886c03 3138this information is not shown.
d77de738
ML
3139
3140
3141@item @emph{Reference}:
3142@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.12
3143@end table
3144
3145
3146
3147@node OMP_DEFAULT_DEVICE
3148@section @env{OMP_DEFAULT_DEVICE} -- Set the device used in target regions
3149@cindex Environment Variable
3150@table @asis
2cd0689a
TB
3151@item @emph{ICV:} @var{default-device-var}
3152@item @emph{Scope:} data environment
d77de738
ML
3153@item @emph{Description}:
3154Set to choose the device which is used in a @code{target} region, unless the
3155value is overridden by @code{omp_set_default_device} or by a @code{device}
3156clause. The value shall be the nonnegative device number. If no device with
3157the given device number exists, the code is executed on the host. If unset,
18c8b56c
TB
3158@env{OMP_TARGET_OFFLOAD} is @code{mandatory} and no non-host devices are
3159available, it is set to @code{omp_invalid_device}. Otherwise, if unset,
15886c03 3160device number 0 is used.
d77de738
ML
3161
3162
3163@item @emph{See also}:
3164@ref{omp_get_default_device}, @ref{omp_set_default_device},
8bd11fa4 3165@ref{OMP_TARGET_OFFLOAD}
d77de738
ML
3166
3167@item @emph{Reference}:
8bd11fa4 3168@uref{https://www.openmp.org, OpenMP specification v5.2}, Section 21.2.7
d77de738
ML
3169@end table
3170
3171
3172
3173@node OMP_DYNAMIC
3174@section @env{OMP_DYNAMIC} -- Dynamic adjustment of threads
3175@cindex Environment Variable
3176@table @asis
2cd0689a
TB
3177@item @emph{ICV:} @var{dyn-var}
3178@item @emph{Scope:} global
d77de738
ML
3179@item @emph{Description}:
3180Enable or disable the dynamic adjustment of the number of threads
3181within a team. The value of this environment variable shall be
3182@code{TRUE} or @code{FALSE}. If undefined, dynamic adjustment is
3183disabled by default.
3184
3185@item @emph{See also}:
3186@ref{omp_set_dynamic}
3187
3188@item @emph{Reference}:
3189@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.3
3190@end table
3191
3192
3193
3194@node OMP_MAX_ACTIVE_LEVELS
3195@section @env{OMP_MAX_ACTIVE_LEVELS} -- Set the maximum number of nested parallel regions
3196@cindex Environment Variable
3197@table @asis
2cd0689a
TB
3198@item @emph{ICV:} @var{max-active-levels-var}
3199@item @emph{Scope:} data environment
d77de738
ML
3200@item @emph{Description}:
3201Specifies the initial value for the maximum number of nested parallel
3202regions. The value of this variable shall be a positive integer.
3203If undefined, then if @env{OMP_NESTED} is defined and set to true, or
3204if @env{OMP_NUM_THREADS} or @env{OMP_PROC_BIND} are defined and set to
3205a list with more than one item, the maximum number of nested parallel
15886c03
TB
3206regions is initialized to the largest number supported, otherwise
3207it is set to one.
d77de738
ML
3208
3209@item @emph{See also}:
2cd0689a
TB
3210@ref{omp_set_max_active_levels}, @ref{OMP_NESTED}, @ref{OMP_PROC_BIND},
3211@ref{OMP_NUM_THREADS}
3212
d77de738
ML
3213
3214@item @emph{Reference}:
3215@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.9
3216@end table
3217
3218
3219
3220@node OMP_MAX_TASK_PRIORITY
3221@section @env{OMP_MAX_TASK_PRIORITY} -- Set the maximum priority
3222number that can be set for a task.
3223@cindex Environment Variable
3224@table @asis
2cd0689a
TB
3225@item @emph{ICV:} @var{max-task-priority-var}
3226@item @emph{Scope:} global
d77de738
ML
3227@item @emph{Description}:
3228Specifies the initial value for the maximum priority value that can be
3229set for a task. The value of this variable shall be a non-negative
3230integer, and zero is allowed. If undefined, the default priority is
32310.
3232
3233@item @emph{See also}:
3234@ref{omp_get_max_task_priority}
3235
3236@item @emph{Reference}:
3237@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.14
3238@end table
3239
3240
3241
3242@node OMP_NESTED
3243@section @env{OMP_NESTED} -- Nested parallel regions
3244@cindex Environment Variable
3245@cindex Implementation specific setting
3246@table @asis
2cd0689a
TB
3247@item @emph{ICV:} @var{max-active-levels-var}
3248@item @emph{Scope:} data environment
d77de738
ML
3249@item @emph{Description}:
3250Enable or disable nested parallel regions, i.e., whether team members
3251are allowed to create new teams. The value of this environment variable
3252shall be @code{TRUE} or @code{FALSE}. If set to @code{TRUE}, the number
15886c03
TB
3253of maximum active nested regions supported is by default set to the
3254maximum supported, otherwise it is set to one. If
3255@env{OMP_MAX_ACTIVE_LEVELS} is defined, its setting overrides this
d77de738
ML
3256setting. If both are undefined, nested parallel regions are enabled if
3257@env{OMP_NUM_THREADS} or @env{OMP_PROC_BINDS} are defined to a list with
3258more than one item, otherwise they are disabled by default.
3259
2cd0689a
TB
3260Note that the @code{OMP_NESTED} environment variable was deprecated in
3261the OpenMP specification 5.2 in favor of @code{OMP_MAX_ACTIVE_LEVELS}.
3262
d77de738 3263@item @emph{See also}:
2cd0689a
TB
3264@ref{omp_set_max_active_levels}, @ref{omp_set_nested},
3265@ref{OMP_MAX_ACTIVE_LEVELS}
d77de738
ML
3266
3267@item @emph{Reference}:
3268@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.6
3269@end table
3270
3271
3272
3273@node OMP_NUM_TEAMS
3274@section @env{OMP_NUM_TEAMS} -- Specifies the number of teams to use by teams region
3275@cindex Environment Variable
3276@table @asis
2cd0689a
TB
3277@item @emph{ICV:} @var{nteams-var}
3278@item @emph{Scope:} device
d77de738
ML
3279@item @emph{Description}:
3280Specifies the upper bound for number of teams to use in teams regions
3281without explicit @code{num_teams} clause. The value of this variable shall
3282be a positive integer. If undefined it defaults to 0 which means
3283implementation defined upper bound.
3284
3285@item @emph{See also}:
3286@ref{omp_set_num_teams}
3287
3288@item @emph{Reference}:
3289@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 6.23
3290@end table
3291
3292
3293
3294@node OMP_NUM_THREADS
3295@section @env{OMP_NUM_THREADS} -- Specifies the number of threads to use
3296@cindex Environment Variable
3297@cindex Implementation specific setting
3298@table @asis
2cd0689a
TB
3299@item @emph{ICV:} @var{nthreads-var}
3300@item @emph{Scope:} data environment
d77de738
ML
3301@item @emph{Description}:
3302Specifies the default number of threads to use in parallel regions. The
3303value of this variable shall be a comma-separated list of positive integers;
3304the value specifies the number of threads to use for the corresponding nested
15886c03 3305level. Specifying more than one item in the list automatically enables
d77de738
ML
3306nesting by default. If undefined one thread per CPU is used.
3307
2cd0689a
TB
3308When a list with more than value is specified, it also affects the
3309@var{max-active-levels-var} ICV as described in @ref{OMP_MAX_ACTIVE_LEVELS}.
3310
d77de738 3311@item @emph{See also}:
2cd0689a 3312@ref{omp_set_num_threads}, @ref{OMP_MAX_ACTIVE_LEVELS}
d77de738
ML
3313
3314@item @emph{Reference}:
3315@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.2
3316@end table
3317
3318
3319
3320@node OMP_PROC_BIND
0b9bd33d 3321@section @env{OMP_PROC_BIND} -- Whether threads may be moved between CPUs
d77de738
ML
3322@cindex Environment Variable
3323@table @asis
2cd0689a
TB
3324@item @emph{ICV:} @var{bind-var}
3325@item @emph{Scope:} data environment
d77de738
ML
3326@item @emph{Description}:
3327Specifies whether threads may be moved between processors. If set to
0b9bd33d 3328@code{TRUE}, OpenMP threads should not be moved; if set to @code{FALSE}
d77de738
ML
3329they may be moved. Alternatively, a comma separated list with the
3330values @code{PRIMARY}, @code{MASTER}, @code{CLOSE} and @code{SPREAD} can
3331be used to specify the thread affinity policy for the corresponding nesting
3332level. With @code{PRIMARY} and @code{MASTER} the worker threads are in the
3333same place partition as the primary thread. With @code{CLOSE} those are
3334kept close to the primary thread in contiguous place partitions. And
3335with @code{SPREAD} a sparse distribution
3336across the place partitions is used. Specifying more than one item in the
15886c03 3337list automatically enables nesting by default.
d77de738 3338
2cd0689a
TB
3339When a list is specified, it also affects the @var{max-active-levels-var} ICV
3340as described in @ref{OMP_MAX_ACTIVE_LEVELS}.
3341
d77de738
ML
3342When undefined, @env{OMP_PROC_BIND} defaults to @code{TRUE} when
3343@env{OMP_PLACES} or @env{GOMP_CPU_AFFINITY} is set and @code{FALSE} otherwise.
3344
3345@item @emph{See also}:
2cd0689a
TB
3346@ref{omp_get_proc_bind}, @ref{GOMP_CPU_AFFINITY}, @ref{OMP_PLACES},
3347@ref{OMP_MAX_ACTIVE_LEVELS}
d77de738
ML
3348
3349@item @emph{Reference}:
3350@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.4
3351@end table
3352
3353
3354
3355@node OMP_PLACES
0b9bd33d 3356@section @env{OMP_PLACES} -- Specifies on which CPUs the threads should be placed
d77de738
ML
3357@cindex Environment Variable
3358@table @asis
2cd0689a
TB
3359@item @emph{ICV:} @var{place-partition-var}
3360@item @emph{Scope:} implicit tasks
d77de738
ML
3361@item @emph{Description}:
3362The thread placement can be either specified using an abstract name or by an
3363explicit list of the places. The abstract names @code{threads}, @code{cores},
3364@code{sockets}, @code{ll_caches} and @code{numa_domains} can be optionally
3365followed by a positive number in parentheses, which denotes the how many places
3366shall be created. With @code{threads} each place corresponds to a single
3367hardware thread; @code{cores} to a single core with the corresponding number of
3368hardware threads; with @code{sockets} the place corresponds to a single
3369socket; with @code{ll_caches} to a set of cores that shares the last level
3370cache on the device; and @code{numa_domains} to a set of cores for which their
3371closest memory on the device is the same memory and at a similar distance from
3372the cores. The resulting placement can be shown by setting the
3373@env{OMP_DISPLAY_ENV} environment variable.
3374
3375Alternatively, the placement can be specified explicitly as comma-separated
3376list of places. A place is specified by set of nonnegative numbers in curly
3377braces, denoting the hardware threads. The curly braces can be omitted
3378when only a single number has been specified. The hardware threads
3379belonging to a place can either be specified as comma-separated list of
3380nonnegative thread numbers or using an interval. Multiple places can also be
3381either specified by a comma-separated list of places or by an interval. To
3382specify an interval, a colon followed by the count is placed after
3383the hardware thread number or the place. Optionally, the length can be
3384followed by a colon and the stride number -- otherwise a unit stride is
3385assumed. Placing an exclamation mark (@code{!}) directly before a curly
15886c03
TB
3386brace or numbers inside the curly braces (excluding intervals)
3387excludes those hardware threads.
d77de738
ML
3388
3389For instance, the following specifies the same places list:
3390@code{"@{0,1,2@}, @{3,4,6@}, @{7,8,9@}, @{10,11,12@}"};
3391@code{"@{0:3@}, @{3:3@}, @{7:3@}, @{10:3@}"}; and @code{"@{0:2@}:4:3"}.
3392
3393If @env{OMP_PLACES} and @env{GOMP_CPU_AFFINITY} are unset and
3394@env{OMP_PROC_BIND} is either unset or @code{false}, threads may be moved
3395between CPUs following no placement policy.
3396
3397@item @emph{See also}:
3398@ref{OMP_PROC_BIND}, @ref{GOMP_CPU_AFFINITY}, @ref{omp_get_proc_bind},
3399@ref{OMP_DISPLAY_ENV}
3400
3401@item @emph{Reference}:
3402@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.5
3403@end table
3404
3405
3406
3407@node OMP_STACKSIZE
3408@section @env{OMP_STACKSIZE} -- Set default thread stack size
3409@cindex Environment Variable
3410@table @asis
2cd0689a
TB
3411@item @emph{ICV:} @var{stacksize-var}
3412@item @emph{Scope:} device
d77de738
ML
3413@item @emph{Description}:
3414Set the default thread stack size in kilobytes, unless the number
3415is suffixed by @code{B}, @code{K}, @code{M} or @code{G}, in which
3416case the size is, respectively, in bytes, kilobytes, megabytes
3417or gigabytes. This is different from @code{pthread_attr_setstacksize}
3418which gets the number of bytes as an argument. If the stack size cannot
3419be set due to system constraints, an error is reported and the initial
3420stack size is left unchanged. If undefined, the stack size is system
3421dependent.
3422
2cd0689a
TB
3423@item @emph{See also}:
3424@ref{GOMP_STACKSIZE}
3425
d77de738
ML
3426@item @emph{Reference}:
3427@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.7
3428@end table
3429
3430
3431
3432@node OMP_SCHEDULE
3433@section @env{OMP_SCHEDULE} -- How threads are scheduled
3434@cindex Environment Variable
3435@cindex Implementation specific setting
3436@table @asis
2cd0689a
TB
3437@item @emph{ICV:} @var{run-sched-var}
3438@item @emph{Scope:} data environment
d77de738
ML
3439@item @emph{Description}:
3440Allows to specify @code{schedule type} and @code{chunk size}.
3441The value of the variable shall have the form: @code{type[,chunk]} where
3442@code{type} is one of @code{static}, @code{dynamic}, @code{guided} or @code{auto}
3443The optional @code{chunk} size shall be a positive integer. If undefined,
3444dynamic scheduling and a chunk size of 1 is used.
3445
3446@item @emph{See also}:
3447@ref{omp_set_schedule}
3448
3449@item @emph{Reference}:
3450@uref{https://www.openmp.org, OpenMP specification v4.5}, Sections 2.7.1.1 and 4.1
3451@end table
3452
3453
3454
3455@node OMP_TARGET_OFFLOAD
bc238c40 3456@section @env{OMP_TARGET_OFFLOAD} -- Controls offloading behavior
d77de738
ML
3457@cindex Environment Variable
3458@cindex Implementation specific setting
3459@table @asis
2cd0689a
TB
3460@item @emph{ICV:} @var{target-offload-var}
3461@item @emph{Scope:} global
d77de738 3462@item @emph{Description}:
bc238c40 3463Specifies the behavior with regard to offloading code to a device. This
d77de738
ML
3464variable can be set to one of three values - @code{MANDATORY}, @code{DISABLED}
3465or @code{DEFAULT}.
3466
15886c03 3467If set to @code{MANDATORY}, the program terminates with an error if
8bd11fa4
TB
3468any device construct or device memory routine uses a device that is unavailable
3469or not supported by the implementation, or uses a non-conforming device number.
15886c03
TB
3470If set to @code{DISABLED}, then offloading is disabled and all code runs on
3471the host. If set to @code{DEFAULT}, the program tries offloading to the
3472device first, then falls back to running code on the host if it cannot.
d77de738 3473
15886c03 3474If undefined, then the program behaves as if @code{DEFAULT} was set.
d77de738 3475
15886c03 3476Note: Even with @code{MANDATORY}, no run-time termination is performed when
8bd11fa4
TB
3477the device number in a @code{device} clause or argument to a device memory
3478routine is for host, which includes using the device number in the
3479@var{default-device-var} ICV. However, the initial value of
3480the @var{default-device-var} ICV is affected by @code{MANDATORY}.
3481
3482@item @emph{See also}:
3483@ref{OMP_DEFAULT_DEVICE}
3484
d77de738 3485@item @emph{Reference}:
8bd11fa4 3486@uref{https://www.openmp.org, OpenMP specification v5.2}, Section 21.2.8
d77de738
ML
3487@end table
3488
3489
3490
3491@node OMP_TEAMS_THREAD_LIMIT
3492@section @env{OMP_TEAMS_THREAD_LIMIT} -- Set the maximum number of threads imposed by teams
3493@cindex Environment Variable
3494@table @asis
2cd0689a
TB
3495@item @emph{ICV:} @var{teams-thread-limit-var}
3496@item @emph{Scope:} device
d77de738
ML
3497@item @emph{Description}:
3498Specifies an upper bound for the number of threads to use by each contention
3499group created by a teams construct without explicit @code{thread_limit}
3500clause. The value of this variable shall be a positive integer. If undefined,
3501the value of 0 is used which stands for an implementation defined upper
3502limit.
3503
3504@item @emph{See also}:
3505@ref{OMP_THREAD_LIMIT}, @ref{omp_set_teams_thread_limit}
3506
3507@item @emph{Reference}:
3508@uref{https://www.openmp.org, OpenMP specification v5.1}, Section 6.24
3509@end table
3510
3511
3512
3513@node OMP_THREAD_LIMIT
3514@section @env{OMP_THREAD_LIMIT} -- Set the maximum number of threads
3515@cindex Environment Variable
3516@table @asis
2cd0689a
TB
3517@item @emph{ICV:} @var{thread-limit-var}
3518@item @emph{Scope:} data environment
d77de738
ML
3519@item @emph{Description}:
3520Specifies the number of threads to use for the whole program. The
3521value of this variable shall be a positive integer. If undefined,
3522the number of threads is not limited.
3523
3524@item @emph{See also}:
3525@ref{OMP_NUM_THREADS}, @ref{omp_get_thread_limit}
3526
3527@item @emph{Reference}:
3528@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.10
3529@end table
3530
3531
3532
3533@node OMP_WAIT_POLICY
3534@section @env{OMP_WAIT_POLICY} -- How waiting threads are handled
3535@cindex Environment Variable
3536@table @asis
3537@item @emph{Description}:
3538Specifies whether waiting threads should be active or passive. If
3539the value is @code{PASSIVE}, waiting threads should not consume CPU
3540power while waiting; while the value is @code{ACTIVE} specifies that
3541they should. If undefined, threads wait actively for a short time
3542before waiting passively.
3543
3544@item @emph{See also}:
3545@ref{GOMP_SPINCOUNT}
3546
3547@item @emph{Reference}:
3548@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.8
3549@end table
3550
3551
3552
3553@node GOMP_CPU_AFFINITY
3554@section @env{GOMP_CPU_AFFINITY} -- Bind threads to specific CPUs
3555@cindex Environment Variable
3556@table @asis
3557@item @emph{Description}:
3558Binds threads to specific CPUs. The variable should contain a space-separated
3559or comma-separated list of CPUs. This list may contain different kinds of
3560entries: either single CPU numbers in any order, a range of CPUs (M-N)
3561or a range with some stride (M-N:S). CPU numbers are zero based. For example,
15886c03 3562@code{GOMP_CPU_AFFINITY="0 3 1-2 4-15:2"} binds the initial thread
d77de738
ML
3563to CPU 0, the second to CPU 3, the third to CPU 1, the fourth to
3564CPU 2, the fifth to CPU 4, the sixth through tenth to CPUs 6, 8, 10, 12,
15886c03 3565and 14 respectively and then starts assigning back from the beginning of
d77de738
ML
3566the list. @code{GOMP_CPU_AFFINITY=0} binds all threads to CPU 0.
3567
3568There is no libgomp library routine to determine whether a CPU affinity
3569specification is in effect. As a workaround, language-specific library
3570functions, e.g., @code{getenv} in C or @code{GET_ENVIRONMENT_VARIABLE} in
3571Fortran, may be used to query the setting of the @code{GOMP_CPU_AFFINITY}
3572environment variable. A defined CPU affinity on startup cannot be changed
3573or disabled during the runtime of the application.
3574
3575If both @env{GOMP_CPU_AFFINITY} and @env{OMP_PROC_BIND} are set,
3576@env{OMP_PROC_BIND} has a higher precedence. If neither has been set and
3577@env{OMP_PROC_BIND} is unset, or when @env{OMP_PROC_BIND} is set to
15886c03 3578@code{FALSE}, the host system handles the assignment of threads to CPUs.
d77de738
ML
3579
3580@item @emph{See also}:
3581@ref{OMP_PLACES}, @ref{OMP_PROC_BIND}
3582@end table
3583
3584
3585
3586@node GOMP_DEBUG
3587@section @env{GOMP_DEBUG} -- Enable debugging output
3588@cindex Environment Variable
3589@table @asis
3590@item @emph{Description}:
3591Enable debugging output. The variable should be set to @code{0}
3592(disabled, also the default if not set), or @code{1} (enabled).
3593
15886c03 3594If enabled, some debugging output is printed during execution.
d77de738
ML
3595This is currently not specified in more detail, and subject to change.
3596@end table
3597
3598
3599
3600@node GOMP_STACKSIZE
3601@section @env{GOMP_STACKSIZE} -- Set default thread stack size
3602@cindex Environment Variable
3603@cindex Implementation specific setting
3604@table @asis
3605@item @emph{Description}:
3606Set the default thread stack size in kilobytes. This is different from
3607@code{pthread_attr_setstacksize} which gets the number of bytes as an
3608argument. If the stack size cannot be set due to system constraints, an
3609error is reported and the initial stack size is left unchanged. If undefined,
3610the stack size is system dependent.
3611
3612@item @emph{See also}:
3613@ref{OMP_STACKSIZE}
3614
3615@item @emph{Reference}:
3616@uref{https://gcc.gnu.org/ml/gcc-patches/2006-06/msg00493.html,
3617GCC Patches Mailinglist},
3618@uref{https://gcc.gnu.org/ml/gcc-patches/2006-06/msg00496.html,
3619GCC Patches Mailinglist}
3620@end table
3621
3622
3623
3624@node GOMP_SPINCOUNT
3625@section @env{GOMP_SPINCOUNT} -- Set the busy-wait spin count
3626@cindex Environment Variable
3627@cindex Implementation specific setting
3628@table @asis
3629@item @emph{Description}:
3630Determines how long a threads waits actively with consuming CPU power
3631before waiting passively without consuming CPU power. The value may be
3632either @code{INFINITE}, @code{INFINITY} to always wait actively or an
3633integer which gives the number of spins of the busy-wait loop. The
3634integer may optionally be followed by the following suffixes acting
3635as multiplication factors: @code{k} (kilo, thousand), @code{M} (mega,
3636million), @code{G} (giga, billion), or @code{T} (tera, trillion).
3637If undefined, 0 is used when @env{OMP_WAIT_POLICY} is @code{PASSIVE},
3638300,000 is used when @env{OMP_WAIT_POLICY} is undefined and
363930 billion is used when @env{OMP_WAIT_POLICY} is @code{ACTIVE}.
3640If there are more OpenMP threads than available CPUs, 1000 and 100
3641spins are used for @env{OMP_WAIT_POLICY} being @code{ACTIVE} or
3642undefined, respectively; unless the @env{GOMP_SPINCOUNT} is lower
3643or @env{OMP_WAIT_POLICY} is @code{PASSIVE}.
3644
3645@item @emph{See also}:
3646@ref{OMP_WAIT_POLICY}
3647@end table
3648
3649
3650
3651@node GOMP_RTEMS_THREAD_POOLS
3652@section @env{GOMP_RTEMS_THREAD_POOLS} -- Set the RTEMS specific thread pools
3653@cindex Environment Variable
3654@cindex Implementation specific setting
3655@table @asis
3656@item @emph{Description}:
3657This environment variable is only used on the RTEMS real-time operating system.
3658It determines the scheduler instance specific thread pools. The format for
3659@env{GOMP_RTEMS_THREAD_POOLS} is a list of optional
3660@code{<thread-pool-count>[$<priority>]@@<scheduler-name>} configurations
3661separated by @code{:} where:
3662@itemize @bullet
3663@item @code{<thread-pool-count>} is the thread pool count for this scheduler
3664instance.
3665@item @code{$<priority>} is an optional priority for the worker threads of a
3666thread pool according to @code{pthread_setschedparam}. In case a priority
15886c03 3667value is omitted, then a worker thread inherits the priority of the OpenMP
d77de738
ML
3668primary thread that created it. The priority of the worker thread is not
3669changed after creation, even if a new OpenMP primary thread using the worker has
3670a different priority.
3671@item @code{@@<scheduler-name>} is the scheduler instance name according to the
3672RTEMS application configuration.
3673@end itemize
3674In case no thread pool configuration is specified for a scheduler instance,
15886c03 3675then each OpenMP primary thread of this scheduler instance uses its own
d77de738
ML
3676dynamically allocated thread pool. To limit the worker thread count of the
3677thread pools, each OpenMP primary thread must call @code{omp_set_num_threads}.
3678@item @emph{Example}:
3679Lets suppose we have three scheduler instances @code{IO}, @code{WRK0}, and
3680@code{WRK1} with @env{GOMP_RTEMS_THREAD_POOLS} set to
3681@code{"1@@WRK0:3$4@@WRK1"}. Then there are no thread pool restrictions for
3682scheduler instance @code{IO}. In the scheduler instance @code{WRK0} there is
3683one thread pool available. Since no priority is specified for this scheduler
3684instance, the worker thread inherits the priority of the OpenMP primary thread
3685that created it. In the scheduler instance @code{WRK1} there are three thread
3686pools available and their worker threads run at priority four.
3687@end table
3688
3689
3690
3691@c ---------------------------------------------------------------------
3692@c Enabling OpenACC
3693@c ---------------------------------------------------------------------
3694
3695@node Enabling OpenACC
3696@chapter Enabling OpenACC
3697
3698To activate the OpenACC extensions for C/C++ and Fortran, the compile-time
3699flag @option{-fopenacc} must be specified. This enables the OpenACC directive
3700@code{#pragma acc} in C/C++ and @code{!$acc} directives in free form,
3701@code{c$acc}, @code{*$acc} and @code{!$acc} directives in fixed form,
3702@code{!$} conditional compilation sentinels in free form and @code{c$},
3703@code{*$} and @code{!$} sentinels in fixed form, for Fortran. The flag also
3704arranges for automatic linking of the OpenACC runtime library
3705(@ref{OpenACC Runtime Library Routines}).
3706
3707See @uref{https://gcc.gnu.org/wiki/OpenACC} for more information.
3708
3709A complete description of all OpenACC directives accepted may be found in
3710the @uref{https://www.openacc.org, OpenACC} Application Programming
3711Interface manual, version 2.6.
3712
3713
3714
3715@c ---------------------------------------------------------------------
3716@c OpenACC Runtime Library Routines
3717@c ---------------------------------------------------------------------
3718
3719@node OpenACC Runtime Library Routines
3720@chapter OpenACC Runtime Library Routines
3721
3722The runtime routines described here are defined by section 3 of the OpenACC
3723specifications in version 2.6.
3724They have C linkage, and do not throw exceptions.
3725Generally, they are available only for the host, with the exception of
3726@code{acc_on_device}, which is available for both the host and the
3727acceleration device.
3728
3729@menu
3730* acc_get_num_devices:: Get number of devices for the given device
3731 type.
3732* acc_set_device_type:: Set type of device accelerator to use.
3733* acc_get_device_type:: Get type of device accelerator to be used.
3734* acc_set_device_num:: Set device number to use.
3735* acc_get_device_num:: Get device number to be used.
3736* acc_get_property:: Get device property.
3737* acc_async_test:: Tests for completion of a specific asynchronous
3738 operation.
3739* acc_async_test_all:: Tests for completion of all asynchronous
3740 operations.
3741* acc_wait:: Wait for completion of a specific asynchronous
3742 operation.
3743* acc_wait_all:: Waits for completion of all asynchronous
3744 operations.
3745* acc_wait_all_async:: Wait for completion of all asynchronous
3746 operations.
3747* acc_wait_async:: Wait for completion of asynchronous operations.
3748* acc_init:: Initialize runtime for a specific device type.
3749* acc_shutdown:: Shuts down the runtime for a specific device
3750 type.
3751* acc_on_device:: Whether executing on a particular device
3752* acc_malloc:: Allocate device memory.
3753* acc_free:: Free device memory.
3754* acc_copyin:: Allocate device memory and copy host memory to
3755 it.
3756* acc_present_or_copyin:: If the data is not present on the device,
3757 allocate device memory and copy from host
3758 memory.
3759* acc_create:: Allocate device memory and map it to host
3760 memory.
3761* acc_present_or_create:: If the data is not present on the device,
3762 allocate device memory and map it to host
3763 memory.
3764* acc_copyout:: Copy device memory to host memory.
3765* acc_delete:: Free device memory.
3766* acc_update_device:: Update device memory from mapped host memory.
3767* acc_update_self:: Update host memory from mapped device memory.
3768* acc_map_data:: Map previously allocated device memory to host
3769 memory.
3770* acc_unmap_data:: Unmap device memory from host memory.
3771* acc_deviceptr:: Get device pointer associated with specific
3772 host address.
3773* acc_hostptr:: Get host pointer associated with specific
3774 device address.
3775* acc_is_present:: Indicate whether host variable / array is
3776 present on device.
3777* acc_memcpy_to_device:: Copy host memory to device memory.
3778* acc_memcpy_from_device:: Copy device memory to host memory.
3779* acc_attach:: Let device pointer point to device-pointer target.
3780* acc_detach:: Let device pointer point to host-pointer target.
3781
3782API routines for target platforms.
3783
3784* acc_get_current_cuda_device:: Get CUDA device handle.
3785* acc_get_current_cuda_context::Get CUDA context handle.
3786* acc_get_cuda_stream:: Get CUDA stream handle.
3787* acc_set_cuda_stream:: Set CUDA stream handle.
3788
3789API routines for the OpenACC Profiling Interface.
3790
3791* acc_prof_register:: Register callbacks.
3792* acc_prof_unregister:: Unregister callbacks.
3793* acc_prof_lookup:: Obtain inquiry functions.
3794* acc_register_library:: Library registration.
3795@end menu
3796
3797
3798
3799@node acc_get_num_devices
3800@section @code{acc_get_num_devices} -- Get number of devices for given device type
3801@table @asis
3802@item @emph{Description}
3803This function returns a value indicating the number of devices available
3804for the device type specified in @var{devicetype}.
3805
3806@item @emph{C/C++}:
3807@multitable @columnfractions .20 .80
3808@item @emph{Prototype}: @tab @code{int acc_get_num_devices(acc_device_t devicetype);}
3809@end multitable
3810
3811@item @emph{Fortran}:
3812@multitable @columnfractions .20 .80
3813@item @emph{Interface}: @tab @code{integer function acc_get_num_devices(devicetype)}
3814@item @tab @code{integer(kind=acc_device_kind) devicetype}
3815@end multitable
3816
3817@item @emph{Reference}:
3818@uref{https://www.openacc.org, OpenACC specification v2.6}, section
38193.2.1.
3820@end table
3821
3822
3823
3824@node acc_set_device_type
3825@section @code{acc_set_device_type} -- Set type of device accelerator to use.
3826@table @asis
3827@item @emph{Description}
3828This function indicates to the runtime library which device type, specified
3829in @var{devicetype}, to use when executing a parallel or kernels region.
3830
3831@item @emph{C/C++}:
3832@multitable @columnfractions .20 .80
3833@item @emph{Prototype}: @tab @code{acc_set_device_type(acc_device_t devicetype);}
3834@end multitable
3835
3836@item @emph{Fortran}:
3837@multitable @columnfractions .20 .80
3838@item @emph{Interface}: @tab @code{subroutine acc_set_device_type(devicetype)}
3839@item @tab @code{integer(kind=acc_device_kind) devicetype}
3840@end multitable
3841
3842@item @emph{Reference}:
3843@uref{https://www.openacc.org, OpenACC specification v2.6}, section
38443.2.2.
3845@end table
3846
3847
3848
3849@node acc_get_device_type
3850@section @code{acc_get_device_type} -- Get type of device accelerator to be used.
3851@table @asis
3852@item @emph{Description}
3853This function returns what device type will be used when executing a
3854parallel or kernels region.
3855
3856This function returns @code{acc_device_none} if
3857@code{acc_get_device_type} is called from
3858@code{acc_ev_device_init_start}, @code{acc_ev_device_init_end}
3859callbacks of the OpenACC Profiling Interface (@ref{OpenACC Profiling
3860Interface}), that is, if the device is currently being initialized.
3861
3862@item @emph{C/C++}:
3863@multitable @columnfractions .20 .80
3864@item @emph{Prototype}: @tab @code{acc_device_t acc_get_device_type(void);}
3865@end multitable
3866
3867@item @emph{Fortran}:
3868@multitable @columnfractions .20 .80
3869@item @emph{Interface}: @tab @code{function acc_get_device_type(void)}
3870@item @tab @code{integer(kind=acc_device_kind) acc_get_device_type}
3871@end multitable
3872
3873@item @emph{Reference}:
3874@uref{https://www.openacc.org, OpenACC specification v2.6}, section
38753.2.3.
3876@end table
3877
3878
3879
3880@node acc_set_device_num
3881@section @code{acc_set_device_num} -- Set device number to use.
3882@table @asis
3883@item @emph{Description}
3884This function will indicate to the runtime which device number,
3885specified by @var{devicenum}, associated with the specified device
3886type @var{devicetype}.
3887
3888@item @emph{C/C++}:
3889@multitable @columnfractions .20 .80
3890@item @emph{Prototype}: @tab @code{acc_set_device_num(int devicenum, acc_device_t devicetype);}
3891@end multitable
3892
3893@item @emph{Fortran}:
3894@multitable @columnfractions .20 .80
3895@item @emph{Interface}: @tab @code{subroutine acc_set_device_num(devicenum, devicetype)}
3896@item @tab @code{integer devicenum}
3897@item @tab @code{integer(kind=acc_device_kind) devicetype}
3898@end multitable
3899
3900@item @emph{Reference}:
3901@uref{https://www.openacc.org, OpenACC specification v2.6}, section
39023.2.4.
3903@end table
3904
3905
3906
3907@node acc_get_device_num
3908@section @code{acc_get_device_num} -- Get device number to be used.
3909@table @asis
3910@item @emph{Description}
3911This function returns which device number associated with the specified device
3912type @var{devicetype}, will be used when executing a parallel or kernels
3913region.
3914
3915@item @emph{C/C++}:
3916@multitable @columnfractions .20 .80
3917@item @emph{Prototype}: @tab @code{int acc_get_device_num(acc_device_t devicetype);}
3918@end multitable
3919
3920@item @emph{Fortran}:
3921@multitable @columnfractions .20 .80
3922@item @emph{Interface}: @tab @code{function acc_get_device_num(devicetype)}
3923@item @tab @code{integer(kind=acc_device_kind) devicetype}
3924@item @tab @code{integer acc_get_device_num}
3925@end multitable
3926
3927@item @emph{Reference}:
3928@uref{https://www.openacc.org, OpenACC specification v2.6}, section
39293.2.5.
3930@end table
3931
3932
3933
3934@node acc_get_property
3935@section @code{acc_get_property} -- Get device property.
3936@cindex acc_get_property
3937@cindex acc_get_property_string
3938@table @asis
3939@item @emph{Description}
3940These routines return the value of the specified @var{property} for the
3941device being queried according to @var{devicenum} and @var{devicetype}.
3942Integer-valued and string-valued properties are returned by
3943@code{acc_get_property} and @code{acc_get_property_string} respectively.
3944The Fortran @code{acc_get_property_string} subroutine returns the string
3945retrieved in its fourth argument while the remaining entry points are
3946functions, which pass the return value as their result.
3947
3948Note for Fortran, only: the OpenACC technical committee corrected and, hence,
3949modified the interface introduced in OpenACC 2.6. The kind-value parameter
3950@code{acc_device_property} has been renamed to @code{acc_device_property_kind}
3951for consistency and the return type of the @code{acc_get_property} function is
3952now a @code{c_size_t} integer instead of a @code{acc_device_property} integer.
15886c03 3953The parameter @code{acc_device_property} is still provided,
d77de738
ML
3954but might be removed in a future version of GCC.
3955
3956@item @emph{C/C++}:
3957@multitable @columnfractions .20 .80
3958@item @emph{Prototype}: @tab @code{size_t acc_get_property(int devicenum, acc_device_t devicetype, acc_device_property_t property);}
3959@item @emph{Prototype}: @tab @code{const char *acc_get_property_string(int devicenum, acc_device_t devicetype, acc_device_property_t property);}
3960@end multitable
3961
3962@item @emph{Fortran}:
3963@multitable @columnfractions .20 .80
3964@item @emph{Interface}: @tab @code{function acc_get_property(devicenum, devicetype, property)}
3965@item @emph{Interface}: @tab @code{subroutine acc_get_property_string(devicenum, devicetype, property, string)}
3966@item @tab @code{use ISO_C_Binding, only: c_size_t}
3967@item @tab @code{integer devicenum}
3968@item @tab @code{integer(kind=acc_device_kind) devicetype}
3969@item @tab @code{integer(kind=acc_device_property_kind) property}
3970@item @tab @code{integer(kind=c_size_t) acc_get_property}
3971@item @tab @code{character(*) string}
3972@end multitable
3973
3974@item @emph{Reference}:
3975@uref{https://www.openacc.org, OpenACC specification v2.6}, section
39763.2.6.
3977@end table
3978
3979
3980
3981@node acc_async_test
3982@section @code{acc_async_test} -- Test for completion of a specific asynchronous operation.
3983@table @asis
3984@item @emph{Description}
3985This function tests for completion of the asynchronous operation specified
15886c03
TB
3986in @var{arg}. In C/C++, a non-zero value is returned to indicate
3987the specified asynchronous operation has completed while Fortran returns
3988@code{true}. If the asynchronous operation has not completed, C/C++ returns
3989zero and Fortran returns @code{false}.
d77de738
ML
3990
3991@item @emph{C/C++}:
3992@multitable @columnfractions .20 .80
3993@item @emph{Prototype}: @tab @code{int acc_async_test(int arg);}
3994@end multitable
3995
3996@item @emph{Fortran}:
3997@multitable @columnfractions .20 .80
3998@item @emph{Interface}: @tab @code{function acc_async_test(arg)}
3999@item @tab @code{integer(kind=acc_handle_kind) arg}
4000@item @tab @code{logical acc_async_test}
4001@end multitable
4002
4003@item @emph{Reference}:
4004@uref{https://www.openacc.org, OpenACC specification v2.6}, section
40053.2.9.
4006@end table
4007
4008
4009
4010@node acc_async_test_all
4011@section @code{acc_async_test_all} -- Tests for completion of all asynchronous operations.
4012@table @asis
4013@item @emph{Description}
4014This function tests for completion of all asynchronous operations.
15886c03
TB
4015In C/C++, a non-zero value is returned to indicate all asynchronous
4016operations have completed while Fortran returns @code{true}. If
4017any asynchronous operation has not completed, C/C++ returns zero and
4018Fortran returns @code{false}.
d77de738
ML
4019
4020@item @emph{C/C++}:
4021@multitable @columnfractions .20 .80
4022@item @emph{Prototype}: @tab @code{int acc_async_test_all(void);}
4023@end multitable
4024
4025@item @emph{Fortran}:
4026@multitable @columnfractions .20 .80
4027@item @emph{Interface}: @tab @code{function acc_async_test()}
4028@item @tab @code{logical acc_get_device_num}
4029@end multitable
4030
4031@item @emph{Reference}:
4032@uref{https://www.openacc.org, OpenACC specification v2.6}, section
40333.2.10.
4034@end table
4035
4036
4037
4038@node acc_wait
4039@section @code{acc_wait} -- Wait for completion of a specific asynchronous operation.
4040@table @asis
4041@item @emph{Description}
4042This function waits for completion of the asynchronous operation
4043specified in @var{arg}.
4044
4045@item @emph{C/C++}:
4046@multitable @columnfractions .20 .80
4047@item @emph{Prototype}: @tab @code{acc_wait(arg);}
4048@item @emph{Prototype (OpenACC 1.0 compatibility)}: @tab @code{acc_async_wait(arg);}
4049@end multitable
4050
4051@item @emph{Fortran}:
4052@multitable @columnfractions .20 .80
4053@item @emph{Interface}: @tab @code{subroutine acc_wait(arg)}
4054@item @tab @code{integer(acc_handle_kind) arg}
4055@item @emph{Interface (OpenACC 1.0 compatibility)}: @tab @code{subroutine acc_async_wait(arg)}
4056@item @tab @code{integer(acc_handle_kind) arg}
4057@end multitable
4058
4059@item @emph{Reference}:
4060@uref{https://www.openacc.org, OpenACC specification v2.6}, section
40613.2.11.
4062@end table
4063
4064
4065
4066@node acc_wait_all
4067@section @code{acc_wait_all} -- Waits for completion of all asynchronous operations.
4068@table @asis
4069@item @emph{Description}
4070This function waits for the completion of all asynchronous operations.
4071
4072@item @emph{C/C++}:
4073@multitable @columnfractions .20 .80
4074@item @emph{Prototype}: @tab @code{acc_wait_all(void);}
4075@item @emph{Prototype (OpenACC 1.0 compatibility)}: @tab @code{acc_async_wait_all(void);}
4076@end multitable
4077
4078@item @emph{Fortran}:
4079@multitable @columnfractions .20 .80
4080@item @emph{Interface}: @tab @code{subroutine acc_wait_all()}
4081@item @emph{Interface (OpenACC 1.0 compatibility)}: @tab @code{subroutine acc_async_wait_all()}
4082@end multitable
4083
4084@item @emph{Reference}:
4085@uref{https://www.openacc.org, OpenACC specification v2.6}, section
40863.2.13.
4087@end table
4088
4089
4090
4091@node acc_wait_all_async
4092@section @code{acc_wait_all_async} -- Wait for completion of all asynchronous operations.
4093@table @asis
4094@item @emph{Description}
4095This function enqueues a wait operation on the queue @var{async} for any
4096and all asynchronous operations that have been previously enqueued on
4097any queue.
4098
4099@item @emph{C/C++}:
4100@multitable @columnfractions .20 .80
4101@item @emph{Prototype}: @tab @code{acc_wait_all_async(int async);}
4102@end multitable
4103
4104@item @emph{Fortran}:
4105@multitable @columnfractions .20 .80
4106@item @emph{Interface}: @tab @code{subroutine acc_wait_all_async(async)}
4107@item @tab @code{integer(acc_handle_kind) async}
4108@end multitable
4109
4110@item @emph{Reference}:
4111@uref{https://www.openacc.org, OpenACC specification v2.6}, section
41123.2.14.
4113@end table
4114
4115
4116
4117@node acc_wait_async
4118@section @code{acc_wait_async} -- Wait for completion of asynchronous operations.
4119@table @asis
4120@item @emph{Description}
4121This function enqueues a wait operation on queue @var{async} for any and all
4122asynchronous operations enqueued on queue @var{arg}.
4123
4124@item @emph{C/C++}:
4125@multitable @columnfractions .20 .80
4126@item @emph{Prototype}: @tab @code{acc_wait_async(int arg, int async);}
4127@end multitable
4128
4129@item @emph{Fortran}:
4130@multitable @columnfractions .20 .80
4131@item @emph{Interface}: @tab @code{subroutine acc_wait_async(arg, async)}
4132@item @tab @code{integer(acc_handle_kind) arg, async}
4133@end multitable
4134
4135@item @emph{Reference}:
4136@uref{https://www.openacc.org, OpenACC specification v2.6}, section
41373.2.12.
4138@end table
4139
4140
4141
4142@node acc_init
4143@section @code{acc_init} -- Initialize runtime for a specific device type.
4144@table @asis
4145@item @emph{Description}
4146This function initializes the runtime for the device type specified in
4147@var{devicetype}.
4148
4149@item @emph{C/C++}:
4150@multitable @columnfractions .20 .80
4151@item @emph{Prototype}: @tab @code{acc_init(acc_device_t devicetype);}
4152@end multitable
4153
4154@item @emph{Fortran}:
4155@multitable @columnfractions .20 .80
4156@item @emph{Interface}: @tab @code{subroutine acc_init(devicetype)}
4157@item @tab @code{integer(acc_device_kind) devicetype}
4158@end multitable
4159
4160@item @emph{Reference}:
4161@uref{https://www.openacc.org, OpenACC specification v2.6}, section
41623.2.7.
4163@end table
4164
4165
4166
4167@node acc_shutdown
4168@section @code{acc_shutdown} -- Shuts down the runtime for a specific device type.
4169@table @asis
4170@item @emph{Description}
4171This function shuts down the runtime for the device type specified in
4172@var{devicetype}.
4173
4174@item @emph{C/C++}:
4175@multitable @columnfractions .20 .80
4176@item @emph{Prototype}: @tab @code{acc_shutdown(acc_device_t devicetype);}
4177@end multitable
4178
4179@item @emph{Fortran}:
4180@multitable @columnfractions .20 .80
4181@item @emph{Interface}: @tab @code{subroutine acc_shutdown(devicetype)}
4182@item @tab @code{integer(acc_device_kind) devicetype}
4183@end multitable
4184
4185@item @emph{Reference}:
4186@uref{https://www.openacc.org, OpenACC specification v2.6}, section
41873.2.8.
4188@end table
4189
4190
4191
4192@node acc_on_device
4193@section @code{acc_on_device} -- Whether executing on a particular device
4194@table @asis
4195@item @emph{Description}:
4196This function returns whether the program is executing on a particular
4197device specified in @var{devicetype}. In C/C++ a non-zero value is
4198returned to indicate the device is executing on the specified device type.
15886c03
TB
4199In Fortran, @code{true} is returned. If the program is not executing
4200on the specified device type C/C++ returns zero, while Fortran
4201returns @code{false}.
d77de738
ML
4202
4203@item @emph{C/C++}:
4204@multitable @columnfractions .20 .80
4205@item @emph{Prototype}: @tab @code{acc_on_device(acc_device_t devicetype);}
4206@end multitable
4207
4208@item @emph{Fortran}:
4209@multitable @columnfractions .20 .80
4210@item @emph{Interface}: @tab @code{function acc_on_device(devicetype)}
4211@item @tab @code{integer(acc_device_kind) devicetype}
4212@item @tab @code{logical acc_on_device}
4213@end multitable
4214
4215
4216@item @emph{Reference}:
4217@uref{https://www.openacc.org, OpenACC specification v2.6}, section
42183.2.17.
4219@end table
4220
4221
4222
4223@node acc_malloc
4224@section @code{acc_malloc} -- Allocate device memory.
4225@table @asis
4226@item @emph{Description}
4227This function allocates @var{len} bytes of device memory. It returns
4228the device address of the allocated memory.
4229
4230@item @emph{C/C++}:
4231@multitable @columnfractions .20 .80
4232@item @emph{Prototype}: @tab @code{d_void* acc_malloc(size_t len);}
4233@end multitable
4234
4235@item @emph{Reference}:
4236@uref{https://www.openacc.org, OpenACC specification v2.6}, section
42373.2.18.
4238@end table
4239
4240
4241
4242@node acc_free
4243@section @code{acc_free} -- Free device memory.
4244@table @asis
4245@item @emph{Description}
4246Free previously allocated device memory at the device address @code{a}.
4247
4248@item @emph{C/C++}:
4249@multitable @columnfractions .20 .80
4250@item @emph{Prototype}: @tab @code{acc_free(d_void *a);}
4251@end multitable
4252
4253@item @emph{Reference}:
4254@uref{https://www.openacc.org, OpenACC specification v2.6}, section
42553.2.19.
4256@end table
4257
4258
4259
4260@node acc_copyin
4261@section @code{acc_copyin} -- Allocate device memory and copy host memory to it.
4262@table @asis
4263@item @emph{Description}
4264In C/C++, this function allocates @var{len} bytes of device memory
4265and maps it to the specified host address in @var{a}. The device
4266address of the newly allocated device memory is returned.
4267
4268In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
4269a contiguous array section. The second form @var{a} specifies a
4270variable or array element and @var{len} specifies the length in bytes.
4271
4272@item @emph{C/C++}:
4273@multitable @columnfractions .20 .80
4274@item @emph{Prototype}: @tab @code{void *acc_copyin(h_void *a, size_t len);}
4275@item @emph{Prototype}: @tab @code{void *acc_copyin_async(h_void *a, size_t len, int async);}
4276@end multitable
4277
4278@item @emph{Fortran}:
4279@multitable @columnfractions .20 .80
4280@item @emph{Interface}: @tab @code{subroutine acc_copyin(a)}
4281@item @tab @code{type, dimension(:[,:]...) :: a}
4282@item @emph{Interface}: @tab @code{subroutine acc_copyin(a, len)}
4283@item @tab @code{type, dimension(:[,:]...) :: a}
4284@item @tab @code{integer len}
4285@item @emph{Interface}: @tab @code{subroutine acc_copyin_async(a, async)}
4286@item @tab @code{type, dimension(:[,:]...) :: a}
4287@item @tab @code{integer(acc_handle_kind) :: async}
4288@item @emph{Interface}: @tab @code{subroutine acc_copyin_async(a, len, async)}
4289@item @tab @code{type, dimension(:[,:]...) :: a}
4290@item @tab @code{integer len}
4291@item @tab @code{integer(acc_handle_kind) :: async}
4292@end multitable
4293
4294@item @emph{Reference}:
4295@uref{https://www.openacc.org, OpenACC specification v2.6}, section
42963.2.20.
4297@end table
4298
4299
4300
4301@node acc_present_or_copyin
4302@section @code{acc_present_or_copyin} -- If the data is not present on the device, allocate device memory and copy from host memory.
4303@table @asis
4304@item @emph{Description}
4305This function tests if the host data specified by @var{a} and of length
15886c03
TB
4306@var{len} is present or not. If it is not present, device memory
4307is allocated and the host memory copied. The device address of
d77de738
ML
4308the newly allocated device memory is returned.
4309
4310In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
4311a contiguous array section. The second form @var{a} specifies a variable or
4312array element and @var{len} specifies the length in bytes.
4313
4314Note that @code{acc_present_or_copyin} and @code{acc_pcopyin} exist for
4315backward compatibility with OpenACC 2.0; use @ref{acc_copyin} instead.
4316
4317@item @emph{C/C++}:
4318@multitable @columnfractions .20 .80
4319@item @emph{Prototype}: @tab @code{void *acc_present_or_copyin(h_void *a, size_t len);}
4320@item @emph{Prototype}: @tab @code{void *acc_pcopyin(h_void *a, size_t len);}
4321@end multitable
4322
4323@item @emph{Fortran}:
4324@multitable @columnfractions .20 .80
4325@item @emph{Interface}: @tab @code{subroutine acc_present_or_copyin(a)}
4326@item @tab @code{type, dimension(:[,:]...) :: a}
4327@item @emph{Interface}: @tab @code{subroutine acc_present_or_copyin(a, len)}
4328@item @tab @code{type, dimension(:[,:]...) :: a}
4329@item @tab @code{integer len}
4330@item @emph{Interface}: @tab @code{subroutine acc_pcopyin(a)}
4331@item @tab @code{type, dimension(:[,:]...) :: a}
4332@item @emph{Interface}: @tab @code{subroutine acc_pcopyin(a, len)}
4333@item @tab @code{type, dimension(:[,:]...) :: a}
4334@item @tab @code{integer len}
4335@end multitable
4336
4337@item @emph{Reference}:
4338@uref{https://www.openacc.org, OpenACC specification v2.6}, section
43393.2.20.
4340@end table
4341
4342
4343
4344@node acc_create
4345@section @code{acc_create} -- Allocate device memory and map it to host memory.
4346@table @asis
4347@item @emph{Description}
4348This function allocates device memory and maps it to host memory specified
4349by the host address @var{a} with a length of @var{len} bytes. In C/C++,
4350the function returns the device address of the allocated device memory.
4351
4352In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
4353a contiguous array section. The second form @var{a} specifies a variable or
4354array element and @var{len} specifies the length in bytes.
4355
4356@item @emph{C/C++}:
4357@multitable @columnfractions .20 .80
4358@item @emph{Prototype}: @tab @code{void *acc_create(h_void *a, size_t len);}
4359@item @emph{Prototype}: @tab @code{void *acc_create_async(h_void *a, size_t len, int async);}
4360@end multitable
4361
4362@item @emph{Fortran}:
4363@multitable @columnfractions .20 .80
4364@item @emph{Interface}: @tab @code{subroutine acc_create(a)}
4365@item @tab @code{type, dimension(:[,:]...) :: a}
4366@item @emph{Interface}: @tab @code{subroutine acc_create(a, len)}
4367@item @tab @code{type, dimension(:[,:]...) :: a}
4368@item @tab @code{integer len}
4369@item @emph{Interface}: @tab @code{subroutine acc_create_async(a, async)}
4370@item @tab @code{type, dimension(:[,:]...) :: a}
4371@item @tab @code{integer(acc_handle_kind) :: async}
4372@item @emph{Interface}: @tab @code{subroutine acc_create_async(a, len, async)}
4373@item @tab @code{type, dimension(:[,:]...) :: a}
4374@item @tab @code{integer len}
4375@item @tab @code{integer(acc_handle_kind) :: async}
4376@end multitable
4377
4378@item @emph{Reference}:
4379@uref{https://www.openacc.org, OpenACC specification v2.6}, section
43803.2.21.
4381@end table
4382
4383
4384
4385@node acc_present_or_create
4386@section @code{acc_present_or_create} -- If the data is not present on the device, allocate device memory and map it to host memory.
4387@table @asis
4388@item @emph{Description}
4389This function tests if the host data specified by @var{a} and of length
15886c03
TB
4390@var{len} is present or not. If it is not present, device memory
4391is allocated and mapped to host memory. In C/C++, the device address
d77de738
ML
4392of the newly allocated device memory is returned.
4393
4394In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
4395a contiguous array section. The second form @var{a} specifies a variable or
4396array element and @var{len} specifies the length in bytes.
4397
4398Note that @code{acc_present_or_create} and @code{acc_pcreate} exist for
4399backward compatibility with OpenACC 2.0; use @ref{acc_create} instead.
4400
4401@item @emph{C/C++}:
4402@multitable @columnfractions .20 .80
4403@item @emph{Prototype}: @tab @code{void *acc_present_or_create(h_void *a, size_t len)}
4404@item @emph{Prototype}: @tab @code{void *acc_pcreate(h_void *a, size_t len)}
4405@end multitable
4406
4407@item @emph{Fortran}:
4408@multitable @columnfractions .20 .80
4409@item @emph{Interface}: @tab @code{subroutine acc_present_or_create(a)}
4410@item @tab @code{type, dimension(:[,:]...) :: a}
4411@item @emph{Interface}: @tab @code{subroutine acc_present_or_create(a, len)}
4412@item @tab @code{type, dimension(:[,:]...) :: a}
4413@item @tab @code{integer len}
4414@item @emph{Interface}: @tab @code{subroutine acc_pcreate(a)}
4415@item @tab @code{type, dimension(:[,:]...) :: a}
4416@item @emph{Interface}: @tab @code{subroutine acc_pcreate(a, len)}
4417@item @tab @code{type, dimension(:[,:]...) :: a}
4418@item @tab @code{integer len}
4419@end multitable
4420
4421@item @emph{Reference}:
4422@uref{https://www.openacc.org, OpenACC specification v2.6}, section
44233.2.21.
4424@end table
4425
4426
4427
4428@node acc_copyout
4429@section @code{acc_copyout} -- Copy device memory to host memory.
4430@table @asis
4431@item @emph{Description}
4432This function copies mapped device memory to host memory which is specified
4433by host address @var{a} for a length @var{len} bytes in C/C++.
4434
4435In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
4436a contiguous array section. The second form @var{a} specifies a variable or
4437array element and @var{len} specifies the length in bytes.
4438
4439@item @emph{C/C++}:
4440@multitable @columnfractions .20 .80
4441@item @emph{Prototype}: @tab @code{acc_copyout(h_void *a, size_t len);}
4442@item @emph{Prototype}: @tab @code{acc_copyout_async(h_void *a, size_t len, int async);}
4443@item @emph{Prototype}: @tab @code{acc_copyout_finalize(h_void *a, size_t len);}
4444@item @emph{Prototype}: @tab @code{acc_copyout_finalize_async(h_void *a, size_t len, int async);}
4445@end multitable
4446
4447@item @emph{Fortran}:
4448@multitable @columnfractions .20 .80
4449@item @emph{Interface}: @tab @code{subroutine acc_copyout(a)}
4450@item @tab @code{type, dimension(:[,:]...) :: a}
4451@item @emph{Interface}: @tab @code{subroutine acc_copyout(a, len)}
4452@item @tab @code{type, dimension(:[,:]...) :: a}
4453@item @tab @code{integer len}
4454@item @emph{Interface}: @tab @code{subroutine acc_copyout_async(a, async)}
4455@item @tab @code{type, dimension(:[,:]...) :: a}
4456@item @tab @code{integer(acc_handle_kind) :: async}
4457@item @emph{Interface}: @tab @code{subroutine acc_copyout_async(a, len, async)}
4458@item @tab @code{type, dimension(:[,:]...) :: a}
4459@item @tab @code{integer len}
4460@item @tab @code{integer(acc_handle_kind) :: async}
4461@item @emph{Interface}: @tab @code{subroutine acc_copyout_finalize(a)}
4462@item @tab @code{type, dimension(:[,:]...) :: a}
4463@item @emph{Interface}: @tab @code{subroutine acc_copyout_finalize(a, len)}
4464@item @tab @code{type, dimension(:[,:]...) :: a}
4465@item @tab @code{integer len}
4466@item @emph{Interface}: @tab @code{subroutine acc_copyout_finalize_async(a, async)}
4467@item @tab @code{type, dimension(:[,:]...) :: a}
4468@item @tab @code{integer(acc_handle_kind) :: async}
4469@item @emph{Interface}: @tab @code{subroutine acc_copyout_finalize_async(a, len, async)}
4470@item @tab @code{type, dimension(:[,:]...) :: a}
4471@item @tab @code{integer len}
4472@item @tab @code{integer(acc_handle_kind) :: async}
4473@end multitable
4474
4475@item @emph{Reference}:
4476@uref{https://www.openacc.org, OpenACC specification v2.6}, section
44773.2.22.
4478@end table
4479
4480
4481
4482@node acc_delete
4483@section @code{acc_delete} -- Free device memory.
4484@table @asis
4485@item @emph{Description}
4486This function frees previously allocated device memory specified by
4487the device address @var{a} and the length of @var{len} bytes.
4488
4489In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
4490a contiguous array section. The second form @var{a} specifies a variable or
4491array element and @var{len} specifies the length in bytes.
4492
4493@item @emph{C/C++}:
4494@multitable @columnfractions .20 .80
4495@item @emph{Prototype}: @tab @code{acc_delete(h_void *a, size_t len);}
4496@item @emph{Prototype}: @tab @code{acc_delete_async(h_void *a, size_t len, int async);}
4497@item @emph{Prototype}: @tab @code{acc_delete_finalize(h_void *a, size_t len);}
4498@item @emph{Prototype}: @tab @code{acc_delete_finalize_async(h_void *a, size_t len, int async);}
4499@end multitable
4500
4501@item @emph{Fortran}:
4502@multitable @columnfractions .20 .80
4503@item @emph{Interface}: @tab @code{subroutine acc_delete(a)}
4504@item @tab @code{type, dimension(:[,:]...) :: a}
4505@item @emph{Interface}: @tab @code{subroutine acc_delete(a, len)}
4506@item @tab @code{type, dimension(:[,:]...) :: a}
4507@item @tab @code{integer len}
4508@item @emph{Interface}: @tab @code{subroutine acc_delete_async(a, async)}
4509@item @tab @code{type, dimension(:[,:]...) :: a}
4510@item @tab @code{integer(acc_handle_kind) :: async}
4511@item @emph{Interface}: @tab @code{subroutine acc_delete_async(a, len, async)}
4512@item @tab @code{type, dimension(:[,:]...) :: a}
4513@item @tab @code{integer len}
4514@item @tab @code{integer(acc_handle_kind) :: async}
4515@item @emph{Interface}: @tab @code{subroutine acc_delete_finalize(a)}
4516@item @tab @code{type, dimension(:[,:]...) :: a}
4517@item @emph{Interface}: @tab @code{subroutine acc_delete_finalize(a, len)}
4518@item @tab @code{type, dimension(:[,:]...) :: a}
4519@item @tab @code{integer len}
4520@item @emph{Interface}: @tab @code{subroutine acc_delete_async_finalize(a, async)}
4521@item @tab @code{type, dimension(:[,:]...) :: a}
4522@item @tab @code{integer(acc_handle_kind) :: async}
4523@item @emph{Interface}: @tab @code{subroutine acc_delete_async_finalize(a, len, async)}
4524@item @tab @code{type, dimension(:[,:]...) :: a}
4525@item @tab @code{integer len}
4526@item @tab @code{integer(acc_handle_kind) :: async}
4527@end multitable
4528
4529@item @emph{Reference}:
4530@uref{https://www.openacc.org, OpenACC specification v2.6}, section
45313.2.23.
4532@end table
4533
4534
4535
4536@node acc_update_device
4537@section @code{acc_update_device} -- Update device memory from mapped host memory.
4538@table @asis
4539@item @emph{Description}
4540This function updates the device copy from the previously mapped host memory.
4541The host memory is specified with the host address @var{a} and a length of
4542@var{len} bytes.
4543
4544In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
4545a contiguous array section. The second form @var{a} specifies a variable or
4546array element and @var{len} specifies the length in bytes.
4547
4548@item @emph{C/C++}:
4549@multitable @columnfractions .20 .80
4550@item @emph{Prototype}: @tab @code{acc_update_device(h_void *a, size_t len);}
4551@item @emph{Prototype}: @tab @code{acc_update_device(h_void *a, size_t len, async);}
4552@end multitable
4553
4554@item @emph{Fortran}:
4555@multitable @columnfractions .20 .80
4556@item @emph{Interface}: @tab @code{subroutine acc_update_device(a)}
4557@item @tab @code{type, dimension(:[,:]...) :: a}
4558@item @emph{Interface}: @tab @code{subroutine acc_update_device(a, len)}
4559@item @tab @code{type, dimension(:[,:]...) :: a}
4560@item @tab @code{integer len}
4561@item @emph{Interface}: @tab @code{subroutine acc_update_device_async(a, async)}
4562@item @tab @code{type, dimension(:[,:]...) :: a}
4563@item @tab @code{integer(acc_handle_kind) :: async}
4564@item @emph{Interface}: @tab @code{subroutine acc_update_device_async(a, len, async)}
4565@item @tab @code{type, dimension(:[,:]...) :: a}
4566@item @tab @code{integer len}
4567@item @tab @code{integer(acc_handle_kind) :: async}
4568@end multitable
4569
4570@item @emph{Reference}:
4571@uref{https://www.openacc.org, OpenACC specification v2.6}, section
45723.2.24.
4573@end table
4574
4575
4576
4577@node acc_update_self
4578@section @code{acc_update_self} -- Update host memory from mapped device memory.
4579@table @asis
4580@item @emph{Description}
4581This function updates the host copy from the previously mapped device memory.
4582The host memory is specified with the host address @var{a} and a length of
4583@var{len} bytes.
4584
4585In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
4586a contiguous array section. The second form @var{a} specifies a variable or
4587array element and @var{len} specifies the length in bytes.
4588
4589@item @emph{C/C++}:
4590@multitable @columnfractions .20 .80
4591@item @emph{Prototype}: @tab @code{acc_update_self(h_void *a, size_t len);}
4592@item @emph{Prototype}: @tab @code{acc_update_self_async(h_void *a, size_t len, int async);}
4593@end multitable
4594
4595@item @emph{Fortran}:
4596@multitable @columnfractions .20 .80
4597@item @emph{Interface}: @tab @code{subroutine acc_update_self(a)}
4598@item @tab @code{type, dimension(:[,:]...) :: a}
4599@item @emph{Interface}: @tab @code{subroutine acc_update_self(a, len)}
4600@item @tab @code{type, dimension(:[,:]...) :: a}
4601@item @tab @code{integer len}
4602@item @emph{Interface}: @tab @code{subroutine acc_update_self_async(a, async)}
4603@item @tab @code{type, dimension(:[,:]...) :: a}
4604@item @tab @code{integer(acc_handle_kind) :: async}
4605@item @emph{Interface}: @tab @code{subroutine acc_update_self_async(a, len, async)}
4606@item @tab @code{type, dimension(:[,:]...) :: a}
4607@item @tab @code{integer len}
4608@item @tab @code{integer(acc_handle_kind) :: async}
4609@end multitable
4610
4611@item @emph{Reference}:
4612@uref{https://www.openacc.org, OpenACC specification v2.6}, section
46133.2.25.
4614@end table
4615
4616
4617
4618@node acc_map_data
4619@section @code{acc_map_data} -- Map previously allocated device memory to host memory.
4620@table @asis
4621@item @emph{Description}
4622This function maps previously allocated device and host memory. The device
4623memory is specified with the device address @var{d}. The host memory is
4624specified with the host address @var{h} and a length of @var{len}.
4625
4626@item @emph{C/C++}:
4627@multitable @columnfractions .20 .80
4628@item @emph{Prototype}: @tab @code{acc_map_data(h_void *h, d_void *d, size_t len);}
4629@end multitable
4630
4631@item @emph{Reference}:
4632@uref{https://www.openacc.org, OpenACC specification v2.6}, section
46333.2.26.
4634@end table
4635
4636
4637
4638@node acc_unmap_data
4639@section @code{acc_unmap_data} -- Unmap device memory from host memory.
4640@table @asis
4641@item @emph{Description}
4642This function unmaps previously mapped device and host memory. The latter
4643specified by @var{h}.
4644
4645@item @emph{C/C++}:
4646@multitable @columnfractions .20 .80
4647@item @emph{Prototype}: @tab @code{acc_unmap_data(h_void *h);}
4648@end multitable
4649
4650@item @emph{Reference}:
4651@uref{https://www.openacc.org, OpenACC specification v2.6}, section
46523.2.27.
4653@end table
4654
4655
4656
4657@node acc_deviceptr
4658@section @code{acc_deviceptr} -- Get device pointer associated with specific host address.
4659@table @asis
4660@item @emph{Description}
4661This function returns the device address that has been mapped to the
4662host address specified by @var{h}.
4663
4664@item @emph{C/C++}:
4665@multitable @columnfractions .20 .80
4666@item @emph{Prototype}: @tab @code{void *acc_deviceptr(h_void *h);}
4667@end multitable
4668
4669@item @emph{Reference}:
4670@uref{https://www.openacc.org, OpenACC specification v2.6}, section
46713.2.28.
4672@end table
4673
4674
4675
4676@node acc_hostptr
4677@section @code{acc_hostptr} -- Get host pointer associated with specific device address.
4678@table @asis
4679@item @emph{Description}
4680This function returns the host address that has been mapped to the
4681device address specified by @var{d}.
4682
4683@item @emph{C/C++}:
4684@multitable @columnfractions .20 .80
4685@item @emph{Prototype}: @tab @code{void *acc_hostptr(d_void *d);}
4686@end multitable
4687
4688@item @emph{Reference}:
4689@uref{https://www.openacc.org, OpenACC specification v2.6}, section
46903.2.29.
4691@end table
4692
4693
4694
4695@node acc_is_present
4696@section @code{acc_is_present} -- Indicate whether host variable / array is present on device.
4697@table @asis
4698@item @emph{Description}
4699This function indicates whether the specified host address in @var{a} and a
4700length of @var{len} bytes is present on the device. In C/C++, a non-zero
4701value is returned to indicate the presence of the mapped memory on the
4702device. A zero is returned to indicate the memory is not mapped on the
4703device.
4704
4705In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
4706a contiguous array section. The second form @var{a} specifies a variable or
4707array element and @var{len} specifies the length in bytes. If the host
4708memory is mapped to device memory, then a @code{true} is returned. Otherwise,
4709a @code{false} is return to indicate the mapped memory is not present.
4710
4711@item @emph{C/C++}:
4712@multitable @columnfractions .20 .80
4713@item @emph{Prototype}: @tab @code{int acc_is_present(h_void *a, size_t len);}
4714@end multitable
4715
4716@item @emph{Fortran}:
4717@multitable @columnfractions .20 .80
4718@item @emph{Interface}: @tab @code{function acc_is_present(a)}
4719@item @tab @code{type, dimension(:[,:]...) :: a}
4720@item @tab @code{logical acc_is_present}
4721@item @emph{Interface}: @tab @code{function acc_is_present(a, len)}
4722@item @tab @code{type, dimension(:[,:]...) :: a}
4723@item @tab @code{integer len}
4724@item @tab @code{logical acc_is_present}
4725@end multitable
4726
4727@item @emph{Reference}:
4728@uref{https://www.openacc.org, OpenACC specification v2.6}, section
47293.2.30.
4730@end table
4731
4732
4733
4734@node acc_memcpy_to_device
4735@section @code{acc_memcpy_to_device} -- Copy host memory to device memory.
4736@table @asis
4737@item @emph{Description}
4738This function copies host memory specified by host address of @var{src} to
4739device memory specified by the device address @var{dest} for a length of
4740@var{bytes} bytes.
4741
4742@item @emph{C/C++}:
4743@multitable @columnfractions .20 .80
4744@item @emph{Prototype}: @tab @code{acc_memcpy_to_device(d_void *dest, h_void *src, size_t bytes);}
4745@end multitable
4746
4747@item @emph{Reference}:
4748@uref{https://www.openacc.org, OpenACC specification v2.6}, section
47493.2.31.
4750@end table
4751
4752
4753
4754@node acc_memcpy_from_device
4755@section @code{acc_memcpy_from_device} -- Copy device memory to host memory.
4756@table @asis
4757@item @emph{Description}
4758This function copies host memory specified by host address of @var{src} from
4759device memory specified by the device address @var{dest} for a length of
4760@var{bytes} bytes.
4761
4762@item @emph{C/C++}:
4763@multitable @columnfractions .20 .80
4764@item @emph{Prototype}: @tab @code{acc_memcpy_from_device(d_void *dest, h_void *src, size_t bytes);}
4765@end multitable
4766
4767@item @emph{Reference}:
4768@uref{https://www.openacc.org, OpenACC specification v2.6}, section
47693.2.32.
4770@end table
4771
4772
4773
4774@node acc_attach
4775@section @code{acc_attach} -- Let device pointer point to device-pointer target.
4776@table @asis
4777@item @emph{Description}
4778This function updates a pointer on the device from pointing to a host-pointer
4779address to pointing to the corresponding device data.
4780
4781@item @emph{C/C++}:
4782@multitable @columnfractions .20 .80
4783@item @emph{Prototype}: @tab @code{acc_attach(h_void **ptr);}
4784@item @emph{Prototype}: @tab @code{acc_attach_async(h_void **ptr, int async);}
4785@end multitable
4786
4787@item @emph{Reference}:
4788@uref{https://www.openacc.org, OpenACC specification v2.6}, section
47893.2.34.
4790@end table
4791
4792
4793
4794@node acc_detach
4795@section @code{acc_detach} -- Let device pointer point to host-pointer target.
4796@table @asis
4797@item @emph{Description}
4798This function updates a pointer on the device from pointing to a device-pointer
4799address to pointing to the corresponding host data.
4800
4801@item @emph{C/C++}:
4802@multitable @columnfractions .20 .80
4803@item @emph{Prototype}: @tab @code{acc_detach(h_void **ptr);}
4804@item @emph{Prototype}: @tab @code{acc_detach_async(h_void **ptr, int async);}
4805@item @emph{Prototype}: @tab @code{acc_detach_finalize(h_void **ptr);}
4806@item @emph{Prototype}: @tab @code{acc_detach_finalize_async(h_void **ptr, int async);}
4807@end multitable
4808
4809@item @emph{Reference}:
4810@uref{https://www.openacc.org, OpenACC specification v2.6}, section
48113.2.35.
4812@end table
4813
4814
4815
4816@node acc_get_current_cuda_device
4817@section @code{acc_get_current_cuda_device} -- Get CUDA device handle.
4818@table @asis
4819@item @emph{Description}
4820This function returns the CUDA device handle. This handle is the same
4821as used by the CUDA Runtime or Driver API's.
4822
4823@item @emph{C/C++}:
4824@multitable @columnfractions .20 .80
4825@item @emph{Prototype}: @tab @code{void *acc_get_current_cuda_device(void);}
4826@end multitable
4827
4828@item @emph{Reference}:
4829@uref{https://www.openacc.org, OpenACC specification v2.6}, section
4830A.2.1.1.
4831@end table
4832
4833
4834
4835@node acc_get_current_cuda_context
4836@section @code{acc_get_current_cuda_context} -- Get CUDA context handle.
4837@table @asis
4838@item @emph{Description}
4839This function returns the CUDA context handle. This handle is the same
4840as used by the CUDA Runtime or Driver API's.
4841
4842@item @emph{C/C++}:
4843@multitable @columnfractions .20 .80
4844@item @emph{Prototype}: @tab @code{void *acc_get_current_cuda_context(void);}
4845@end multitable
4846
4847@item @emph{Reference}:
4848@uref{https://www.openacc.org, OpenACC specification v2.6}, section
4849A.2.1.2.
4850@end table
4851
4852
4853
4854@node acc_get_cuda_stream
4855@section @code{acc_get_cuda_stream} -- Get CUDA stream handle.
4856@table @asis
4857@item @emph{Description}
4858This function returns the CUDA stream handle for the queue @var{async}.
4859This handle is the same as used by the CUDA Runtime or Driver API's.
4860
4861@item @emph{C/C++}:
4862@multitable @columnfractions .20 .80
4863@item @emph{Prototype}: @tab @code{void *acc_get_cuda_stream(int async);}
4864@end multitable
4865
4866@item @emph{Reference}:
4867@uref{https://www.openacc.org, OpenACC specification v2.6}, section
4868A.2.1.3.
4869@end table
4870
4871
4872
4873@node acc_set_cuda_stream
4874@section @code{acc_set_cuda_stream} -- Set CUDA stream handle.
4875@table @asis
4876@item @emph{Description}
4877This function associates the stream handle specified by @var{stream} with
4878the queue @var{async}.
4879
4880This cannot be used to change the stream handle associated with
4881@code{acc_async_sync}.
4882
4883The return value is not specified.
4884
4885@item @emph{C/C++}:
4886@multitable @columnfractions .20 .80
4887@item @emph{Prototype}: @tab @code{int acc_set_cuda_stream(int async, void *stream);}
4888@end multitable
4889
4890@item @emph{Reference}:
4891@uref{https://www.openacc.org, OpenACC specification v2.6}, section
4892A.2.1.4.
4893@end table
4894
4895
4896
4897@node acc_prof_register
4898@section @code{acc_prof_register} -- Register callbacks.
4899@table @asis
4900@item @emph{Description}:
4901This function registers callbacks.
4902
4903@item @emph{C/C++}:
4904@multitable @columnfractions .20 .80
4905@item @emph{Prototype}: @tab @code{void acc_prof_register (acc_event_t, acc_prof_callback, acc_register_t);}
4906@end multitable
4907
4908@item @emph{See also}:
4909@ref{OpenACC Profiling Interface}
4910
4911@item @emph{Reference}:
4912@uref{https://www.openacc.org, OpenACC specification v2.6}, section
49135.3.
4914@end table
4915
4916
4917
4918@node acc_prof_unregister
4919@section @code{acc_prof_unregister} -- Unregister callbacks.
4920@table @asis
4921@item @emph{Description}:
4922This function unregisters callbacks.
4923
4924@item @emph{C/C++}:
4925@multitable @columnfractions .20 .80
4926@item @emph{Prototype}: @tab @code{void acc_prof_unregister (acc_event_t, acc_prof_callback, acc_register_t);}
4927@end multitable
4928
4929@item @emph{See also}:
4930@ref{OpenACC Profiling Interface}
4931
4932@item @emph{Reference}:
4933@uref{https://www.openacc.org, OpenACC specification v2.6}, section
49345.3.
4935@end table
4936
4937
4938
4939@node acc_prof_lookup
4940@section @code{acc_prof_lookup} -- Obtain inquiry functions.
4941@table @asis
4942@item @emph{Description}:
4943Function to obtain inquiry functions.
4944
4945@item @emph{C/C++}:
4946@multitable @columnfractions .20 .80
4947@item @emph{Prototype}: @tab @code{acc_query_fn acc_prof_lookup (const char *);}
4948@end multitable
4949
4950@item @emph{See also}:
4951@ref{OpenACC Profiling Interface}
4952
4953@item @emph{Reference}:
4954@uref{https://www.openacc.org, OpenACC specification v2.6}, section
49555.3.
4956@end table
4957
4958
4959
4960@node acc_register_library
4961@section @code{acc_register_library} -- Library registration.
4962@table @asis
4963@item @emph{Description}:
4964Function for library registration.
4965
4966@item @emph{C/C++}:
4967@multitable @columnfractions .20 .80
4968@item @emph{Prototype}: @tab @code{void acc_register_library (acc_prof_reg, acc_prof_reg, acc_prof_lookup_func);}
4969@end multitable
4970
4971@item @emph{See also}:
4972@ref{OpenACC Profiling Interface}, @ref{ACC_PROFLIB}
4973
4974@item @emph{Reference}:
4975@uref{https://www.openacc.org, OpenACC specification v2.6}, section
49765.3.
4977@end table
4978
4979
4980
4981@c ---------------------------------------------------------------------
4982@c OpenACC Environment Variables
4983@c ---------------------------------------------------------------------
4984
4985@node OpenACC Environment Variables
4986@chapter OpenACC Environment Variables
4987
4988The variables @env{ACC_DEVICE_TYPE} and @env{ACC_DEVICE_NUM}
4989are defined by section 4 of the OpenACC specification in version 2.0.
4990The variable @env{ACC_PROFLIB}
4991is defined by section 4 of the OpenACC specification in version 2.6.
d77de738
ML
4992
4993@menu
4994* ACC_DEVICE_TYPE::
4995* ACC_DEVICE_NUM::
4996* ACC_PROFLIB::
d77de738
ML
4997@end menu
4998
4999
5000
5001@node ACC_DEVICE_TYPE
5002@section @code{ACC_DEVICE_TYPE}
5003@table @asis
67f5d368
TB
5004@item @emph{Description}:
5005Control the default device type to use when executing compute regions.
5006If unset, the code can be run on any device type, favoring a non-host
5007device type.
5008
5009Supported values in GCC (if compiled in) are
5010@itemize
5011@item @code{host}
5012@item @code{nvidia}
5013@item @code{radeon}
5014@end itemize
d77de738
ML
5015@item @emph{Reference}:
5016@uref{https://www.openacc.org, OpenACC specification v2.6}, section
50174.1.
5018@end table
5019
5020
5021
5022@node ACC_DEVICE_NUM
5023@section @code{ACC_DEVICE_NUM}
5024@table @asis
67f5d368
TB
5025@item @emph{Description}:
5026Control which device, identified by device number, is the default device.
5027The value must be a nonnegative integer less than the number of devices.
5028If unset, device number zero is used.
d77de738
ML
5029@item @emph{Reference}:
5030@uref{https://www.openacc.org, OpenACC specification v2.6}, section
50314.2.
5032@end table
5033
5034
5035
5036@node ACC_PROFLIB
5037@section @code{ACC_PROFLIB}
5038@table @asis
67f5d368
TB
5039@item @emph{Description}:
5040Semicolon-separated list of dynamic libraries that are loaded as profiling
5041libraries. Each library must provide at least the @code{acc_register_library}
5042routine. Each library file is found as described by the documentation of
5043@code{dlopen} of your operating system.
d77de738
ML
5044@item @emph{See also}:
5045@ref{acc_register_library}, @ref{OpenACC Profiling Interface}
5046
5047@item @emph{Reference}:
5048@uref{https://www.openacc.org, OpenACC specification v2.6}, section
50494.3.
5050@end table
5051
5052
5053
d77de738
ML
5054@c ---------------------------------------------------------------------
5055@c CUDA Streams Usage
5056@c ---------------------------------------------------------------------
5057
5058@node CUDA Streams Usage
5059@chapter CUDA Streams Usage
5060
5061This applies to the @code{nvptx} plugin only.
5062
5063The library provides elements that perform asynchronous movement of
5064data and asynchronous operation of computing constructs. This
5065asynchronous functionality is implemented by making use of CUDA
5066streams@footnote{See "Stream Management" in "CUDA Driver API",
5067TRM-06703-001, Version 5.5, for additional information}.
5068
5069The primary means by that the asynchronous functionality is accessed
5070is through the use of those OpenACC directives which make use of the
5071@code{async} and @code{wait} clauses. When the @code{async} clause is
5072first used with a directive, it creates a CUDA stream. If an
5073@code{async-argument} is used with the @code{async} clause, then the
5074stream is associated with the specified @code{async-argument}.
5075
5076Following the creation of an association between a CUDA stream and the
5077@code{async-argument} of an @code{async} clause, both the @code{wait}
5078clause and the @code{wait} directive can be used. When either the
5079clause or directive is used after stream creation, it creates a
5080rendezvous point whereby execution waits until all operations
5081associated with the @code{async-argument}, that is, stream, have
5082completed.
5083
5084Normally, the management of the streams that are created as a result of
5085using the @code{async} clause, is done without any intervention by the
5086caller. This implies the association between the @code{async-argument}
15886c03 5087and the CUDA stream is maintained for the lifetime of the program.
d77de738
ML
5088However, this association can be changed through the use of the library
5089function @code{acc_set_cuda_stream}. When the function
5090@code{acc_set_cuda_stream} is called, the CUDA stream that was
15886c03 5091originally associated with the @code{async} clause is destroyed.
d77de738
ML
5092Caution should be taken when changing the association as subsequent
5093references to the @code{async-argument} refer to a different
5094CUDA stream.
5095
5096
5097
5098@c ---------------------------------------------------------------------
5099@c OpenACC Library Interoperability
5100@c ---------------------------------------------------------------------
5101
5102@node OpenACC Library Interoperability
5103@chapter OpenACC Library Interoperability
5104
5105@section Introduction
5106
5107The OpenACC library uses the CUDA Driver API, and may interact with
5108programs that use the Runtime library directly, or another library
5109based on the Runtime library, e.g., CUBLAS@footnote{See section 2.26,
5110"Interactions with the CUDA Driver API" in
5111"CUDA Runtime API", Version 5.5, and section 2.27, "VDPAU
5112Interoperability", in "CUDA Driver API", TRM-06703-001, Version 5.5,
5113for additional information on library interoperability.}.
5114This chapter describes the use cases and what changes are
5115required in order to use both the OpenACC library and the CUBLAS and Runtime
5116libraries within a program.
5117
5118@section First invocation: NVIDIA CUBLAS library API
5119
5120In this first use case (see below), a function in the CUBLAS library is called
5121prior to any of the functions in the OpenACC library. More specifically, the
5122function @code{cublasCreate()}.
5123
5124When invoked, the function initializes the library and allocates the
5125hardware resources on the host and the device on behalf of the caller. Once
5126the initialization and allocation has completed, a handle is returned to the
5127caller. The OpenACC library also requires initialization and allocation of
5128hardware resources. Since the CUBLAS library has already allocated the
5129hardware resources for the device, all that is left to do is to initialize
5130the OpenACC library and acquire the hardware resources on the host.
5131
5132Prior to calling the OpenACC function that initializes the library and
5133allocate the host hardware resources, you need to acquire the device number
5134that was allocated during the call to @code{cublasCreate()}. The invoking of the
5135runtime library function @code{cudaGetDevice()} accomplishes this. Once
5136acquired, the device number is passed along with the device type as
5137parameters to the OpenACC library function @code{acc_set_device_num()}.
5138
5139Once the call to @code{acc_set_device_num()} has completed, the OpenACC
5140library uses the context that was created during the call to
15886c03 5141@code{cublasCreate()}. In other words, both libraries share the
d77de738
ML
5142same context.
5143
5144@smallexample
5145 /* Create the handle */
5146 s = cublasCreate(&h);
5147 if (s != CUBLAS_STATUS_SUCCESS)
5148 @{
5149 fprintf(stderr, "cublasCreate failed %d\n", s);
5150 exit(EXIT_FAILURE);
5151 @}
5152
5153 /* Get the device number */
5154 e = cudaGetDevice(&dev);
5155 if (e != cudaSuccess)
5156 @{
5157 fprintf(stderr, "cudaGetDevice failed %d\n", e);
5158 exit(EXIT_FAILURE);
5159 @}
5160
5161 /* Initialize OpenACC library and use device 'dev' */
5162 acc_set_device_num(dev, acc_device_nvidia);
5163
5164@end smallexample
5165@center Use Case 1
5166
5167@section First invocation: OpenACC library API
5168
5169In this second use case (see below), a function in the OpenACC library is
eda38850 5170called prior to any of the functions in the CUBLAS library. More specifically,
d77de738
ML
5171the function @code{acc_set_device_num()}.
5172
5173In the use case presented here, the function @code{acc_set_device_num()}
5174is used to both initialize the OpenACC library and allocate the hardware
5175resources on the host and the device. In the call to the function, the
5176call parameters specify which device to use and what device
5177type to use, i.e., @code{acc_device_nvidia}. It should be noted that this
5178is but one method to initialize the OpenACC library and allocate the
5179appropriate hardware resources. Other methods are available through the
15886c03 5180use of environment variables and these is discussed in the next section.
d77de738
ML
5181
5182Once the call to @code{acc_set_device_num()} has completed, other OpenACC
5183functions can be called as seen with multiple calls being made to
5184@code{acc_copyin()}. In addition, calls can be made to functions in the
5185CUBLAS library. In the use case a call to @code{cublasCreate()} is made
5186subsequent to the calls to @code{acc_copyin()}.
5187As seen in the previous use case, a call to @code{cublasCreate()}
5188initializes the CUBLAS library and allocates the hardware resources on the
5189host and the device. However, since the device has already been allocated,
15886c03 5190@code{cublasCreate()} only initializes the CUBLAS library and allocates
d77de738
ML
5191the appropriate hardware resources on the host. The context that was created
5192as part of the OpenACC initialization is shared with the CUBLAS library,
5193similarly to the first use case.
5194
5195@smallexample
5196 dev = 0;
5197
5198 acc_set_device_num(dev, acc_device_nvidia);
5199
5200 /* Copy the first set to the device */
5201 d_X = acc_copyin(&h_X[0], N * sizeof (float));
5202 if (d_X == NULL)
5203 @{
5204 fprintf(stderr, "copyin error h_X\n");
5205 exit(EXIT_FAILURE);
5206 @}
5207
5208 /* Copy the second set to the device */
5209 d_Y = acc_copyin(&h_Y1[0], N * sizeof (float));
5210 if (d_Y == NULL)
5211 @{
5212 fprintf(stderr, "copyin error h_Y1\n");
5213 exit(EXIT_FAILURE);
5214 @}
5215
5216 /* Create the handle */
5217 s = cublasCreate(&h);
5218 if (s != CUBLAS_STATUS_SUCCESS)
5219 @{
5220 fprintf(stderr, "cublasCreate failed %d\n", s);
5221 exit(EXIT_FAILURE);
5222 @}
5223
5224 /* Perform saxpy using CUBLAS library function */
5225 s = cublasSaxpy(h, N, &alpha, d_X, 1, d_Y, 1);
5226 if (s != CUBLAS_STATUS_SUCCESS)
5227 @{
5228 fprintf(stderr, "cublasSaxpy failed %d\n", s);
5229 exit(EXIT_FAILURE);
5230 @}
5231
5232 /* Copy the results from the device */
5233 acc_memcpy_from_device(&h_Y1[0], d_Y, N * sizeof (float));
5234
5235@end smallexample
5236@center Use Case 2
5237
5238@section OpenACC library and environment variables
5239
5240There are two environment variables associated with the OpenACC library
5241that may be used to control the device type and device number:
5242@env{ACC_DEVICE_TYPE} and @env{ACC_DEVICE_NUM}, respectively. These two
5243environment variables can be used as an alternative to calling
5244@code{acc_set_device_num()}. As seen in the second use case, the device
5245type and device number were specified using @code{acc_set_device_num()}.
5246If however, the aforementioned environment variables were set, then the
5247call to @code{acc_set_device_num()} would not be required.
5248
5249
5250The use of the environment variables is only relevant when an OpenACC function
5251is called prior to a call to @code{cudaCreate()}. If @code{cudaCreate()}
5252is called prior to a call to an OpenACC function, then you must call
5253@code{acc_set_device_num()}@footnote{More complete information
5254about @env{ACC_DEVICE_TYPE} and @env{ACC_DEVICE_NUM} can be found in
5255sections 4.1 and 4.2 of the @uref{https://www.openacc.org, OpenACC}
5256Application Programming Interface”, Version 2.6.}
5257
5258
5259
5260@c ---------------------------------------------------------------------
5261@c OpenACC Profiling Interface
5262@c ---------------------------------------------------------------------
5263
5264@node OpenACC Profiling Interface
5265@chapter OpenACC Profiling Interface
5266
5267@section Implementation Status and Implementation-Defined Behavior
5268
5269We're implementing the OpenACC Profiling Interface as defined by the
5270OpenACC 2.6 specification. We're clarifying some aspects here as
5271@emph{implementation-defined behavior}, while they're still under
5272discussion within the OpenACC Technical Committee.
5273
5274This implementation is tuned to keep the performance impact as low as
5275possible for the (very common) case that the Profiling Interface is
5276not enabled. This is relevant, as the Profiling Interface affects all
5277the @emph{hot} code paths (in the target code, not in the offloaded
5278code). Users of the OpenACC Profiling Interface can be expected to
15886c03
TB
5279understand that performance is impacted to some degree once the
5280Profiling Interface is enabled: for example, because of the
d77de738
ML
5281@emph{runtime} (libgomp) calling into a third-party @emph{library} for
5282every event that has been registered.
5283
5284We're not yet accounting for the fact that @cite{OpenACC events may
5285occur during event processing}.
5286We just handle one case specially, as required by CUDA 9.0
5287@command{nvprof}, that @code{acc_get_device_type}
5288(@ref{acc_get_device_type})) may be called from
5289@code{acc_ev_device_init_start}, @code{acc_ev_device_init_end}
5290callbacks.
5291
5292We're not yet implementing initialization via a
5293@code{acc_register_library} function that is either statically linked
5294in, or dynamically via @env{LD_PRELOAD}.
5295Initialization via @code{acc_register_library} functions dynamically
5296loaded via the @env{ACC_PROFLIB} environment variable does work, as
5297does directly calling @code{acc_prof_register},
5298@code{acc_prof_unregister}, @code{acc_prof_lookup}.
5299
5300As currently there are no inquiry functions defined, calls to
15886c03 5301@code{acc_prof_lookup} always returns @code{NULL}.
d77de738
ML
5302
5303There aren't separate @emph{start}, @emph{stop} events defined for the
5304event types @code{acc_ev_create}, @code{acc_ev_delete},
5305@code{acc_ev_alloc}, @code{acc_ev_free}. It's not clear if these
5306should be triggered before or after the actual device-specific call is
5307made. We trigger them after.
5308
5309Remarks about data provided to callbacks:
5310
5311@table @asis
5312
5313@item @code{acc_prof_info.event_type}
5314It's not clear if for @emph{nested} event callbacks (for example,
5315@code{acc_ev_enqueue_launch_start} as part of a parent compute
5316construct), this should be set for the nested event
5317(@code{acc_ev_enqueue_launch_start}), or if the value of the parent
5318construct should remain (@code{acc_ev_compute_construct_start}). In
15886c03 5319this implementation, the value generally corresponds to the
d77de738
ML
5320innermost nested event type.
5321
5322@item @code{acc_prof_info.device_type}
5323@itemize
5324
5325@item
5326For @code{acc_ev_compute_construct_start}, and in presence of an
15886c03 5327@code{if} clause with @emph{false} argument, this still refers to
d77de738
ML
5328the offloading device type.
5329It's not clear if that's the expected behavior.
5330
5331@item
5332Complementary to the item before, for
5333@code{acc_ev_compute_construct_end}, this is set to
5334@code{acc_device_host} in presence of an @code{if} clause with
5335@emph{false} argument.
5336It's not clear if that's the expected behavior.
5337
5338@end itemize
5339
5340@item @code{acc_prof_info.thread_id}
5341Always @code{-1}; not yet implemented.
5342
5343@item @code{acc_prof_info.async}
5344@itemize
5345
5346@item
5347Not yet implemented correctly for
5348@code{acc_ev_compute_construct_start}.
5349
5350@item
5351In a compute construct, for host-fallback
15886c03 5352execution/@code{acc_device_host} it always is
d77de738 5353@code{acc_async_sync}.
15886c03 5354It is unclear if that is the expected behavior.
d77de738
ML
5355
5356@item
5357For @code{acc_ev_device_init_start} and @code{acc_ev_device_init_end},
5358it will always be @code{acc_async_sync}.
15886c03 5359It is unclear if that is the expected behavior.
d77de738
ML
5360
5361@end itemize
5362
5363@item @code{acc_prof_info.async_queue}
5364There is no @cite{limited number of asynchronous queues} in libgomp.
15886c03 5365This always has the same value as @code{acc_prof_info.async}.
d77de738
ML
5366
5367@item @code{acc_prof_info.src_file}
5368Always @code{NULL}; not yet implemented.
5369
5370@item @code{acc_prof_info.func_name}
5371Always @code{NULL}; not yet implemented.
5372
5373@item @code{acc_prof_info.line_no}
5374Always @code{-1}; not yet implemented.
5375
5376@item @code{acc_prof_info.end_line_no}
5377Always @code{-1}; not yet implemented.
5378
5379@item @code{acc_prof_info.func_line_no}
5380Always @code{-1}; not yet implemented.
5381
5382@item @code{acc_prof_info.func_end_line_no}
5383Always @code{-1}; not yet implemented.
5384
5385@item @code{acc_event_info.event_type}, @code{acc_event_info.*.event_type}
5386Relating to @code{acc_prof_info.event_type} discussed above, in this
5387implementation, this will always be the same value as
5388@code{acc_prof_info.event_type}.
5389
5390@item @code{acc_event_info.*.parent_construct}
5391@itemize
5392
5393@item
5394Will be @code{acc_construct_parallel} for all OpenACC compute
5395constructs as well as many OpenACC Runtime API calls; should be the
5396one matching the actual construct, or
5397@code{acc_construct_runtime_api}, respectively.
5398
5399@item
5400Will be @code{acc_construct_enter_data} or
5401@code{acc_construct_exit_data} when processing variable mappings
5402specified in OpenACC @emph{declare} directives; should be
5403@code{acc_construct_declare}.
5404
5405@item
5406For implicit @code{acc_ev_device_init_start},
5407@code{acc_ev_device_init_end}, and explicit as well as implicit
5408@code{acc_ev_alloc}, @code{acc_ev_free},
5409@code{acc_ev_enqueue_upload_start}, @code{acc_ev_enqueue_upload_end},
5410@code{acc_ev_enqueue_download_start}, and
5411@code{acc_ev_enqueue_download_end}, will be
5412@code{acc_construct_parallel}; should reflect the real parent
5413construct.
5414
5415@end itemize
5416
5417@item @code{acc_event_info.*.implicit}
5418For @code{acc_ev_alloc}, @code{acc_ev_free},
5419@code{acc_ev_enqueue_upload_start}, @code{acc_ev_enqueue_upload_end},
5420@code{acc_ev_enqueue_download_start}, and
5421@code{acc_ev_enqueue_download_end}, this currently will be @code{1}
5422also for explicit usage.
5423
5424@item @code{acc_event_info.data_event.var_name}
5425Always @code{NULL}; not yet implemented.
5426
5427@item @code{acc_event_info.data_event.host_ptr}
5428For @code{acc_ev_alloc}, and @code{acc_ev_free}, this is always
5429@code{NULL}.
5430
5431@item @code{typedef union acc_api_info}
5432@dots{} as printed in @cite{5.2.3. Third Argument: API-Specific
5433Information}. This should obviously be @code{typedef @emph{struct}
5434acc_api_info}.
5435
5436@item @code{acc_api_info.device_api}
5437Possibly not yet implemented correctly for
5438@code{acc_ev_compute_construct_start},
5439@code{acc_ev_device_init_start}, @code{acc_ev_device_init_end}:
5440will always be @code{acc_device_api_none} for these event types.
5441For @code{acc_ev_enter_data_start}, it will be
5442@code{acc_device_api_none} in some cases.
5443
5444@item @code{acc_api_info.device_type}
5445Always the same as @code{acc_prof_info.device_type}.
5446
5447@item @code{acc_api_info.vendor}
5448Always @code{-1}; not yet implemented.
5449
5450@item @code{acc_api_info.device_handle}
5451Always @code{NULL}; not yet implemented.
5452
5453@item @code{acc_api_info.context_handle}
5454Always @code{NULL}; not yet implemented.
5455
5456@item @code{acc_api_info.async_handle}
5457Always @code{NULL}; not yet implemented.
5458
5459@end table
5460
5461Remarks about certain event types:
5462
5463@table @asis
5464
5465@item @code{acc_ev_device_init_start}, @code{acc_ev_device_init_end}
5466@itemize
5467
5468@item
5469@c See 'DEVICE_INIT_INSIDE_COMPUTE_CONSTRUCT' in
5470@c 'libgomp.oacc-c-c++-common/acc_prof-kernels-1.c',
5471@c 'libgomp.oacc-c-c++-common/acc_prof-parallel-1.c'.
5472When a compute construct triggers implicit
5473@code{acc_ev_device_init_start} and @code{acc_ev_device_init_end}
5474events, they currently aren't @emph{nested within} the corresponding
5475@code{acc_ev_compute_construct_start} and
5476@code{acc_ev_compute_construct_end}, but they're currently observed
5477@emph{before} @code{acc_ev_compute_construct_start}.
5478It's not clear what to do: the standard asks us provide a lot of
5479details to the @code{acc_ev_compute_construct_start} callback, without
5480(implicitly) initializing a device before?
5481
5482@item
5483Callbacks for these event types will not be invoked for calls to the
5484@code{acc_set_device_type} and @code{acc_set_device_num} functions.
5485It's not clear if they should be.
5486
5487@end itemize
5488
5489@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}
5490@itemize
5491
5492@item
5493Callbacks for these event types will also be invoked for OpenACC
5494@emph{host_data} constructs.
5495It's not clear if they should be.
5496
5497@item
5498Callbacks for these event types will also be invoked when processing
5499variable mappings specified in OpenACC @emph{declare} directives.
5500It's not clear if they should be.
5501
5502@end itemize
5503
5504@end table
5505
5506Callbacks for the following event types will be invoked, but dispatch
5507and information provided therein has not yet been thoroughly reviewed:
5508
5509@itemize
5510@item @code{acc_ev_alloc}
5511@item @code{acc_ev_free}
5512@item @code{acc_ev_update_start}, @code{acc_ev_update_end}
5513@item @code{acc_ev_enqueue_upload_start}, @code{acc_ev_enqueue_upload_end}
5514@item @code{acc_ev_enqueue_download_start}, @code{acc_ev_enqueue_download_end}
5515@end itemize
5516
5517During device initialization, and finalization, respectively,
5518callbacks for the following event types will not yet be invoked:
5519
5520@itemize
5521@item @code{acc_ev_alloc}
5522@item @code{acc_ev_free}
5523@end itemize
5524
5525Callbacks for the following event types have not yet been implemented,
5526so currently won't be invoked:
5527
5528@itemize
5529@item @code{acc_ev_device_shutdown_start}, @code{acc_ev_device_shutdown_end}
5530@item @code{acc_ev_runtime_shutdown}
5531@item @code{acc_ev_create}, @code{acc_ev_delete}
5532@item @code{acc_ev_wait_start}, @code{acc_ev_wait_end}
5533@end itemize
5534
5535For the following runtime library functions, not all expected
5536callbacks will be invoked (mostly concerning implicit device
5537initialization):
5538
5539@itemize
5540@item @code{acc_get_num_devices}
5541@item @code{acc_set_device_type}
5542@item @code{acc_get_device_type}
5543@item @code{acc_set_device_num}
5544@item @code{acc_get_device_num}
5545@item @code{acc_init}
5546@item @code{acc_shutdown}
5547@end itemize
5548
5549Aside from implicit device initialization, for the following runtime
5550library functions, no callbacks will be invoked for shared-memory
5551offloading devices (it's not clear if they should be):
5552
5553@itemize
5554@item @code{acc_malloc}
5555@item @code{acc_free}
5556@item @code{acc_copyin}, @code{acc_present_or_copyin}, @code{acc_copyin_async}
5557@item @code{acc_create}, @code{acc_present_or_create}, @code{acc_create_async}
5558@item @code{acc_copyout}, @code{acc_copyout_async}, @code{acc_copyout_finalize}, @code{acc_copyout_finalize_async}
5559@item @code{acc_delete}, @code{acc_delete_async}, @code{acc_delete_finalize}, @code{acc_delete_finalize_async}
5560@item @code{acc_update_device}, @code{acc_update_device_async}
5561@item @code{acc_update_self}, @code{acc_update_self_async}
5562@item @code{acc_map_data}, @code{acc_unmap_data}
5563@item @code{acc_memcpy_to_device}, @code{acc_memcpy_to_device_async}
5564@item @code{acc_memcpy_from_device}, @code{acc_memcpy_from_device_async}
5565@end itemize
5566
5567@c ---------------------------------------------------------------------
5568@c OpenMP-Implementation Specifics
5569@c ---------------------------------------------------------------------
5570
5571@node OpenMP-Implementation Specifics
5572@chapter OpenMP-Implementation Specifics
5573
5574@menu
2cd0689a 5575* Implementation-defined ICV Initialization::
d77de738 5576* OpenMP Context Selectors::
450b05ce 5577* Memory allocation::
d77de738
ML
5578@end menu
5579
2cd0689a
TB
5580@node Implementation-defined ICV Initialization
5581@section Implementation-defined ICV Initialization
5582@cindex Implementation specific setting
5583
5584@multitable @columnfractions .30 .70
5585@item @var{affinity-format-var} @tab See @ref{OMP_AFFINITY_FORMAT}.
5586@item @var{def-allocator-var} @tab See @ref{OMP_ALLOCATOR}.
5587@item @var{max-active-levels-var} @tab See @ref{OMP_MAX_ACTIVE_LEVELS}.
5588@item @var{dyn-var} @tab See @ref{OMP_DYNAMIC}.
819f3d36 5589@item @var{nthreads-var} @tab See @ref{OMP_NUM_THREADS}.
2cd0689a
TB
5590@item @var{num-devices-var} @tab Number of non-host devices found
5591by GCC's run-time library
5592@item @var{num-procs-var} @tab The number of CPU cores on the
5593initial device, except that affinity settings might lead to a
5594smaller number. On non-host devices, the value of the
5595@var{nthreads-var} ICV.
5596@item @var{place-partition-var} @tab See @ref{OMP_PLACES}.
5597@item @var{run-sched-var} @tab See @ref{OMP_SCHEDULE}.
5598@item @var{stacksize-var} @tab See @ref{OMP_STACKSIZE}.
5599@item @var{thread-limit-var} @tab See @ref{OMP_TEAMS_THREAD_LIMIT}
5600@item @var{wait-policy-var} @tab See @ref{OMP_WAIT_POLICY} and
5601@ref{GOMP_SPINCOUNT}
5602@end multitable
5603
d77de738
ML
5604@node OpenMP Context Selectors
5605@section OpenMP Context Selectors
5606
5607@code{vendor} is always @code{gnu}. References are to the GCC manual.
5608
75e3773b
TB
5609@c NOTE: Only the following selectors have been implemented. To add
5610@c additional traits for target architecture, TARGET_OMP_DEVICE_KIND_ARCH_ISA
5611@c has to be implemented; cf. also PR target/105640.
5612@c For offload devices, add *additionally* gcc/config/*/t-omp-device.
5613
5614For the host compiler, @code{kind} always matches @code{host}; for the
5615offloading architectures AMD GCN and Nvidia PTX, @code{kind} always matches
5616@code{gpu}. For the x86 family of computers, AMD GCN and Nvidia PTX
5617the following traits are supported in addition; while OpenMP is supported
5618on more architectures, GCC currently does not match any @code{arch} or
5619@code{isa} traits for those.
5620
5621@multitable @columnfractions .65 .30
5622@headitem @code{arch} @tab @code{isa}
d77de738
ML
5623@item @code{x86}, @code{x86_64}, @code{i386}, @code{i486},
5624 @code{i586}, @code{i686}, @code{ia32}
d77de738
ML
5625 @tab See @code{-m...} flags in ``x86 Options'' (without @code{-m})
5626@item @code{amdgcn}, @code{gcn}
e0b95c2e
TB
5627 @tab See @code{-march=} in ``AMD GCN Options''@footnote{Additionally,
5628 @code{gfx803} is supported as an alias for @code{fiji}.}
d77de738 5629@item @code{nvptx}
d77de738
ML
5630 @tab See @code{-march=} in ``Nvidia PTX Options''
5631@end multitable
5632
450b05ce
TB
5633@node Memory allocation
5634@section Memory allocation
d77de738 5635
bc238c40
TB
5636The description below applies to:
5637
5638@itemize
5639@item Explicit use of the OpenMP API routines, see
5640 @ref{Memory Management Routines}.
5641@item The @code{allocate} clause, except when the @code{allocator} modifier is a
5642 constant expression with value @code{omp_default_mem_alloc} and no
5643 @code{align} modifier has been specified. (In that case, the normal
5644 @code{malloc} allocation is used.)
5645@item Using the @code{allocate} directive for automatic/stack variables, except
5646 when the @code{allocator} clause is a constant expression with value
5647 @code{omp_default_mem_alloc} and no @code{align} clause has been
5648 specified. (In that case, the normal allocation is used: stack allocation
5649 and, sometimes for Fortran, also @code{malloc} [depending on flags such as
5650 @option{-fstack-arrays}].)
5651@item Using the @code{allocate} directive for variable in static memory is
5652 currently not supported (compile time error).
5653@item Using the @code{allocators} directive for Fortran pointers and
5654 allocatables is currently not supported (compile time error).
5655@end itemize
5656
a85a106c
TB
5657For the available predefined allocators and, as applicable, their associated
5658predefined memory spaces and for the available traits and their default values,
5659see @ref{OMP_ALLOCATOR}. Predefined allocators without an associated memory
5660space use the @code{omp_default_mem_space} memory space.
5661
8c2fc744
TB
5662For the memory spaces, the following applies:
5663@itemize
5664@item @code{omp_default_mem_space} is supported
5665@item @code{omp_const_mem_space} maps to @code{omp_default_mem_space}
5666@item @code{omp_low_lat_mem_space} maps to @code{omp_default_mem_space}
5667@item @code{omp_large_cap_mem_space} maps to @code{omp_default_mem_space},
5668 unless the memkind library is available
5669@item @code{omp_high_bw_mem_space} maps to @code{omp_default_mem_space},
5670 unless the memkind library is available
5671@end itemize
5672
d77de738
ML
5673On Linux systems, where the @uref{https://github.com/memkind/memkind, memkind
5674library} (@code{libmemkind.so.0}) is available at runtime, it is used when
5675creating memory allocators requesting
5676
5677@itemize
5678@item the memory space @code{omp_high_bw_mem_space}
5679@item the memory space @code{omp_large_cap_mem_space}
450b05ce 5680@item the @code{partition} trait @code{interleaved}; note that for
8c2fc744 5681 @code{omp_large_cap_mem_space} the allocation will not be interleaved
d77de738
ML
5682@end itemize
5683
450b05ce
TB
5684On Linux systems, where the @uref{https://github.com/numactl/numactl, numa
5685library} (@code{libnuma.so.1}) is available at runtime, it used when creating
5686memory allocators requesting
5687
5688@itemize
5689@item the @code{partition} trait @code{nearest}, except when both the
5690libmemkind library is available and the memory space is either
5691@code{omp_large_cap_mem_space} or @code{omp_high_bw_mem_space}
5692@end itemize
5693
5694Note that the numa library will round up the allocation size to a multiple of
5695the system page size; therefore, consider using it only with large data or
5696by sharing allocations via the @code{pool_size} trait. Furthermore, the Linux
5697kernel does not guarantee that an allocation will always be on the nearest NUMA
5698node nor that after reallocation the same node will be used. Note additionally
5699that, on Linux, the default setting of the memory placement policy is to use the
5700current node; therefore, unless the memory placement policy has been overridden,
5701the @code{partition} trait @code{environment} (the default) will be effectively
5702a @code{nearest} allocation.
5703
a85a106c 5704Additional notes regarding the traits:
8c2fc744
TB
5705@itemize
5706@item The @code{pinned} trait is unsupported.
a85a106c
TB
5707@item The default for the @code{pool_size} trait is no pool and for every
5708 (re)allocation the associated library routine is called, which might
5709 internally use a memory pool.
8c2fc744
TB
5710@item For the @code{partition} trait, the partition part size will be the same
5711 as the requested size (i.e. @code{interleaved} or @code{blocked} has no
5712 effect), except for @code{interleaved} when the memkind library is
450b05ce
TB
5713 available. Furthermore, for @code{nearest} and unless the numa library
5714 is available, the memory might not be on the same NUMA node as thread
5715 that allocated the memory; on Linux, this is in particular the case when
5716 the memory placement policy is set to preferred.
8c2fc744
TB
5717@item The @code{access} trait has no effect such that memory is always
5718 accessible by all threads.
5719@item The @code{sync_hint} trait has no effect.
5720@end itemize
d77de738
ML
5721
5722@c ---------------------------------------------------------------------
5723@c Offload-Target Specifics
5724@c ---------------------------------------------------------------------
5725
5726@node Offload-Target Specifics
5727@chapter Offload-Target Specifics
5728
5729The following sections present notes on the offload-target specifics
5730
5731@menu
5732* AMD Radeon::
5733* nvptx::
5734@end menu
5735
5736@node AMD Radeon
5737@section AMD Radeon (GCN)
5738
5739On the hardware side, there is the hierarchy (fine to coarse):
5740@itemize
5741@item work item (thread)
5742@item wavefront
5743@item work group
81476bc4 5744@item compute unit (CU)
d77de738
ML
5745@end itemize
5746
5747All OpenMP and OpenACC levels are used, i.e.
5748@itemize
5749@item OpenMP's simd and OpenACC's vector map to work items (thread)
5750@item OpenMP's threads (``parallel'') and OpenACC's workers map
5751 to wavefronts
5752@item OpenMP's teams and OpenACC's gang use a threadpool with the
5753 size of the number of teams or gangs, respectively.
5754@end itemize
5755
5756The used sizes are
5757@itemize
5758@item Number of teams is the specified @code{num_teams} (OpenMP) or
81476bc4
MV
5759 @code{num_gangs} (OpenACC) or otherwise the number of CU. It is limited
5760 by two times the number of CU.
d77de738
ML
5761@item Number of wavefronts is 4 for gfx900 and 16 otherwise;
5762 @code{num_threads} (OpenMP) and @code{num_workers} (OpenACC)
5763 overrides this if smaller.
5764@item The wavefront has 102 scalars and 64 vectors
5765@item Number of workitems is always 64
5766@item The hardware permits maximally 40 workgroups/CU and
5767 16 wavefronts/workgroup up to a limit of 40 wavefronts in total per CU.
5768@item 80 scalars registers and 24 vector registers in non-kernel functions
5769 (the chosen procedure-calling API).
5770@item For the kernel itself: as many as register pressure demands (number of
5771 teams and number of threads, scaled down if registers are exhausted)
5772@end itemize
5773
5774The implementation remark:
5775@itemize
5776@item I/O within OpenMP target regions and OpenACC parallel/kernels is supported
5777 using the C library @code{printf} functions and the Fortran
5778 @code{print}/@code{write} statements.
243fa488 5779@item Reverse offload regions (i.e. @code{target} regions with
f84fdb13
TB
5780 @code{device(ancestor:1)}) are processed serially per @code{target} region
5781 such that the next reverse offload region is only executed after the previous
5782 one returned.
f1af7d65 5783@item OpenMP code that has a @code{requires} directive with
f84fdb13
TB
5784 @code{unified_shared_memory} will remove any GCN device from the list of
5785 available devices (``host fallback'').
2e3dd14d
TB
5786@item The available stack size can be changed using the @code{GCN_STACK_SIZE}
5787 environment variable; the default is 32 kiB per thread.
d77de738
ML
5788@end itemize
5789
5790
5791
5792@node nvptx
5793@section nvptx
5794
5795On the hardware side, there is the hierarchy (fine to coarse):
5796@itemize
5797@item thread
5798@item warp
5799@item thread block
5800@item streaming multiprocessor
5801@end itemize
5802
5803All OpenMP and OpenACC levels are used, i.e.
5804@itemize
5805@item OpenMP's simd and OpenACC's vector map to threads
5806@item OpenMP's threads (``parallel'') and OpenACC's workers map to warps
5807@item OpenMP's teams and OpenACC's gang use a threadpool with the
5808 size of the number of teams or gangs, respectively.
5809@end itemize
5810
5811The used sizes are
5812@itemize
5813@item The @code{warp_size} is always 32
5814@item CUDA kernel launched: @code{dim=@{#teams,1,1@}, blocks=@{#threads,warp_size,1@}}.
81476bc4
MV
5815@item The number of teams is limited by the number of blocks the device can
5816 host simultaneously.
d77de738
ML
5817@end itemize
5818
5819Additional information can be obtained by setting the environment variable to
5820@code{GOMP_DEBUG=1} (very verbose; grep for @code{kernel.*launch} for launch
5821parameters).
5822
5823GCC generates generic PTX ISA code, which is just-in-time compiled by CUDA,
5824which caches the JIT in the user's directory (see CUDA documentation; can be
5825tuned by the environment variables @code{CUDA_CACHE_@{DISABLE,MAXSIZE,PATH@}}.
5826
5827Note: While PTX ISA is generic, the @code{-mptx=} and @code{-march=} commandline
eda38850 5828options still affect the used PTX ISA code and, thus, the requirements on
d77de738
ML
5829CUDA version and hardware.
5830
5831The implementation remark:
5832@itemize
5833@item I/O within OpenMP target regions and OpenACC parallel/kernels is supported
5834 using the C library @code{printf} functions. Note that the Fortran
5835 @code{print}/@code{write} statements are not supported, yet.
5836@item Compilation OpenMP code that contains @code{requires reverse_offload}
5837 requires at least @code{-march=sm_35}, compiling for @code{-march=sm_30}
5838 is not supported.
eda38850
TB
5839@item For code containing reverse offload (i.e. @code{target} regions with
5840 @code{device(ancestor:1)}), there is a slight performance penalty
5841 for @emph{all} target regions, consisting mostly of shutdown delay
5842 Per device, reverse offload regions are processed serially such that
5843 the next reverse offload region is only executed after the previous
5844 one returned.
f1af7d65
TB
5845@item OpenMP code that has a @code{requires} directive with
5846 @code{unified_shared_memory} will remove any nvptx device from the
eda38850 5847 list of available devices (``host fallback'').
2cd0689a
TB
5848@item The default per-warp stack size is 128 kiB; see also @code{-msoft-stack}
5849 in the GCC manual.
25072a47
TB
5850@item The OpenMP routines @code{omp_target_memcpy_rect} and
5851 @code{omp_target_memcpy_rect_async} and the @code{target update}
5852 directive for non-contiguous list items will use the 2D and 3D
5853 memory-copy functions of the CUDA library. Higher dimensions will
5854 call those functions in a loop and are therefore supported.
d77de738
ML
5855@end itemize
5856
5857
5858@c ---------------------------------------------------------------------
5859@c The libgomp ABI
5860@c ---------------------------------------------------------------------
5861
5862@node The libgomp ABI
5863@chapter The libgomp ABI
5864
5865The following sections present notes on the external ABI as
5866presented by libgomp. Only maintainers should need them.
5867
5868@menu
5869* Implementing MASTER construct::
5870* Implementing CRITICAL construct::
5871* Implementing ATOMIC construct::
5872* Implementing FLUSH construct::
5873* Implementing BARRIER construct::
5874* Implementing THREADPRIVATE construct::
5875* Implementing PRIVATE clause::
5876* Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses::
5877* Implementing REDUCTION clause::
5878* Implementing PARALLEL construct::
5879* Implementing FOR construct::
5880* Implementing ORDERED construct::
5881* Implementing SECTIONS construct::
5882* Implementing SINGLE construct::
5883* Implementing OpenACC's PARALLEL construct::
5884@end menu
5885
5886
5887@node Implementing MASTER construct
5888@section Implementing MASTER construct
5889
5890@smallexample
5891if (omp_get_thread_num () == 0)
5892 block
5893@end smallexample
5894
5895Alternately, we generate two copies of the parallel subfunction
5896and only include this in the version run by the primary thread.
5897Surely this is not worthwhile though...
5898
5899
5900
5901@node Implementing CRITICAL construct
5902@section Implementing CRITICAL construct
5903
5904Without a specified name,
5905
5906@smallexample
5907 void GOMP_critical_start (void);
5908 void GOMP_critical_end (void);
5909@end smallexample
5910
5911so that we don't get COPY relocations from libgomp to the main
5912application.
5913
5914With a specified name, use omp_set_lock and omp_unset_lock with
5915name being transformed into a variable declared like
5916
5917@smallexample
5918 omp_lock_t gomp_critical_user_<name> __attribute__((common))
5919@end smallexample
5920
5921Ideally the ABI would specify that all zero is a valid unlocked
5922state, and so we wouldn't need to initialize this at
5923startup.
5924
5925
5926
5927@node Implementing ATOMIC construct
5928@section Implementing ATOMIC construct
5929
5930The target should implement the @code{__sync} builtins.
5931
5932Failing that we could add
5933
5934@smallexample
5935 void GOMP_atomic_enter (void)
5936 void GOMP_atomic_exit (void)
5937@end smallexample
5938
5939which reuses the regular lock code, but with yet another lock
5940object private to the library.
5941
5942
5943
5944@node Implementing FLUSH construct
5945@section Implementing FLUSH construct
5946
5947Expands to the @code{__sync_synchronize} builtin.
5948
5949
5950
5951@node Implementing BARRIER construct
5952@section Implementing BARRIER construct
5953
5954@smallexample
5955 void GOMP_barrier (void)
5956@end smallexample
5957
5958
5959@node Implementing THREADPRIVATE construct
5960@section Implementing THREADPRIVATE construct
5961
5962In _most_ cases we can map this directly to @code{__thread}. Except
5963that OMP allows constructors for C++ objects. We can either
5964refuse to support this (how often is it used?) or we can
5965implement something akin to .ctors.
5966
5967Even more ideally, this ctor feature is handled by extensions
5968to the main pthreads library. Failing that, we can have a set
5969of entry points to register ctor functions to be called.
5970
5971
5972
5973@node Implementing PRIVATE clause
5974@section Implementing PRIVATE clause
5975
5976In association with a PARALLEL, or within the lexical extent
5977of a PARALLEL block, the variable becomes a local variable in
5978the parallel subfunction.
5979
5980In association with FOR or SECTIONS blocks, create a new
5981automatic variable within the current function. This preserves
5982the semantic of new variable creation.
5983
5984
5985
5986@node Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses
5987@section Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses
5988
5989This seems simple enough for PARALLEL blocks. Create a private
5990struct for communicating between the parent and subfunction.
5991In the parent, copy in values for scalar and "small" structs;
5992copy in addresses for others TREE_ADDRESSABLE types. In the
5993subfunction, copy the value into the local variable.
5994
5995It is not clear what to do with bare FOR or SECTION blocks.
5996The only thing I can figure is that we do something like:
5997
5998@smallexample
5999#pragma omp for firstprivate(x) lastprivate(y)
6000for (int i = 0; i < n; ++i)
6001 body;
6002@end smallexample
6003
6004which becomes
6005
6006@smallexample
6007@{
6008 int x = x, y;
6009
6010 // for stuff
6011
6012 if (i == n)
6013 y = y;
6014@}
6015@end smallexample
6016
6017where the "x=x" and "y=y" assignments actually have different
6018uids for the two variables, i.e. not something you could write
6019directly in C. Presumably this only makes sense if the "outer"
6020x and y are global variables.
6021
6022COPYPRIVATE would work the same way, except the structure
6023broadcast would have to happen via SINGLE machinery instead.
6024
6025
6026
6027@node Implementing REDUCTION clause
6028@section Implementing REDUCTION clause
6029
6030The private struct mentioned in the previous section should have
6031a pointer to an array of the type of the variable, indexed by the
6032thread's @var{team_id}. The thread stores its final value into the
6033array, and after the barrier, the primary thread iterates over the
6034array to collect the values.
6035
6036
6037@node Implementing PARALLEL construct
6038@section Implementing PARALLEL construct
6039
6040@smallexample
6041 #pragma omp parallel
6042 @{
6043 body;
6044 @}
6045@end smallexample
6046
6047becomes
6048
6049@smallexample
6050 void subfunction (void *data)
6051 @{
6052 use data;
6053 body;
6054 @}
6055
6056 setup data;
6057 GOMP_parallel_start (subfunction, &data, num_threads);
6058 subfunction (&data);
6059 GOMP_parallel_end ();
6060@end smallexample
6061
6062@smallexample
6063 void GOMP_parallel_start (void (*fn)(void *), void *data, unsigned num_threads)
6064@end smallexample
6065
6066The @var{FN} argument is the subfunction to be run in parallel.
6067
6068The @var{DATA} argument is a pointer to a structure used to
6069communicate data in and out of the subfunction, as discussed
6070above with respect to FIRSTPRIVATE et al.
6071
6072The @var{NUM_THREADS} argument is 1 if an IF clause is present
6073and false, or the value of the NUM_THREADS clause, if
6074present, or 0.
6075
6076The function needs to create the appropriate number of
6077threads and/or launch them from the dock. It needs to
6078create the team structure and assign team ids.
6079
6080@smallexample
6081 void GOMP_parallel_end (void)
6082@end smallexample
6083
6084Tears down the team and returns us to the previous @code{omp_in_parallel()} state.
6085
6086
6087
6088@node Implementing FOR construct
6089@section Implementing FOR construct
6090
6091@smallexample
6092 #pragma omp parallel for
6093 for (i = lb; i <= ub; i++)
6094 body;
6095@end smallexample
6096
6097becomes
6098
6099@smallexample
6100 void subfunction (void *data)
6101 @{
6102 long _s0, _e0;
6103 while (GOMP_loop_static_next (&_s0, &_e0))
6104 @{
6105 long _e1 = _e0, i;
6106 for (i = _s0; i < _e1; i++)
6107 body;
6108 @}
6109 GOMP_loop_end_nowait ();
6110 @}
6111
6112 GOMP_parallel_loop_static (subfunction, NULL, 0, lb, ub+1, 1, 0);
6113 subfunction (NULL);
6114 GOMP_parallel_end ();
6115@end smallexample
6116
6117@smallexample
6118 #pragma omp for schedule(runtime)
6119 for (i = 0; i < n; i++)
6120 body;
6121@end smallexample
6122
6123becomes
6124
6125@smallexample
6126 @{
6127 long i, _s0, _e0;
6128 if (GOMP_loop_runtime_start (0, n, 1, &_s0, &_e0))
6129 do @{
6130 long _e1 = _e0;
6131 for (i = _s0, i < _e0; i++)
6132 body;
6133 @} while (GOMP_loop_runtime_next (&_s0, _&e0));
6134 GOMP_loop_end ();
6135 @}
6136@end smallexample
6137
6138Note that while it looks like there is trickiness to propagating
6139a non-constant STEP, there isn't really. We're explicitly allowed
6140to evaluate it as many times as we want, and any variables involved
6141should automatically be handled as PRIVATE or SHARED like any other
6142variables. So the expression should remain evaluable in the
6143subfunction. We can also pull it into a local variable if we like,
6144but since its supposed to remain unchanged, we can also not if we like.
6145
6146If we have SCHEDULE(STATIC), and no ORDERED, then we ought to be
6147able to get away with no work-sharing context at all, since we can
6148simply perform the arithmetic directly in each thread to divide up
6149the iterations. Which would mean that we wouldn't need to call any
6150of these routines.
6151
6152There are separate routines for handling loops with an ORDERED
6153clause. Bookkeeping for that is non-trivial...
6154
6155
6156
6157@node Implementing ORDERED construct
6158@section Implementing ORDERED construct
6159
6160@smallexample
6161 void GOMP_ordered_start (void)
6162 void GOMP_ordered_end (void)
6163@end smallexample
6164
6165
6166
6167@node Implementing SECTIONS construct
6168@section Implementing SECTIONS construct
6169
6170A block as
6171
6172@smallexample
6173 #pragma omp sections
6174 @{
6175 #pragma omp section
6176 stmt1;
6177 #pragma omp section
6178 stmt2;
6179 #pragma omp section
6180 stmt3;
6181 @}
6182@end smallexample
6183
6184becomes
6185
6186@smallexample
6187 for (i = GOMP_sections_start (3); i != 0; i = GOMP_sections_next ())
6188 switch (i)
6189 @{
6190 case 1:
6191 stmt1;
6192 break;
6193 case 2:
6194 stmt2;
6195 break;
6196 case 3:
6197 stmt3;
6198 break;
6199 @}
6200 GOMP_barrier ();
6201@end smallexample
6202
6203
6204@node Implementing SINGLE construct
6205@section Implementing SINGLE construct
6206
6207A block like
6208
6209@smallexample
6210 #pragma omp single
6211 @{
6212 body;
6213 @}
6214@end smallexample
6215
6216becomes
6217
6218@smallexample
6219 if (GOMP_single_start ())
6220 body;
6221 GOMP_barrier ();
6222@end smallexample
6223
6224while
6225
6226@smallexample
6227 #pragma omp single copyprivate(x)
6228 body;
6229@end smallexample
6230
6231becomes
6232
6233@smallexample
6234 datap = GOMP_single_copy_start ();
6235 if (datap == NULL)
6236 @{
6237 body;
6238 data.x = x;
6239 GOMP_single_copy_end (&data);
6240 @}
6241 else
6242 x = datap->x;
6243 GOMP_barrier ();
6244@end smallexample
6245
6246
6247
6248@node Implementing OpenACC's PARALLEL construct
6249@section Implementing OpenACC's PARALLEL construct
6250
6251@smallexample
6252 void GOACC_parallel ()
6253@end smallexample
6254
6255
6256
6257@c ---------------------------------------------------------------------
6258@c Reporting Bugs
6259@c ---------------------------------------------------------------------
6260
6261@node Reporting Bugs
6262@chapter Reporting Bugs
6263
6264Bugs in the GNU Offloading and Multi Processing Runtime Library should
6265be reported via @uref{https://gcc.gnu.org/bugzilla/, Bugzilla}. Please add
6266"openacc", or "openmp", or both to the keywords field in the bug
6267report, as appropriate.
6268
6269
6270
6271@c ---------------------------------------------------------------------
6272@c GNU General Public License
6273@c ---------------------------------------------------------------------
6274
6275@include gpl_v3.texi
6276
6277
6278
6279@c ---------------------------------------------------------------------
6280@c GNU Free Documentation License
6281@c ---------------------------------------------------------------------
6282
6283@include fdl.texi
6284
6285
6286
6287@c ---------------------------------------------------------------------
6288@c Funding Free Software
6289@c ---------------------------------------------------------------------
6290
6291@include funding.texi
6292
6293@c ---------------------------------------------------------------------
6294@c Index
6295@c ---------------------------------------------------------------------
6296
6297@node Library Index
6298@unnumbered Library Index
6299
6300@printindex cp
6301
6302@bye