1 \input texinfo @c -*-texinfo-*-
4 @setfilename libgomp.info
10 Copyright @copyright{} 2006-2023 Free Software Foundation, Inc.
12 Permission is granted to copy, distribute and/or modify this document
13 under the terms of the GNU Free Documentation License, Version 1.3 or
14 any later version published by the Free Software Foundation; with the
15 Invariant Sections being ``Funding Free Software'', the Front-Cover
16 texts 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''.
20 (a) The FSF's Front-Cover Text is:
24 (b) The FSF's Back-Cover Text is:
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.
32 @dircategory GNU Libraries
34 * libgomp: (libgomp). GNU Offloading and Multi Processing Runtime Library.
37 This manual documents libgomp, the GNU Offloading and Multi Processing
38 Runtime library. This is the GNU implementation of the OpenMP and
39 OpenACC APIs for parallel and accelerator programming in C/C++ and
42 Published by the Free Software Foundation
43 51 Franklin Street, Fifth Floor
44 Boston, MA 02110-1301 USA
50 @setchapternewpage odd
53 @title GNU Offloading and Multi Processing Runtime Library
54 @subtitle The GNU OpenMP and OpenACC Implementation
56 @vskip 0pt plus 1filll
57 @comment For the @value{version-GCC} Version*
59 Published by the Free Software Foundation @*
60 51 Franklin Street, Fifth Floor@*
61 Boston, MA 02110-1301, USA@*
71 @node Top, Enabling OpenMP
75 This manual documents the usage of libgomp, the GNU Offloading and
76 Multi Processing Runtime Library. This includes the GNU
77 implementation of the @uref{https://www.openmp.org, OpenMP} Application
78 Programming Interface (API) for multi-platform shared-memory parallel
79 programming in C/C++ and Fortran, and the GNU implementation of the
80 @uref{https://www.openacc.org, OpenACC} Application Programming
81 Interface (API) for offloading of code to accelerator devices in C/C++
84 Originally, libgomp implemented the GNU OpenMP Runtime Library. Based
85 on this, support for OpenACC and offloading (both OpenACC and OpenMP
86 4's target construct) has been added later on, and the library's name
87 changed to GNU Offloading and Multi Processing Runtime Library.
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.
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
102 * OpenMP Environment Variables: Environment Variables.
103 Influencing OpenMP runtime behavior with
104 environment variables.
105 * Enabling OpenACC:: How to enable OpenACC for your
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
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
128 * Library Index:: Index of this documentation.
132 @c ---------------------------------------------------------------------
134 @c ---------------------------------------------------------------------
136 @node Enabling OpenMP
137 @chapter Enabling OpenMP
139 To activate the OpenMP extensions for C/C++ and Fortran, the compile-time
140 flag @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
145 arranges for automatic linking of the OpenMP runtime library
146 (@ref{Runtime Library Routines}).
148 A complete description of all OpenMP directives may be found in the
149 @uref{https://www.openmp.org, OpenMP Application Program Interface} manuals.
150 See also @ref{OpenMP Implementation Status}.
153 @c ---------------------------------------------------------------------
154 @c OpenMP Implementation Status
155 @c ---------------------------------------------------------------------
157 @node OpenMP Implementation Status
158 @chapter OpenMP Implementation Status
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
165 * OpenMP Technical Report 11:: Feature completion status to first 6.0 preview
168 The @code{_OPENMP} preprocessor macro and Fortran's @code{openmp_version}
169 parameter, provided by @code{omp_lib.h} and the @code{omp_lib} module, have
170 the value @code{201511} (i.e. OpenMP 4.5).
175 The OpenMP 4.5 specification is fully supported.
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
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
191 @item @emph{target-offload-var} ICV and @code{OMP_TARGET_OFFLOAD}
192 env variable @tab Y @tab
193 @item Nested-parallel changes to @emph{max-active-levels-var} ICV @tab Y @tab
194 @item @code{requires} directive @tab P
195 @tab complete but no non-host devices provides @code{unified_address} or
196 @code{unified_shared_memory}
197 @item @code{teams} construct outside an enclosing target region @tab Y @tab
198 @item Non-rectangular loop nests @tab P @tab Full support for C/C++, partial for Fortran
199 @item @code{!=} as relational-op in canonical loop form for C/C++ @tab Y @tab
200 @item @code{nonmonotonic} as default loop schedule modifier for worksharing-loop
201 constructs @tab Y @tab
202 @item Collapse of associated loops that are imperfectly nested loops @tab N @tab
203 @item Clauses @code{if}, @code{nontemporal} and @code{order(concurrent)} in
204 @code{simd} construct @tab Y @tab
205 @item @code{atomic} constructs in @code{simd} @tab Y @tab
206 @item @code{loop} construct @tab Y @tab
207 @item @code{order(concurrent)} clause @tab Y @tab
208 @item @code{scan} directive and @code{in_scan} modifier for the
209 @code{reduction} clause @tab Y @tab
210 @item @code{in_reduction} clause on @code{task} constructs @tab Y @tab
211 @item @code{in_reduction} clause on @code{target} constructs @tab P
212 @tab @code{nowait} only stub
213 @item @code{task_reduction} clause with @code{taskgroup} @tab Y @tab
214 @item @code{task} modifier to @code{reduction} clause @tab Y @tab
215 @item @code{affinity} clause to @code{task} construct @tab Y @tab Stub only
216 @item @code{detach} clause to @code{task} construct @tab Y @tab
217 @item @code{omp_fulfill_event} runtime routine @tab Y @tab
218 @item @code{reduction} and @code{in_reduction} clauses on @code{taskloop}
219 and @code{taskloop simd} constructs @tab Y @tab
220 @item @code{taskloop} construct cancelable by @code{cancel} construct
222 @item @code{mutexinoutset} @emph{dependence-type} for @code{depend} clause
224 @item Predefined memory spaces, memory allocators, allocator traits
225 @tab Y @tab Some are only stubs
226 @item Memory management routines @tab Y @tab
227 @item @code{allocate} directive @tab N @tab
228 @item @code{allocate} clause @tab P @tab Initial support
229 @item @code{use_device_addr} clause on @code{target data} @tab Y @tab
230 @item @code{ancestor} modifier on @code{device} clause @tab Y @tab
231 @item Implicit declare target directive @tab Y @tab
232 @item Discontiguous array section with @code{target update} construct
234 @item C/C++'s lvalue expressions in @code{to}, @code{from}
235 and @code{map} clauses @tab N @tab
236 @item C/C++'s lvalue expressions in @code{depend} clauses @tab Y @tab
237 @item Nested @code{declare target} directive @tab Y @tab
238 @item Combined @code{master} constructs @tab Y @tab
239 @item @code{depend} clause on @code{taskwait} @tab Y @tab
240 @item Weak memory ordering clauses on @code{atomic} and @code{flush} construct
242 @item @code{hint} clause on the @code{atomic} construct @tab Y @tab Stub only
243 @item @code{depobj} construct and depend objects @tab Y @tab
244 @item Lock hints were renamed to synchronization hints @tab Y @tab
245 @item @code{conditional} modifier to @code{lastprivate} clause @tab Y @tab
246 @item Map-order clarifications @tab P @tab
247 @item @code{close} @emph{map-type-modifier} @tab Y @tab
248 @item Mapping C/C++ pointer variables and to assign the address of
249 device memory mapped by an array section @tab P @tab
250 @item Mapping of Fortran pointer and allocatable variables, including pointer
251 and allocatable components of variables
252 @tab P @tab Mapping of vars with allocatable components unsupported
253 @item @code{defaultmap} extensions @tab Y @tab
254 @item @code{declare mapper} directive @tab N @tab
255 @item @code{omp_get_supported_active_levels} routine @tab Y @tab
256 @item Runtime routines and environment variables to display runtime thread
257 affinity information @tab Y @tab
258 @item @code{omp_pause_resource} and @code{omp_pause_resource_all} runtime
260 @item @code{omp_get_device_num} runtime routine @tab Y @tab
261 @item OMPT interface @tab N @tab
262 @item OMPD interface @tab N @tab
265 @unnumberedsubsec Other new OpenMP 5.0 features
267 @multitable @columnfractions .60 .10 .25
268 @headitem Description @tab Status @tab Comments
269 @item Supporting C++'s range-based for loop @tab Y @tab
276 @unnumberedsubsec New features listed in Appendix B of the OpenMP specification
278 @multitable @columnfractions .60 .10 .25
279 @headitem Description @tab Status @tab Comments
280 @item OpenMP directive as C++ attribute specifiers @tab Y @tab
281 @item @code{omp_all_memory} reserved locator @tab Y @tab
282 @item @emph{target_device trait} in OpenMP Context @tab N @tab
283 @item @code{target_device} selector set in context selectors @tab N @tab
284 @item C/C++'s @code{declare variant} directive: elision support of
285 preprocessed code @tab N @tab
286 @item @code{declare variant}: new clauses @code{adjust_args} and
287 @code{append_args} @tab N @tab
288 @item @code{dispatch} construct @tab N @tab
289 @item device-specific ICV settings with environment variables @tab Y @tab
290 @item @code{assume} and @code{assumes} directives @tab Y @tab
291 @item @code{nothing} directive @tab Y @tab
292 @item @code{error} directive @tab Y @tab
293 @item @code{masked} construct @tab Y @tab
294 @item @code{scope} directive @tab Y @tab
295 @item Loop transformation constructs @tab N @tab
296 @item @code{strict} modifier in the @code{grainsize} and @code{num_tasks}
297 clauses of the @code{taskloop} construct @tab Y @tab
298 @item @code{align} clause in @code{allocate} directive @tab N @tab
299 @item @code{align} modifier in @code{allocate} clause @tab Y @tab
300 @item @code{thread_limit} clause to @code{target} construct @tab Y @tab
301 @item @code{has_device_addr} clause to @code{target} construct @tab Y @tab
302 @item Iterators in @code{target update} motion clauses and @code{map}
304 @item Indirect calls to the device version of a procedure or function in
305 @code{target} regions @tab N @tab
306 @item @code{interop} directive @tab N @tab
307 @item @code{omp_interop_t} object support in runtime routines @tab N @tab
308 @item @code{nowait} clause in @code{taskwait} directive @tab Y @tab
309 @item Extensions to the @code{atomic} directive @tab Y @tab
310 @item @code{seq_cst} clause on a @code{flush} construct @tab Y @tab
311 @item @code{inoutset} argument to the @code{depend} clause @tab Y @tab
312 @item @code{private} and @code{firstprivate} argument to @code{default}
313 clause in C and C++ @tab Y @tab
314 @item @code{present} argument to @code{defaultmap} clause @tab N @tab
315 @item @code{omp_set_num_teams}, @code{omp_set_teams_thread_limit},
316 @code{omp_get_max_teams}, @code{omp_get_teams_thread_limit} runtime
318 @item @code{omp_target_is_accessible} runtime routine @tab Y @tab
319 @item @code{omp_target_memcpy_async} and @code{omp_target_memcpy_rect_async}
320 runtime routines @tab Y @tab
321 @item @code{omp_get_mapped_ptr} runtime routine @tab Y @tab
322 @item @code{omp_calloc}, @code{omp_realloc}, @code{omp_aligned_alloc} and
323 @code{omp_aligned_calloc} runtime routines @tab Y @tab
324 @item @code{omp_alloctrait_key_t} enum: @code{omp_atv_serialized} added,
325 @code{omp_atv_default} changed @tab Y @tab
326 @item @code{omp_display_env} runtime routine @tab Y @tab
327 @item @code{ompt_scope_endpoint_t} enum: @code{ompt_scope_beginend} @tab N @tab
328 @item @code{ompt_sync_region_t} enum additions @tab N @tab
329 @item @code{ompt_state_t} enum: @code{ompt_state_wait_barrier_implementation}
330 and @code{ompt_state_wait_barrier_teams} @tab N @tab
331 @item @code{ompt_callback_target_data_op_emi_t},
332 @code{ompt_callback_target_emi_t}, @code{ompt_callback_target_map_emi_t}
333 and @code{ompt_callback_target_submit_emi_t} @tab N @tab
334 @item @code{ompt_callback_error_t} type @tab N @tab
335 @item @code{OMP_PLACES} syntax extensions @tab Y @tab
336 @item @code{OMP_NUM_TEAMS} and @code{OMP_TEAMS_THREAD_LIMIT} environment
337 variables @tab Y @tab
340 @unnumberedsubsec Other new OpenMP 5.1 features
342 @multitable @columnfractions .60 .10 .25
343 @headitem Description @tab Status @tab Comments
344 @item Support of strictly structured blocks in Fortran @tab Y @tab
345 @item Support of structured block sequences in C/C++ @tab Y @tab
346 @item @code{unconstrained} and @code{reproducible} modifiers on @code{order}
348 @item Support @code{begin/end declare target} syntax in C/C++ @tab Y @tab
349 @item Pointer predetermined firstprivate getting initialized
350 to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
351 @item For Fortran, diagnose placing declarative before/between @code{USE},
352 @code{IMPORT}, and @code{IMPLICIT} as invalid @tab N @tab
353 @item Optional comma between directive and clause in the @code{#pragma} form @tab Y @tab
354 @item @code{indirect} clause in @code{declare target} @tab N @tab
355 @item @code{device_type(nohost)}/@code{device_type(host)} for variables @tab N @tab
362 @unnumberedsubsec New features listed in Appendix B of the OpenMP specification
364 @multitable @columnfractions .60 .10 .25
365 @headitem Description @tab Status @tab Comments
366 @item @code{omp_in_explicit_task} routine and @emph{explicit-task-var} ICV
368 @item @code{omp}/@code{ompx}/@code{omx} sentinels and @code{omp_}/@code{ompx_}
370 @tab warning for @code{ompx/omx} sentinels@footnote{The @code{ompx}
371 sentinel as C/C++ pragma and C++ attributes are warned for with
372 @code{-Wunknown-pragmas} (implied by @code{-Wall}) and @code{-Wattributes}
373 (enabled by default), respectively; for Fortran free-source code, there is
374 a warning enabled by default and, for fixed-source code, the @code{omx}
375 sentinel is warned for with with @code{-Wsurprising} (enabled by
376 @code{-Wall}). Unknown clauses are always rejected with an error.}
377 @item Clauses on @code{end} directive can be on directive @tab Y @tab
378 @item Deprecation of no-argument @code{destroy} clause on @code{depobj}
380 @item @code{linear} clause syntax changes and @code{step} modifier @tab Y @tab
381 @item Deprecation of minus operator for reductions @tab N @tab
382 @item Deprecation of separating @code{map} modifiers without comma @tab N @tab
383 @item @code{declare mapper} with iterator and @code{present} modifiers
385 @item If a matching mapped list item is not found in the data environment, the
386 pointer retains its original value @tab N @tab
387 @item New @code{enter} clause as alias for @code{to} on declare target directive
389 @item Deprecation of @code{to} clause on declare target directive @tab N @tab
390 @item Extended list of directives permitted in Fortran pure procedures
392 @item New @code{allocators} directive for Fortran @tab N @tab
393 @item Deprecation of @code{allocate} directive for Fortran
394 allocatables/pointers @tab N @tab
395 @item Optional paired @code{end} directive with @code{dispatch} @tab N @tab
396 @item New @code{memspace} and @code{traits} modifiers for @code{uses_allocators}
398 @item Deprecation of traits array following the allocator_handle expression in
399 @code{uses_allocators} @tab N @tab
400 @item New @code{otherwise} clause as alias for @code{default} on metadirectives
402 @item Deprecation of @code{default} clause on metadirectives @tab N @tab
403 @item Deprecation of delimited form of @code{declare target} @tab N @tab
404 @item Reproducible semantics changed for @code{order(concurrent)} @tab N @tab
405 @item @code{allocate} and @code{firstprivate} clauses on @code{scope}
407 @item @code{ompt_callback_work} @tab N @tab
408 @item Default map-type for the @code{map} clause in @code{target enter/exit data}
410 @item New @code{doacross} clause as alias for @code{depend} with
411 @code{source}/@code{sink} modifier @tab Y @tab
412 @item Deprecation of @code{depend} with @code{source}/@code{sink} modifier
414 @item @code{omp_cur_iteration} keyword @tab Y @tab
417 @unnumberedsubsec Other new OpenMP 5.2 features
419 @multitable @columnfractions .60 .10 .25
420 @headitem Description @tab Status @tab Comments
421 @item For Fortran, optional comma between directive and clause @tab N @tab
422 @item Conforming device numbers and @code{omp_initial_device} and
423 @code{omp_invalid_device} enum/PARAMETER @tab Y @tab
424 @item Initial value of @emph{default-device-var} ICV with
425 @code{OMP_TARGET_OFFLOAD=mandatory} @tab N @tab
426 @item @emph{interop_types} in any position of the modifier list for the @code{init} clause
427 of the @code{interop} construct @tab N @tab
431 @node OpenMP Technical Report 11
432 @section OpenMP Technical Report 11
434 Technical Report (TR) 11 is the first preview for OpenMP 6.0.
436 @unnumberedsubsec New features listed in Appendix B of the OpenMP specification
437 @multitable @columnfractions .60 .10 .25
438 @item Features deprecated in versions 5.2, 5.1 and 5.0 were removed
439 @tab N/A @tab Backward compatibility
440 @item The @code{decl} attribute was added to the C++ attribute syntax
442 @item @code{_ALL} suffix to the device-scope environment variables
443 @tab P @tab Host device number wrongly accepted
444 @item For Fortran, @emph{locator list} can be also function reference with
445 data pointer result @tab N @tab
446 @item Ref-count change for @code{use_device_ptr}/@code{use_device_addr}
448 @item Implicit reduction identifiers of C++ classes
450 @item Change of the @emph{map-type} property from @emph{ultimate} to
451 @emph{default} @tab N @tab
452 @item Concept of @emph{assumed-size arrays} in C and C++
454 @item Mapping of @emph{assumed-size arrays} in C, C++ and Fortran
456 @item @code{groupprivate} directive @tab N @tab
457 @item @code{local} clause to declare target directive @tab N @tab
458 @item @code{part_size} allocator trait @tab N @tab
459 @item @code{pin_device}, @code{preferred_device} and @code{target_access}
462 @item @code{access} allocator trait changes @tab N @tab
463 @item Extension of @code{interop} operation of @code{append_args}, allowing all
464 modifiers of the @code{init} clause
466 @item @code{interop} clause to @code{dispatch} @tab N @tab
467 @item @code{apply} code to loop-transforming constructs @tab N @tab
468 @item @code{omp_curr_progress_width} identifier @tab N @tab
469 @item @code{safesync} clause to the @code{parallel} construct @tab N @tab
470 @item @code{omp_get_max_progress_width} runtime routine @tab N @tab
471 @item @code{strict} modifier keyword to @code{num_threads} @tab N @tab
472 @item @code{memscope} clause to @code{atomic} and @code{flush} @tab N @tab
473 @item Routines for obtaining memory spaces/allocators for shared/device memory
475 @item @code{omp_get_memspace_num_resources} routine @tab N @tab
476 @item @code{omp_get_submemspace} routine @tab N @tab
477 @item @code{ompt_get_buffer_limits} OMPT routine @tab N @tab
478 @item Extension of @code{OMP_DEFAULT_DEVICE} and new
479 @code{OMP_AVAILABLE_DEVICES} environment vars @tab N @tab
480 @item Supporting increments with abstract names in @code{OMP_PLACES} @tab N @tab
483 @unnumberedsubsec Other new TR 11 features
484 @multitable @columnfractions .60 .10 .25
485 @item Relaxed Fortran restrictions to the @code{aligned} clause @tab N @tab
486 @item Mapping lambda captures @tab N @tab
487 @item For Fortran, atomic compare with storing the comparison result
489 @item @code{aligned} clause changes for @code{simd} and @code{declare simd}
495 @c ---------------------------------------------------------------------
496 @c OpenMP Runtime Library Routines
497 @c ---------------------------------------------------------------------
499 @node Runtime Library Routines
500 @chapter OpenMP Runtime Library Routines
502 The runtime routines described here are defined by Section 3 of the OpenMP
503 specification in version 4.5. The routines are structured in following
507 Control threads, processors and the parallel environment. They have C
508 linkage, and do not throw exceptions.
510 * omp_get_active_level:: Number of active parallel regions
511 * omp_get_ancestor_thread_num:: Ancestor thread ID
512 * omp_get_cancellation:: Whether cancellation support is enabled
513 * omp_get_default_device:: Get the default device for target regions
514 * omp_get_device_num:: Get device that current thread is running on
515 * omp_get_dynamic:: Dynamic teams setting
516 * omp_get_initial_device:: Device number of host device
517 * omp_get_level:: Number of parallel regions
518 * omp_get_max_active_levels:: Current maximum number of active regions
519 * omp_get_max_task_priority:: Maximum task priority value that can be set
520 * omp_get_max_teams:: Maximum number of teams for teams region
521 * omp_get_max_threads:: Maximum number of threads of parallel region
522 * omp_get_nested:: Nested parallel regions
523 * omp_get_num_devices:: Number of target devices
524 * omp_get_num_procs:: Number of processors online
525 * omp_get_num_teams:: Number of teams
526 * omp_get_num_threads:: Size of the active team
527 * omp_get_proc_bind:: Whether threads may be moved between CPUs
528 * omp_get_schedule:: Obtain the runtime scheduling method
529 * omp_get_supported_active_levels:: Maximum number of active regions supported
530 * omp_get_team_num:: Get team number
531 * omp_get_team_size:: Number of threads in a team
532 * omp_get_teams_thread_limit:: Maximum number of threads imposed by teams
533 * omp_get_thread_limit:: Maximum number of threads
534 * omp_get_thread_num:: Current thread ID
535 * omp_in_parallel:: Whether a parallel region is active
536 * omp_in_final:: Whether in final or included task region
537 * omp_is_initial_device:: Whether executing on the host device
538 * omp_set_default_device:: Set the default device for target regions
539 * omp_set_dynamic:: Enable/disable dynamic teams
540 * omp_set_max_active_levels:: Limits the number of active parallel regions
541 * omp_set_nested:: Enable/disable nested parallel regions
542 * omp_set_num_teams:: Set upper teams limit for teams region
543 * omp_set_num_threads:: Set upper team size limit
544 * omp_set_schedule:: Set the runtime scheduling method
545 * omp_set_teams_thread_limit:: Set upper thread limit for teams construct
547 Initialize, set, test, unset and destroy simple and nested locks.
549 * omp_init_lock:: Initialize simple lock
550 * omp_set_lock:: Wait for and set simple lock
551 * omp_test_lock:: Test and set simple lock if available
552 * omp_unset_lock:: Unset simple lock
553 * omp_destroy_lock:: Destroy simple lock
554 * omp_init_nest_lock:: Initialize nested lock
555 * omp_set_nest_lock:: Wait for and set simple lock
556 * omp_test_nest_lock:: Test and set nested lock if available
557 * omp_unset_nest_lock:: Unset nested lock
558 * omp_destroy_nest_lock:: Destroy nested lock
560 Portable, thread-based, wall clock timer.
562 * omp_get_wtick:: Get timer precision.
563 * omp_get_wtime:: Elapsed wall clock time.
565 Support for event objects.
567 * omp_fulfill_event:: Fulfill and destroy an OpenMP event.
572 @node omp_get_active_level
573 @section @code{omp_get_active_level} -- Number of parallel regions
575 @item @emph{Description}:
576 This function returns the nesting level for the active parallel blocks,
577 which enclose the calling call.
580 @multitable @columnfractions .20 .80
581 @item @emph{Prototype}: @tab @code{int omp_get_active_level(void);}
584 @item @emph{Fortran}:
585 @multitable @columnfractions .20 .80
586 @item @emph{Interface}: @tab @code{integer function omp_get_active_level()}
589 @item @emph{See also}:
590 @ref{omp_get_level}, @ref{omp_get_max_active_levels}, @ref{omp_set_max_active_levels}
592 @item @emph{Reference}:
593 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.20.
598 @node omp_get_ancestor_thread_num
599 @section @code{omp_get_ancestor_thread_num} -- Ancestor thread ID
601 @item @emph{Description}:
602 This function returns the thread identification number for the given
603 nesting level of the current thread. For values of @var{level} outside
604 zero to @code{omp_get_level} -1 is returned; if @var{level} is
605 @code{omp_get_level} the result is identical to @code{omp_get_thread_num}.
608 @multitable @columnfractions .20 .80
609 @item @emph{Prototype}: @tab @code{int omp_get_ancestor_thread_num(int level);}
612 @item @emph{Fortran}:
613 @multitable @columnfractions .20 .80
614 @item @emph{Interface}: @tab @code{integer function omp_get_ancestor_thread_num(level)}
615 @item @tab @code{integer level}
618 @item @emph{See also}:
619 @ref{omp_get_level}, @ref{omp_get_thread_num}, @ref{omp_get_team_size}
621 @item @emph{Reference}:
622 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.18.
627 @node omp_get_cancellation
628 @section @code{omp_get_cancellation} -- Whether cancellation support is enabled
630 @item @emph{Description}:
631 This function returns @code{true} if cancellation is activated, @code{false}
632 otherwise. Here, @code{true} and @code{false} represent their language-specific
633 counterparts. Unless @env{OMP_CANCELLATION} is set true, cancellations are
637 @multitable @columnfractions .20 .80
638 @item @emph{Prototype}: @tab @code{int omp_get_cancellation(void);}
641 @item @emph{Fortran}:
642 @multitable @columnfractions .20 .80
643 @item @emph{Interface}: @tab @code{logical function omp_get_cancellation()}
646 @item @emph{See also}:
647 @ref{OMP_CANCELLATION}
649 @item @emph{Reference}:
650 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.9.
655 @node omp_get_default_device
656 @section @code{omp_get_default_device} -- Get the default device for target regions
658 @item @emph{Description}:
659 Get the default device for target regions without device clause.
662 @multitable @columnfractions .20 .80
663 @item @emph{Prototype}: @tab @code{int omp_get_default_device(void);}
666 @item @emph{Fortran}:
667 @multitable @columnfractions .20 .80
668 @item @emph{Interface}: @tab @code{integer function omp_get_default_device()}
671 @item @emph{See also}:
672 @ref{OMP_DEFAULT_DEVICE}, @ref{omp_set_default_device}
674 @item @emph{Reference}:
675 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.30.
680 @node omp_get_device_num
681 @section @code{omp_get_device_num} -- Return device number of current device
683 @item @emph{Description}:
684 This function returns a device number that represents the device that the
685 current thread is executing on. For OpenMP 5.0, this must be equal to the
686 value returned by the @code{omp_get_initial_device} function when called
690 @multitable @columnfractions .20 .80
691 @item @emph{Prototype}: @tab @code{int omp_get_device_num(void);}
694 @item @emph{Fortran}:
695 @multitable @columnfractions .20 .80
696 @item @emph{Interface}: @tab @code{integer function omp_get_device_num()}
699 @item @emph{See also}:
700 @ref{omp_get_initial_device}
702 @item @emph{Reference}:
703 @uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.2.37.
708 @node omp_get_dynamic
709 @section @code{omp_get_dynamic} -- Dynamic teams setting
711 @item @emph{Description}:
712 This function returns @code{true} if enabled, @code{false} otherwise.
713 Here, @code{true} and @code{false} represent their language-specific
716 The dynamic team setting may be initialized at startup by the
717 @env{OMP_DYNAMIC} environment variable or at runtime using
718 @code{omp_set_dynamic}. If undefined, dynamic adjustment is
722 @multitable @columnfractions .20 .80
723 @item @emph{Prototype}: @tab @code{int omp_get_dynamic(void);}
726 @item @emph{Fortran}:
727 @multitable @columnfractions .20 .80
728 @item @emph{Interface}: @tab @code{logical function omp_get_dynamic()}
731 @item @emph{See also}:
732 @ref{omp_set_dynamic}, @ref{OMP_DYNAMIC}
734 @item @emph{Reference}:
735 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.8.
740 @node omp_get_initial_device
741 @section @code{omp_get_initial_device} -- Return device number of initial device
743 @item @emph{Description}:
744 This function returns a device number that represents the host device.
745 For OpenMP 5.1, this must be equal to the value returned by the
746 @code{omp_get_num_devices} function.
749 @multitable @columnfractions .20 .80
750 @item @emph{Prototype}: @tab @code{int omp_get_initial_device(void);}
753 @item @emph{Fortran}:
754 @multitable @columnfractions .20 .80
755 @item @emph{Interface}: @tab @code{integer function omp_get_initial_device()}
758 @item @emph{See also}:
759 @ref{omp_get_num_devices}
761 @item @emph{Reference}:
762 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.35.
768 @section @code{omp_get_level} -- Obtain the current nesting level
770 @item @emph{Description}:
771 This function returns the nesting level for the parallel blocks,
772 which enclose the calling call.
775 @multitable @columnfractions .20 .80
776 @item @emph{Prototype}: @tab @code{int omp_get_level(void);}
779 @item @emph{Fortran}:
780 @multitable @columnfractions .20 .80
781 @item @emph{Interface}: @tab @code{integer function omp_level()}
784 @item @emph{See also}:
785 @ref{omp_get_active_level}
787 @item @emph{Reference}:
788 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.17.
793 @node omp_get_max_active_levels
794 @section @code{omp_get_max_active_levels} -- Current maximum number of active regions
796 @item @emph{Description}:
797 This function obtains the maximum allowed number of nested, active parallel regions.
800 @multitable @columnfractions .20 .80
801 @item @emph{Prototype}: @tab @code{int omp_get_max_active_levels(void);}
804 @item @emph{Fortran}:
805 @multitable @columnfractions .20 .80
806 @item @emph{Interface}: @tab @code{integer function omp_get_max_active_levels()}
809 @item @emph{See also}:
810 @ref{omp_set_max_active_levels}, @ref{omp_get_active_level}
812 @item @emph{Reference}:
813 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.16.
817 @node omp_get_max_task_priority
818 @section @code{omp_get_max_task_priority} -- Maximum priority value
819 that can be set for tasks.
821 @item @emph{Description}:
822 This function obtains the maximum allowed priority number for tasks.
825 @multitable @columnfractions .20 .80
826 @item @emph{Prototype}: @tab @code{int omp_get_max_task_priority(void);}
829 @item @emph{Fortran}:
830 @multitable @columnfractions .20 .80
831 @item @emph{Interface}: @tab @code{integer function omp_get_max_task_priority()}
834 @item @emph{Reference}:
835 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.29.
839 @node omp_get_max_teams
840 @section @code{omp_get_max_teams} -- Maximum number of teams of teams region
842 @item @emph{Description}:
843 Return the maximum number of teams used for the teams region
844 that does not use the clause @code{num_teams}.
847 @multitable @columnfractions .20 .80
848 @item @emph{Prototype}: @tab @code{int omp_get_max_teams(void);}
851 @item @emph{Fortran}:
852 @multitable @columnfractions .20 .80
853 @item @emph{Interface}: @tab @code{integer function omp_get_max_teams()}
856 @item @emph{See also}:
857 @ref{omp_set_num_teams}, @ref{omp_get_num_teams}
859 @item @emph{Reference}:
860 @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.4.4.
865 @node omp_get_max_threads
866 @section @code{omp_get_max_threads} -- Maximum number of threads of parallel region
868 @item @emph{Description}:
869 Return the maximum number of threads used for the current parallel region
870 that does not use the clause @code{num_threads}.
873 @multitable @columnfractions .20 .80
874 @item @emph{Prototype}: @tab @code{int omp_get_max_threads(void);}
877 @item @emph{Fortran}:
878 @multitable @columnfractions .20 .80
879 @item @emph{Interface}: @tab @code{integer function omp_get_max_threads()}
882 @item @emph{See also}:
883 @ref{omp_set_num_threads}, @ref{omp_set_dynamic}, @ref{omp_get_thread_limit}
885 @item @emph{Reference}:
886 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.3.
892 @section @code{omp_get_nested} -- Nested parallel regions
894 @item @emph{Description}:
895 This function returns @code{true} if nested parallel regions are
896 enabled, @code{false} otherwise. Here, @code{true} and @code{false}
897 represent their language-specific counterparts.
899 The state of nested parallel regions at startup depends on several
900 environment variables. If @env{OMP_MAX_ACTIVE_LEVELS} is defined
901 and is set to greater than one, then nested parallel regions will be
902 enabled. If not defined, then the value of the @env{OMP_NESTED}
903 environment variable will be followed if defined. If neither are
904 defined, then if either @env{OMP_NUM_THREADS} or @env{OMP_PROC_BIND}
905 are defined with a list of more than one value, then nested parallel
906 regions are enabled. If none of these are defined, then nested parallel
907 regions are disabled by default.
909 Nested parallel regions can be enabled or disabled at runtime using
910 @code{omp_set_nested}, or by setting the maximum number of nested
911 regions with @code{omp_set_max_active_levels} to one to disable, or
915 @multitable @columnfractions .20 .80
916 @item @emph{Prototype}: @tab @code{int omp_get_nested(void);}
919 @item @emph{Fortran}:
920 @multitable @columnfractions .20 .80
921 @item @emph{Interface}: @tab @code{logical function omp_get_nested()}
924 @item @emph{See also}:
925 @ref{omp_set_max_active_levels}, @ref{omp_set_nested},
926 @ref{OMP_MAX_ACTIVE_LEVELS}, @ref{OMP_NESTED}
928 @item @emph{Reference}:
929 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.11.
934 @node omp_get_num_devices
935 @section @code{omp_get_num_devices} -- Number of target devices
937 @item @emph{Description}:
938 Returns the number of target devices.
941 @multitable @columnfractions .20 .80
942 @item @emph{Prototype}: @tab @code{int omp_get_num_devices(void);}
945 @item @emph{Fortran}:
946 @multitable @columnfractions .20 .80
947 @item @emph{Interface}: @tab @code{integer function omp_get_num_devices()}
950 @item @emph{Reference}:
951 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.31.
956 @node omp_get_num_procs
957 @section @code{omp_get_num_procs} -- Number of processors online
959 @item @emph{Description}:
960 Returns the number of processors online on that device.
963 @multitable @columnfractions .20 .80
964 @item @emph{Prototype}: @tab @code{int omp_get_num_procs(void);}
967 @item @emph{Fortran}:
968 @multitable @columnfractions .20 .80
969 @item @emph{Interface}: @tab @code{integer function omp_get_num_procs()}
972 @item @emph{Reference}:
973 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.5.
978 @node omp_get_num_teams
979 @section @code{omp_get_num_teams} -- Number of teams
981 @item @emph{Description}:
982 Returns the number of teams in the current team region.
985 @multitable @columnfractions .20 .80
986 @item @emph{Prototype}: @tab @code{int omp_get_num_teams(void);}
989 @item @emph{Fortran}:
990 @multitable @columnfractions .20 .80
991 @item @emph{Interface}: @tab @code{integer function omp_get_num_teams()}
994 @item @emph{Reference}:
995 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.32.
1000 @node omp_get_num_threads
1001 @section @code{omp_get_num_threads} -- Size of the active team
1003 @item @emph{Description}:
1004 Returns the number of threads in the current team. In a sequential section of
1005 the program @code{omp_get_num_threads} returns 1.
1007 The default team size may be initialized at startup by the
1008 @env{OMP_NUM_THREADS} environment variable. At runtime, the size
1009 of the current team may be set either by the @code{NUM_THREADS}
1010 clause or by @code{omp_set_num_threads}. If none of the above were
1011 used to define a specific value and @env{OMP_DYNAMIC} is disabled,
1012 one thread per CPU online is used.
1015 @multitable @columnfractions .20 .80
1016 @item @emph{Prototype}: @tab @code{int omp_get_num_threads(void);}
1019 @item @emph{Fortran}:
1020 @multitable @columnfractions .20 .80
1021 @item @emph{Interface}: @tab @code{integer function omp_get_num_threads()}
1024 @item @emph{See also}:
1025 @ref{omp_get_max_threads}, @ref{omp_set_num_threads}, @ref{OMP_NUM_THREADS}
1027 @item @emph{Reference}:
1028 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.2.
1033 @node omp_get_proc_bind
1034 @section @code{omp_get_proc_bind} -- Whether threads may be moved between CPUs
1036 @item @emph{Description}:
1037 This functions returns the currently active thread affinity policy, which is
1038 set via @env{OMP_PROC_BIND}. Possible values are @code{omp_proc_bind_false},
1039 @code{omp_proc_bind_true}, @code{omp_proc_bind_primary},
1040 @code{omp_proc_bind_master}, @code{omp_proc_bind_close} and @code{omp_proc_bind_spread},
1041 where @code{omp_proc_bind_master} is an alias for @code{omp_proc_bind_primary}.
1044 @multitable @columnfractions .20 .80
1045 @item @emph{Prototype}: @tab @code{omp_proc_bind_t omp_get_proc_bind(void);}
1048 @item @emph{Fortran}:
1049 @multitable @columnfractions .20 .80
1050 @item @emph{Interface}: @tab @code{integer(kind=omp_proc_bind_kind) function omp_get_proc_bind()}
1053 @item @emph{See also}:
1054 @ref{OMP_PROC_BIND}, @ref{OMP_PLACES}, @ref{GOMP_CPU_AFFINITY},
1056 @item @emph{Reference}:
1057 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.22.
1062 @node omp_get_schedule
1063 @section @code{omp_get_schedule} -- Obtain the runtime scheduling method
1065 @item @emph{Description}:
1066 Obtain the runtime scheduling method. The @var{kind} argument will be
1067 set to the value @code{omp_sched_static}, @code{omp_sched_dynamic},
1068 @code{omp_sched_guided} or @code{omp_sched_auto}. The second argument,
1069 @var{chunk_size}, is set to the chunk size.
1072 @multitable @columnfractions .20 .80
1073 @item @emph{Prototype}: @tab @code{void omp_get_schedule(omp_sched_t *kind, int *chunk_size);}
1076 @item @emph{Fortran}:
1077 @multitable @columnfractions .20 .80
1078 @item @emph{Interface}: @tab @code{subroutine omp_get_schedule(kind, chunk_size)}
1079 @item @tab @code{integer(kind=omp_sched_kind) kind}
1080 @item @tab @code{integer chunk_size}
1083 @item @emph{See also}:
1084 @ref{omp_set_schedule}, @ref{OMP_SCHEDULE}
1086 @item @emph{Reference}:
1087 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.13.
1091 @node omp_get_supported_active_levels
1092 @section @code{omp_get_supported_active_levels} -- Maximum number of active regions supported
1094 @item @emph{Description}:
1095 This function returns the maximum number of nested, active parallel regions
1096 supported by this implementation.
1099 @multitable @columnfractions .20 .80
1100 @item @emph{Prototype}: @tab @code{int omp_get_supported_active_levels(void);}
1103 @item @emph{Fortran}:
1104 @multitable @columnfractions .20 .80
1105 @item @emph{Interface}: @tab @code{integer function omp_get_supported_active_levels()}
1108 @item @emph{See also}:
1109 @ref{omp_get_max_active_levels}, @ref{omp_set_max_active_levels}
1111 @item @emph{Reference}:
1112 @uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.2.15.
1117 @node omp_get_team_num
1118 @section @code{omp_get_team_num} -- Get team number
1120 @item @emph{Description}:
1121 Returns the team number of the calling thread.
1124 @multitable @columnfractions .20 .80
1125 @item @emph{Prototype}: @tab @code{int omp_get_team_num(void);}
1128 @item @emph{Fortran}:
1129 @multitable @columnfractions .20 .80
1130 @item @emph{Interface}: @tab @code{integer function omp_get_team_num()}
1133 @item @emph{Reference}:
1134 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.33.
1139 @node omp_get_team_size
1140 @section @code{omp_get_team_size} -- Number of threads in a team
1142 @item @emph{Description}:
1143 This function returns the number of threads in a thread team to which
1144 either the current thread or its ancestor belongs. For values of @var{level}
1145 outside zero to @code{omp_get_level}, -1 is returned; if @var{level} is zero,
1146 1 is returned, and for @code{omp_get_level}, the result is identical
1147 to @code{omp_get_num_threads}.
1150 @multitable @columnfractions .20 .80
1151 @item @emph{Prototype}: @tab @code{int omp_get_team_size(int level);}
1154 @item @emph{Fortran}:
1155 @multitable @columnfractions .20 .80
1156 @item @emph{Interface}: @tab @code{integer function omp_get_team_size(level)}
1157 @item @tab @code{integer level}
1160 @item @emph{See also}:
1161 @ref{omp_get_num_threads}, @ref{omp_get_level}, @ref{omp_get_ancestor_thread_num}
1163 @item @emph{Reference}:
1164 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.19.
1169 @node omp_get_teams_thread_limit
1170 @section @code{omp_get_teams_thread_limit} -- Maximum number of threads imposed by teams
1172 @item @emph{Description}:
1173 Return the maximum number of threads that will be able to participate in
1174 each team created by a teams construct.
1177 @multitable @columnfractions .20 .80
1178 @item @emph{Prototype}: @tab @code{int omp_get_teams_thread_limit(void);}
1181 @item @emph{Fortran}:
1182 @multitable @columnfractions .20 .80
1183 @item @emph{Interface}: @tab @code{integer function omp_get_teams_thread_limit()}
1186 @item @emph{See also}:
1187 @ref{omp_set_teams_thread_limit}, @ref{OMP_TEAMS_THREAD_LIMIT}
1189 @item @emph{Reference}:
1190 @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.4.6.
1195 @node omp_get_thread_limit
1196 @section @code{omp_get_thread_limit} -- Maximum number of threads
1198 @item @emph{Description}:
1199 Return the maximum number of threads of the program.
1202 @multitable @columnfractions .20 .80
1203 @item @emph{Prototype}: @tab @code{int omp_get_thread_limit(void);}
1206 @item @emph{Fortran}:
1207 @multitable @columnfractions .20 .80
1208 @item @emph{Interface}: @tab @code{integer function omp_get_thread_limit()}
1211 @item @emph{See also}:
1212 @ref{omp_get_max_threads}, @ref{OMP_THREAD_LIMIT}
1214 @item @emph{Reference}:
1215 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.14.
1220 @node omp_get_thread_num
1221 @section @code{omp_get_thread_num} -- Current thread ID
1223 @item @emph{Description}:
1224 Returns a unique thread identification number within the current team.
1225 In a sequential parts of the program, @code{omp_get_thread_num}
1226 always returns 0. In parallel regions the return value varies
1227 from 0 to @code{omp_get_num_threads}-1 inclusive. The return
1228 value of the primary thread of a team is always 0.
1231 @multitable @columnfractions .20 .80
1232 @item @emph{Prototype}: @tab @code{int omp_get_thread_num(void);}
1235 @item @emph{Fortran}:
1236 @multitable @columnfractions .20 .80
1237 @item @emph{Interface}: @tab @code{integer function omp_get_thread_num()}
1240 @item @emph{See also}:
1241 @ref{omp_get_num_threads}, @ref{omp_get_ancestor_thread_num}
1243 @item @emph{Reference}:
1244 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.4.
1249 @node omp_in_parallel
1250 @section @code{omp_in_parallel} -- Whether a parallel region is active
1252 @item @emph{Description}:
1253 This function returns @code{true} if currently running in parallel,
1254 @code{false} otherwise. Here, @code{true} and @code{false} represent
1255 their language-specific counterparts.
1258 @multitable @columnfractions .20 .80
1259 @item @emph{Prototype}: @tab @code{int omp_in_parallel(void);}
1262 @item @emph{Fortran}:
1263 @multitable @columnfractions .20 .80
1264 @item @emph{Interface}: @tab @code{logical function omp_in_parallel()}
1267 @item @emph{Reference}:
1268 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.6.
1273 @section @code{omp_in_final} -- Whether in final or included task region
1275 @item @emph{Description}:
1276 This function returns @code{true} if currently running in a final
1277 or included task region, @code{false} otherwise. Here, @code{true}
1278 and @code{false} represent their language-specific counterparts.
1281 @multitable @columnfractions .20 .80
1282 @item @emph{Prototype}: @tab @code{int omp_in_final(void);}
1285 @item @emph{Fortran}:
1286 @multitable @columnfractions .20 .80
1287 @item @emph{Interface}: @tab @code{logical function omp_in_final()}
1290 @item @emph{Reference}:
1291 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.21.
1296 @node omp_is_initial_device
1297 @section @code{omp_is_initial_device} -- Whether executing on the host device
1299 @item @emph{Description}:
1300 This function returns @code{true} if currently running on the host device,
1301 @code{false} otherwise. Here, @code{true} and @code{false} represent
1302 their language-specific counterparts.
1305 @multitable @columnfractions .20 .80
1306 @item @emph{Prototype}: @tab @code{int omp_is_initial_device(void);}
1309 @item @emph{Fortran}:
1310 @multitable @columnfractions .20 .80
1311 @item @emph{Interface}: @tab @code{logical function omp_is_initial_device()}
1314 @item @emph{Reference}:
1315 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.34.
1320 @node omp_set_default_device
1321 @section @code{omp_set_default_device} -- Set the default device for target regions
1323 @item @emph{Description}:
1324 Set the default device for target regions without device clause. The argument
1325 shall be a nonnegative device number.
1328 @multitable @columnfractions .20 .80
1329 @item @emph{Prototype}: @tab @code{void omp_set_default_device(int device_num);}
1332 @item @emph{Fortran}:
1333 @multitable @columnfractions .20 .80
1334 @item @emph{Interface}: @tab @code{subroutine omp_set_default_device(device_num)}
1335 @item @tab @code{integer device_num}
1338 @item @emph{See also}:
1339 @ref{OMP_DEFAULT_DEVICE}, @ref{omp_get_default_device}
1341 @item @emph{Reference}:
1342 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.29.
1347 @node omp_set_dynamic
1348 @section @code{omp_set_dynamic} -- Enable/disable dynamic teams
1350 @item @emph{Description}:
1351 Enable or disable the dynamic adjustment of the number of threads
1352 within a team. The function takes the language-specific equivalent
1353 of @code{true} and @code{false}, where @code{true} enables dynamic
1354 adjustment of team sizes and @code{false} disables it.
1357 @multitable @columnfractions .20 .80
1358 @item @emph{Prototype}: @tab @code{void omp_set_dynamic(int dynamic_threads);}
1361 @item @emph{Fortran}:
1362 @multitable @columnfractions .20 .80
1363 @item @emph{Interface}: @tab @code{subroutine omp_set_dynamic(dynamic_threads)}
1364 @item @tab @code{logical, intent(in) :: dynamic_threads}
1367 @item @emph{See also}:
1368 @ref{OMP_DYNAMIC}, @ref{omp_get_dynamic}
1370 @item @emph{Reference}:
1371 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.7.
1376 @node omp_set_max_active_levels
1377 @section @code{omp_set_max_active_levels} -- Limits the number of active parallel regions
1379 @item @emph{Description}:
1380 This function limits the maximum allowed number of nested, active
1381 parallel regions. @var{max_levels} must be less or equal to
1382 the value returned by @code{omp_get_supported_active_levels}.
1385 @multitable @columnfractions .20 .80
1386 @item @emph{Prototype}: @tab @code{void omp_set_max_active_levels(int max_levels);}
1389 @item @emph{Fortran}:
1390 @multitable @columnfractions .20 .80
1391 @item @emph{Interface}: @tab @code{subroutine omp_set_max_active_levels(max_levels)}
1392 @item @tab @code{integer max_levels}
1395 @item @emph{See also}:
1396 @ref{omp_get_max_active_levels}, @ref{omp_get_active_level},
1397 @ref{omp_get_supported_active_levels}
1399 @item @emph{Reference}:
1400 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.15.
1405 @node omp_set_nested
1406 @section @code{omp_set_nested} -- Enable/disable nested parallel regions
1408 @item @emph{Description}:
1409 Enable or disable nested parallel regions, i.e., whether team members
1410 are allowed to create new teams. The function takes the language-specific
1411 equivalent of @code{true} and @code{false}, where @code{true} enables
1412 dynamic adjustment of team sizes and @code{false} disables it.
1414 Enabling nested parallel regions will also set the maximum number of
1415 active nested regions to the maximum supported. Disabling nested parallel
1416 regions will set the maximum number of active nested regions to one.
1419 @multitable @columnfractions .20 .80
1420 @item @emph{Prototype}: @tab @code{void omp_set_nested(int nested);}
1423 @item @emph{Fortran}:
1424 @multitable @columnfractions .20 .80
1425 @item @emph{Interface}: @tab @code{subroutine omp_set_nested(nested)}
1426 @item @tab @code{logical, intent(in) :: nested}
1429 @item @emph{See also}:
1430 @ref{omp_get_nested}, @ref{omp_set_max_active_levels},
1431 @ref{OMP_MAX_ACTIVE_LEVELS}, @ref{OMP_NESTED}
1433 @item @emph{Reference}:
1434 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.10.
1439 @node omp_set_num_teams
1440 @section @code{omp_set_num_teams} -- Set upper teams limit for teams construct
1442 @item @emph{Description}:
1443 Specifies the upper bound for number of teams created by the teams construct
1444 which does not specify a @code{num_teams} clause. The
1445 argument of @code{omp_set_num_teams} shall be a positive integer.
1448 @multitable @columnfractions .20 .80
1449 @item @emph{Prototype}: @tab @code{void omp_set_num_teams(int num_teams);}
1452 @item @emph{Fortran}:
1453 @multitable @columnfractions .20 .80
1454 @item @emph{Interface}: @tab @code{subroutine omp_set_num_teams(num_teams)}
1455 @item @tab @code{integer, intent(in) :: num_teams}
1458 @item @emph{See also}:
1459 @ref{OMP_NUM_TEAMS}, @ref{omp_get_num_teams}, @ref{omp_get_max_teams}
1461 @item @emph{Reference}:
1462 @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.4.3.
1467 @node omp_set_num_threads
1468 @section @code{omp_set_num_threads} -- Set upper team size limit
1470 @item @emph{Description}:
1471 Specifies the number of threads used by default in subsequent parallel
1472 sections, if those do not specify a @code{num_threads} clause. The
1473 argument of @code{omp_set_num_threads} shall be a positive integer.
1476 @multitable @columnfractions .20 .80
1477 @item @emph{Prototype}: @tab @code{void omp_set_num_threads(int num_threads);}
1480 @item @emph{Fortran}:
1481 @multitable @columnfractions .20 .80
1482 @item @emph{Interface}: @tab @code{subroutine omp_set_num_threads(num_threads)}
1483 @item @tab @code{integer, intent(in) :: num_threads}
1486 @item @emph{See also}:
1487 @ref{OMP_NUM_THREADS}, @ref{omp_get_num_threads}, @ref{omp_get_max_threads}
1489 @item @emph{Reference}:
1490 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.1.
1495 @node omp_set_schedule
1496 @section @code{omp_set_schedule} -- Set the runtime scheduling method
1498 @item @emph{Description}:
1499 Sets the runtime scheduling method. The @var{kind} argument can have the
1500 value @code{omp_sched_static}, @code{omp_sched_dynamic},
1501 @code{omp_sched_guided} or @code{omp_sched_auto}. Except for
1502 @code{omp_sched_auto}, the chunk size is set to the value of
1503 @var{chunk_size} if positive, or to the default value if zero or negative.
1504 For @code{omp_sched_auto} the @var{chunk_size} argument is ignored.
1507 @multitable @columnfractions .20 .80
1508 @item @emph{Prototype}: @tab @code{void omp_set_schedule(omp_sched_t kind, int chunk_size);}
1511 @item @emph{Fortran}:
1512 @multitable @columnfractions .20 .80
1513 @item @emph{Interface}: @tab @code{subroutine omp_set_schedule(kind, chunk_size)}
1514 @item @tab @code{integer(kind=omp_sched_kind) kind}
1515 @item @tab @code{integer chunk_size}
1518 @item @emph{See also}:
1519 @ref{omp_get_schedule}
1522 @item @emph{Reference}:
1523 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.12.
1528 @node omp_set_teams_thread_limit
1529 @section @code{omp_set_teams_thread_limit} -- Set upper thread limit for teams construct
1531 @item @emph{Description}:
1532 Specifies the upper bound for number of threads that will be available
1533 for each team created by the teams construct which does not specify a
1534 @code{thread_limit} clause. The argument of
1535 @code{omp_set_teams_thread_limit} shall be a positive integer.
1538 @multitable @columnfractions .20 .80
1539 @item @emph{Prototype}: @tab @code{void omp_set_teams_thread_limit(int thread_limit);}
1542 @item @emph{Fortran}:
1543 @multitable @columnfractions .20 .80
1544 @item @emph{Interface}: @tab @code{subroutine omp_set_teams_thread_limit(thread_limit)}
1545 @item @tab @code{integer, intent(in) :: thread_limit}
1548 @item @emph{See also}:
1549 @ref{OMP_TEAMS_THREAD_LIMIT}, @ref{omp_get_teams_thread_limit}, @ref{omp_get_thread_limit}
1551 @item @emph{Reference}:
1552 @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.4.5.
1558 @section @code{omp_init_lock} -- Initialize simple lock
1560 @item @emph{Description}:
1561 Initialize a simple lock. After initialization, the lock is in
1565 @multitable @columnfractions .20 .80
1566 @item @emph{Prototype}: @tab @code{void omp_init_lock(omp_lock_t *lock);}
1569 @item @emph{Fortran}:
1570 @multitable @columnfractions .20 .80
1571 @item @emph{Interface}: @tab @code{subroutine omp_init_lock(svar)}
1572 @item @tab @code{integer(omp_lock_kind), intent(out) :: svar}
1575 @item @emph{See also}:
1576 @ref{omp_destroy_lock}
1578 @item @emph{Reference}:
1579 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.1.
1585 @section @code{omp_set_lock} -- Wait for and set simple lock
1587 @item @emph{Description}:
1588 Before setting a simple lock, the lock variable must be initialized by
1589 @code{omp_init_lock}. The calling thread is blocked until the lock
1590 is available. If the lock is already held by the current thread,
1594 @multitable @columnfractions .20 .80
1595 @item @emph{Prototype}: @tab @code{void omp_set_lock(omp_lock_t *lock);}
1598 @item @emph{Fortran}:
1599 @multitable @columnfractions .20 .80
1600 @item @emph{Interface}: @tab @code{subroutine omp_set_lock(svar)}
1601 @item @tab @code{integer(omp_lock_kind), intent(inout) :: svar}
1604 @item @emph{See also}:
1605 @ref{omp_init_lock}, @ref{omp_test_lock}, @ref{omp_unset_lock}
1607 @item @emph{Reference}:
1608 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.4.
1614 @section @code{omp_test_lock} -- Test and set simple lock if available
1616 @item @emph{Description}:
1617 Before setting a simple lock, the lock variable must be initialized by
1618 @code{omp_init_lock}. Contrary to @code{omp_set_lock}, @code{omp_test_lock}
1619 does not block if the lock is not available. This function returns
1620 @code{true} upon success, @code{false} otherwise. Here, @code{true} and
1621 @code{false} represent their language-specific counterparts.
1624 @multitable @columnfractions .20 .80
1625 @item @emph{Prototype}: @tab @code{int omp_test_lock(omp_lock_t *lock);}
1628 @item @emph{Fortran}:
1629 @multitable @columnfractions .20 .80
1630 @item @emph{Interface}: @tab @code{logical function omp_test_lock(svar)}
1631 @item @tab @code{integer(omp_lock_kind), intent(inout) :: svar}
1634 @item @emph{See also}:
1635 @ref{omp_init_lock}, @ref{omp_set_lock}, @ref{omp_set_lock}
1637 @item @emph{Reference}:
1638 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.6.
1643 @node omp_unset_lock
1644 @section @code{omp_unset_lock} -- Unset simple lock
1646 @item @emph{Description}:
1647 A simple lock about to be unset must have been locked by @code{omp_set_lock}
1648 or @code{omp_test_lock} before. In addition, the lock must be held by the
1649 thread calling @code{omp_unset_lock}. Then, the lock becomes unlocked. If one
1650 or more threads attempted to set the lock before, one of them is chosen to,
1651 again, set the lock to itself.
1654 @multitable @columnfractions .20 .80
1655 @item @emph{Prototype}: @tab @code{void omp_unset_lock(omp_lock_t *lock);}
1658 @item @emph{Fortran}:
1659 @multitable @columnfractions .20 .80
1660 @item @emph{Interface}: @tab @code{subroutine omp_unset_lock(svar)}
1661 @item @tab @code{integer(omp_lock_kind), intent(inout) :: svar}
1664 @item @emph{See also}:
1665 @ref{omp_set_lock}, @ref{omp_test_lock}
1667 @item @emph{Reference}:
1668 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.5.
1673 @node omp_destroy_lock
1674 @section @code{omp_destroy_lock} -- Destroy simple lock
1676 @item @emph{Description}:
1677 Destroy a simple lock. In order to be destroyed, a simple lock must be
1678 in the unlocked state.
1681 @multitable @columnfractions .20 .80
1682 @item @emph{Prototype}: @tab @code{void omp_destroy_lock(omp_lock_t *lock);}
1685 @item @emph{Fortran}:
1686 @multitable @columnfractions .20 .80
1687 @item @emph{Interface}: @tab @code{subroutine omp_destroy_lock(svar)}
1688 @item @tab @code{integer(omp_lock_kind), intent(inout) :: svar}
1691 @item @emph{See also}:
1694 @item @emph{Reference}:
1695 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.3.
1700 @node omp_init_nest_lock
1701 @section @code{omp_init_nest_lock} -- Initialize nested lock
1703 @item @emph{Description}:
1704 Initialize a nested lock. After initialization, the lock is in
1705 an unlocked state and the nesting count is set to zero.
1708 @multitable @columnfractions .20 .80
1709 @item @emph{Prototype}: @tab @code{void omp_init_nest_lock(omp_nest_lock_t *lock);}
1712 @item @emph{Fortran}:
1713 @multitable @columnfractions .20 .80
1714 @item @emph{Interface}: @tab @code{subroutine omp_init_nest_lock(nvar)}
1715 @item @tab @code{integer(omp_nest_lock_kind), intent(out) :: nvar}
1718 @item @emph{See also}:
1719 @ref{omp_destroy_nest_lock}
1721 @item @emph{Reference}:
1722 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.1.
1726 @node omp_set_nest_lock
1727 @section @code{omp_set_nest_lock} -- Wait for and set nested lock
1729 @item @emph{Description}:
1730 Before setting a nested lock, the lock variable must be initialized by
1731 @code{omp_init_nest_lock}. The calling thread is blocked until the lock
1732 is available. If the lock is already held by the current thread, the
1733 nesting count for the lock is incremented.
1736 @multitable @columnfractions .20 .80
1737 @item @emph{Prototype}: @tab @code{void omp_set_nest_lock(omp_nest_lock_t *lock);}
1740 @item @emph{Fortran}:
1741 @multitable @columnfractions .20 .80
1742 @item @emph{Interface}: @tab @code{subroutine omp_set_nest_lock(nvar)}
1743 @item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: nvar}
1746 @item @emph{See also}:
1747 @ref{omp_init_nest_lock}, @ref{omp_unset_nest_lock}
1749 @item @emph{Reference}:
1750 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.4.
1755 @node omp_test_nest_lock
1756 @section @code{omp_test_nest_lock} -- Test and set nested lock if available
1758 @item @emph{Description}:
1759 Before setting a nested lock, the lock variable must be initialized by
1760 @code{omp_init_nest_lock}. Contrary to @code{omp_set_nest_lock},
1761 @code{omp_test_nest_lock} does not block if the lock is not available.
1762 If the lock is already held by the current thread, the new nesting count
1763 is returned. Otherwise, the return value equals zero.
1766 @multitable @columnfractions .20 .80
1767 @item @emph{Prototype}: @tab @code{int omp_test_nest_lock(omp_nest_lock_t *lock);}
1770 @item @emph{Fortran}:
1771 @multitable @columnfractions .20 .80
1772 @item @emph{Interface}: @tab @code{logical function omp_test_nest_lock(nvar)}
1773 @item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: nvar}
1777 @item @emph{See also}:
1778 @ref{omp_init_lock}, @ref{omp_set_lock}, @ref{omp_set_lock}
1780 @item @emph{Reference}:
1781 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.6.
1786 @node omp_unset_nest_lock
1787 @section @code{omp_unset_nest_lock} -- Unset nested lock
1789 @item @emph{Description}:
1790 A nested lock about to be unset must have been locked by @code{omp_set_nested_lock}
1791 or @code{omp_test_nested_lock} before. In addition, the lock must be held by the
1792 thread calling @code{omp_unset_nested_lock}. If the nesting count drops to zero, the
1793 lock becomes unlocked. If one ore more threads attempted to set the lock before,
1794 one of them is chosen to, again, set the lock to itself.
1797 @multitable @columnfractions .20 .80
1798 @item @emph{Prototype}: @tab @code{void omp_unset_nest_lock(omp_nest_lock_t *lock);}
1801 @item @emph{Fortran}:
1802 @multitable @columnfractions .20 .80
1803 @item @emph{Interface}: @tab @code{subroutine omp_unset_nest_lock(nvar)}
1804 @item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: nvar}
1807 @item @emph{See also}:
1808 @ref{omp_set_nest_lock}
1810 @item @emph{Reference}:
1811 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.5.
1816 @node omp_destroy_nest_lock
1817 @section @code{omp_destroy_nest_lock} -- Destroy nested lock
1819 @item @emph{Description}:
1820 Destroy a nested lock. In order to be destroyed, a nested lock must be
1821 in the unlocked state and its nesting count must equal zero.
1824 @multitable @columnfractions .20 .80
1825 @item @emph{Prototype}: @tab @code{void omp_destroy_nest_lock(omp_nest_lock_t *);}
1828 @item @emph{Fortran}:
1829 @multitable @columnfractions .20 .80
1830 @item @emph{Interface}: @tab @code{subroutine omp_destroy_nest_lock(nvar)}
1831 @item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: nvar}
1834 @item @emph{See also}:
1837 @item @emph{Reference}:
1838 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.3.3.
1844 @section @code{omp_get_wtick} -- Get timer precision
1846 @item @emph{Description}:
1847 Gets the timer precision, i.e., the number of seconds between two
1848 successive clock ticks.
1851 @multitable @columnfractions .20 .80
1852 @item @emph{Prototype}: @tab @code{double omp_get_wtick(void);}
1855 @item @emph{Fortran}:
1856 @multitable @columnfractions .20 .80
1857 @item @emph{Interface}: @tab @code{double precision function omp_get_wtick()}
1860 @item @emph{See also}:
1863 @item @emph{Reference}:
1864 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.4.2.
1870 @section @code{omp_get_wtime} -- Elapsed wall clock time
1872 @item @emph{Description}:
1873 Elapsed wall clock time in seconds. The time is measured per thread, no
1874 guarantee can be made that two distinct threads measure the same time.
1875 Time is measured from some "time in the past", which is an arbitrary time
1876 guaranteed not to change during the execution of the program.
1879 @multitable @columnfractions .20 .80
1880 @item @emph{Prototype}: @tab @code{double omp_get_wtime(void);}
1883 @item @emph{Fortran}:
1884 @multitable @columnfractions .20 .80
1885 @item @emph{Interface}: @tab @code{double precision function omp_get_wtime()}
1888 @item @emph{See also}:
1891 @item @emph{Reference}:
1892 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.4.1.
1897 @node omp_fulfill_event
1898 @section @code{omp_fulfill_event} -- Fulfill and destroy an OpenMP event
1900 @item @emph{Description}:
1901 Fulfill the event associated with the event handle argument. Currently, it
1902 is only used to fulfill events generated by detach clauses on task
1903 constructs - the effect of fulfilling the event is to allow the task to
1906 The result of calling @code{omp_fulfill_event} with an event handle other
1907 than that generated by a detach clause is undefined. Calling it with an
1908 event handle that has already been fulfilled is also undefined.
1911 @multitable @columnfractions .20 .80
1912 @item @emph{Prototype}: @tab @code{void omp_fulfill_event(omp_event_handle_t event);}
1915 @item @emph{Fortran}:
1916 @multitable @columnfractions .20 .80
1917 @item @emph{Interface}: @tab @code{subroutine omp_fulfill_event(event)}
1918 @item @tab @code{integer (kind=omp_event_handle_kind) :: event}
1921 @item @emph{Reference}:
1922 @uref{https://www.openmp.org, OpenMP specification v5.0}, Section 3.5.1.
1927 @c ---------------------------------------------------------------------
1928 @c OpenMP Environment Variables
1929 @c ---------------------------------------------------------------------
1931 @node Environment Variables
1932 @chapter OpenMP Environment Variables
1934 The environment variables which beginning with @env{OMP_} are defined by
1935 section 4 of the OpenMP specification in version 4.5, while those
1936 beginning with @env{GOMP_} are GNU extensions.
1939 * OMP_CANCELLATION:: Set whether cancellation is activated
1940 * OMP_DISPLAY_ENV:: Show OpenMP version and environment variables
1941 * OMP_DEFAULT_DEVICE:: Set the device used in target regions
1942 * OMP_DYNAMIC:: Dynamic adjustment of threads
1943 * OMP_MAX_ACTIVE_LEVELS:: Set the maximum number of nested parallel regions
1944 * OMP_MAX_TASK_PRIORITY:: Set the maximum task priority value
1945 * OMP_NESTED:: Nested parallel regions
1946 * OMP_NUM_TEAMS:: Specifies the number of teams to use by teams region
1947 * OMP_NUM_THREADS:: Specifies the number of threads to use
1948 * OMP_PROC_BIND:: Whether threads may be moved between CPUs
1949 * OMP_PLACES:: Specifies on which CPUs the threads should be placed
1950 * OMP_STACKSIZE:: Set default thread stack size
1951 * OMP_SCHEDULE:: How threads are scheduled
1952 * OMP_TARGET_OFFLOAD:: Controls offloading behaviour
1953 * OMP_TEAMS_THREAD_LIMIT:: Set the maximum number of threads imposed by teams
1954 * OMP_THREAD_LIMIT:: Set the maximum number of threads
1955 * OMP_WAIT_POLICY:: How waiting threads are handled
1956 * GOMP_CPU_AFFINITY:: Bind threads to specific CPUs
1957 * GOMP_DEBUG:: Enable debugging output
1958 * GOMP_STACKSIZE:: Set default thread stack size
1959 * GOMP_SPINCOUNT:: Set the busy-wait spin count
1960 * GOMP_RTEMS_THREAD_POOLS:: Set the RTEMS specific thread pools
1964 @node OMP_CANCELLATION
1965 @section @env{OMP_CANCELLATION} -- Set whether cancellation is activated
1966 @cindex Environment Variable
1968 @item @emph{Description}:
1969 If set to @code{TRUE}, the cancellation is activated. If set to @code{FALSE} or
1970 if unset, cancellation is disabled and the @code{cancel} construct is ignored.
1972 @item @emph{See also}:
1973 @ref{omp_get_cancellation}
1975 @item @emph{Reference}:
1976 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.11
1981 @node OMP_DISPLAY_ENV
1982 @section @env{OMP_DISPLAY_ENV} -- Show OpenMP version and environment variables
1983 @cindex Environment Variable
1985 @item @emph{Description}:
1986 If set to @code{TRUE}, the OpenMP version number and the values
1987 associated with the OpenMP environment variables are printed to @code{stderr}.
1988 If set to @code{VERBOSE}, it additionally shows the value of the environment
1989 variables which are GNU extensions. If undefined or set to @code{FALSE},
1990 this information will not be shown.
1993 @item @emph{Reference}:
1994 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.12
1999 @node OMP_DEFAULT_DEVICE
2000 @section @env{OMP_DEFAULT_DEVICE} -- Set the device used in target regions
2001 @cindex Environment Variable
2003 @item @emph{Description}:
2004 Set to choose the device which is used in a @code{target} region, unless the
2005 value is overridden by @code{omp_set_default_device} or by a @code{device}
2006 clause. The value shall be the nonnegative device number. If no device with
2007 the given device number exists, the code is executed on the host. If unset,
2008 device number 0 will be used.
2011 @item @emph{See also}:
2012 @ref{omp_get_default_device}, @ref{omp_set_default_device},
2014 @item @emph{Reference}:
2015 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.13
2021 @section @env{OMP_DYNAMIC} -- Dynamic adjustment of threads
2022 @cindex Environment Variable
2024 @item @emph{Description}:
2025 Enable or disable the dynamic adjustment of the number of threads
2026 within a team. The value of this environment variable shall be
2027 @code{TRUE} or @code{FALSE}. If undefined, dynamic adjustment is
2028 disabled by default.
2030 @item @emph{See also}:
2031 @ref{omp_set_dynamic}
2033 @item @emph{Reference}:
2034 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.3
2039 @node OMP_MAX_ACTIVE_LEVELS
2040 @section @env{OMP_MAX_ACTIVE_LEVELS} -- Set the maximum number of nested parallel regions
2041 @cindex Environment Variable
2043 @item @emph{Description}:
2044 Specifies the initial value for the maximum number of nested parallel
2045 regions. The value of this variable shall be a positive integer.
2046 If undefined, then if @env{OMP_NESTED} is defined and set to true, or
2047 if @env{OMP_NUM_THREADS} or @env{OMP_PROC_BIND} are defined and set to
2048 a list with more than one item, the maximum number of nested parallel
2049 regions will be initialized to the largest number supported, otherwise
2050 it will be set to one.
2052 @item @emph{See also}:
2053 @ref{omp_set_max_active_levels}, @ref{OMP_NESTED}
2055 @item @emph{Reference}:
2056 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.9
2061 @node OMP_MAX_TASK_PRIORITY
2062 @section @env{OMP_MAX_TASK_PRIORITY} -- Set the maximum priority
2063 number that can be set for a task.
2064 @cindex Environment Variable
2066 @item @emph{Description}:
2067 Specifies the initial value for the maximum priority value that can be
2068 set for a task. The value of this variable shall be a non-negative
2069 integer, and zero is allowed. If undefined, the default priority is
2072 @item @emph{See also}:
2073 @ref{omp_get_max_task_priority}
2075 @item @emph{Reference}:
2076 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.14
2082 @section @env{OMP_NESTED} -- Nested parallel regions
2083 @cindex Environment Variable
2084 @cindex Implementation specific setting
2086 @item @emph{Description}:
2087 Enable or disable nested parallel regions, i.e., whether team members
2088 are allowed to create new teams. The value of this environment variable
2089 shall be @code{TRUE} or @code{FALSE}. If set to @code{TRUE}, the number
2090 of maximum active nested regions supported will by default be set to the
2091 maximum supported, otherwise it will be set to one. If
2092 @env{OMP_MAX_ACTIVE_LEVELS} is defined, its setting will override this
2093 setting. If both are undefined, nested parallel regions are enabled if
2094 @env{OMP_NUM_THREADS} or @env{OMP_PROC_BINDS} are defined to a list with
2095 more than one item, otherwise they are disabled by default.
2097 @item @emph{See also}:
2098 @ref{omp_set_max_active_levels}, @ref{omp_set_nested}
2100 @item @emph{Reference}:
2101 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.6
2107 @section @env{OMP_NUM_TEAMS} -- Specifies the number of teams to use by teams region
2108 @cindex Environment Variable
2110 @item @emph{Description}:
2111 Specifies the upper bound for number of teams to use in teams regions
2112 without explicit @code{num_teams} clause. The value of this variable shall
2113 be a positive integer. If undefined it defaults to 0 which means
2114 implementation defined upper bound.
2116 @item @emph{See also}:
2117 @ref{omp_set_num_teams}
2119 @item @emph{Reference}:
2120 @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 6.23
2125 @node OMP_NUM_THREADS
2126 @section @env{OMP_NUM_THREADS} -- Specifies the number of threads to use
2127 @cindex Environment Variable
2128 @cindex Implementation specific setting
2130 @item @emph{Description}:
2131 Specifies the default number of threads to use in parallel regions. The
2132 value of this variable shall be a comma-separated list of positive integers;
2133 the value specifies the number of threads to use for the corresponding nested
2134 level. Specifying more than one item in the list will automatically enable
2135 nesting by default. If undefined one thread per CPU is used.
2137 @item @emph{See also}:
2138 @ref{omp_set_num_threads}, @ref{OMP_NESTED}
2140 @item @emph{Reference}:
2141 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.2
2147 @section @env{OMP_PROC_BIND} -- Whether threads may be moved between CPUs
2148 @cindex Environment Variable
2150 @item @emph{Description}:
2151 Specifies whether threads may be moved between processors. If set to
2152 @code{TRUE}, OpenMP threads should not be moved; if set to @code{FALSE}
2153 they may be moved. Alternatively, a comma separated list with the
2154 values @code{PRIMARY}, @code{MASTER}, @code{CLOSE} and @code{SPREAD} can
2155 be used to specify the thread affinity policy for the corresponding nesting
2156 level. With @code{PRIMARY} and @code{MASTER} the worker threads are in the
2157 same place partition as the primary thread. With @code{CLOSE} those are
2158 kept close to the primary thread in contiguous place partitions. And
2159 with @code{SPREAD} a sparse distribution
2160 across the place partitions is used. Specifying more than one item in the
2161 list will automatically enable nesting by default.
2163 When undefined, @env{OMP_PROC_BIND} defaults to @code{TRUE} when
2164 @env{OMP_PLACES} or @env{GOMP_CPU_AFFINITY} is set and @code{FALSE} otherwise.
2166 @item @emph{See also}:
2167 @ref{omp_get_proc_bind}, @ref{GOMP_CPU_AFFINITY},
2168 @ref{OMP_NESTED}, @ref{OMP_PLACES}
2170 @item @emph{Reference}:
2171 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.4
2177 @section @env{OMP_PLACES} -- Specifies on which CPUs the threads should be placed
2178 @cindex Environment Variable
2180 @item @emph{Description}:
2181 The thread placement can be either specified using an abstract name or by an
2182 explicit list of the places. The abstract names @code{threads}, @code{cores},
2183 @code{sockets}, @code{ll_caches} and @code{numa_domains} can be optionally
2184 followed by a positive number in parentheses, which denotes the how many places
2185 shall be created. With @code{threads} each place corresponds to a single
2186 hardware thread; @code{cores} to a single core with the corresponding number of
2187 hardware threads; with @code{sockets} the place corresponds to a single
2188 socket; with @code{ll_caches} to a set of cores that shares the last level
2189 cache on the device; and @code{numa_domains} to a set of cores for which their
2190 closest memory on the device is the same memory and at a similar distance from
2191 the cores. The resulting placement can be shown by setting the
2192 @env{OMP_DISPLAY_ENV} environment variable.
2194 Alternatively, the placement can be specified explicitly as comma-separated
2195 list of places. A place is specified by set of nonnegative numbers in curly
2196 braces, denoting the hardware threads. The curly braces can be omitted
2197 when only a single number has been specified. The hardware threads
2198 belonging to a place can either be specified as comma-separated list of
2199 nonnegative thread numbers or using an interval. Multiple places can also be
2200 either specified by a comma-separated list of places or by an interval. To
2201 specify an interval, a colon followed by the count is placed after
2202 the hardware thread number or the place. Optionally, the length can be
2203 followed by a colon and the stride number -- otherwise a unit stride is
2204 assumed. Placing an exclamation mark (@code{!}) directly before a curly
2205 brace or numbers inside the curly braces (excluding intervals) will
2206 exclude those hardware threads.
2208 For instance, the following specifies the same places list:
2209 @code{"@{0,1,2@}, @{3,4,6@}, @{7,8,9@}, @{10,11,12@}"};
2210 @code{"@{0:3@}, @{3:3@}, @{7:3@}, @{10:3@}"}; and @code{"@{0:2@}:4:3"}.
2212 If @env{OMP_PLACES} and @env{GOMP_CPU_AFFINITY} are unset and
2213 @env{OMP_PROC_BIND} is either unset or @code{false}, threads may be moved
2214 between CPUs following no placement policy.
2216 @item @emph{See also}:
2217 @ref{OMP_PROC_BIND}, @ref{GOMP_CPU_AFFINITY}, @ref{omp_get_proc_bind},
2218 @ref{OMP_DISPLAY_ENV}
2220 @item @emph{Reference}:
2221 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.5
2227 @section @env{OMP_STACKSIZE} -- Set default thread stack size
2228 @cindex Environment Variable
2230 @item @emph{Description}:
2231 Set the default thread stack size in kilobytes, unless the number
2232 is suffixed by @code{B}, @code{K}, @code{M} or @code{G}, in which
2233 case the size is, respectively, in bytes, kilobytes, megabytes
2234 or gigabytes. This is different from @code{pthread_attr_setstacksize}
2235 which gets the number of bytes as an argument. If the stack size cannot
2236 be set due to system constraints, an error is reported and the initial
2237 stack size is left unchanged. If undefined, the stack size is system
2240 @item @emph{Reference}:
2241 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.7
2247 @section @env{OMP_SCHEDULE} -- How threads are scheduled
2248 @cindex Environment Variable
2249 @cindex Implementation specific setting
2251 @item @emph{Description}:
2252 Allows to specify @code{schedule type} and @code{chunk size}.
2253 The value of the variable shall have the form: @code{type[,chunk]} where
2254 @code{type} is one of @code{static}, @code{dynamic}, @code{guided} or @code{auto}
2255 The optional @code{chunk} size shall be a positive integer. If undefined,
2256 dynamic scheduling and a chunk size of 1 is used.
2258 @item @emph{See also}:
2259 @ref{omp_set_schedule}
2261 @item @emph{Reference}:
2262 @uref{https://www.openmp.org, OpenMP specification v4.5}, Sections 2.7.1.1 and 4.1
2267 @node OMP_TARGET_OFFLOAD
2268 @section @env{OMP_TARGET_OFFLOAD} -- Controls offloading behaviour
2269 @cindex Environment Variable
2270 @cindex Implementation specific setting
2272 @item @emph{Description}:
2273 Specifies the behaviour with regard to offloading code to a device. This
2274 variable can be set to one of three values - @code{MANDATORY}, @code{DISABLED}
2277 If set to @code{MANDATORY}, the program will terminate with an error if
2278 the offload device is not present or is not supported. If set to
2279 @code{DISABLED}, then offloading is disabled and all code will run on the
2280 host. If set to @code{DEFAULT}, the program will try offloading to the
2281 device first, then fall back to running code on the host if it cannot.
2283 If undefined, then the program will behave as if @code{DEFAULT} was set.
2285 @item @emph{Reference}:
2286 @uref{https://www.openmp.org, OpenMP specification v5.0}, Section 6.17
2291 @node OMP_TEAMS_THREAD_LIMIT
2292 @section @env{OMP_TEAMS_THREAD_LIMIT} -- Set the maximum number of threads imposed by teams
2293 @cindex Environment Variable
2295 @item @emph{Description}:
2296 Specifies an upper bound for the number of threads to use by each contention
2297 group created by a teams construct without explicit @code{thread_limit}
2298 clause. The value of this variable shall be a positive integer. If undefined,
2299 the value of 0 is used which stands for an implementation defined upper
2302 @item @emph{See also}:
2303 @ref{OMP_THREAD_LIMIT}, @ref{omp_set_teams_thread_limit}
2305 @item @emph{Reference}:
2306 @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 6.24
2311 @node OMP_THREAD_LIMIT
2312 @section @env{OMP_THREAD_LIMIT} -- Set the maximum number of threads
2313 @cindex Environment Variable
2315 @item @emph{Description}:
2316 Specifies the number of threads to use for the whole program. The
2317 value of this variable shall be a positive integer. If undefined,
2318 the number of threads is not limited.
2320 @item @emph{See also}:
2321 @ref{OMP_NUM_THREADS}, @ref{omp_get_thread_limit}
2323 @item @emph{Reference}:
2324 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.10
2329 @node OMP_WAIT_POLICY
2330 @section @env{OMP_WAIT_POLICY} -- How waiting threads are handled
2331 @cindex Environment Variable
2333 @item @emph{Description}:
2334 Specifies whether waiting threads should be active or passive. If
2335 the value is @code{PASSIVE}, waiting threads should not consume CPU
2336 power while waiting; while the value is @code{ACTIVE} specifies that
2337 they should. If undefined, threads wait actively for a short time
2338 before waiting passively.
2340 @item @emph{See also}:
2341 @ref{GOMP_SPINCOUNT}
2343 @item @emph{Reference}:
2344 @uref{https://www.openmp.org, OpenMP specification v4.5}, Section 4.8
2349 @node GOMP_CPU_AFFINITY
2350 @section @env{GOMP_CPU_AFFINITY} -- Bind threads to specific CPUs
2351 @cindex Environment Variable
2353 @item @emph{Description}:
2354 Binds threads to specific CPUs. The variable should contain a space-separated
2355 or comma-separated list of CPUs. This list may contain different kinds of
2356 entries: either single CPU numbers in any order, a range of CPUs (M-N)
2357 or a range with some stride (M-N:S). CPU numbers are zero based. For example,
2358 @code{GOMP_CPU_AFFINITY="0 3 1-2 4-15:2"} will bind the initial thread
2359 to CPU 0, the second to CPU 3, the third to CPU 1, the fourth to
2360 CPU 2, the fifth to CPU 4, the sixth through tenth to CPUs 6, 8, 10, 12,
2361 and 14 respectively and then start assigning back from the beginning of
2362 the list. @code{GOMP_CPU_AFFINITY=0} binds all threads to CPU 0.
2364 There is no libgomp library routine to determine whether a CPU affinity
2365 specification is in effect. As a workaround, language-specific library
2366 functions, e.g., @code{getenv} in C or @code{GET_ENVIRONMENT_VARIABLE} in
2367 Fortran, may be used to query the setting of the @code{GOMP_CPU_AFFINITY}
2368 environment variable. A defined CPU affinity on startup cannot be changed
2369 or disabled during the runtime of the application.
2371 If both @env{GOMP_CPU_AFFINITY} and @env{OMP_PROC_BIND} are set,
2372 @env{OMP_PROC_BIND} has a higher precedence. If neither has been set and
2373 @env{OMP_PROC_BIND} is unset, or when @env{OMP_PROC_BIND} is set to
2374 @code{FALSE}, the host system will handle the assignment of threads to CPUs.
2376 @item @emph{See also}:
2377 @ref{OMP_PLACES}, @ref{OMP_PROC_BIND}
2383 @section @env{GOMP_DEBUG} -- Enable debugging output
2384 @cindex Environment Variable
2386 @item @emph{Description}:
2387 Enable debugging output. The variable should be set to @code{0}
2388 (disabled, also the default if not set), or @code{1} (enabled).
2390 If enabled, some debugging output will be printed during execution.
2391 This is currently not specified in more detail, and subject to change.
2396 @node GOMP_STACKSIZE
2397 @section @env{GOMP_STACKSIZE} -- Set default thread stack size
2398 @cindex Environment Variable
2399 @cindex Implementation specific setting
2401 @item @emph{Description}:
2402 Set the default thread stack size in kilobytes. This is different from
2403 @code{pthread_attr_setstacksize} which gets the number of bytes as an
2404 argument. If the stack size cannot be set due to system constraints, an
2405 error is reported and the initial stack size is left unchanged. If undefined,
2406 the stack size is system dependent.
2408 @item @emph{See also}:
2411 @item @emph{Reference}:
2412 @uref{https://gcc.gnu.org/ml/gcc-patches/2006-06/msg00493.html,
2413 GCC Patches Mailinglist},
2414 @uref{https://gcc.gnu.org/ml/gcc-patches/2006-06/msg00496.html,
2415 GCC Patches Mailinglist}
2420 @node GOMP_SPINCOUNT
2421 @section @env{GOMP_SPINCOUNT} -- Set the busy-wait spin count
2422 @cindex Environment Variable
2423 @cindex Implementation specific setting
2425 @item @emph{Description}:
2426 Determines how long a threads waits actively with consuming CPU power
2427 before waiting passively without consuming CPU power. The value may be
2428 either @code{INFINITE}, @code{INFINITY} to always wait actively or an
2429 integer which gives the number of spins of the busy-wait loop. The
2430 integer may optionally be followed by the following suffixes acting
2431 as multiplication factors: @code{k} (kilo, thousand), @code{M} (mega,
2432 million), @code{G} (giga, billion), or @code{T} (tera, trillion).
2433 If undefined, 0 is used when @env{OMP_WAIT_POLICY} is @code{PASSIVE},
2434 300,000 is used when @env{OMP_WAIT_POLICY} is undefined and
2435 30 billion is used when @env{OMP_WAIT_POLICY} is @code{ACTIVE}.
2436 If there are more OpenMP threads than available CPUs, 1000 and 100
2437 spins are used for @env{OMP_WAIT_POLICY} being @code{ACTIVE} or
2438 undefined, respectively; unless the @env{GOMP_SPINCOUNT} is lower
2439 or @env{OMP_WAIT_POLICY} is @code{PASSIVE}.
2441 @item @emph{See also}:
2442 @ref{OMP_WAIT_POLICY}
2447 @node GOMP_RTEMS_THREAD_POOLS
2448 @section @env{GOMP_RTEMS_THREAD_POOLS} -- Set the RTEMS specific thread pools
2449 @cindex Environment Variable
2450 @cindex Implementation specific setting
2452 @item @emph{Description}:
2453 This environment variable is only used on the RTEMS real-time operating system.
2454 It determines the scheduler instance specific thread pools. The format for
2455 @env{GOMP_RTEMS_THREAD_POOLS} is a list of optional
2456 @code{<thread-pool-count>[$<priority>]@@<scheduler-name>} configurations
2457 separated by @code{:} where:
2459 @item @code{<thread-pool-count>} is the thread pool count for this scheduler
2461 @item @code{$<priority>} is an optional priority for the worker threads of a
2462 thread pool according to @code{pthread_setschedparam}. In case a priority
2463 value is omitted, then a worker thread will inherit the priority of the OpenMP
2464 primary thread that created it. The priority of the worker thread is not
2465 changed after creation, even if a new OpenMP primary thread using the worker has
2466 a different priority.
2467 @item @code{@@<scheduler-name>} is the scheduler instance name according to the
2468 RTEMS application configuration.
2470 In case no thread pool configuration is specified for a scheduler instance,
2471 then each OpenMP primary thread of this scheduler instance will use its own
2472 dynamically allocated thread pool. To limit the worker thread count of the
2473 thread pools, each OpenMP primary thread must call @code{omp_set_num_threads}.
2474 @item @emph{Example}:
2475 Lets suppose we have three scheduler instances @code{IO}, @code{WRK0}, and
2476 @code{WRK1} with @env{GOMP_RTEMS_THREAD_POOLS} set to
2477 @code{"1@@WRK0:3$4@@WRK1"}. Then there are no thread pool restrictions for
2478 scheduler instance @code{IO}. In the scheduler instance @code{WRK0} there is
2479 one thread pool available. Since no priority is specified for this scheduler
2480 instance, the worker thread inherits the priority of the OpenMP primary thread
2481 that created it. In the scheduler instance @code{WRK1} there are three thread
2482 pools available and their worker threads run at priority four.
2487 @c ---------------------------------------------------------------------
2489 @c ---------------------------------------------------------------------
2491 @node Enabling OpenACC
2492 @chapter Enabling OpenACC
2494 To activate the OpenACC extensions for C/C++ and Fortran, the compile-time
2495 flag @option{-fopenacc} must be specified. This enables the OpenACC directive
2496 @code{#pragma acc} in C/C++ and @code{!$acc} directives in free form,
2497 @code{c$acc}, @code{*$acc} and @code{!$acc} directives in fixed form,
2498 @code{!$} conditional compilation sentinels in free form and @code{c$},
2499 @code{*$} and @code{!$} sentinels in fixed form, for Fortran. The flag also
2500 arranges for automatic linking of the OpenACC runtime library
2501 (@ref{OpenACC Runtime Library Routines}).
2503 See @uref{https://gcc.gnu.org/wiki/OpenACC} for more information.
2505 A complete description of all OpenACC directives accepted may be found in
2506 the @uref{https://www.openacc.org, OpenACC} Application Programming
2507 Interface manual, version 2.6.
2511 @c ---------------------------------------------------------------------
2512 @c OpenACC Runtime Library Routines
2513 @c ---------------------------------------------------------------------
2515 @node OpenACC Runtime Library Routines
2516 @chapter OpenACC Runtime Library Routines
2518 The runtime routines described here are defined by section 3 of the OpenACC
2519 specifications in version 2.6.
2520 They have C linkage, and do not throw exceptions.
2521 Generally, they are available only for the host, with the exception of
2522 @code{acc_on_device}, which is available for both the host and the
2523 acceleration device.
2526 * acc_get_num_devices:: Get number of devices for the given device
2528 * acc_set_device_type:: Set type of device accelerator to use.
2529 * acc_get_device_type:: Get type of device accelerator to be used.
2530 * acc_set_device_num:: Set device number to use.
2531 * acc_get_device_num:: Get device number to be used.
2532 * acc_get_property:: Get device property.
2533 * acc_async_test:: Tests for completion of a specific asynchronous
2535 * acc_async_test_all:: Tests for completion of all asynchronous
2537 * acc_wait:: Wait for completion of a specific asynchronous
2539 * acc_wait_all:: Waits for completion of all asynchronous
2541 * acc_wait_all_async:: Wait for completion of all asynchronous
2543 * acc_wait_async:: Wait for completion of asynchronous operations.
2544 * acc_init:: Initialize runtime for a specific device type.
2545 * acc_shutdown:: Shuts down the runtime for a specific device
2547 * acc_on_device:: Whether executing on a particular device
2548 * acc_malloc:: Allocate device memory.
2549 * acc_free:: Free device memory.
2550 * acc_copyin:: Allocate device memory and copy host memory to
2552 * acc_present_or_copyin:: If the data is not present on the device,
2553 allocate device memory and copy from host
2555 * acc_create:: Allocate device memory and map it to host
2557 * acc_present_or_create:: If the data is not present on the device,
2558 allocate device memory and map it to host
2560 * acc_copyout:: Copy device memory to host memory.
2561 * acc_delete:: Free device memory.
2562 * acc_update_device:: Update device memory from mapped host memory.
2563 * acc_update_self:: Update host memory from mapped device memory.
2564 * acc_map_data:: Map previously allocated device memory to host
2566 * acc_unmap_data:: Unmap device memory from host memory.
2567 * acc_deviceptr:: Get device pointer associated with specific
2569 * acc_hostptr:: Get host pointer associated with specific
2571 * acc_is_present:: Indicate whether host variable / array is
2573 * acc_memcpy_to_device:: Copy host memory to device memory.
2574 * acc_memcpy_from_device:: Copy device memory to host memory.
2575 * acc_attach:: Let device pointer point to device-pointer target.
2576 * acc_detach:: Let device pointer point to host-pointer target.
2578 API routines for target platforms.
2580 * acc_get_current_cuda_device:: Get CUDA device handle.
2581 * acc_get_current_cuda_context::Get CUDA context handle.
2582 * acc_get_cuda_stream:: Get CUDA stream handle.
2583 * acc_set_cuda_stream:: Set CUDA stream handle.
2585 API routines for the OpenACC Profiling Interface.
2587 * acc_prof_register:: Register callbacks.
2588 * acc_prof_unregister:: Unregister callbacks.
2589 * acc_prof_lookup:: Obtain inquiry functions.
2590 * acc_register_library:: Library registration.
2595 @node acc_get_num_devices
2596 @section @code{acc_get_num_devices} -- Get number of devices for given device type
2598 @item @emph{Description}
2599 This function returns a value indicating the number of devices available
2600 for the device type specified in @var{devicetype}.
2603 @multitable @columnfractions .20 .80
2604 @item @emph{Prototype}: @tab @code{int acc_get_num_devices(acc_device_t devicetype);}
2607 @item @emph{Fortran}:
2608 @multitable @columnfractions .20 .80
2609 @item @emph{Interface}: @tab @code{integer function acc_get_num_devices(devicetype)}
2610 @item @tab @code{integer(kind=acc_device_kind) devicetype}
2613 @item @emph{Reference}:
2614 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2620 @node acc_set_device_type
2621 @section @code{acc_set_device_type} -- Set type of device accelerator to use.
2623 @item @emph{Description}
2624 This function indicates to the runtime library which device type, specified
2625 in @var{devicetype}, to use when executing a parallel or kernels region.
2628 @multitable @columnfractions .20 .80
2629 @item @emph{Prototype}: @tab @code{acc_set_device_type(acc_device_t devicetype);}
2632 @item @emph{Fortran}:
2633 @multitable @columnfractions .20 .80
2634 @item @emph{Interface}: @tab @code{subroutine acc_set_device_type(devicetype)}
2635 @item @tab @code{integer(kind=acc_device_kind) devicetype}
2638 @item @emph{Reference}:
2639 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2645 @node acc_get_device_type
2646 @section @code{acc_get_device_type} -- Get type of device accelerator to be used.
2648 @item @emph{Description}
2649 This function returns what device type will be used when executing a
2650 parallel or kernels region.
2652 This function returns @code{acc_device_none} if
2653 @code{acc_get_device_type} is called from
2654 @code{acc_ev_device_init_start}, @code{acc_ev_device_init_end}
2655 callbacks of the OpenACC Profiling Interface (@ref{OpenACC Profiling
2656 Interface}), that is, if the device is currently being initialized.
2659 @multitable @columnfractions .20 .80
2660 @item @emph{Prototype}: @tab @code{acc_device_t acc_get_device_type(void);}
2663 @item @emph{Fortran}:
2664 @multitable @columnfractions .20 .80
2665 @item @emph{Interface}: @tab @code{function acc_get_device_type(void)}
2666 @item @tab @code{integer(kind=acc_device_kind) acc_get_device_type}
2669 @item @emph{Reference}:
2670 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2676 @node acc_set_device_num
2677 @section @code{acc_set_device_num} -- Set device number to use.
2679 @item @emph{Description}
2680 This function will indicate to the runtime which device number,
2681 specified by @var{devicenum}, associated with the specified device
2682 type @var{devicetype}.
2685 @multitable @columnfractions .20 .80
2686 @item @emph{Prototype}: @tab @code{acc_set_device_num(int devicenum, acc_device_t devicetype);}
2689 @item @emph{Fortran}:
2690 @multitable @columnfractions .20 .80
2691 @item @emph{Interface}: @tab @code{subroutine acc_set_device_num(devicenum, devicetype)}
2692 @item @tab @code{integer devicenum}
2693 @item @tab @code{integer(kind=acc_device_kind) devicetype}
2696 @item @emph{Reference}:
2697 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2703 @node acc_get_device_num
2704 @section @code{acc_get_device_num} -- Get device number to be used.
2706 @item @emph{Description}
2707 This function returns which device number associated with the specified device
2708 type @var{devicetype}, will be used when executing a parallel or kernels
2712 @multitable @columnfractions .20 .80
2713 @item @emph{Prototype}: @tab @code{int acc_get_device_num(acc_device_t devicetype);}
2716 @item @emph{Fortran}:
2717 @multitable @columnfractions .20 .80
2718 @item @emph{Interface}: @tab @code{function acc_get_device_num(devicetype)}
2719 @item @tab @code{integer(kind=acc_device_kind) devicetype}
2720 @item @tab @code{integer acc_get_device_num}
2723 @item @emph{Reference}:
2724 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2730 @node acc_get_property
2731 @section @code{acc_get_property} -- Get device property.
2732 @cindex acc_get_property
2733 @cindex acc_get_property_string
2735 @item @emph{Description}
2736 These routines return the value of the specified @var{property} for the
2737 device being queried according to @var{devicenum} and @var{devicetype}.
2738 Integer-valued and string-valued properties are returned by
2739 @code{acc_get_property} and @code{acc_get_property_string} respectively.
2740 The Fortran @code{acc_get_property_string} subroutine returns the string
2741 retrieved in its fourth argument while the remaining entry points are
2742 functions, which pass the return value as their result.
2744 Note for Fortran, only: the OpenACC technical committee corrected and, hence,
2745 modified the interface introduced in OpenACC 2.6. The kind-value parameter
2746 @code{acc_device_property} has been renamed to @code{acc_device_property_kind}
2747 for consistency and the return type of the @code{acc_get_property} function is
2748 now a @code{c_size_t} integer instead of a @code{acc_device_property} integer.
2749 The parameter @code{acc_device_property} will continue to be provided,
2750 but might be removed in a future version of GCC.
2753 @multitable @columnfractions .20 .80
2754 @item @emph{Prototype}: @tab @code{size_t acc_get_property(int devicenum, acc_device_t devicetype, acc_device_property_t property);}
2755 @item @emph{Prototype}: @tab @code{const char *acc_get_property_string(int devicenum, acc_device_t devicetype, acc_device_property_t property);}
2758 @item @emph{Fortran}:
2759 @multitable @columnfractions .20 .80
2760 @item @emph{Interface}: @tab @code{function acc_get_property(devicenum, devicetype, property)}
2761 @item @emph{Interface}: @tab @code{subroutine acc_get_property_string(devicenum, devicetype, property, string)}
2762 @item @tab @code{use ISO_C_Binding, only: c_size_t}
2763 @item @tab @code{integer devicenum}
2764 @item @tab @code{integer(kind=acc_device_kind) devicetype}
2765 @item @tab @code{integer(kind=acc_device_property_kind) property}
2766 @item @tab @code{integer(kind=c_size_t) acc_get_property}
2767 @item @tab @code{character(*) string}
2770 @item @emph{Reference}:
2771 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2777 @node acc_async_test
2778 @section @code{acc_async_test} -- Test for completion of a specific asynchronous operation.
2780 @item @emph{Description}
2781 This function tests for completion of the asynchronous operation specified
2782 in @var{arg}. In C/C++, a non-zero value will be returned to indicate
2783 the specified asynchronous operation has completed. While Fortran will return
2784 a @code{true}. If the asynchronous operation has not completed, C/C++ returns
2785 a zero and Fortran returns a @code{false}.
2788 @multitable @columnfractions .20 .80
2789 @item @emph{Prototype}: @tab @code{int acc_async_test(int arg);}
2792 @item @emph{Fortran}:
2793 @multitable @columnfractions .20 .80
2794 @item @emph{Interface}: @tab @code{function acc_async_test(arg)}
2795 @item @tab @code{integer(kind=acc_handle_kind) arg}
2796 @item @tab @code{logical acc_async_test}
2799 @item @emph{Reference}:
2800 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2806 @node acc_async_test_all
2807 @section @code{acc_async_test_all} -- Tests for completion of all asynchronous operations.
2809 @item @emph{Description}
2810 This function tests for completion of all asynchronous operations.
2811 In C/C++, a non-zero value will be returned to indicate all asynchronous
2812 operations have completed. While Fortran will return a @code{true}. If
2813 any asynchronous operation has not completed, C/C++ returns a zero and
2814 Fortran returns a @code{false}.
2817 @multitable @columnfractions .20 .80
2818 @item @emph{Prototype}: @tab @code{int acc_async_test_all(void);}
2821 @item @emph{Fortran}:
2822 @multitable @columnfractions .20 .80
2823 @item @emph{Interface}: @tab @code{function acc_async_test()}
2824 @item @tab @code{logical acc_get_device_num}
2827 @item @emph{Reference}:
2828 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2835 @section @code{acc_wait} -- Wait for completion of a specific asynchronous operation.
2837 @item @emph{Description}
2838 This function waits for completion of the asynchronous operation
2839 specified in @var{arg}.
2842 @multitable @columnfractions .20 .80
2843 @item @emph{Prototype}: @tab @code{acc_wait(arg);}
2844 @item @emph{Prototype (OpenACC 1.0 compatibility)}: @tab @code{acc_async_wait(arg);}
2847 @item @emph{Fortran}:
2848 @multitable @columnfractions .20 .80
2849 @item @emph{Interface}: @tab @code{subroutine acc_wait(arg)}
2850 @item @tab @code{integer(acc_handle_kind) arg}
2851 @item @emph{Interface (OpenACC 1.0 compatibility)}: @tab @code{subroutine acc_async_wait(arg)}
2852 @item @tab @code{integer(acc_handle_kind) arg}
2855 @item @emph{Reference}:
2856 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2863 @section @code{acc_wait_all} -- Waits for completion of all asynchronous operations.
2865 @item @emph{Description}
2866 This function waits for the completion of all asynchronous operations.
2869 @multitable @columnfractions .20 .80
2870 @item @emph{Prototype}: @tab @code{acc_wait_all(void);}
2871 @item @emph{Prototype (OpenACC 1.0 compatibility)}: @tab @code{acc_async_wait_all(void);}
2874 @item @emph{Fortran}:
2875 @multitable @columnfractions .20 .80
2876 @item @emph{Interface}: @tab @code{subroutine acc_wait_all()}
2877 @item @emph{Interface (OpenACC 1.0 compatibility)}: @tab @code{subroutine acc_async_wait_all()}
2880 @item @emph{Reference}:
2881 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2887 @node acc_wait_all_async
2888 @section @code{acc_wait_all_async} -- Wait for completion of all asynchronous operations.
2890 @item @emph{Description}
2891 This function enqueues a wait operation on the queue @var{async} for any
2892 and all asynchronous operations that have been previously enqueued on
2896 @multitable @columnfractions .20 .80
2897 @item @emph{Prototype}: @tab @code{acc_wait_all_async(int async);}
2900 @item @emph{Fortran}:
2901 @multitable @columnfractions .20 .80
2902 @item @emph{Interface}: @tab @code{subroutine acc_wait_all_async(async)}
2903 @item @tab @code{integer(acc_handle_kind) async}
2906 @item @emph{Reference}:
2907 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2913 @node acc_wait_async
2914 @section @code{acc_wait_async} -- Wait for completion of asynchronous operations.
2916 @item @emph{Description}
2917 This function enqueues a wait operation on queue @var{async} for any and all
2918 asynchronous operations enqueued on queue @var{arg}.
2921 @multitable @columnfractions .20 .80
2922 @item @emph{Prototype}: @tab @code{acc_wait_async(int arg, int async);}
2925 @item @emph{Fortran}:
2926 @multitable @columnfractions .20 .80
2927 @item @emph{Interface}: @tab @code{subroutine acc_wait_async(arg, async)}
2928 @item @tab @code{integer(acc_handle_kind) arg, async}
2931 @item @emph{Reference}:
2932 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2939 @section @code{acc_init} -- Initialize runtime for a specific device type.
2941 @item @emph{Description}
2942 This function initializes the runtime for the device type specified in
2946 @multitable @columnfractions .20 .80
2947 @item @emph{Prototype}: @tab @code{acc_init(acc_device_t devicetype);}
2950 @item @emph{Fortran}:
2951 @multitable @columnfractions .20 .80
2952 @item @emph{Interface}: @tab @code{subroutine acc_init(devicetype)}
2953 @item @tab @code{integer(acc_device_kind) devicetype}
2956 @item @emph{Reference}:
2957 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2964 @section @code{acc_shutdown} -- Shuts down the runtime for a specific device type.
2966 @item @emph{Description}
2967 This function shuts down the runtime for the device type specified in
2971 @multitable @columnfractions .20 .80
2972 @item @emph{Prototype}: @tab @code{acc_shutdown(acc_device_t devicetype);}
2975 @item @emph{Fortran}:
2976 @multitable @columnfractions .20 .80
2977 @item @emph{Interface}: @tab @code{subroutine acc_shutdown(devicetype)}
2978 @item @tab @code{integer(acc_device_kind) devicetype}
2981 @item @emph{Reference}:
2982 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
2989 @section @code{acc_on_device} -- Whether executing on a particular device
2991 @item @emph{Description}:
2992 This function returns whether the program is executing on a particular
2993 device specified in @var{devicetype}. In C/C++ a non-zero value is
2994 returned to indicate the device is executing on the specified device type.
2995 In Fortran, @code{true} will be returned. If the program is not executing
2996 on the specified device type C/C++ will return a zero, while Fortran will
2997 return @code{false}.
3000 @multitable @columnfractions .20 .80
3001 @item @emph{Prototype}: @tab @code{acc_on_device(acc_device_t devicetype);}
3004 @item @emph{Fortran}:
3005 @multitable @columnfractions .20 .80
3006 @item @emph{Interface}: @tab @code{function acc_on_device(devicetype)}
3007 @item @tab @code{integer(acc_device_kind) devicetype}
3008 @item @tab @code{logical acc_on_device}
3012 @item @emph{Reference}:
3013 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3020 @section @code{acc_malloc} -- Allocate device memory.
3022 @item @emph{Description}
3023 This function allocates @var{len} bytes of device memory. It returns
3024 the device address of the allocated memory.
3027 @multitable @columnfractions .20 .80
3028 @item @emph{Prototype}: @tab @code{d_void* acc_malloc(size_t len);}
3031 @item @emph{Reference}:
3032 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3039 @section @code{acc_free} -- Free device memory.
3041 @item @emph{Description}
3042 Free previously allocated device memory at the device address @code{a}.
3045 @multitable @columnfractions .20 .80
3046 @item @emph{Prototype}: @tab @code{acc_free(d_void *a);}
3049 @item @emph{Reference}:
3050 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3057 @section @code{acc_copyin} -- Allocate device memory and copy host memory to it.
3059 @item @emph{Description}
3060 In C/C++, this function allocates @var{len} bytes of device memory
3061 and maps it to the specified host address in @var{a}. The device
3062 address of the newly allocated device memory is returned.
3064 In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
3065 a contiguous array section. The second form @var{a} specifies a
3066 variable or array element and @var{len} specifies the length in bytes.
3069 @multitable @columnfractions .20 .80
3070 @item @emph{Prototype}: @tab @code{void *acc_copyin(h_void *a, size_t len);}
3071 @item @emph{Prototype}: @tab @code{void *acc_copyin_async(h_void *a, size_t len, int async);}
3074 @item @emph{Fortran}:
3075 @multitable @columnfractions .20 .80
3076 @item @emph{Interface}: @tab @code{subroutine acc_copyin(a)}
3077 @item @tab @code{type, dimension(:[,:]...) :: a}
3078 @item @emph{Interface}: @tab @code{subroutine acc_copyin(a, len)}
3079 @item @tab @code{type, dimension(:[,:]...) :: a}
3080 @item @tab @code{integer len}
3081 @item @emph{Interface}: @tab @code{subroutine acc_copyin_async(a, async)}
3082 @item @tab @code{type, dimension(:[,:]...) :: a}
3083 @item @tab @code{integer(acc_handle_kind) :: async}
3084 @item @emph{Interface}: @tab @code{subroutine acc_copyin_async(a, len, async)}
3085 @item @tab @code{type, dimension(:[,:]...) :: a}
3086 @item @tab @code{integer len}
3087 @item @tab @code{integer(acc_handle_kind) :: async}
3090 @item @emph{Reference}:
3091 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3097 @node acc_present_or_copyin
3098 @section @code{acc_present_or_copyin} -- If the data is not present on the device, allocate device memory and copy from host memory.
3100 @item @emph{Description}
3101 This function tests if the host data specified by @var{a} and of length
3102 @var{len} is present or not. If it is not present, then device memory
3103 will be allocated and the host memory copied. The device address of
3104 the newly allocated device memory is returned.
3106 In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
3107 a contiguous array section. The second form @var{a} specifies a variable or
3108 array element and @var{len} specifies the length in bytes.
3110 Note that @code{acc_present_or_copyin} and @code{acc_pcopyin} exist for
3111 backward compatibility with OpenACC 2.0; use @ref{acc_copyin} instead.
3114 @multitable @columnfractions .20 .80
3115 @item @emph{Prototype}: @tab @code{void *acc_present_or_copyin(h_void *a, size_t len);}
3116 @item @emph{Prototype}: @tab @code{void *acc_pcopyin(h_void *a, size_t len);}
3119 @item @emph{Fortran}:
3120 @multitable @columnfractions .20 .80
3121 @item @emph{Interface}: @tab @code{subroutine acc_present_or_copyin(a)}
3122 @item @tab @code{type, dimension(:[,:]...) :: a}
3123 @item @emph{Interface}: @tab @code{subroutine acc_present_or_copyin(a, len)}
3124 @item @tab @code{type, dimension(:[,:]...) :: a}
3125 @item @tab @code{integer len}
3126 @item @emph{Interface}: @tab @code{subroutine acc_pcopyin(a)}
3127 @item @tab @code{type, dimension(:[,:]...) :: a}
3128 @item @emph{Interface}: @tab @code{subroutine acc_pcopyin(a, len)}
3129 @item @tab @code{type, dimension(:[,:]...) :: a}
3130 @item @tab @code{integer len}
3133 @item @emph{Reference}:
3134 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3141 @section @code{acc_create} -- Allocate device memory and map it to host memory.
3143 @item @emph{Description}
3144 This function allocates device memory and maps it to host memory specified
3145 by the host address @var{a} with a length of @var{len} bytes. In C/C++,
3146 the function returns the device address of the allocated device memory.
3148 In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
3149 a contiguous array section. The second form @var{a} specifies a variable or
3150 array element and @var{len} specifies the length in bytes.
3153 @multitable @columnfractions .20 .80
3154 @item @emph{Prototype}: @tab @code{void *acc_create(h_void *a, size_t len);}
3155 @item @emph{Prototype}: @tab @code{void *acc_create_async(h_void *a, size_t len, int async);}
3158 @item @emph{Fortran}:
3159 @multitable @columnfractions .20 .80
3160 @item @emph{Interface}: @tab @code{subroutine acc_create(a)}
3161 @item @tab @code{type, dimension(:[,:]...) :: a}
3162 @item @emph{Interface}: @tab @code{subroutine acc_create(a, len)}
3163 @item @tab @code{type, dimension(:[,:]...) :: a}
3164 @item @tab @code{integer len}
3165 @item @emph{Interface}: @tab @code{subroutine acc_create_async(a, async)}
3166 @item @tab @code{type, dimension(:[,:]...) :: a}
3167 @item @tab @code{integer(acc_handle_kind) :: async}
3168 @item @emph{Interface}: @tab @code{subroutine acc_create_async(a, len, async)}
3169 @item @tab @code{type, dimension(:[,:]...) :: a}
3170 @item @tab @code{integer len}
3171 @item @tab @code{integer(acc_handle_kind) :: async}
3174 @item @emph{Reference}:
3175 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3181 @node acc_present_or_create
3182 @section @code{acc_present_or_create} -- If the data is not present on the device, allocate device memory and map it to host memory.
3184 @item @emph{Description}
3185 This function tests if the host data specified by @var{a} and of length
3186 @var{len} is present or not. If it is not present, then device memory
3187 will be allocated and mapped to host memory. In C/C++, the device address
3188 of the newly allocated device memory is returned.
3190 In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
3191 a contiguous array section. The second form @var{a} specifies a variable or
3192 array element and @var{len} specifies the length in bytes.
3194 Note that @code{acc_present_or_create} and @code{acc_pcreate} exist for
3195 backward compatibility with OpenACC 2.0; use @ref{acc_create} instead.
3198 @multitable @columnfractions .20 .80
3199 @item @emph{Prototype}: @tab @code{void *acc_present_or_create(h_void *a, size_t len)}
3200 @item @emph{Prototype}: @tab @code{void *acc_pcreate(h_void *a, size_t len)}
3203 @item @emph{Fortran}:
3204 @multitable @columnfractions .20 .80
3205 @item @emph{Interface}: @tab @code{subroutine acc_present_or_create(a)}
3206 @item @tab @code{type, dimension(:[,:]...) :: a}
3207 @item @emph{Interface}: @tab @code{subroutine acc_present_or_create(a, len)}
3208 @item @tab @code{type, dimension(:[,:]...) :: a}
3209 @item @tab @code{integer len}
3210 @item @emph{Interface}: @tab @code{subroutine acc_pcreate(a)}
3211 @item @tab @code{type, dimension(:[,:]...) :: a}
3212 @item @emph{Interface}: @tab @code{subroutine acc_pcreate(a, len)}
3213 @item @tab @code{type, dimension(:[,:]...) :: a}
3214 @item @tab @code{integer len}
3217 @item @emph{Reference}:
3218 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3225 @section @code{acc_copyout} -- Copy device memory to host memory.
3227 @item @emph{Description}
3228 This function copies mapped device memory to host memory which is specified
3229 by host address @var{a} for a length @var{len} bytes in C/C++.
3231 In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
3232 a contiguous array section. The second form @var{a} specifies a variable or
3233 array element and @var{len} specifies the length in bytes.
3236 @multitable @columnfractions .20 .80
3237 @item @emph{Prototype}: @tab @code{acc_copyout(h_void *a, size_t len);}
3238 @item @emph{Prototype}: @tab @code{acc_copyout_async(h_void *a, size_t len, int async);}
3239 @item @emph{Prototype}: @tab @code{acc_copyout_finalize(h_void *a, size_t len);}
3240 @item @emph{Prototype}: @tab @code{acc_copyout_finalize_async(h_void *a, size_t len, int async);}
3243 @item @emph{Fortran}:
3244 @multitable @columnfractions .20 .80
3245 @item @emph{Interface}: @tab @code{subroutine acc_copyout(a)}
3246 @item @tab @code{type, dimension(:[,:]...) :: a}
3247 @item @emph{Interface}: @tab @code{subroutine acc_copyout(a, len)}
3248 @item @tab @code{type, dimension(:[,:]...) :: a}
3249 @item @tab @code{integer len}
3250 @item @emph{Interface}: @tab @code{subroutine acc_copyout_async(a, async)}
3251 @item @tab @code{type, dimension(:[,:]...) :: a}
3252 @item @tab @code{integer(acc_handle_kind) :: async}
3253 @item @emph{Interface}: @tab @code{subroutine acc_copyout_async(a, len, async)}
3254 @item @tab @code{type, dimension(:[,:]...) :: a}
3255 @item @tab @code{integer len}
3256 @item @tab @code{integer(acc_handle_kind) :: async}
3257 @item @emph{Interface}: @tab @code{subroutine acc_copyout_finalize(a)}
3258 @item @tab @code{type, dimension(:[,:]...) :: a}
3259 @item @emph{Interface}: @tab @code{subroutine acc_copyout_finalize(a, len)}
3260 @item @tab @code{type, dimension(:[,:]...) :: a}
3261 @item @tab @code{integer len}
3262 @item @emph{Interface}: @tab @code{subroutine acc_copyout_finalize_async(a, async)}
3263 @item @tab @code{type, dimension(:[,:]...) :: a}
3264 @item @tab @code{integer(acc_handle_kind) :: async}
3265 @item @emph{Interface}: @tab @code{subroutine acc_copyout_finalize_async(a, len, async)}
3266 @item @tab @code{type, dimension(:[,:]...) :: a}
3267 @item @tab @code{integer len}
3268 @item @tab @code{integer(acc_handle_kind) :: async}
3271 @item @emph{Reference}:
3272 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3279 @section @code{acc_delete} -- Free device memory.
3281 @item @emph{Description}
3282 This function frees previously allocated device memory specified by
3283 the device address @var{a} and the length of @var{len} bytes.
3285 In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
3286 a contiguous array section. The second form @var{a} specifies a variable or
3287 array element and @var{len} specifies the length in bytes.
3290 @multitable @columnfractions .20 .80
3291 @item @emph{Prototype}: @tab @code{acc_delete(h_void *a, size_t len);}
3292 @item @emph{Prototype}: @tab @code{acc_delete_async(h_void *a, size_t len, int async);}
3293 @item @emph{Prototype}: @tab @code{acc_delete_finalize(h_void *a, size_t len);}
3294 @item @emph{Prototype}: @tab @code{acc_delete_finalize_async(h_void *a, size_t len, int async);}
3297 @item @emph{Fortran}:
3298 @multitable @columnfractions .20 .80
3299 @item @emph{Interface}: @tab @code{subroutine acc_delete(a)}
3300 @item @tab @code{type, dimension(:[,:]...) :: a}
3301 @item @emph{Interface}: @tab @code{subroutine acc_delete(a, len)}
3302 @item @tab @code{type, dimension(:[,:]...) :: a}
3303 @item @tab @code{integer len}
3304 @item @emph{Interface}: @tab @code{subroutine acc_delete_async(a, async)}
3305 @item @tab @code{type, dimension(:[,:]...) :: a}
3306 @item @tab @code{integer(acc_handle_kind) :: async}
3307 @item @emph{Interface}: @tab @code{subroutine acc_delete_async(a, len, async)}
3308 @item @tab @code{type, dimension(:[,:]...) :: a}
3309 @item @tab @code{integer len}
3310 @item @tab @code{integer(acc_handle_kind) :: async}
3311 @item @emph{Interface}: @tab @code{subroutine acc_delete_finalize(a)}
3312 @item @tab @code{type, dimension(:[,:]...) :: a}
3313 @item @emph{Interface}: @tab @code{subroutine acc_delete_finalize(a, len)}
3314 @item @tab @code{type, dimension(:[,:]...) :: a}
3315 @item @tab @code{integer len}
3316 @item @emph{Interface}: @tab @code{subroutine acc_delete_async_finalize(a, async)}
3317 @item @tab @code{type, dimension(:[,:]...) :: a}
3318 @item @tab @code{integer(acc_handle_kind) :: async}
3319 @item @emph{Interface}: @tab @code{subroutine acc_delete_async_finalize(a, len, async)}
3320 @item @tab @code{type, dimension(:[,:]...) :: a}
3321 @item @tab @code{integer len}
3322 @item @tab @code{integer(acc_handle_kind) :: async}
3325 @item @emph{Reference}:
3326 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3332 @node acc_update_device
3333 @section @code{acc_update_device} -- Update device memory from mapped host memory.
3335 @item @emph{Description}
3336 This function updates the device copy from the previously mapped host memory.
3337 The host memory is specified with the host address @var{a} and a length of
3340 In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
3341 a contiguous array section. The second form @var{a} specifies a variable or
3342 array element and @var{len} specifies the length in bytes.
3345 @multitable @columnfractions .20 .80
3346 @item @emph{Prototype}: @tab @code{acc_update_device(h_void *a, size_t len);}
3347 @item @emph{Prototype}: @tab @code{acc_update_device(h_void *a, size_t len, async);}
3350 @item @emph{Fortran}:
3351 @multitable @columnfractions .20 .80
3352 @item @emph{Interface}: @tab @code{subroutine acc_update_device(a)}
3353 @item @tab @code{type, dimension(:[,:]...) :: a}
3354 @item @emph{Interface}: @tab @code{subroutine acc_update_device(a, len)}
3355 @item @tab @code{type, dimension(:[,:]...) :: a}
3356 @item @tab @code{integer len}
3357 @item @emph{Interface}: @tab @code{subroutine acc_update_device_async(a, async)}
3358 @item @tab @code{type, dimension(:[,:]...) :: a}
3359 @item @tab @code{integer(acc_handle_kind) :: async}
3360 @item @emph{Interface}: @tab @code{subroutine acc_update_device_async(a, len, async)}
3361 @item @tab @code{type, dimension(:[,:]...) :: a}
3362 @item @tab @code{integer len}
3363 @item @tab @code{integer(acc_handle_kind) :: async}
3366 @item @emph{Reference}:
3367 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3373 @node acc_update_self
3374 @section @code{acc_update_self} -- Update host memory from mapped device memory.
3376 @item @emph{Description}
3377 This function updates the host copy from the previously mapped device memory.
3378 The host memory is specified with the host address @var{a} and a length of
3381 In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
3382 a contiguous array section. The second form @var{a} specifies a variable or
3383 array element and @var{len} specifies the length in bytes.
3386 @multitable @columnfractions .20 .80
3387 @item @emph{Prototype}: @tab @code{acc_update_self(h_void *a, size_t len);}
3388 @item @emph{Prototype}: @tab @code{acc_update_self_async(h_void *a, size_t len, int async);}
3391 @item @emph{Fortran}:
3392 @multitable @columnfractions .20 .80
3393 @item @emph{Interface}: @tab @code{subroutine acc_update_self(a)}
3394 @item @tab @code{type, dimension(:[,:]...) :: a}
3395 @item @emph{Interface}: @tab @code{subroutine acc_update_self(a, len)}
3396 @item @tab @code{type, dimension(:[,:]...) :: a}
3397 @item @tab @code{integer len}
3398 @item @emph{Interface}: @tab @code{subroutine acc_update_self_async(a, async)}
3399 @item @tab @code{type, dimension(:[,:]...) :: a}
3400 @item @tab @code{integer(acc_handle_kind) :: async}
3401 @item @emph{Interface}: @tab @code{subroutine acc_update_self_async(a, len, async)}
3402 @item @tab @code{type, dimension(:[,:]...) :: a}
3403 @item @tab @code{integer len}
3404 @item @tab @code{integer(acc_handle_kind) :: async}
3407 @item @emph{Reference}:
3408 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3415 @section @code{acc_map_data} -- Map previously allocated device memory to host memory.
3417 @item @emph{Description}
3418 This function maps previously allocated device and host memory. The device
3419 memory is specified with the device address @var{d}. The host memory is
3420 specified with the host address @var{h} and a length of @var{len}.
3423 @multitable @columnfractions .20 .80
3424 @item @emph{Prototype}: @tab @code{acc_map_data(h_void *h, d_void *d, size_t len);}
3427 @item @emph{Reference}:
3428 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3434 @node acc_unmap_data
3435 @section @code{acc_unmap_data} -- Unmap device memory from host memory.
3437 @item @emph{Description}
3438 This function unmaps previously mapped device and host memory. The latter
3439 specified by @var{h}.
3442 @multitable @columnfractions .20 .80
3443 @item @emph{Prototype}: @tab @code{acc_unmap_data(h_void *h);}
3446 @item @emph{Reference}:
3447 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3454 @section @code{acc_deviceptr} -- Get device pointer associated with specific host address.
3456 @item @emph{Description}
3457 This function returns the device address that has been mapped to the
3458 host address specified by @var{h}.
3461 @multitable @columnfractions .20 .80
3462 @item @emph{Prototype}: @tab @code{void *acc_deviceptr(h_void *h);}
3465 @item @emph{Reference}:
3466 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3473 @section @code{acc_hostptr} -- Get host pointer associated with specific device address.
3475 @item @emph{Description}
3476 This function returns the host address that has been mapped to the
3477 device address specified by @var{d}.
3480 @multitable @columnfractions .20 .80
3481 @item @emph{Prototype}: @tab @code{void *acc_hostptr(d_void *d);}
3484 @item @emph{Reference}:
3485 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3491 @node acc_is_present
3492 @section @code{acc_is_present} -- Indicate whether host variable / array is present on device.
3494 @item @emph{Description}
3495 This function indicates whether the specified host address in @var{a} and a
3496 length of @var{len} bytes is present on the device. In C/C++, a non-zero
3497 value is returned to indicate the presence of the mapped memory on the
3498 device. A zero is returned to indicate the memory is not mapped on the
3501 In Fortran, two (2) forms are supported. In the first form, @var{a} specifies
3502 a contiguous array section. The second form @var{a} specifies a variable or
3503 array element and @var{len} specifies the length in bytes. If the host
3504 memory is mapped to device memory, then a @code{true} is returned. Otherwise,
3505 a @code{false} is return to indicate the mapped memory is not present.
3508 @multitable @columnfractions .20 .80
3509 @item @emph{Prototype}: @tab @code{int acc_is_present(h_void *a, size_t len);}
3512 @item @emph{Fortran}:
3513 @multitable @columnfractions .20 .80
3514 @item @emph{Interface}: @tab @code{function acc_is_present(a)}
3515 @item @tab @code{type, dimension(:[,:]...) :: a}
3516 @item @tab @code{logical acc_is_present}
3517 @item @emph{Interface}: @tab @code{function acc_is_present(a, len)}
3518 @item @tab @code{type, dimension(:[,:]...) :: a}
3519 @item @tab @code{integer len}
3520 @item @tab @code{logical acc_is_present}
3523 @item @emph{Reference}:
3524 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3530 @node acc_memcpy_to_device
3531 @section @code{acc_memcpy_to_device} -- Copy host memory to device memory.
3533 @item @emph{Description}
3534 This function copies host memory specified by host address of @var{src} to
3535 device memory specified by the device address @var{dest} for a length of
3539 @multitable @columnfractions .20 .80
3540 @item @emph{Prototype}: @tab @code{acc_memcpy_to_device(d_void *dest, h_void *src, size_t bytes);}
3543 @item @emph{Reference}:
3544 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3550 @node acc_memcpy_from_device
3551 @section @code{acc_memcpy_from_device} -- Copy device memory to host memory.
3553 @item @emph{Description}
3554 This function copies host memory specified by host address of @var{src} from
3555 device memory specified by the device address @var{dest} for a length of
3559 @multitable @columnfractions .20 .80
3560 @item @emph{Prototype}: @tab @code{acc_memcpy_from_device(d_void *dest, h_void *src, size_t bytes);}
3563 @item @emph{Reference}:
3564 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3571 @section @code{acc_attach} -- Let device pointer point to device-pointer target.
3573 @item @emph{Description}
3574 This function updates a pointer on the device from pointing to a host-pointer
3575 address to pointing to the corresponding device data.
3578 @multitable @columnfractions .20 .80
3579 @item @emph{Prototype}: @tab @code{acc_attach(h_void **ptr);}
3580 @item @emph{Prototype}: @tab @code{acc_attach_async(h_void **ptr, int async);}
3583 @item @emph{Reference}:
3584 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3591 @section @code{acc_detach} -- Let device pointer point to host-pointer target.
3593 @item @emph{Description}
3594 This function updates a pointer on the device from pointing to a device-pointer
3595 address to pointing to the corresponding host data.
3598 @multitable @columnfractions .20 .80
3599 @item @emph{Prototype}: @tab @code{acc_detach(h_void **ptr);}
3600 @item @emph{Prototype}: @tab @code{acc_detach_async(h_void **ptr, int async);}
3601 @item @emph{Prototype}: @tab @code{acc_detach_finalize(h_void **ptr);}
3602 @item @emph{Prototype}: @tab @code{acc_detach_finalize_async(h_void **ptr, int async);}
3605 @item @emph{Reference}:
3606 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3612 @node acc_get_current_cuda_device
3613 @section @code{acc_get_current_cuda_device} -- Get CUDA device handle.
3615 @item @emph{Description}
3616 This function returns the CUDA device handle. This handle is the same
3617 as used by the CUDA Runtime or Driver API's.
3620 @multitable @columnfractions .20 .80
3621 @item @emph{Prototype}: @tab @code{void *acc_get_current_cuda_device(void);}
3624 @item @emph{Reference}:
3625 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3631 @node acc_get_current_cuda_context
3632 @section @code{acc_get_current_cuda_context} -- Get CUDA context handle.
3634 @item @emph{Description}
3635 This function returns the CUDA context handle. This handle is the same
3636 as used by the CUDA Runtime or Driver API's.
3639 @multitable @columnfractions .20 .80
3640 @item @emph{Prototype}: @tab @code{void *acc_get_current_cuda_context(void);}
3643 @item @emph{Reference}:
3644 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3650 @node acc_get_cuda_stream
3651 @section @code{acc_get_cuda_stream} -- Get CUDA stream handle.
3653 @item @emph{Description}
3654 This function returns the CUDA stream handle for the queue @var{async}.
3655 This handle is the same as used by the CUDA Runtime or Driver API's.
3658 @multitable @columnfractions .20 .80
3659 @item @emph{Prototype}: @tab @code{void *acc_get_cuda_stream(int async);}
3662 @item @emph{Reference}:
3663 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3669 @node acc_set_cuda_stream
3670 @section @code{acc_set_cuda_stream} -- Set CUDA stream handle.
3672 @item @emph{Description}
3673 This function associates the stream handle specified by @var{stream} with
3674 the queue @var{async}.
3676 This cannot be used to change the stream handle associated with
3677 @code{acc_async_sync}.
3679 The return value is not specified.
3682 @multitable @columnfractions .20 .80
3683 @item @emph{Prototype}: @tab @code{int acc_set_cuda_stream(int async, void *stream);}
3686 @item @emph{Reference}:
3687 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3693 @node acc_prof_register
3694 @section @code{acc_prof_register} -- Register callbacks.
3696 @item @emph{Description}:
3697 This function registers callbacks.
3700 @multitable @columnfractions .20 .80
3701 @item @emph{Prototype}: @tab @code{void acc_prof_register (acc_event_t, acc_prof_callback, acc_register_t);}
3704 @item @emph{See also}:
3705 @ref{OpenACC Profiling Interface}
3707 @item @emph{Reference}:
3708 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3714 @node acc_prof_unregister
3715 @section @code{acc_prof_unregister} -- Unregister callbacks.
3717 @item @emph{Description}:
3718 This function unregisters callbacks.
3721 @multitable @columnfractions .20 .80
3722 @item @emph{Prototype}: @tab @code{void acc_prof_unregister (acc_event_t, acc_prof_callback, acc_register_t);}
3725 @item @emph{See also}:
3726 @ref{OpenACC Profiling Interface}
3728 @item @emph{Reference}:
3729 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3735 @node acc_prof_lookup
3736 @section @code{acc_prof_lookup} -- Obtain inquiry functions.
3738 @item @emph{Description}:
3739 Function to obtain inquiry functions.
3742 @multitable @columnfractions .20 .80
3743 @item @emph{Prototype}: @tab @code{acc_query_fn acc_prof_lookup (const char *);}
3746 @item @emph{See also}:
3747 @ref{OpenACC Profiling Interface}
3749 @item @emph{Reference}:
3750 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3756 @node acc_register_library
3757 @section @code{acc_register_library} -- Library registration.
3759 @item @emph{Description}:
3760 Function for library registration.
3763 @multitable @columnfractions .20 .80
3764 @item @emph{Prototype}: @tab @code{void acc_register_library (acc_prof_reg, acc_prof_reg, acc_prof_lookup_func);}
3767 @item @emph{See also}:
3768 @ref{OpenACC Profiling Interface}, @ref{ACC_PROFLIB}
3770 @item @emph{Reference}:
3771 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3777 @c ---------------------------------------------------------------------
3778 @c OpenACC Environment Variables
3779 @c ---------------------------------------------------------------------
3781 @node OpenACC Environment Variables
3782 @chapter OpenACC Environment Variables
3784 The variables @env{ACC_DEVICE_TYPE} and @env{ACC_DEVICE_NUM}
3785 are defined by section 4 of the OpenACC specification in version 2.0.
3786 The variable @env{ACC_PROFLIB}
3787 is defined by section 4 of the OpenACC specification in version 2.6.
3788 The variable @env{GCC_ACC_NOTIFY} is used for diagnostic purposes.
3799 @node ACC_DEVICE_TYPE
3800 @section @code{ACC_DEVICE_TYPE}
3802 @item @emph{Reference}:
3803 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3809 @node ACC_DEVICE_NUM
3810 @section @code{ACC_DEVICE_NUM}
3812 @item @emph{Reference}:
3813 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3820 @section @code{ACC_PROFLIB}
3822 @item @emph{See also}:
3823 @ref{acc_register_library}, @ref{OpenACC Profiling Interface}
3825 @item @emph{Reference}:
3826 @uref{https://www.openacc.org, OpenACC specification v2.6}, section
3832 @node GCC_ACC_NOTIFY
3833 @section @code{GCC_ACC_NOTIFY}
3835 @item @emph{Description}:
3836 Print debug information pertaining to the accelerator.
3841 @c ---------------------------------------------------------------------
3842 @c CUDA Streams Usage
3843 @c ---------------------------------------------------------------------
3845 @node CUDA Streams Usage
3846 @chapter CUDA Streams Usage
3848 This applies to the @code{nvptx} plugin only.
3850 The library provides elements that perform asynchronous movement of
3851 data and asynchronous operation of computing constructs. This
3852 asynchronous functionality is implemented by making use of CUDA
3853 streams@footnote{See "Stream Management" in "CUDA Driver API",
3854 TRM-06703-001, Version 5.5, for additional information}.
3856 The primary means by that the asynchronous functionality is accessed
3857 is through the use of those OpenACC directives which make use of the
3858 @code{async} and @code{wait} clauses. When the @code{async} clause is
3859 first used with a directive, it creates a CUDA stream. If an
3860 @code{async-argument} is used with the @code{async} clause, then the
3861 stream is associated with the specified @code{async-argument}.
3863 Following the creation of an association between a CUDA stream and the
3864 @code{async-argument} of an @code{async} clause, both the @code{wait}
3865 clause and the @code{wait} directive can be used. When either the
3866 clause or directive is used after stream creation, it creates a
3867 rendezvous point whereby execution waits until all operations
3868 associated with the @code{async-argument}, that is, stream, have
3871 Normally, the management of the streams that are created as a result of
3872 using the @code{async} clause, is done without any intervention by the
3873 caller. This implies the association between the @code{async-argument}
3874 and the CUDA stream will be maintained for the lifetime of the program.
3875 However, this association can be changed through the use of the library
3876 function @code{acc_set_cuda_stream}. When the function
3877 @code{acc_set_cuda_stream} is called, the CUDA stream that was
3878 originally associated with the @code{async} clause will be destroyed.
3879 Caution should be taken when changing the association as subsequent
3880 references to the @code{async-argument} refer to a different
3885 @c ---------------------------------------------------------------------
3886 @c OpenACC Library Interoperability
3887 @c ---------------------------------------------------------------------
3889 @node OpenACC Library Interoperability
3890 @chapter OpenACC Library Interoperability
3892 @section Introduction
3894 The OpenACC library uses the CUDA Driver API, and may interact with
3895 programs that use the Runtime library directly, or another library
3896 based on the Runtime library, e.g., CUBLAS@footnote{See section 2.26,
3897 "Interactions with the CUDA Driver API" in
3898 "CUDA Runtime API", Version 5.5, and section 2.27, "VDPAU
3899 Interoperability", in "CUDA Driver API", TRM-06703-001, Version 5.5,
3900 for additional information on library interoperability.}.
3901 This chapter describes the use cases and what changes are
3902 required in order to use both the OpenACC library and the CUBLAS and Runtime
3903 libraries within a program.
3905 @section First invocation: NVIDIA CUBLAS library API
3907 In this first use case (see below), a function in the CUBLAS library is called
3908 prior to any of the functions in the OpenACC library. More specifically, the
3909 function @code{cublasCreate()}.
3911 When invoked, the function initializes the library and allocates the
3912 hardware resources on the host and the device on behalf of the caller. Once
3913 the initialization and allocation has completed, a handle is returned to the
3914 caller. The OpenACC library also requires initialization and allocation of
3915 hardware resources. Since the CUBLAS library has already allocated the
3916 hardware resources for the device, all that is left to do is to initialize
3917 the OpenACC library and acquire the hardware resources on the host.
3919 Prior to calling the OpenACC function that initializes the library and
3920 allocate the host hardware resources, you need to acquire the device number
3921 that was allocated during the call to @code{cublasCreate()}. The invoking of the
3922 runtime library function @code{cudaGetDevice()} accomplishes this. Once
3923 acquired, the device number is passed along with the device type as
3924 parameters to the OpenACC library function @code{acc_set_device_num()}.
3926 Once the call to @code{acc_set_device_num()} has completed, the OpenACC
3927 library uses the context that was created during the call to
3928 @code{cublasCreate()}. In other words, both libraries will be sharing the
3932 /* Create the handle */
3933 s = cublasCreate(&h);
3934 if (s != CUBLAS_STATUS_SUCCESS)
3936 fprintf(stderr, "cublasCreate failed %d\n", s);
3940 /* Get the device number */
3941 e = cudaGetDevice(&dev);
3942 if (e != cudaSuccess)
3944 fprintf(stderr, "cudaGetDevice failed %d\n", e);
3948 /* Initialize OpenACC library and use device 'dev' */
3949 acc_set_device_num(dev, acc_device_nvidia);
3954 @section First invocation: OpenACC library API
3956 In this second use case (see below), a function in the OpenACC library is
3957 called prior to any of the functions in the CUBLAS library. More specifically,
3958 the function @code{acc_set_device_num()}.
3960 In the use case presented here, the function @code{acc_set_device_num()}
3961 is used to both initialize the OpenACC library and allocate the hardware
3962 resources on the host and the device. In the call to the function, the
3963 call parameters specify which device to use and what device
3964 type to use, i.e., @code{acc_device_nvidia}. It should be noted that this
3965 is but one method to initialize the OpenACC library and allocate the
3966 appropriate hardware resources. Other methods are available through the
3967 use of environment variables and these will be discussed in the next section.
3969 Once the call to @code{acc_set_device_num()} has completed, other OpenACC
3970 functions can be called as seen with multiple calls being made to
3971 @code{acc_copyin()}. In addition, calls can be made to functions in the
3972 CUBLAS library. In the use case a call to @code{cublasCreate()} is made
3973 subsequent to the calls to @code{acc_copyin()}.
3974 As seen in the previous use case, a call to @code{cublasCreate()}
3975 initializes the CUBLAS library and allocates the hardware resources on the
3976 host and the device. However, since the device has already been allocated,
3977 @code{cublasCreate()} will only initialize the CUBLAS library and allocate
3978 the appropriate hardware resources on the host. The context that was created
3979 as part of the OpenACC initialization is shared with the CUBLAS library,
3980 similarly to the first use case.
3985 acc_set_device_num(dev, acc_device_nvidia);
3987 /* Copy the first set to the device */
3988 d_X = acc_copyin(&h_X[0], N * sizeof (float));
3991 fprintf(stderr, "copyin error h_X\n");
3995 /* Copy the second set to the device */
3996 d_Y = acc_copyin(&h_Y1[0], N * sizeof (float));
3999 fprintf(stderr, "copyin error h_Y1\n");
4003 /* Create the handle */
4004 s = cublasCreate(&h);
4005 if (s != CUBLAS_STATUS_SUCCESS)
4007 fprintf(stderr, "cublasCreate failed %d\n", s);
4011 /* Perform saxpy using CUBLAS library function */
4012 s = cublasSaxpy(h, N, &alpha, d_X, 1, d_Y, 1);
4013 if (s != CUBLAS_STATUS_SUCCESS)
4015 fprintf(stderr, "cublasSaxpy failed %d\n", s);
4019 /* Copy the results from the device */
4020 acc_memcpy_from_device(&h_Y1[0], d_Y, N * sizeof (float));
4025 @section OpenACC library and environment variables
4027 There are two environment variables associated with the OpenACC library
4028 that may be used to control the device type and device number:
4029 @env{ACC_DEVICE_TYPE} and @env{ACC_DEVICE_NUM}, respectively. These two
4030 environment variables can be used as an alternative to calling
4031 @code{acc_set_device_num()}. As seen in the second use case, the device
4032 type and device number were specified using @code{acc_set_device_num()}.
4033 If however, the aforementioned environment variables were set, then the
4034 call to @code{acc_set_device_num()} would not be required.
4037 The use of the environment variables is only relevant when an OpenACC function
4038 is called prior to a call to @code{cudaCreate()}. If @code{cudaCreate()}
4039 is called prior to a call to an OpenACC function, then you must call
4040 @code{acc_set_device_num()}@footnote{More complete information
4041 about @env{ACC_DEVICE_TYPE} and @env{ACC_DEVICE_NUM} can be found in
4042 sections 4.1 and 4.2 of the @uref{https://www.openacc.org, OpenACC}
4043 Application Programming Interface”, Version 2.6.}
4047 @c ---------------------------------------------------------------------
4048 @c OpenACC Profiling Interface
4049 @c ---------------------------------------------------------------------
4051 @node OpenACC Profiling Interface
4052 @chapter OpenACC Profiling Interface
4054 @section Implementation Status and Implementation-Defined Behavior
4056 We're implementing the OpenACC Profiling Interface as defined by the
4057 OpenACC 2.6 specification. We're clarifying some aspects here as
4058 @emph{implementation-defined behavior}, while they're still under
4059 discussion within the OpenACC Technical Committee.
4061 This implementation is tuned to keep the performance impact as low as
4062 possible for the (very common) case that the Profiling Interface is
4063 not enabled. This is relevant, as the Profiling Interface affects all
4064 the @emph{hot} code paths (in the target code, not in the offloaded
4065 code). Users of the OpenACC Profiling Interface can be expected to
4066 understand that performance will be impacted to some degree once the
4067 Profiling Interface has gotten enabled: for example, because of the
4068 @emph{runtime} (libgomp) calling into a third-party @emph{library} for
4069 every event that has been registered.
4071 We're not yet accounting for the fact that @cite{OpenACC events may
4072 occur during event processing}.
4073 We just handle one case specially, as required by CUDA 9.0
4074 @command{nvprof}, that @code{acc_get_device_type}
4075 (@ref{acc_get_device_type})) may be called from
4076 @code{acc_ev_device_init_start}, @code{acc_ev_device_init_end}
4079 We're not yet implementing initialization via a
4080 @code{acc_register_library} function that is either statically linked
4081 in, or dynamically via @env{LD_PRELOAD}.
4082 Initialization via @code{acc_register_library} functions dynamically
4083 loaded via the @env{ACC_PROFLIB} environment variable does work, as
4084 does directly calling @code{acc_prof_register},
4085 @code{acc_prof_unregister}, @code{acc_prof_lookup}.
4087 As currently there are no inquiry functions defined, calls to
4088 @code{acc_prof_lookup} will always return @code{NULL}.
4090 There aren't separate @emph{start}, @emph{stop} events defined for the
4091 event types @code{acc_ev_create}, @code{acc_ev_delete},
4092 @code{acc_ev_alloc}, @code{acc_ev_free}. It's not clear if these
4093 should be triggered before or after the actual device-specific call is
4094 made. We trigger them after.
4096 Remarks about data provided to callbacks:
4100 @item @code{acc_prof_info.event_type}
4101 It's not clear if for @emph{nested} event callbacks (for example,
4102 @code{acc_ev_enqueue_launch_start} as part of a parent compute
4103 construct), this should be set for the nested event
4104 (@code{acc_ev_enqueue_launch_start}), or if the value of the parent
4105 construct should remain (@code{acc_ev_compute_construct_start}). In
4106 this implementation, the value will generally correspond to the
4107 innermost nested event type.
4109 @item @code{acc_prof_info.device_type}
4113 For @code{acc_ev_compute_construct_start}, and in presence of an
4114 @code{if} clause with @emph{false} argument, this will still refer to
4115 the offloading device type.
4116 It's not clear if that's the expected behavior.
4119 Complementary to the item before, for
4120 @code{acc_ev_compute_construct_end}, this is set to
4121 @code{acc_device_host} in presence of an @code{if} clause with
4122 @emph{false} argument.
4123 It's not clear if that's the expected behavior.
4127 @item @code{acc_prof_info.thread_id}
4128 Always @code{-1}; not yet implemented.
4130 @item @code{acc_prof_info.async}
4134 Not yet implemented correctly for
4135 @code{acc_ev_compute_construct_start}.
4138 In a compute construct, for host-fallback
4139 execution/@code{acc_device_host} it will always be
4140 @code{acc_async_sync}.
4141 It's not clear if that's the expected behavior.
4144 For @code{acc_ev_device_init_start} and @code{acc_ev_device_init_end},
4145 it will always be @code{acc_async_sync}.
4146 It's not clear if that's the expected behavior.
4150 @item @code{acc_prof_info.async_queue}
4151 There is no @cite{limited number of asynchronous queues} in libgomp.
4152 This will always have the same value as @code{acc_prof_info.async}.
4154 @item @code{acc_prof_info.src_file}
4155 Always @code{NULL}; not yet implemented.
4157 @item @code{acc_prof_info.func_name}
4158 Always @code{NULL}; not yet implemented.
4160 @item @code{acc_prof_info.line_no}
4161 Always @code{-1}; not yet implemented.
4163 @item @code{acc_prof_info.end_line_no}
4164 Always @code{-1}; not yet implemented.
4166 @item @code{acc_prof_info.func_line_no}
4167 Always @code{-1}; not yet implemented.
4169 @item @code{acc_prof_info.func_end_line_no}
4170 Always @code{-1}; not yet implemented.
4172 @item @code{acc_event_info.event_type}, @code{acc_event_info.*.event_type}
4173 Relating to @code{acc_prof_info.event_type} discussed above, in this
4174 implementation, this will always be the same value as
4175 @code{acc_prof_info.event_type}.
4177 @item @code{acc_event_info.*.parent_construct}
4181 Will be @code{acc_construct_parallel} for all OpenACC compute
4182 constructs as well as many OpenACC Runtime API calls; should be the
4183 one matching the actual construct, or
4184 @code{acc_construct_runtime_api}, respectively.
4187 Will be @code{acc_construct_enter_data} or
4188 @code{acc_construct_exit_data} when processing variable mappings
4189 specified in OpenACC @emph{declare} directives; should be
4190 @code{acc_construct_declare}.
4193 For implicit @code{acc_ev_device_init_start},
4194 @code{acc_ev_device_init_end}, and explicit as well as implicit
4195 @code{acc_ev_alloc}, @code{acc_ev_free},
4196 @code{acc_ev_enqueue_upload_start}, @code{acc_ev_enqueue_upload_end},
4197 @code{acc_ev_enqueue_download_start}, and
4198 @code{acc_ev_enqueue_download_end}, will be
4199 @code{acc_construct_parallel}; should reflect the real parent
4204 @item @code{acc_event_info.*.implicit}
4205 For @code{acc_ev_alloc}, @code{acc_ev_free},
4206 @code{acc_ev_enqueue_upload_start}, @code{acc_ev_enqueue_upload_end},
4207 @code{acc_ev_enqueue_download_start}, and
4208 @code{acc_ev_enqueue_download_end}, this currently will be @code{1}
4209 also for explicit usage.
4211 @item @code{acc_event_info.data_event.var_name}
4212 Always @code{NULL}; not yet implemented.
4214 @item @code{acc_event_info.data_event.host_ptr}
4215 For @code{acc_ev_alloc}, and @code{acc_ev_free}, this is always
4218 @item @code{typedef union acc_api_info}
4219 @dots{} as printed in @cite{5.2.3. Third Argument: API-Specific
4220 Information}. This should obviously be @code{typedef @emph{struct}
4223 @item @code{acc_api_info.device_api}
4224 Possibly not yet implemented correctly for
4225 @code{acc_ev_compute_construct_start},
4226 @code{acc_ev_device_init_start}, @code{acc_ev_device_init_end}:
4227 will always be @code{acc_device_api_none} for these event types.
4228 For @code{acc_ev_enter_data_start}, it will be
4229 @code{acc_device_api_none} in some cases.
4231 @item @code{acc_api_info.device_type}
4232 Always the same as @code{acc_prof_info.device_type}.
4234 @item @code{acc_api_info.vendor}
4235 Always @code{-1}; not yet implemented.
4237 @item @code{acc_api_info.device_handle}
4238 Always @code{NULL}; not yet implemented.
4240 @item @code{acc_api_info.context_handle}
4241 Always @code{NULL}; not yet implemented.
4243 @item @code{acc_api_info.async_handle}
4244 Always @code{NULL}; not yet implemented.
4248 Remarks about certain event types:
4252 @item @code{acc_ev_device_init_start}, @code{acc_ev_device_init_end}
4256 @c See 'DEVICE_INIT_INSIDE_COMPUTE_CONSTRUCT' in
4257 @c 'libgomp.oacc-c-c++-common/acc_prof-kernels-1.c',
4258 @c 'libgomp.oacc-c-c++-common/acc_prof-parallel-1.c'.
4259 When a compute construct triggers implicit
4260 @code{acc_ev_device_init_start} and @code{acc_ev_device_init_end}
4261 events, they currently aren't @emph{nested within} the corresponding
4262 @code{acc_ev_compute_construct_start} and
4263 @code{acc_ev_compute_construct_end}, but they're currently observed
4264 @emph{before} @code{acc_ev_compute_construct_start}.
4265 It's not clear what to do: the standard asks us provide a lot of
4266 details to the @code{acc_ev_compute_construct_start} callback, without
4267 (implicitly) initializing a device before?
4270 Callbacks for these event types will not be invoked for calls to the
4271 @code{acc_set_device_type} and @code{acc_set_device_num} functions.
4272 It's not clear if they should be.
4276 @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}
4280 Callbacks for these event types will also be invoked for OpenACC
4281 @emph{host_data} constructs.
4282 It's not clear if they should be.
4285 Callbacks for these event types will also be invoked when processing
4286 variable mappings specified in OpenACC @emph{declare} directives.
4287 It's not clear if they should be.
4293 Callbacks for the following event types will be invoked, but dispatch
4294 and information provided therein has not yet been thoroughly reviewed:
4297 @item @code{acc_ev_alloc}
4298 @item @code{acc_ev_free}
4299 @item @code{acc_ev_update_start}, @code{acc_ev_update_end}
4300 @item @code{acc_ev_enqueue_upload_start}, @code{acc_ev_enqueue_upload_end}
4301 @item @code{acc_ev_enqueue_download_start}, @code{acc_ev_enqueue_download_end}
4304 During device initialization, and finalization, respectively,
4305 callbacks for the following event types will not yet be invoked:
4308 @item @code{acc_ev_alloc}
4309 @item @code{acc_ev_free}
4312 Callbacks for the following event types have not yet been implemented,
4313 so currently won't be invoked:
4316 @item @code{acc_ev_device_shutdown_start}, @code{acc_ev_device_shutdown_end}
4317 @item @code{acc_ev_runtime_shutdown}
4318 @item @code{acc_ev_create}, @code{acc_ev_delete}
4319 @item @code{acc_ev_wait_start}, @code{acc_ev_wait_end}
4322 For the following runtime library functions, not all expected
4323 callbacks will be invoked (mostly concerning implicit device
4327 @item @code{acc_get_num_devices}
4328 @item @code{acc_set_device_type}
4329 @item @code{acc_get_device_type}
4330 @item @code{acc_set_device_num}
4331 @item @code{acc_get_device_num}
4332 @item @code{acc_init}
4333 @item @code{acc_shutdown}
4336 Aside from implicit device initialization, for the following runtime
4337 library functions, no callbacks will be invoked for shared-memory
4338 offloading devices (it's not clear if they should be):
4341 @item @code{acc_malloc}
4342 @item @code{acc_free}
4343 @item @code{acc_copyin}, @code{acc_present_or_copyin}, @code{acc_copyin_async}
4344 @item @code{acc_create}, @code{acc_present_or_create}, @code{acc_create_async}
4345 @item @code{acc_copyout}, @code{acc_copyout_async}, @code{acc_copyout_finalize}, @code{acc_copyout_finalize_async}
4346 @item @code{acc_delete}, @code{acc_delete_async}, @code{acc_delete_finalize}, @code{acc_delete_finalize_async}
4347 @item @code{acc_update_device}, @code{acc_update_device_async}
4348 @item @code{acc_update_self}, @code{acc_update_self_async}
4349 @item @code{acc_map_data}, @code{acc_unmap_data}
4350 @item @code{acc_memcpy_to_device}, @code{acc_memcpy_to_device_async}
4351 @item @code{acc_memcpy_from_device}, @code{acc_memcpy_from_device_async}
4354 @c ---------------------------------------------------------------------
4355 @c OpenMP-Implementation Specifics
4356 @c ---------------------------------------------------------------------
4358 @node OpenMP-Implementation Specifics
4359 @chapter OpenMP-Implementation Specifics
4362 * OpenMP Context Selectors::
4363 * Memory allocation with libmemkind::
4366 @node OpenMP Context Selectors
4367 @section OpenMP Context Selectors
4369 @code{vendor} is always @code{gnu}. References are to the GCC manual.
4371 @multitable @columnfractions .60 .10 .25
4372 @headitem @code{arch} @tab @code{kind} @tab @code{isa}
4373 @item @code{x86}, @code{x86_64}, @code{i386}, @code{i486},
4374 @code{i586}, @code{i686}, @code{ia32}
4376 @tab See @code{-m...} flags in ``x86 Options'' (without @code{-m})
4377 @item @code{amdgcn}, @code{gcn}
4379 @tab See @code{-march=} in ``AMD GCN Options''@footnote{Additionally,
4380 @code{gfx803} is supported as an alias for @code{fiji}.}
4383 @tab See @code{-march=} in ``Nvidia PTX Options''
4386 @node Memory allocation with libmemkind
4387 @section Memory allocation with libmemkind
4389 On Linux systems, where the @uref{https://github.com/memkind/memkind, memkind
4390 library} (@code{libmemkind.so.0}) is available at runtime, it is used when
4391 creating memory allocators requesting
4394 @item the memory space @code{omp_high_bw_mem_space}
4395 @item the memory space @code{omp_large_cap_mem_space}
4396 @item the partition trait @code{omp_atv_interleaved}
4400 @c ---------------------------------------------------------------------
4401 @c Offload-Target Specifics
4402 @c ---------------------------------------------------------------------
4404 @node Offload-Target Specifics
4405 @chapter Offload-Target Specifics
4407 The following sections present notes on the offload-target specifics
4415 @section AMD Radeon (GCN)
4417 On the hardware side, there is the hierarchy (fine to coarse):
4419 @item work item (thread)
4422 @item compute unit (CU)
4425 All OpenMP and OpenACC levels are used, i.e.
4427 @item OpenMP's simd and OpenACC's vector map to work items (thread)
4428 @item OpenMP's threads (``parallel'') and OpenACC's workers map
4430 @item OpenMP's teams and OpenACC's gang use a threadpool with the
4431 size of the number of teams or gangs, respectively.
4436 @item Number of teams is the specified @code{num_teams} (OpenMP) or
4437 @code{num_gangs} (OpenACC) or otherwise the number of CU. It is limited
4438 by two times the number of CU.
4439 @item Number of wavefronts is 4 for gfx900 and 16 otherwise;
4440 @code{num_threads} (OpenMP) and @code{num_workers} (OpenACC)
4441 overrides this if smaller.
4442 @item The wavefront has 102 scalars and 64 vectors
4443 @item Number of workitems is always 64
4444 @item The hardware permits maximally 40 workgroups/CU and
4445 16 wavefronts/workgroup up to a limit of 40 wavefronts in total per CU.
4446 @item 80 scalars registers and 24 vector registers in non-kernel functions
4447 (the chosen procedure-calling API).
4448 @item For the kernel itself: as many as register pressure demands (number of
4449 teams and number of threads, scaled down if registers are exhausted)
4452 The implementation remark:
4454 @item I/O within OpenMP target regions and OpenACC parallel/kernels is supported
4455 using the C library @code{printf} functions and the Fortran
4456 @code{print}/@code{write} statements.
4457 @item Reverse offload regions (i.e. @code{target} regions with
4458 @code{device(ancestor:1)}) are processed serially per @code{target} region
4459 such that the next reverse offload region is only executed after the previous
4461 @item OpenMP code that has a requires directive with @code{unified_address} or
4462 @code{unified_shared_memory} will remove any GCN device from the list of
4463 available devices (``host fallback'').
4464 @item The available stack size can be changed using the @code{GCN_STACK_SIZE}
4465 environment variable; the default is 32 kiB per thread.
4473 On the hardware side, there is the hierarchy (fine to coarse):
4478 @item streaming multiprocessor
4481 All OpenMP and OpenACC levels are used, i.e.
4483 @item OpenMP's simd and OpenACC's vector map to threads
4484 @item OpenMP's threads (``parallel'') and OpenACC's workers map to warps
4485 @item OpenMP's teams and OpenACC's gang use a threadpool with the
4486 size of the number of teams or gangs, respectively.
4491 @item The @code{warp_size} is always 32
4492 @item CUDA kernel launched: @code{dim=@{#teams,1,1@}, blocks=@{#threads,warp_size,1@}}.
4493 @item The number of teams is limited by the number of blocks the device can
4494 host simultaneously.
4497 Additional information can be obtained by setting the environment variable to
4498 @code{GOMP_DEBUG=1} (very verbose; grep for @code{kernel.*launch} for launch
4501 GCC generates generic PTX ISA code, which is just-in-time compiled by CUDA,
4502 which caches the JIT in the user's directory (see CUDA documentation; can be
4503 tuned by the environment variables @code{CUDA_CACHE_@{DISABLE,MAXSIZE,PATH@}}.
4505 Note: While PTX ISA is generic, the @code{-mptx=} and @code{-march=} commandline
4506 options still affect the used PTX ISA code and, thus, the requirements on
4507 CUDA version and hardware.
4509 The implementation remark:
4511 @item I/O within OpenMP target regions and OpenACC parallel/kernels is supported
4512 using the C library @code{printf} functions. Note that the Fortran
4513 @code{print}/@code{write} statements are not supported, yet.
4514 @item Compilation OpenMP code that contains @code{requires reverse_offload}
4515 requires at least @code{-march=sm_35}, compiling for @code{-march=sm_30}
4517 @item For code containing reverse offload (i.e. @code{target} regions with
4518 @code{device(ancestor:1)}), there is a slight performance penalty
4519 for @emph{all} target regions, consisting mostly of shutdown delay
4520 Per device, reverse offload regions are processed serially such that
4521 the next reverse offload region is only executed after the previous
4523 @item OpenMP code that has a requires directive with @code{unified_address}
4524 or @code{unified_shared_memory} will remove any nvptx device from the
4525 list of available devices (``host fallback'').
4529 @c ---------------------------------------------------------------------
4531 @c ---------------------------------------------------------------------
4533 @node The libgomp ABI
4534 @chapter The libgomp ABI
4536 The following sections present notes on the external ABI as
4537 presented by libgomp. Only maintainers should need them.
4540 * Implementing MASTER construct::
4541 * Implementing CRITICAL construct::
4542 * Implementing ATOMIC construct::
4543 * Implementing FLUSH construct::
4544 * Implementing BARRIER construct::
4545 * Implementing THREADPRIVATE construct::
4546 * Implementing PRIVATE clause::
4547 * Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses::
4548 * Implementing REDUCTION clause::
4549 * Implementing PARALLEL construct::
4550 * Implementing FOR construct::
4551 * Implementing ORDERED construct::
4552 * Implementing SECTIONS construct::
4553 * Implementing SINGLE construct::
4554 * Implementing OpenACC's PARALLEL construct::
4558 @node Implementing MASTER construct
4559 @section Implementing MASTER construct
4562 if (omp_get_thread_num () == 0)
4566 Alternately, we generate two copies of the parallel subfunction
4567 and only include this in the version run by the primary thread.
4568 Surely this is not worthwhile though...
4572 @node Implementing CRITICAL construct
4573 @section Implementing CRITICAL construct
4575 Without a specified name,
4578 void GOMP_critical_start (void);
4579 void GOMP_critical_end (void);
4582 so that we don't get COPY relocations from libgomp to the main
4585 With a specified name, use omp_set_lock and omp_unset_lock with
4586 name being transformed into a variable declared like
4589 omp_lock_t gomp_critical_user_<name> __attribute__((common))
4592 Ideally the ABI would specify that all zero is a valid unlocked
4593 state, and so we wouldn't need to initialize this at
4598 @node Implementing ATOMIC construct
4599 @section Implementing ATOMIC construct
4601 The target should implement the @code{__sync} builtins.
4603 Failing that we could add
4606 void GOMP_atomic_enter (void)
4607 void GOMP_atomic_exit (void)
4610 which reuses the regular lock code, but with yet another lock
4611 object private to the library.
4615 @node Implementing FLUSH construct
4616 @section Implementing FLUSH construct
4618 Expands to the @code{__sync_synchronize} builtin.
4622 @node Implementing BARRIER construct
4623 @section Implementing BARRIER construct
4626 void GOMP_barrier (void)
4630 @node Implementing THREADPRIVATE construct
4631 @section Implementing THREADPRIVATE construct
4633 In _most_ cases we can map this directly to @code{__thread}. Except
4634 that OMP allows constructors for C++ objects. We can either
4635 refuse to support this (how often is it used?) or we can
4636 implement something akin to .ctors.
4638 Even more ideally, this ctor feature is handled by extensions
4639 to the main pthreads library. Failing that, we can have a set
4640 of entry points to register ctor functions to be called.
4644 @node Implementing PRIVATE clause
4645 @section Implementing PRIVATE clause
4647 In association with a PARALLEL, or within the lexical extent
4648 of a PARALLEL block, the variable becomes a local variable in
4649 the parallel subfunction.
4651 In association with FOR or SECTIONS blocks, create a new
4652 automatic variable within the current function. This preserves
4653 the semantic of new variable creation.
4657 @node Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses
4658 @section Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses
4660 This seems simple enough for PARALLEL blocks. Create a private
4661 struct for communicating between the parent and subfunction.
4662 In the parent, copy in values for scalar and "small" structs;
4663 copy in addresses for others TREE_ADDRESSABLE types. In the
4664 subfunction, copy the value into the local variable.
4666 It is not clear what to do with bare FOR or SECTION blocks.
4667 The only thing I can figure is that we do something like:
4670 #pragma omp for firstprivate(x) lastprivate(y)
4671 for (int i = 0; i < n; ++i)
4688 where the "x=x" and "y=y" assignments actually have different
4689 uids for the two variables, i.e. not something you could write
4690 directly in C. Presumably this only makes sense if the "outer"
4691 x and y are global variables.
4693 COPYPRIVATE would work the same way, except the structure
4694 broadcast would have to happen via SINGLE machinery instead.
4698 @node Implementing REDUCTION clause
4699 @section Implementing REDUCTION clause
4701 The private struct mentioned in the previous section should have
4702 a pointer to an array of the type of the variable, indexed by the
4703 thread's @var{team_id}. The thread stores its final value into the
4704 array, and after the barrier, the primary thread iterates over the
4705 array to collect the values.
4708 @node Implementing PARALLEL construct
4709 @section Implementing PARALLEL construct
4712 #pragma omp parallel
4721 void subfunction (void *data)
4728 GOMP_parallel_start (subfunction, &data, num_threads);
4729 subfunction (&data);
4730 GOMP_parallel_end ();
4734 void GOMP_parallel_start (void (*fn)(void *), void *data, unsigned num_threads)
4737 The @var{FN} argument is the subfunction to be run in parallel.
4739 The @var{DATA} argument is a pointer to a structure used to
4740 communicate data in and out of the subfunction, as discussed
4741 above with respect to FIRSTPRIVATE et al.
4743 The @var{NUM_THREADS} argument is 1 if an IF clause is present
4744 and false, or the value of the NUM_THREADS clause, if
4747 The function needs to create the appropriate number of
4748 threads and/or launch them from the dock. It needs to
4749 create the team structure and assign team ids.
4752 void GOMP_parallel_end (void)
4755 Tears down the team and returns us to the previous @code{omp_in_parallel()} state.
4759 @node Implementing FOR construct
4760 @section Implementing FOR construct
4763 #pragma omp parallel for
4764 for (i = lb; i <= ub; i++)
4771 void subfunction (void *data)
4774 while (GOMP_loop_static_next (&_s0, &_e0))
4777 for (i = _s0; i < _e1; i++)
4780 GOMP_loop_end_nowait ();
4783 GOMP_parallel_loop_static (subfunction, NULL, 0, lb, ub+1, 1, 0);
4785 GOMP_parallel_end ();
4789 #pragma omp for schedule(runtime)
4790 for (i = 0; i < n; i++)
4799 if (GOMP_loop_runtime_start (0, n, 1, &_s0, &_e0))
4802 for (i = _s0, i < _e0; i++)
4804 @} while (GOMP_loop_runtime_next (&_s0, _&e0));
4809 Note that while it looks like there is trickiness to propagating
4810 a non-constant STEP, there isn't really. We're explicitly allowed
4811 to evaluate it as many times as we want, and any variables involved
4812 should automatically be handled as PRIVATE or SHARED like any other
4813 variables. So the expression should remain evaluable in the
4814 subfunction. We can also pull it into a local variable if we like,
4815 but since its supposed to remain unchanged, we can also not if we like.
4817 If we have SCHEDULE(STATIC), and no ORDERED, then we ought to be
4818 able to get away with no work-sharing context at all, since we can
4819 simply perform the arithmetic directly in each thread to divide up
4820 the iterations. Which would mean that we wouldn't need to call any
4823 There are separate routines for handling loops with an ORDERED
4824 clause. Bookkeeping for that is non-trivial...
4828 @node Implementing ORDERED construct
4829 @section Implementing ORDERED construct
4832 void GOMP_ordered_start (void)
4833 void GOMP_ordered_end (void)
4838 @node Implementing SECTIONS construct
4839 @section Implementing SECTIONS construct
4844 #pragma omp sections
4858 for (i = GOMP_sections_start (3); i != 0; i = GOMP_sections_next ())
4875 @node Implementing SINGLE construct
4876 @section Implementing SINGLE construct
4890 if (GOMP_single_start ())
4898 #pragma omp single copyprivate(x)
4905 datap = GOMP_single_copy_start ();
4910 GOMP_single_copy_end (&data);
4919 @node Implementing OpenACC's PARALLEL construct
4920 @section Implementing OpenACC's PARALLEL construct
4923 void GOACC_parallel ()
4928 @c ---------------------------------------------------------------------
4930 @c ---------------------------------------------------------------------
4932 @node Reporting Bugs
4933 @chapter Reporting Bugs
4935 Bugs in the GNU Offloading and Multi Processing Runtime Library should
4936 be reported via @uref{https://gcc.gnu.org/bugzilla/, Bugzilla}. Please add
4937 "openacc", or "openmp", or both to the keywords field in the bug
4938 report, as appropriate.
4942 @c ---------------------------------------------------------------------
4943 @c GNU General Public License
4944 @c ---------------------------------------------------------------------
4946 @include gpl_v3.texi
4950 @c ---------------------------------------------------------------------
4951 @c GNU Free Documentation License
4952 @c ---------------------------------------------------------------------
4958 @c ---------------------------------------------------------------------
4959 @c Funding Free Software
4960 @c ---------------------------------------------------------------------
4962 @include funding.texi
4964 @c ---------------------------------------------------------------------
4966 @c ---------------------------------------------------------------------
4969 @unnumbered Library Index