1 \input texinfo @c -*-texinfo-*-
4 @setfilename libgomp.info
10 Copyright @copyright{} 2006, 2007, 2008, 2010, 2011 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 OpenMP runtime library
37 This manual documents the GNU implementation of the OpenMP API for
38 multi-platform shared-memory parallel programming in C/C++ and Fortran.
40 Published by the Free Software Foundation
41 51 Franklin Street, Fifth Floor
42 Boston, MA 02110-1301 USA
48 @setchapternewpage odd
51 @title The GNU OpenMP Implementation
53 @vskip 0pt plus 1filll
54 @comment For the @value{version-GCC} Version*
56 Published by the Free Software Foundation @*
57 51 Franklin Street, Fifth Floor@*
58 Boston, MA 02110-1301, USA@*
72 This manual documents the usage of libgomp, the GNU implementation of the
73 @uref{http://www.openmp.org, OpenMP} Application Programming Interface (API)
74 for multi-platform shared-memory parallel programming in C/C++ and Fortran.
79 @comment When you add a new menu item, please keep the right hand
80 @comment aligned to the same column. Do not use tabs. This provides
81 @comment better formatting.
84 * Enabling OpenMP:: How to enable OpenMP for your applications.
85 * Runtime Library Routines:: The OpenMP runtime application programming
87 * Environment Variables:: Influencing runtime behavior with environment
89 * The libgomp ABI:: Notes on the external ABI presented by libgomp.
90 * Reporting Bugs:: How to report bugs in GNU OpenMP.
91 * Copying:: GNU general public license says
92 how you can copy and share libgomp.
93 * GNU Free Documentation License::
94 How you can copy and share this manual.
95 * Funding:: How to help assure continued work for free
97 * Index:: Index of this documentation.
101 @c ---------------------------------------------------------------------
103 @c ---------------------------------------------------------------------
105 @node Enabling OpenMP
106 @chapter Enabling OpenMP
108 To activate the OpenMP extensions for C/C++ and Fortran, the compile-time
109 flag @command{-fopenmp} must be specified. This enables the OpenMP directive
110 @code{#pragma omp} in C/C++ and @code{!$omp} directives in free form,
111 @code{c$omp}, @code{*$omp} and @code{!$omp} directives in fixed form,
112 @code{!$} conditional compilation sentinels in free form and @code{c$},
113 @code{*$} and @code{!$} sentinels in fixed form, for Fortran. The flag also
114 arranges for automatic linking of the OpenMP runtime library
115 (@ref{Runtime Library Routines}).
117 A complete description of all OpenMP directives accepted may be found in
118 the @uref{http://www.openmp.org, OpenMP Application Program Interface} manual,
122 @c ---------------------------------------------------------------------
123 @c Runtime Library Routines
124 @c ---------------------------------------------------------------------
126 @node Runtime Library Routines
127 @chapter Runtime Library Routines
129 The runtime routines described here are defined by section 3 of the OpenMP
130 specifications in version 3.0. The routines are structured in following
133 Control threads, processors and the parallel environment.
136 * omp_get_active_level:: Number of active parallel regions
137 * omp_get_ancestor_thread_num:: Ancestor thread ID
138 * omp_get_dynamic:: Dynamic teams setting
139 * omp_get_level:: Number of parallel regions
140 * omp_get_max_active_levels:: Maximum number of active regions
141 * omp_get_max_threads:: Maximum number of threads of parallel region
142 * omp_get_nested:: Nested parallel regions
143 * omp_get_num_procs:: Number of processors online
144 * omp_get_num_threads:: Size of the active team
145 * omp_get_schedule:: Obtain the runtime scheduling method
146 * omp_get_team_size:: Number of threads in a team
147 * omp_get_thread_limit:: Maximum number of threads
148 * omp_get_thread_num:: Current thread ID
149 * omp_in_parallel:: Whether a parallel region is active
150 * omp_set_dynamic:: Enable/disable dynamic teams
151 * omp_set_max_active_levels:: Limits the number of active parallel regions
152 * omp_set_nested:: Enable/disable nested parallel regions
153 * omp_set_num_threads:: Set upper team size limit
154 * omp_set_schedule:: Set the runtime scheduling method
157 Initialize, set, test, unset and destroy simple and nested locks.
160 * omp_init_lock:: Initialize simple lock
161 * omp_set_lock:: Wait for and set simple lock
162 * omp_test_lock:: Test and set simple lock if available
163 * omp_unset_lock:: Unset simple lock
164 * omp_destroy_lock:: Destroy simple lock
165 * omp_init_nest_lock:: Initialize nested lock
166 * omp_set_nest_lock:: Wait for and set simple lock
167 * omp_test_nest_lock:: Test and set nested lock if available
168 * omp_unset_nest_lock:: Unset nested lock
169 * omp_destroy_nest_lock:: Destroy nested lock
172 Portable, thread-based, wall clock timer.
175 * omp_get_wtick:: Get timer precision.
176 * omp_get_wtime:: Elapsed wall clock time.
181 @node omp_get_active_level
182 @section @code{omp_get_active_level} -- Number of parallel regions
184 @item @emph{Description}:
185 This function returns the nesting level for the active parallel blocks,
186 which enclose the calling call.
189 @multitable @columnfractions .20 .80
190 @item @emph{Prototype}: @tab @code{int omp_get_active_level(void);}
193 @item @emph{Fortran}:
194 @multitable @columnfractions .20 .80
195 @item @emph{Interface}: @tab @code{integer function omp_get_active_level()}
198 @item @emph{See also}:
199 @ref{omp_get_level}, @ref{omp_get_max_active_levels}, @ref{omp_set_max_active_levels}
201 @item @emph{Reference}:
202 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.19.
207 @node omp_get_ancestor_thread_num
208 @section @code{omp_get_ancestor_thread_num} -- Ancestor thread ID
210 @item @emph{Description}:
211 This function returns the thread identification number for the given
212 nesting level of the current thread. For values of @var{level} outside
213 zero to @code{omp_get_level} -1 is returned; if @var{level} is
214 @code{omp_get_level} the result is identical to @code{omp_get_thread_num}.
217 @multitable @columnfractions .20 .80
218 @item @emph{Prototype}: @tab @code{int omp_get_ancestor_thread_num(int level);}
221 @item @emph{Fortran}:
222 @multitable @columnfractions .20 .80
223 @item @emph{Interface}: @tab @code{integer function omp_get_ancestor_thread_num(level)}
224 @item @tab @code{integer level}
227 @item @emph{See also}:
228 @ref{omp_get_level}, @ref{omp_get_thread_num}, @ref{omp_get_team_size}
230 @item @emph{Reference}:
231 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.17.
236 @node omp_get_dynamic
237 @section @code{omp_get_dynamic} -- Dynamic teams setting
239 @item @emph{Description}:
240 This function returns @code{true} if enabled, @code{false} otherwise.
241 Here, @code{true} and @code{false} represent their language-specific
244 The dynamic team setting may be initialized at startup by the
245 @code{OMP_DYNAMIC} environment variable or at runtime using
246 @code{omp_set_dynamic}. If undefined, dynamic adjustment is
250 @multitable @columnfractions .20 .80
251 @item @emph{Prototype}: @tab @code{int omp_get_dynamic(void);}
254 @item @emph{Fortran}:
255 @multitable @columnfractions .20 .80
256 @item @emph{Interface}: @tab @code{logical function omp_get_dynamic()}
259 @item @emph{See also}:
260 @ref{omp_set_dynamic}, @ref{OMP_DYNAMIC}
262 @item @emph{Reference}:
263 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.8.
269 @section @code{omp_get_level} -- Obtain the current nesting level
271 @item @emph{Description}:
272 This function returns the nesting level for the parallel blocks,
273 which enclose the calling call.
276 @multitable @columnfractions .20 .80
277 @item @emph{Prototype}: @tab @code{int omp_get_level(void);}
280 @item @emph{Fortran}:
281 @multitable @columnfractions .20 .80
282 @item @emph{Interface}: @tab @code{integer function omp_level()}
285 @item @emph{See also}:
286 @ref{omp_get_active_level}
288 @item @emph{Reference}:
289 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.16.
294 @node omp_get_max_active_levels
295 @section @code{omp_get_max_active_levels} -- Maximum number of active regions
297 @item @emph{Description}:
298 This function obtains the maximum allowed number of nested, active parallel regions.
301 @multitable @columnfractions .20 .80
302 @item @emph{Prototype}: @tab @code{int omp_get_max_active_levels(void);}
305 @item @emph{Fortran}:
306 @multitable @columnfractions .20 .80
307 @item @emph{Interface}: @tab @code{integer function omp_get_max_active_levels()}
310 @item @emph{See also}:
311 @ref{omp_set_max_active_levels}, @ref{omp_get_active_level}
313 @item @emph{Reference}:
314 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.14.
319 @node omp_get_max_threads
320 @section @code{omp_get_max_threads} -- Maximum number of threads of parallel region
322 @item @emph{Description}:
323 Return the maximum number of threads used for the current parallel region
324 that does not use the clause @code{num_threads}.
327 @multitable @columnfractions .20 .80
328 @item @emph{Prototype}: @tab @code{int omp_get_max_threads(void);}
331 @item @emph{Fortran}:
332 @multitable @columnfractions .20 .80
333 @item @emph{Interface}: @tab @code{integer function omp_get_max_threads()}
336 @item @emph{See also}:
337 @ref{omp_set_num_threads}, @ref{omp_set_dynamic}, @ref{omp_get_thread_limit}
339 @item @emph{Reference}:
340 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.3.
346 @section @code{omp_get_nested} -- Nested parallel regions
348 @item @emph{Description}:
349 This function returns @code{true} if nested parallel regions are
350 enabled, @code{false} otherwise. Here, @code{true} and @code{false}
351 represent their language-specific counterparts.
353 Nested parallel regions may be initialized at startup by the
354 @code{OMP_NESTED} environment variable or at runtime using
355 @code{omp_set_nested}. If undefined, nested parallel regions are
359 @multitable @columnfractions .20 .80
360 @item @emph{Prototype}: @tab @code{int omp_get_nested(void);}
363 @item @emph{Fortran}:
364 @multitable @columnfractions .20 .80
365 @item @emph{Interface}: @tab @code{logical function omp_get_nested()}
368 @item @emph{See also}:
369 @ref{omp_set_nested}, @ref{OMP_NESTED}
371 @item @emph{Reference}:
372 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.10.
377 @node omp_get_num_procs
378 @section @code{omp_get_num_procs} -- Number of processors online
380 @item @emph{Description}:
381 Returns the number of processors online.
384 @multitable @columnfractions .20 .80
385 @item @emph{Prototype}: @tab @code{int omp_get_num_procs(void);}
388 @item @emph{Fortran}:
389 @multitable @columnfractions .20 .80
390 @item @emph{Interface}: @tab @code{integer function omp_get_num_procs()}
393 @item @emph{Reference}:
394 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.5.
399 @node omp_get_num_threads
400 @section @code{omp_get_num_threads} -- Size of the active team
402 @item @emph{Description}:
403 Returns the number of threads in the current team. In a sequential section of
404 the program @code{omp_get_num_threads} returns 1.
406 The default team size may be initialized at startup by the
407 @code{OMP_NUM_THREADS} environment variable. At runtime, the size
408 of the current team may be set either by the @code{NUM_THREADS}
409 clause or by @code{omp_set_num_threads}. If none of the above were
410 used to define a specific value and @code{OMP_DYNAMIC} is disabled,
411 one thread per CPU online is used.
414 @multitable @columnfractions .20 .80
415 @item @emph{Prototype}: @tab @code{int omp_get_num_threads(void);}
418 @item @emph{Fortran}:
419 @multitable @columnfractions .20 .80
420 @item @emph{Interface}: @tab @code{integer function omp_get_num_threads()}
423 @item @emph{See also}:
424 @ref{omp_get_max_threads}, @ref{omp_set_num_threads}, @ref{OMP_NUM_THREADS}
426 @item @emph{Reference}:
427 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.2.
432 @node omp_get_schedule
433 @section @code{omp_get_schedule} -- Obtain the runtime scheduling method
435 @item @emph{Description}:
436 Obtain the runtime scheduling method. The @var{kind} argument will be
437 set to the value @code{omp_sched_static}, @code{omp_sched_dynamic},
438 @code{omp_sched_guided} or @code{omp_sched_auto}. The second argument,
439 @var{modifier}, is set to the chunk size.
442 @multitable @columnfractions .20 .80
443 @item @emph{Prototype}: @tab @code{omp_schedule(omp_sched_t *kind, int *modifier);}
446 @item @emph{Fortran}:
447 @multitable @columnfractions .20 .80
448 @item @emph{Interface}: @tab @code{subroutine omp_schedule(kind, modifier)}
449 @item @tab @code{integer(kind=omp_sched_kind) kind}
450 @item @tab @code{integer modifier}
453 @item @emph{See also}:
454 @ref{omp_set_schedule}, @ref{OMP_SCHEDULE}
456 @item @emph{Reference}:
457 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.12.
462 @node omp_get_team_size
463 @section @code{omp_get_team_size} -- Number of threads in a team
465 @item @emph{Description}:
466 This function returns the number of threads in a thread team to which
467 either the current thread or its ancestor belongs. For values of @var{level}
468 outside zero to @code{omp_get_level}, -1 is returned; if @var{level} is zero,
469 1 is returned, and for @code{omp_get_level}, the result is identical
470 to @code{omp_get_num_threads}.
473 @multitable @columnfractions .20 .80
474 @item @emph{Prototype}: @tab @code{int omp_get_team_size(int level);}
477 @item @emph{Fortran}:
478 @multitable @columnfractions .20 .80
479 @item @emph{Interface}: @tab @code{integer function omp_get_team_size(level)}
480 @item @tab @code{integer level}
483 @item @emph{See also}:
484 @ref{omp_get_num_threads}, @ref{omp_get_level}, @ref{omp_get_ancestor_thread_num}
486 @item @emph{Reference}:
487 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.18.
492 @node omp_get_thread_limit
493 @section @code{omp_get_thread_limit} -- Maximum number of threads
495 @item @emph{Description}:
496 Return the maximum number of threads of the program.
499 @multitable @columnfractions .20 .80
500 @item @emph{Prototype}: @tab @code{int omp_get_thread_limit(void);}
503 @item @emph{Fortran}:
504 @multitable @columnfractions .20 .80
505 @item @emph{Interface}: @tab @code{integer function omp_get_thread_limit()}
508 @item @emph{See also}:
509 @ref{omp_get_max_threads}, @ref{OMP_THREAD_LIMIT}
511 @item @emph{Reference}:
512 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.13.
517 @node omp_get_thread_num
518 @section @code{omp_get_thread_num} -- Current thread ID
520 @item @emph{Description}:
521 Returns a unique thread identification number within the current team.
522 In a sequential parts of the program, @code{omp_get_thread_num}
523 always returns 0. In parallel regions the return value varies
524 from 0 to @code{omp_get_num_threads}-1 inclusive. The return
525 value of the master thread of a team is always 0.
528 @multitable @columnfractions .20 .80
529 @item @emph{Prototype}: @tab @code{int omp_get_thread_num(void);}
532 @item @emph{Fortran}:
533 @multitable @columnfractions .20 .80
534 @item @emph{Interface}: @tab @code{integer function omp_get_thread_num()}
537 @item @emph{See also}:
538 @ref{omp_get_num_threads}, @ref{omp_get_ancestor_thread_num}
540 @item @emph{Reference}:
541 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.4.
546 @node omp_in_parallel
547 @section @code{omp_in_parallel} -- Whether a parallel region is active
549 @item @emph{Description}:
550 This function returns @code{true} if currently running in parallel,
551 @code{false} otherwise. Here, @code{true} and @code{false} represent
552 their language-specific counterparts.
555 @multitable @columnfractions .20 .80
556 @item @emph{Prototype}: @tab @code{int omp_in_parallel(void);}
559 @item @emph{Fortran}:
560 @multitable @columnfractions .20 .80
561 @item @emph{Interface}: @tab @code{logical function omp_in_parallel()}
564 @item @emph{Reference}:
565 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.6.
569 @node omp_set_dynamic
570 @section @code{omp_set_dynamic} -- Enable/disable dynamic teams
572 @item @emph{Description}:
573 Enable or disable the dynamic adjustment of the number of threads
574 within a team. The function takes the language-specific equivalent
575 of @code{true} and @code{false}, where @code{true} enables dynamic
576 adjustment of team sizes and @code{false} disables it.
579 @multitable @columnfractions .20 .80
580 @item @emph{Prototype}: @tab @code{void omp_set_dynamic(int set);}
583 @item @emph{Fortran}:
584 @multitable @columnfractions .20 .80
585 @item @emph{Interface}: @tab @code{subroutine omp_set_dynamic(set)}
586 @item @tab @code{logical, intent(in) :: set}
589 @item @emph{See also}:
590 @ref{OMP_DYNAMIC}, @ref{omp_get_dynamic}
592 @item @emph{Reference}:
593 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.7.
598 @node omp_set_max_active_levels
599 @section @code{omp_set_max_active_levels} -- Limits the number of active parallel regions
601 @item @emph{Description}:
602 This function limits the maximum allowed number of nested, active
606 @multitable @columnfractions .20 .80
607 @item @emph{Prototype}: @tab @code{void omp_set_max_active_levels(int max_levels);}
610 @item @emph{Fortran}:
611 @multitable @columnfractions .20 .80
612 @item @emph{Interface}: @tab @code{subroutine omp_set_max_active_levels(max_levels)}
613 @item @tab @code{integer max_levels}
616 @item @emph{See also}:
617 @ref{omp_get_max_active_levels}, @ref{omp_get_active_level}
619 @item @emph{Reference}:
620 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.14.
626 @section @code{omp_set_nested} -- Enable/disable nested parallel regions
628 @item @emph{Description}:
629 Enable or disable nested parallel regions, i.e., whether team members
630 are allowed to create new teams. The function takes the language-specific
631 equivalent of @code{true} and @code{false}, where @code{true} enables
632 dynamic adjustment of team sizes and @code{false} disables it.
635 @multitable @columnfractions .20 .80
636 @item @emph{Prototype}: @tab @code{void omp_set_nested(int set);}
639 @item @emph{Fortran}:
640 @multitable @columnfractions .20 .80
641 @item @emph{Interface}: @tab @code{subroutine omp_set_nested(set)}
642 @item @tab @code{logical, intent(in) :: set}
645 @item @emph{See also}:
646 @ref{OMP_NESTED}, @ref{omp_get_nested}
648 @item @emph{Reference}:
649 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.9.
654 @node omp_set_num_threads
655 @section @code{omp_set_num_threads} -- Set upper team size limit
657 @item @emph{Description}:
658 Specifies the number of threads used by default in subsequent parallel
659 sections, if those do not specify a @code{num_threads} clause. The
660 argument of @code{omp_set_num_threads} shall be a positive integer.
663 @multitable @columnfractions .20 .80
664 @item @emph{Prototype}: @tab @code{void omp_set_num_threads(int n);}
667 @item @emph{Fortran}:
668 @multitable @columnfractions .20 .80
669 @item @emph{Interface}: @tab @code{subroutine omp_set_num_threads(n)}
670 @item @tab @code{integer, intent(in) :: n}
673 @item @emph{See also}:
674 @ref{OMP_NUM_THREADS}, @ref{omp_get_num_threads}, @ref{omp_get_max_threads}
676 @item @emph{Reference}:
677 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.1.
682 @node omp_set_schedule
683 @section @code{omp_set_schedule} -- Set the runtime scheduling method
685 @item @emph{Description}:
686 Sets the runtime scheduling method. The @var{kind} argument can have the
687 value @code{omp_sched_static}, @code{omp_sched_dynamic},
688 @code{omp_sched_guided} or @code{omp_sched_auto}. Except for
689 @code{omp_sched_auto}, the chunk size is set to the value of
690 @var{modifier} if positive, or to the default value if zero or negative.
691 For @code{omp_sched_auto} the @var{modifier} argument is ignored.
694 @multitable @columnfractions .20 .80
695 @item @emph{Prototype}: @tab @code{int omp_set_schedule(omp_sched_t *kind, int *modifier);}
698 @item @emph{Fortran}:
699 @multitable @columnfractions .20 .80
700 @item @emph{Interface}: @tab @code{subroutine omp_set_schedule(kind, modifier)}
701 @item @tab @code{integer(kind=omp_sched_kind) kind}
702 @item @tab @code{integer modifier}
705 @item @emph{See also}:
706 @ref{omp_get_schedule}
709 @item @emph{Reference}:
710 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.2.11.
716 @section @code{omp_init_lock} -- Initialize simple lock
718 @item @emph{Description}:
719 Initialize a simple lock. After initialization, the lock is in
723 @multitable @columnfractions .20 .80
724 @item @emph{Prototype}: @tab @code{void omp_init_lock(omp_lock_t *lock);}
727 @item @emph{Fortran}:
728 @multitable @columnfractions .20 .80
729 @item @emph{Interface}: @tab @code{subroutine omp_init_lock(lock)}
730 @item @tab @code{integer(omp_lock_kind), intent(out) :: lock}
733 @item @emph{See also}:
734 @ref{omp_destroy_lock}
736 @item @emph{Reference}:
737 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.3.1.
743 @section @code{omp_set_lock} -- Wait for and set simple lock
745 @item @emph{Description}:
746 Before setting a simple lock, the lock variable must be initialized by
747 @code{omp_init_lock}. The calling thread is blocked until the lock
748 is available. If the lock is already held by the current thread,
752 @multitable @columnfractions .20 .80
753 @item @emph{Prototype}: @tab @code{void omp_set_lock(omp_lock_t *lock);}
756 @item @emph{Fortran}:
757 @multitable @columnfractions .20 .80
758 @item @emph{Interface}: @tab @code{subroutine omp_set_lock(lock)}
759 @item @tab @code{integer(omp_lock_kind), intent(inout) :: lock}
762 @item @emph{See also}:
763 @ref{omp_init_lock}, @ref{omp_test_lock}, @ref{omp_unset_lock}
765 @item @emph{Reference}:
766 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.3.3.
772 @section @code{omp_test_lock} -- Test and set simple lock if available
774 @item @emph{Description}:
775 Before setting a simple lock, the lock variable must be initialized by
776 @code{omp_init_lock}. Contrary to @code{omp_set_lock}, @code{omp_test_lock}
777 does not block if the lock is not available. This function returns
778 @code{true} upon success, @code{false} otherwise. Here, @code{true} and
779 @code{false} represent their language-specific counterparts.
782 @multitable @columnfractions .20 .80
783 @item @emph{Prototype}: @tab @code{int omp_test_lock(omp_lock_t *lock);}
786 @item @emph{Fortran}:
787 @multitable @columnfractions .20 .80
788 @item @emph{Interface}: @tab @code{subroutine omp_test_lock(lock)}
789 @item @tab @code{logical(omp_logical_kind) :: omp_test_lock}
790 @item @tab @code{integer(omp_lock_kind), intent(inout) :: lock}
793 @item @emph{See also}:
794 @ref{omp_init_lock}, @ref{omp_set_lock}, @ref{omp_set_lock}
796 @item @emph{Reference}:
797 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.3.5.
803 @section @code{omp_unset_lock} -- Unset simple lock
805 @item @emph{Description}:
806 A simple lock about to be unset must have been locked by @code{omp_set_lock}
807 or @code{omp_test_lock} before. In addition, the lock must be held by the
808 thread calling @code{omp_unset_lock}. Then, the lock becomes unlocked. If one
809 or more threads attempted to set the lock before, one of them is chosen to,
810 again, set the lock for itself.
813 @multitable @columnfractions .20 .80
814 @item @emph{Prototype}: @tab @code{void omp_unset_lock(omp_lock_t *lock);}
817 @item @emph{Fortran}:
818 @multitable @columnfractions .20 .80
819 @item @emph{Interface}: @tab @code{subroutine omp_unset_lock(lock)}
820 @item @tab @code{integer(omp_lock_kind), intent(inout) :: lock}
823 @item @emph{See also}:
824 @ref{omp_set_lock}, @ref{omp_test_lock}
826 @item @emph{Reference}:
827 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.3.4.
832 @node omp_destroy_lock
833 @section @code{omp_destroy_lock} -- Destroy simple lock
835 @item @emph{Description}:
836 Destroy a simple lock. In order to be destroyed, a simple lock must be
837 in the unlocked state.
840 @multitable @columnfractions .20 .80
841 @item @emph{Prototype}: @tab @code{void omp_destroy_lock(omp_lock_t *lock);}
844 @item @emph{Fortran}:
845 @multitable @columnfractions .20 .80
846 @item @emph{Interface}: @tab @code{subroutine omp_destroy_lock(lock)}
847 @item @tab @code{integer(omp_lock_kind), intent(inout) :: lock}
850 @item @emph{See also}:
853 @item @emph{Reference}:
854 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.3.2.
859 @node omp_init_nest_lock
860 @section @code{omp_init_nest_lock} -- Initialize nested lock
862 @item @emph{Description}:
863 Initialize a nested lock. After initialization, the lock is in
864 an unlocked state and the nesting count is set to zero.
867 @multitable @columnfractions .20 .80
868 @item @emph{Prototype}: @tab @code{void omp_init_nest_lock(omp_nest_lock_t *lock);}
871 @item @emph{Fortran}:
872 @multitable @columnfractions .20 .80
873 @item @emph{Interface}: @tab @code{subroutine omp_init_nest_lock(lock)}
874 @item @tab @code{integer(omp_nest_lock_kind), intent(out) :: lock}
877 @item @emph{See also}:
878 @ref{omp_destroy_nest_lock}
880 @item @emph{Reference}:
881 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.3.1.
885 @node omp_set_nest_lock
886 @section @code{omp_set_nest_lock} -- Wait for and set nested lock
888 @item @emph{Description}:
889 Before setting a nested lock, the lock variable must be initialized by
890 @code{omp_init_nest_lock}. The calling thread is blocked until the lock
891 is available. If the lock is already held by the current thread, the
892 nesting count for the lock in incremented.
895 @multitable @columnfractions .20 .80
896 @item @emph{Prototype}: @tab @code{void omp_set_nest_lock(omp_nest_lock_t *lock);}
899 @item @emph{Fortran}:
900 @multitable @columnfractions .20 .80
901 @item @emph{Interface}: @tab @code{subroutine omp_set_nest_lock(lock)}
902 @item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: lock}
905 @item @emph{See also}:
906 @ref{omp_init_nest_lock}, @ref{omp_unset_nest_lock}
908 @item @emph{Reference}:
909 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.3.3.
914 @node omp_test_nest_lock
915 @section @code{omp_test_nest_lock} -- Test and set nested lock if available
917 @item @emph{Description}:
918 Before setting a nested lock, the lock variable must be initialized by
919 @code{omp_init_nest_lock}. Contrary to @code{omp_set_nest_lock},
920 @code{omp_test_nest_lock} does not block if the lock is not available.
921 If the lock is already held by the current thread, the new nesting count
922 is returned. Otherwise, the return value equals zero.
925 @multitable @columnfractions .20 .80
926 @item @emph{Prototype}: @tab @code{int omp_test_nest_lock(omp_nest_lock_t *lock);}
929 @item @emph{Fortran}:
930 @multitable @columnfractions .20 .80
931 @item @emph{Interface}: @tab @code{integer function omp_test_nest_lock(lock)}
932 @item @tab @code{integer(omp_integer_kind) :: omp_test_nest_lock}
933 @item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: lock}
937 @item @emph{See also}:
938 @ref{omp_init_lock}, @ref{omp_set_lock}, @ref{omp_set_lock}
940 @item @emph{Reference}:
941 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.3.5.
946 @node omp_unset_nest_lock
947 @section @code{omp_unset_nest_lock} -- Unset nested lock
949 @item @emph{Description}:
950 A nested lock about to be unset must have been locked by @code{omp_set_nested_lock}
951 or @code{omp_test_nested_lock} before. In addition, the lock must be held by the
952 thread calling @code{omp_unset_nested_lock}. If the nesting count drops to zero, the
953 lock becomes unlocked. If one ore more threads attempted to set the lock before,
954 one of them is chosen to, again, set the lock for itself.
957 @multitable @columnfractions .20 .80
958 @item @emph{Prototype}: @tab @code{void omp_unset_nest_lock(omp_nest_lock_t *lock);}
961 @item @emph{Fortran}:
962 @multitable @columnfractions .20 .80
963 @item @emph{Interface}: @tab @code{subroutine omp_unset_nest_lock(lock)}
964 @item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: lock}
967 @item @emph{See also}:
968 @ref{omp_set_nest_lock}
970 @item @emph{Reference}:
971 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.3.4.
976 @node omp_destroy_nest_lock
977 @section @code{omp_destroy_nest_lock} -- Destroy nested lock
979 @item @emph{Description}:
980 Destroy a nested lock. In order to be destroyed, a nested lock must be
981 in the unlocked state and its nesting count must equal zero.
984 @multitable @columnfractions .20 .80
985 @item @emph{Prototype}: @tab @code{void omp_destroy_nest_lock(omp_nest_lock_t *);}
988 @item @emph{Fortran}:
989 @multitable @columnfractions .20 .80
990 @item @emph{Interface}: @tab @code{subroutine omp_destroy_nest_lock(lock)}
991 @item @tab @code{integer(omp_nest_lock_kind), intent(inout) :: lock}
994 @item @emph{See also}:
997 @item @emph{Reference}:
998 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.3.2.
1004 @section @code{omp_get_wtick} -- Get timer precision
1006 @item @emph{Description}:
1007 Gets the timer precision, i.e., the number of seconds between two
1008 successive clock ticks.
1011 @multitable @columnfractions .20 .80
1012 @item @emph{Prototype}: @tab @code{double omp_get_wtick(void);}
1015 @item @emph{Fortran}:
1016 @multitable @columnfractions .20 .80
1017 @item @emph{Interface}: @tab @code{double precision function omp_get_wtick()}
1020 @item @emph{See also}:
1023 @item @emph{Reference}:
1024 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.4.2.
1030 @section @code{omp_get_wtime} -- Elapsed wall clock time
1032 @item @emph{Description}:
1033 Elapsed wall clock time in seconds. The time is measured per thread, no
1034 guarantee can be made that two distinct threads measure the same time.
1035 Time is measured from some "time in the past", which is an arbitrary time
1036 guaranteed not to change during the execution of the program.
1039 @multitable @columnfractions .20 .80
1040 @item @emph{Prototype}: @tab @code{double omp_get_wtime(void);}
1043 @item @emph{Fortran}:
1044 @multitable @columnfractions .20 .80
1045 @item @emph{Interface}: @tab @code{double precision function omp_get_wtime()}
1048 @item @emph{See also}:
1051 @item @emph{Reference}:
1052 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 3.4.1.
1057 @c ---------------------------------------------------------------------
1058 @c Environment Variables
1059 @c ---------------------------------------------------------------------
1061 @node Environment Variables
1062 @chapter Environment Variables
1064 The variables @env{OMP_DYNAMIC}, @env{OMP_MAX_ACTIVE_LEVELS},
1065 @env{OMP_NESTED}, @env{OMP_NUM_THREADS}, @env{OMP_SCHEDULE},
1066 @env{OMP_STACKSIZE},@env{OMP_THREAD_LIMIT} and @env{OMP_WAIT_POLICY}
1067 are defined by section 4 of the OpenMP specifications in version 3.0,
1068 while @env{GOMP_CPU_AFFINITY} and @env{GOMP_STACKSIZE} are GNU
1072 * OMP_DYNAMIC:: Dynamic adjustment of threads
1073 * OMP_MAX_ACTIVE_LEVELS:: Set the maximum number of nested parallel regions
1074 * OMP_NESTED:: Nested parallel regions
1075 * OMP_NUM_THREADS:: Specifies the number of threads to use
1076 * OMP_STACKSIZE:: Set default thread stack size
1077 * OMP_SCHEDULE:: How threads are scheduled
1078 * OMP_THREAD_LIMIT:: Set the maximum number of threads
1079 * OMP_WAIT_POLICY:: How waiting threads are handled
1080 * GOMP_CPU_AFFINITY:: Bind threads to specific CPUs
1081 * GOMP_STACKSIZE:: Set default thread stack size
1086 @section @env{OMP_DYNAMIC} -- Dynamic adjustment of threads
1087 @cindex Environment Variable
1089 @item @emph{Description}:
1090 Enable or disable the dynamic adjustment of the number of threads
1091 within a team. The value of this environment variable shall be
1092 @code{TRUE} or @code{FALSE}. If undefined, dynamic adjustment is
1093 disabled by default.
1095 @item @emph{See also}:
1096 @ref{omp_set_dynamic}
1098 @item @emph{Reference}:
1099 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 4.3
1104 @node OMP_MAX_ACTIVE_LEVELS
1105 @section @env{OMP_MAX_ACTIVE_LEVELS} -- Set the maximum number of nested parallel regions
1106 @cindex Environment Variable
1108 @item @emph{Description}:
1109 Specifies the initial value for the maximum number of nested parallel
1110 regions. The value of this variable shall be positive integer.
1111 If undefined, the number of active levels is unlimited.
1113 @item @emph{See also}:
1114 @ref{omp_set_max_active_levels}
1116 @item @emph{Reference}:
1117 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 4.7
1123 @section @env{OMP_NESTED} -- Nested parallel regions
1124 @cindex Environment Variable
1125 @cindex Implementation specific setting
1127 @item @emph{Description}:
1128 Enable or disable nested parallel regions, i.e., whether team members
1129 are allowed to create new teams. The value of this environment variable
1130 shall be @code{TRUE} or @code{FALSE}. If undefined, nested parallel
1131 regions are disabled by default.
1133 @item @emph{See also}:
1134 @ref{omp_set_nested}
1136 @item @emph{Reference}:
1137 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 4.4
1142 @node OMP_NUM_THREADS
1143 @section @env{OMP_NUM_THREADS} -- Specifies the number of threads to use
1144 @cindex Environment Variable
1145 @cindex Implementation specific setting
1147 @item @emph{Description}:
1148 Specifies the default number of threads to use in parallel regions. The
1149 value of this variable shall be a positive integer. If undefined one thread
1152 @item @emph{See also}:
1153 @ref{omp_set_num_threads}
1155 @item @emph{Reference}:
1156 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 4.2
1162 @section @env{OMP_SCHEDULE} -- How threads are scheduled
1163 @cindex Environment Variable
1164 @cindex Implementation specific setting
1166 @item @emph{Description}:
1167 Allows to specify @code{schedule type} and @code{chunk size}.
1168 The value of the variable shall have the form: @code{type[,chunk]} where
1169 @code{type} is one of @code{static}, @code{dynamic}, @code{guided} or @code{auto}
1170 The optional @code{chunk} size shall be a positive integer. If undefined,
1171 dynamic scheduling and a chunk size of 1 is used.
1173 @item @emph{See also}:
1174 @ref{omp_set_schedule}
1176 @item @emph{Reference}:
1177 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, sections 2.5.1 and 4.1
1183 @section @env{OMP_STACKSIZE} -- Set default thread stack size
1184 @cindex Environment Variable
1186 @item @emph{Description}:
1187 Set the default thread stack size in kilobytes, unless the number
1188 is suffixed by @code{B}, @code{K}, @code{M} or @code{G}, in which
1189 case the size is, respectively, in bytes, kilobytes, megabytes
1190 or gigabytes. This is different from @code{pthread_attr_setstacksize}
1191 which gets the number of bytes as an argument. If the stacksize cannot
1192 be set due to system constraints, an error is reported and the initial
1193 stacksize is left unchanged. If undefined, the stack size is system
1196 @item @emph{Reference}:
1197 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, sections 4.5
1202 @node OMP_THREAD_LIMIT
1203 @section @env{OMP_THREAD_LIMIT} -- Set the maximum number of threads
1204 @cindex Environment Variable
1206 @item @emph{Description}:
1207 Specifies the number of threads to use for the whole program. The
1208 value of this variable shall be a positive integer. If undefined,
1209 the number of threads is not limited.
1211 @item @emph{See also}:
1212 @ref{OMP_NUM_THREADS}
1213 @ref{omp_get_thread_limit}
1215 @item @emph{Reference}:
1216 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, section 4.8
1221 @node OMP_WAIT_POLICY
1222 @section @env{OMP_WAIT_POLICY} -- How waiting threads are handled
1223 @cindex Environment Variable
1225 @item @emph{Description}:
1226 Specifies whether waiting threads should be active or passive. If
1227 the value is @code{PASSIVE}, waiting threads should not consume CPU
1228 power while waiting; while the value is @code{ACTIVE} specifies that
1231 @item @emph{Reference}:
1232 @uref{http://www.openmp.org/, OpenMP specifications v3.0}, sections 4.6
1237 @node GOMP_CPU_AFFINITY
1238 @section @env{GOMP_CPU_AFFINITY} -- Bind threads to specific CPUs
1239 @cindex Environment Variable
1241 @item @emph{Description}:
1242 Binds threads to specific CPUs. The variable should contain a space-separated
1243 or comma-separated list of CPUs. This list may contain different kinds of
1244 entries: either single CPU numbers in any order, a range of CPUs (M-N)
1245 or a range with some stride (M-N:S). CPU numbers are zero based. For example,
1246 @code{GOMP_CPU_AFFINITY="0 3 1-2 4-15:2"} will bind the initial thread
1247 to CPU 0, the second to CPU 3, the third to CPU 1, the fourth to
1248 CPU 2, the fifth to CPU 4, the sixth through tenth to CPUs 6, 8, 10, 12,
1249 and 14 respectively and then start assigning back from the beginning of
1250 the list. @code{GOMP_CPU_AFFINITY=0} binds all threads to CPU 0.
1252 There is no GNU OpenMP library routine to determine whether a CPU affinity
1253 specification is in effect. As a workaround, language-specific library
1254 functions, e.g., @code{getenv} in C or @code{GET_ENVIRONMENT_VARIABLE} in
1255 Fortran, may be used to query the setting of the @code{GOMP_CPU_AFFINITY}
1256 environment variable. A defined CPU affinity on startup cannot be changed
1257 or disabled during the runtime of the application.
1259 If this environment variable is omitted, the host system will handle the
1260 assignment of threads to CPUs.
1265 @node GOMP_STACKSIZE
1266 @section @env{GOMP_STACKSIZE} -- Set default thread stack size
1267 @cindex Environment Variable
1268 @cindex Implementation specific setting
1270 @item @emph{Description}:
1271 Set the default thread stack size in kilobytes. This is different from
1272 @code{pthread_attr_setstacksize} which gets the number of bytes as an
1273 argument. If the stacksize cannot be set due to system constraints, an
1274 error is reported and the initial stacksize is left unchanged. If undefined,
1275 the stack size is system dependent.
1277 @item @emph{See also}:
1280 @item @emph{Reference}:
1281 @uref{http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00493.html,
1282 GCC Patches Mailinglist},
1283 @uref{http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00496.html,
1284 GCC Patches Mailinglist}
1289 @c ---------------------------------------------------------------------
1291 @c ---------------------------------------------------------------------
1293 @node The libgomp ABI
1294 @chapter The libgomp ABI
1296 The following sections present notes on the external ABI as
1297 presented by libgomp. Only maintainers should need them.
1300 * Implementing MASTER construct::
1301 * Implementing CRITICAL construct::
1302 * Implementing ATOMIC construct::
1303 * Implementing FLUSH construct::
1304 * Implementing BARRIER construct::
1305 * Implementing THREADPRIVATE construct::
1306 * Implementing PRIVATE clause::
1307 * Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses::
1308 * Implementing REDUCTION clause::
1309 * Implementing PARALLEL construct::
1310 * Implementing FOR construct::
1311 * Implementing ORDERED construct::
1312 * Implementing SECTIONS construct::
1313 * Implementing SINGLE construct::
1317 @node Implementing MASTER construct
1318 @section Implementing MASTER construct
1321 if (omp_get_thread_num () == 0)
1325 Alternately, we generate two copies of the parallel subfunction
1326 and only include this in the version run by the master thread.
1327 Surely this is not worthwhile though...
1331 @node Implementing CRITICAL construct
1332 @section Implementing CRITICAL construct
1334 Without a specified name,
1337 void GOMP_critical_start (void);
1338 void GOMP_critical_end (void);
1341 so that we don't get COPY relocations from libgomp to the main
1344 With a specified name, use omp_set_lock and omp_unset_lock with
1345 name being transformed into a variable declared like
1348 omp_lock_t gomp_critical_user_<name> __attribute__((common))
1351 Ideally the ABI would specify that all zero is a valid unlocked
1352 state, and so we wouldn't need to initialize this at
1357 @node Implementing ATOMIC construct
1358 @section Implementing ATOMIC construct
1360 The target should implement the @code{__sync} builtins.
1362 Failing that we could add
1365 void GOMP_atomic_enter (void)
1366 void GOMP_atomic_exit (void)
1369 which reuses the regular lock code, but with yet another lock
1370 object private to the library.
1374 @node Implementing FLUSH construct
1375 @section Implementing FLUSH construct
1377 Expands to the @code{__sync_synchronize} builtin.
1381 @node Implementing BARRIER construct
1382 @section Implementing BARRIER construct
1385 void GOMP_barrier (void)
1389 @node Implementing THREADPRIVATE construct
1390 @section Implementing THREADPRIVATE construct
1392 In _most_ cases we can map this directly to @code{__thread}. Except
1393 that OMP allows constructors for C++ objects. We can either
1394 refuse to support this (how often is it used?) or we can
1395 implement something akin to .ctors.
1397 Even more ideally, this ctor feature is handled by extensions
1398 to the main pthreads library. Failing that, we can have a set
1399 of entry points to register ctor functions to be called.
1403 @node Implementing PRIVATE clause
1404 @section Implementing PRIVATE clause
1406 In association with a PARALLEL, or within the lexical extent
1407 of a PARALLEL block, the variable becomes a local variable in
1408 the parallel subfunction.
1410 In association with FOR or SECTIONS blocks, create a new
1411 automatic variable within the current function. This preserves
1412 the semantic of new variable creation.
1416 @node Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses
1417 @section Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses
1419 This seems simple enough for PARALLEL blocks. Create a private
1420 struct for communicating between the parent and subfunction.
1421 In the parent, copy in values for scalar and "small" structs;
1422 copy in addresses for others TREE_ADDRESSABLE types. In the
1423 subfunction, copy the value into the local variable.
1425 It is not clear what to do with bare FOR or SECTION blocks.
1426 The only thing I can figure is that we do something like:
1429 #pragma omp for firstprivate(x) lastprivate(y)
1430 for (int i = 0; i < n; ++i)
1447 where the "x=x" and "y=y" assignments actually have different
1448 uids for the two variables, i.e. not something you could write
1449 directly in C. Presumably this only makes sense if the "outer"
1450 x and y are global variables.
1452 COPYPRIVATE would work the same way, except the structure
1453 broadcast would have to happen via SINGLE machinery instead.
1457 @node Implementing REDUCTION clause
1458 @section Implementing REDUCTION clause
1460 The private struct mentioned in the previous section should have
1461 a pointer to an array of the type of the variable, indexed by the
1462 thread's @var{team_id}. The thread stores its final value into the
1463 array, and after the barrier, the master thread iterates over the
1464 array to collect the values.
1467 @node Implementing PARALLEL construct
1468 @section Implementing PARALLEL construct
1471 #pragma omp parallel
1480 void subfunction (void *data)
1487 GOMP_parallel_start (subfunction, &data, num_threads);
1488 subfunction (&data);
1489 GOMP_parallel_end ();
1493 void GOMP_parallel_start (void (*fn)(void *), void *data, unsigned num_threads)
1496 The @var{FN} argument is the subfunction to be run in parallel.
1498 The @var{DATA} argument is a pointer to a structure used to
1499 communicate data in and out of the subfunction, as discussed
1500 above with respect to FIRSTPRIVATE et al.
1502 The @var{NUM_THREADS} argument is 1 if an IF clause is present
1503 and false, or the value of the NUM_THREADS clause, if
1506 The function needs to create the appropriate number of
1507 threads and/or launch them from the dock. It needs to
1508 create the team structure and assign team ids.
1511 void GOMP_parallel_end (void)
1514 Tears down the team and returns us to the previous @code{omp_in_parallel()} state.
1518 @node Implementing FOR construct
1519 @section Implementing FOR construct
1522 #pragma omp parallel for
1523 for (i = lb; i <= ub; i++)
1530 void subfunction (void *data)
1533 while (GOMP_loop_static_next (&_s0, &_e0))
1536 for (i = _s0; i < _e1; i++)
1539 GOMP_loop_end_nowait ();
1542 GOMP_parallel_loop_static (subfunction, NULL, 0, lb, ub+1, 1, 0);
1544 GOMP_parallel_end ();
1548 #pragma omp for schedule(runtime)
1549 for (i = 0; i < n; i++)
1558 if (GOMP_loop_runtime_start (0, n, 1, &_s0, &_e0))
1561 for (i = _s0, i < _e0; i++)
1563 @} while (GOMP_loop_runtime_next (&_s0, _&e0));
1568 Note that while it looks like there is trickiness to propagating
1569 a non-constant STEP, there isn't really. We're explicitly allowed
1570 to evaluate it as many times as we want, and any variables involved
1571 should automatically be handled as PRIVATE or SHARED like any other
1572 variables. So the expression should remain evaluable in the
1573 subfunction. We can also pull it into a local variable if we like,
1574 but since its supposed to remain unchanged, we can also not if we like.
1576 If we have SCHEDULE(STATIC), and no ORDERED, then we ought to be
1577 able to get away with no work-sharing context at all, since we can
1578 simply perform the arithmetic directly in each thread to divide up
1579 the iterations. Which would mean that we wouldn't need to call any
1582 There are separate routines for handling loops with an ORDERED
1583 clause. Bookkeeping for that is non-trivial...
1587 @node Implementing ORDERED construct
1588 @section Implementing ORDERED construct
1591 void GOMP_ordered_start (void)
1592 void GOMP_ordered_end (void)
1597 @node Implementing SECTIONS construct
1598 @section Implementing SECTIONS construct
1603 #pragma omp sections
1617 for (i = GOMP_sections_start (3); i != 0; i = GOMP_sections_next ())
1634 @node Implementing SINGLE construct
1635 @section Implementing SINGLE construct
1649 if (GOMP_single_start ())
1657 #pragma omp single copyprivate(x)
1664 datap = GOMP_single_copy_start ();
1669 GOMP_single_copy_end (&data);
1678 @c ---------------------------------------------------------------------
1680 @c ---------------------------------------------------------------------
1682 @node Reporting Bugs
1683 @chapter Reporting Bugs
1685 Bugs in the GNU OpenMP implementation should be reported via
1686 @uref{http://gcc.gnu.org/bugzilla/, bugzilla}. For all cases, please add
1687 "openmp" to the keywords field in the bug report.
1691 @c ---------------------------------------------------------------------
1692 @c GNU General Public License
1693 @c ---------------------------------------------------------------------
1699 @c ---------------------------------------------------------------------
1700 @c GNU Free Documentation License
1701 @c ---------------------------------------------------------------------
1707 @c ---------------------------------------------------------------------
1708 @c Funding Free Software
1709 @c ---------------------------------------------------------------------
1711 @include funding.texi
1713 @c ---------------------------------------------------------------------
1715 @c ---------------------------------------------------------------------