This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
/
libgomp.info
2123 lines (1652 loc) · 85.4 KB
/
libgomp.info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
This is libgomp.info, produced by makeinfo version 4.8 from
../../../gcc-4.3.3/libgomp/libgomp.texi.
Copyright (C) 2006 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "GNU General Public License" and "Funding Free
Software", the Front-Cover texts being (a) (see below), and with the
Back-Cover Texts being (b) (see below). A copy of the license is
included in the section entitled "GNU Free Documentation License".
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development.
INFO-DIR-SECTION GNU Libraries
START-INFO-DIR-ENTRY
* libgomp: (libgomp). GNU OpenMP runtime library
END-INFO-DIR-ENTRY
This manual documents the GNU implementation of the OpenMP API for
multi-platform shared-memory parallel programming in C/C++ and Fortran.
Published by the Free Software Foundation 51 Franklin Street, Fifth
Floor Boston, MA 02110-1301 USA
Copyright (C) 2006 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "GNU General Public License" and "Funding Free
Software", the Front-Cover texts being (a) (see below), and with the
Back-Cover Texts being (b) (see below). A copy of the license is
included in the section entitled "GNU Free Documentation License".
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development.
File: libgomp.info, Node: Top, Next: Enabling OpenMP, Up: (dir)
Introduction
************
This manual documents the usage of libgomp, the GNU implementation of
the OpenMP (http://www.openmp.org) Application Programming Interface
(API) for multi-platform shared-memory parallel programming in C/C++
and Fortran.
* Menu:
* Enabling OpenMP:: How to enable OpenMP for your applications.
* Runtime Library Routines:: The OpenMP runtime application programming
interface.
* Environment Variables:: Influencing runtime behavior with environment
variables.
* The libgomp ABI:: Notes on the external ABI presented by libgomp.
* Reporting Bugs:: How to report bugs in GNU OpenMP.
* Copying:: GNU general public license says
how you can copy and share libgomp.
* GNU Free Documentation License::
How you can copy and share this manual.
* Funding:: How to help assure continued work for free
software.
* Index:: Index of this documentation.
File: libgomp.info, Node: Enabling OpenMP, Next: Runtime Library Routines, Prev: Top, Up: Top
1 Enabling OpenMP
*****************
To activate the OpenMP extensions for C/C++ and Fortran, the
compile-time flag `-fopenmp' must be specified. This enables the OpenMP
directive `#pragma omp' in C/C++ and `!$omp' directives in free form,
`c$omp', `*$omp' and `!$omp' directives in fixed form, `!$' conditional
compilation sentinels in free form and `c$', `*$' and `!$' sentinels in
fixed form, for Fortran. The flag also arranges for automatic linking
of the OpenMP runtime library (*Note Runtime Library Routines::).
A complete description of all OpenMP directives accepted may be
found in the OpenMP Application Program Interface
(http://www.openmp.org) manual, version 2.5.
File: libgomp.info, Node: Runtime Library Routines, Next: Environment Variables, Prev: Enabling OpenMP, Up: Top
2 Runtime Library Routines
**************************
The runtime routines described here are defined by section 3 of the
OpenMP specifications in version 2.5.
Control threads, processors and the parallel environment.
* Menu:
* omp_get_dynamic:: Dynamic teams setting
* omp_get_max_threads:: Maximum number of threads
* omp_get_nested:: Nested parallel regions
* omp_get_num_procs:: Number of processors online
* omp_get_num_threads:: Size of the active team
* omp_get_thread_num:: Current thread ID
* omp_in_parallel:: Whether a parallel region is active
* omp_set_dynamic:: Enable/disable dynamic teams
* omp_set_nested:: Enable/disable nested parallel regions
* omp_set_num_threads:: Set upper team size limit
Initialize, set, test, unset and destroy simple and nested locks.
* Menu:
* omp_init_lock:: Initialize simple lock
* omp_set_lock:: Wait for and set simple lock
* omp_test_lock:: Test and set simple lock if available
* omp_unset_lock:: Unset simple lock
* omp_destroy_lock:: Destroy simple lock
* omp_init_nest_lock:: Initialize nested lock
* omp_set_nest_lock:: Wait for and set simple lock
* omp_test_nest_lock:: Test and set nested lock if available
* omp_unset_nest_lock:: Unset nested lock
* omp_destroy_nest_lock:: Destroy nested lock
Portable, thread-based, wall clock timer.
* Menu:
* omp_get_wtick:: Get timer precision.
* omp_get_wtime:: Elapsed wall clock time.
File: libgomp.info, Node: omp_get_dynamic, Next: omp_get_max_threads, Up: Runtime Library Routines
2.1 `omp_get_dynamic' - Dynamic teams setting
=============================================
_Description_:
This function returns `true' if enabled, `false' otherwise. Here,
`true' and `false' represent their language-specific counterparts.
The dynamic team setting may be initialized at startup by the
`OMP_DYNAMIC' environment variable or at runtime using
`omp_set_dynamic'. If undefined, dynamic adjustment is disabled by
default.
_C/C++_:
_Prototype_: `int omp_get_dynamic();'
_Fortran_:
_Interface_: `logical function omp_get_dynamic()'
_See also_:
*Note omp_set_dynamic::, *Note OMP_DYNAMIC::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.2.8.
File: libgomp.info, Node: omp_get_max_threads, Next: omp_get_nested, Prev: omp_get_dynamic, Up: Runtime Library Routines
2.2 `omp_get_max_threads' - Maximum number of threads
=====================================================
_Description_:
Return the maximum number of threads used for parallel regions
that do not use the clause `num_threads'.
_C/C++_:
_Prototype_: `int omp_get_max_threads();'
_Fortran_:
_Interface_: `integer function omp_get_max_threads()'
_See also_:
*Note omp_set_num_threads::, *Note omp_set_dynamic::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.2.3.
File: libgomp.info, Node: omp_get_nested, Next: omp_get_num_procs, Prev: omp_get_max_threads, Up: Runtime Library Routines
2.3 `omp_get_nested' - Nested parallel regions
==============================================
_Description_:
This function returns `true' if nested parallel regions are
enabled, `false' otherwise. Here, `true' and `false' represent
their language-specific counterparts.
Nested parallel regions may be initialized at startup by the
`OMP_NESTED' environment variable or at runtime using
`omp_set_nested'. If undefined, nested parallel regions are
disabled by default.
_C/C++_:
_Prototype_: `int omp_get_nested();'
_Fortran_:
_Interface_: `integer function omp_get_nested()'
_See also_:
*Note omp_set_nested::, *Note OMP_NESTED::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section
3.2.10.
File: libgomp.info, Node: omp_get_num_procs, Next: omp_get_num_threads, Prev: omp_get_nested, Up: Runtime Library Routines
2.4 `omp_get_num_procs' - Number of processors online
=====================================================
_Description_:
Returns the number of processors online.
_C/C++_:
_Prototype_: `int omp_get_num_procs();'
_Fortran_:
_Interface_: `integer function omp_get_num_procs()'
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.2.5.
File: libgomp.info, Node: omp_get_num_threads, Next: omp_get_thread_num, Prev: omp_get_num_procs, Up: Runtime Library Routines
2.5 `omp_get_num_threads' - Size of the active team
===================================================
_Description_:
The number of threads in the current team. In a sequential section
of the program `omp_get_num_threads' returns 1.
The default team size may be initialized at startup by the
`OMP_NUM_THREADS' environment variable. At runtime, the size of
the current team may be set either by the `NUM_THREADS' clause or
by `omp_set_num_threads'. If none of the above were used to define
a specific value and `OMP_DYNAMIC' is disabled, one thread per CPU
online is used.
_C/C++_:
_Prototype_: `int omp_get_num_threads();'
_Fortran_:
_Interface_: `integer function omp_get_num_threads()'
_See also_:
*Note omp_get_max_threads::, *Note omp_set_num_threads::, *Note
OMP_NUM_THREADS::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.2.2.
File: libgomp.info, Node: omp_get_thread_num, Next: omp_in_parallel, Prev: omp_get_num_threads, Up: Runtime Library Routines
2.6 `omp_get_thread_num' - Current thread ID
============================================
_Description_:
Unique thread identification number. In a sequential parts of the
program, `omp_get_thread_num' always returns 0. In parallel
regions the return value varies from 0 to `omp_get_max_threads'-1
inclusive. The return value of the master thread of a team is
always 0.
_C/C++_:
_Prototype_: `int omp_get_thread_num();'
_Fortran_:
_Interface_: `integer function omp_get_thread_num()'
_See also_:
*Note omp_get_max_threads::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.2.4.
File: libgomp.info, Node: omp_in_parallel, Next: omp_set_dynamic, Prev: omp_get_thread_num, Up: Runtime Library Routines
2.7 `omp_in_parallel' - Whether a parallel region is active
===========================================================
_Description_:
This function returns `true' if currently running in parallel,
`false' otherwise. Here, `true' and `false' represent their
language-specific counterparts.
_C/C++_:
_Prototype_: `int omp_in_parallel();'
_Fortran_:
_Interface_: `logical function omp_in_parallel()'
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.2.6.
File: libgomp.info, Node: omp_set_dynamic, Next: omp_set_nested, Prev: omp_in_parallel, Up: Runtime Library Routines
2.8 `omp_set_dynamic' - Enable/disable dynamic teams
====================================================
_Description_:
Enable or disable the dynamic adjustment of the number of threads
within a team. The function takes the language-specific equivalent
of `true' and `false', where `true' enables dynamic adjustment of
team sizes and `false' disables it.
_C/C++_:
_Prototype_: `void omp_set_dynamic(int);'
_Fortran_:
_Interface_: `subroutine omp_set_dynamic(set)'
`integer, intent(in) :: set'
_See also_:
*Note OMP_DYNAMIC::, *Note omp_get_dynamic::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.2.7.
File: libgomp.info, Node: omp_set_nested, Next: omp_set_num_threads, Prev: omp_set_dynamic, Up: Runtime Library Routines
2.9 `omp_set_nested' - Enable/disable nested parallel regions
=============================================================
_Description_:
Enable or disable nested parallel regions, i.e., whether team
members are allowed to create new teams. The function takes the
language-specific equivalent of `true' and `false', where `true'
enables dynamic adjustment of team sizes and `false' disables it.
_C/C++_:
_Prototype_: `void omp_set_dynamic(int);'
_Fortran_:
_Interface_: `subroutine omp_set_dynamic(set)'
`integer, intent(in) :: set'
_See also_:
*Note OMP_NESTED::, *Note omp_get_nested::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.2.9.
File: libgomp.info, Node: omp_set_num_threads, Next: omp_init_lock, Prev: omp_set_nested, Up: Runtime Library Routines
2.10 `omp_set_num_threads' - Set upper team size limit
======================================================
_Description_:
Specifies the number of threads used by default in subsequent
parallel sections, if those do not specify a `num_threads' clause.
The argument of `omp_set_num_threads' shall be a positive integer.
_C/C++_:
_Prototype_: `void omp_set_num_threads(int);'
_Fortran_:
_Interface_: `subroutine omp_set_num_threads(set)'
`integer, intent(in) :: set'
_See also_:
*Note OMP_NUM_THREADS::, *Note omp_get_num_threads::, *Note
omp_get_max_threads::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.2.1.
File: libgomp.info, Node: omp_init_lock, Next: omp_set_lock, Prev: omp_set_num_threads, Up: Runtime Library Routines
2.11 `omp_init_lock' - Initialize simple lock
=============================================
_Description_:
Initialize a simple lock. After initialization, the lock is in an
unlocked state.
_C/C++_:
_Prototype_: `void omp_init_lock(omp_lock_t *lock);'
_Fortran_:
_Interface_: `subroutine omp_init_lock(lock)'
`integer(omp_lock_kind), intent(out) :: lock'
_See also_:
*Note omp_destroy_lock::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.3.1.
File: libgomp.info, Node: omp_set_lock, Next: omp_test_lock, Prev: omp_init_lock, Up: Runtime Library Routines
2.12 `omp_set_lock' - Wait for and set simple lock
==================================================
_Description_:
Before setting a simple lock, the lock variable must be
initialized by `omp_init_lock'. The calling thread is blocked
until the lock is available. If the lock is already held by the
current thread, a deadlock occurs.
_C/C++_:
_Prototype_: `void omp_set_lock(omp_lock_t *lock);'
_Fortran_:
_Interface_: `subroutine omp_set_lock(lock)'
`integer(omp_lock_kind), intent(out) :: lock'
_See also_:
*Note omp_init_lock::, *Note omp_test_lock::, *Note
omp_unset_lock::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.3.3.
File: libgomp.info, Node: omp_test_lock, Next: omp_unset_lock, Prev: omp_set_lock, Up: Runtime Library Routines
2.13 `omp_test_lock' - Test and set simple lock if available
============================================================
_Description_:
Before setting a simple lock, the lock variable must be
initialized by `omp_init_lock'. Contrary to `omp_set_lock',
`omp_test_lock' does not block if the lock is not available. This
function returns `true' upon success,`false' otherwise. Here,
`true' and `false' represent their language-specific counterparts.
_C/C++_:
_Prototype_: `int omp_test_lock(omp_lock_t *lock);'
_Fortran_:
_Interface_: `subroutine omp_test_lock(lock)'
`logical(omp_logical_kind) :: omp_test_lock'
`integer(omp_lock_kind), intent(out) :: lock'
_See also_:
*Note omp_init_lock::, *Note omp_set_lock::, *Note omp_set_lock::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.3.5.
File: libgomp.info, Node: omp_unset_lock, Next: omp_destroy_lock, Prev: omp_test_lock, Up: Runtime Library Routines
2.14 `omp_unset_lock' - Unset simple lock
=========================================
_Description_:
A simple lock about to be unset must have been locked by
`omp_set_lock' or `omp_test_lock' before. In addition, the lock
must be held by the thread calling `omp_unset_lock'. Then, the
lock becomes unlocked. If one ore more threads attempted to set
the lock before, one of them is chosen to, again, set the lock for
itself.
_C/C++_:
_Prototype_: `void omp_unset_lock(omp_lock_t *lock);'
_Fortran_:
_Interface_: `subroutine omp_unset_lock(lock)'
`integer(omp_lock_kind), intent(out) :: lock'
_See also_:
*Note omp_set_lock::, *Note omp_test_lock::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.3.4.
File: libgomp.info, Node: omp_destroy_lock, Next: omp_init_nest_lock, Prev: omp_unset_lock, Up: Runtime Library Routines
2.15 `omp_destroy_lock' - Destroy simple lock
=============================================
_Description_:
Destroy a simple lock. In order to be destroyed, a simple lock
must be in the unlocked state.
_C/C++_:
_Prototype_: `void omp_destroy_lock(omp_lock_t *);'
_Fortran_:
_Interface_: `subroutine omp_destroy_lock(lock)'
`integer(omp_lock_kind), intent(inout) :: lock'
_See also_:
*Note omp_init_lock::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.3.2.
File: libgomp.info, Node: omp_init_nest_lock, Next: omp_set_nest_lock, Prev: omp_destroy_lock, Up: Runtime Library Routines
2.16 `omp_init_nest_lock' - Initialize nested lock
==================================================
_Description_:
Initialize a nested lock. After initialization, the lock is in an
unlocked state and the nesting count is set to zero.
_C/C++_:
_Prototype_: `void omp_init_nest_lock(omp_nest_lock_t *lock);'
_Fortran_:
_Interface_: `subroutine omp_init_nest_lock(lock)'
`integer(omp_nest_lock_kind), intent(out) :: lock'
_See also_:
*Note omp_destroy_nest_lock::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.3.1.
File: libgomp.info, Node: omp_set_nest_lock, Next: omp_test_nest_lock, Prev: omp_init_nest_lock, Up: Runtime Library Routines
2.17 `omp_set_nest_lock' - Wait for and set simple lock
=======================================================
_Description_:
Before setting a nested lock, the lock variable must be
initialized by `omp_init_nest_lock'. The calling thread is blocked
until the lock is available. If the lock is already held by the
current thread, the nesting count for the lock in incremented.
_C/C++_:
_Prototype_: `void omp_set_nest_lock(omp_nest_lock_t *lock);'
_Fortran_:
_Interface_: `subroutine omp_set_nest_lock(lock)'
`integer(omp_nest_lock_kind), intent(out) :: lock'
_See also_:
*Note omp_init_nest_lock::, *Note omp_unset_nest_lock::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.3.3.
File: libgomp.info, Node: omp_test_nest_lock, Next: omp_unset_nest_lock, Prev: omp_set_nest_lock, Up: Runtime Library Routines
2.18 `omp_test_nest_lock' - Test and set nested lock if available
=================================================================
_Description_:
Before setting a nested lock, the lock variable must be
initialized by `omp_init_nest_lock'. Contrary to
`omp_set_nest_lock', `omp_test_nest_lock' does not block if the
lock is not available. If the lock is already held by the current
thread, the new nesting count is returned. Otherwise, the return
value equals zero.
_C/C++_:
_Prototype_: `int omp_test_nest_lock(omp_nest_lock_t *lock);'
_Fortran_:
_Interface_: `integer function omp_test_nest_lock(lock)'
`integer(omp_integer_kind) :: omp_test_nest_lock'
`integer(omp_nest_lock_kind), intent(inout) :: lock'
_See also_:
*Note omp_init_lock::, *Note omp_set_lock::, *Note omp_set_lock::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.3.5.
File: libgomp.info, Node: omp_unset_nest_lock, Next: omp_destroy_nest_lock, Prev: omp_test_nest_lock, Up: Runtime Library Routines
2.19 `omp_unset_nest_lock' - Unset nested lock
==============================================
_Description_:
A nested lock about to be unset must have been locked by
`omp_set_nested_lock' or `omp_test_nested_lock' before. In
addition, the lock must be held by the thread calling
`omp_unset_nested_lock'. If the nesting count drops to zero, the
lock becomes unlocked. If one ore more threads attempted to set
the lock before, one of them is chosen to, again, set the lock for
itself.
_C/C++_:
_Prototype_: `void omp_unset_nest_lock(omp_nest_lock_t *lock);'
_Fortran_:
_Interface_: `subroutine omp_unset_nest_lock(lock)'
`integer(omp_nest_lock_kind), intent(out) :: lock'
_See also_:
*Note omp_set_nest_lock::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.3.4.
File: libgomp.info, Node: omp_destroy_nest_lock, Next: omp_get_wtick, Prev: omp_unset_nest_lock, Up: Runtime Library Routines
2.20 `omp_destroy_nest_lock' - Destroy nested lock
==================================================
_Description_:
Destroy a nested lock. In order to be destroyed, a nested lock
must be in the unlocked state and its nesting count must equal
zero.
_C/C++_:
_Prototype_: `void omp_destroy_nest_lock(omp_nest_lock_t *);'
_Fortran_:
_Interface_: `subroutine omp_destroy_nest_lock(lock)'
`integer(omp_nest_lock_kind), intent(inout) :: lock'
_See also_:
*Note omp_init_lock::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.3.2.
File: libgomp.info, Node: omp_get_wtick, Next: omp_get_wtime, Prev: omp_destroy_nest_lock, Up: Runtime Library Routines
2.21 `omp_get_wtick' - Get timer precision
==========================================
_Description_:
Gets the timer precision, i.e., the number of seconds between two
successive clock ticks.
_C/C++_:
_Prototype_: `double omp_get_wtick();'
_Fortran_:
_Interface_: `double precision function omp_get_wtick()'
_See also_:
*Note omp_get_wtime::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.4.2.
File: libgomp.info, Node: omp_get_wtime, Prev: omp_get_wtick, Up: Runtime Library Routines
2.22 `omp_get_wtime' - Elapsed wall clock time
==============================================
_Description_:
Elapsed wall clock time in seconds. The time is measured per
thread, no guarantee can bee made that two distinct threads
measure the same time. Time is measured from some "time in the
past". On POSIX compliant systems the seconds since the Epoch
(00:00:00 UTC, January 1, 1970) are returned.
_C/C++_:
_Prototype_: `double omp_get_wtime();'
_Fortran_:
_Interface_: `double precision function omp_get_wtime()'
_See also_:
*Note omp_get_wtick::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 3.4.1.
File: libgomp.info, Node: Environment Variables, Next: The libgomp ABI, Prev: Runtime Library Routines, Up: Top
3 Environment Variables
***********************
The variables `OMP_DYNAMIC', `OMP_NESTED', `OMP_NUM_THREADS' and
`OMP_SCHEDULE' are defined by section 4 of the OpenMP specifications in
version 2.5, while `GOMP_CPU_AFFINITY' and `GOMP_STACKSIZE' are GNU
extensions.
* Menu:
* OMP_DYNAMIC:: Dynamic adjustment of threads
* OMP_NESTED:: Nested parallel regions
* OMP_NUM_THREADS:: Specifies the number of threads to use
* OMP_SCHEDULE:: How threads are scheduled
* GOMP_CPU_AFFINITY:: Bind threads to specific CPUs
* GOMP_STACKSIZE:: Set default thread stack size
File: libgomp.info, Node: OMP_DYNAMIC, Next: OMP_NESTED, Up: Environment Variables
3.1 `OMP_DYNAMIC' - Dynamic adjustment of threads
=================================================
_Description_:
Enable or disable the dynamic adjustment of the number of threads
within a team. The value of this environment variable shall be
`TRUE' or `FALSE'. If undefined, dynamic adjustment is disabled by
default.
_See also_:
*Note omp_set_dynamic::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 4.3
File: libgomp.info, Node: OMP_NESTED, Next: OMP_NUM_THREADS, Prev: OMP_DYNAMIC, Up: Environment Variables
3.2 `OMP_NESTED' - Nested parallel regions
==========================================
_Description_:
Enable or disable nested parallel regions, i.e., whether team
members are allowed to create new teams. The value of this
environment variable shall be `TRUE' or `FALSE'. If undefined,
nested parallel regions are disabled by default.
_See also_:
*Note omp_set_nested::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 4.4
File: libgomp.info, Node: OMP_NUM_THREADS, Next: OMP_SCHEDULE, Prev: OMP_NESTED, Up: Environment Variables
3.3 `OMP_NUM_THREADS' - Specifies the number of threads to use
==============================================================
_Description_:
Specifies the default number of threads to use in parallel
regions. The value of this variable shall be positive integer. If
undefined one thread per CPU online is used.
_See also_:
*Note omp_set_num_threads::
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), section 4.2
File: libgomp.info, Node: OMP_SCHEDULE, Next: GOMP_CPU_AFFINITY, Prev: OMP_NUM_THREADS, Up: Environment Variables
3.4 `OMP_SCHEDULE' - How threads are scheduled
==============================================
_Description_:
Allows to specify `schedule type' and `chunk size'. The value of
the variable shall have the form: `type[,chunk]' where `type' is
one of `static', `dynamic' or `guided'. The optional `chunk size'
shall be a positive integer. If undefined, dynamic scheduling and
a chunk size of 1 is used.
_Reference_:
OpenMP specifications v2.5 (http://www.openmp.org/), sections
2.5.1 and 4.1
File: libgomp.info, Node: GOMP_CPU_AFFINITY, Next: GOMP_STACKSIZE, Prev: OMP_SCHEDULE, Up: Environment Variables
3.5 `GOMP_CPU_AFFINITY' - Bind threads to specific CPUs
=======================================================
_Description_:
Binds threads to specific CPUs. The variable should contain a
space- or comma-separated list of CPUs. This list may contain
different kind of entries: either single CPU numbers in any order,
a range of CPUs (M-N) or a range with some stride (M-N:S). CPU
numbers are zero based. For example, `GOMP_CPU_AFFINITY="0 3 1-2
4-15:2"' will bind the initial thread to CPU 0, the second to CPU
3, the third to CPU 1, the fourth to CPU 2, the fifth to CPU 4,
the sixth through tenth to CPUs 6, 8, 10, 12, and 14 respectively
and then start assigning back from the beginning of the list.
`GOMP_CPU_AFFINITY=0' binds all threads to CPU 0.
There is no GNU OpenMP library routine to determine whether a CPU
affinity specification is in effect. As a workaround,
language-specific library functions, e.g., `getenv' in C or
`GET_ENVIRONMENT_VARIABLE' in Fortran, may be used to query the
setting of the `GOMP_CPU_AFFINITY' environment variable. A defined
CPU affinity on startup cannot be changed or disabled during the
runtime of the application.
If this environment variable is omitted, the host system will
handle the assignment of threads to CPUs.
File: libgomp.info, Node: GOMP_STACKSIZE, Prev: GOMP_CPU_AFFINITY, Up: Environment Variables
3.6 `GOMP_STACKSIZE' - Set default thread stack size
====================================================
_Description_:
Set the default thread stack size in kilobytes. This is in
opposition to `pthread_attr_setstacksize' which gets the number of
bytes as an argument. If the stacksize can not be set due to
system constraints, an error is reported and the initial stacksize
is left unchanged. If undefined, the stack size is system
dependent.
_Reference_:
GCC Patches Mailinglist
(http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00493.html), GCC
Patches Mailinglist
(http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00496.html)
File: libgomp.info, Node: The libgomp ABI, Next: Reporting Bugs, Prev: Environment Variables, Up: Top
4 The libgomp ABI
*****************
The following sections present notes on the external ABI as presented
by libgomp. Only maintainers should need them.
* Menu:
* Implementing MASTER construct::
* Implementing CRITICAL construct::
* Implementing ATOMIC construct::
* Implementing FLUSH construct::
* Implementing BARRIER construct::
* Implementing THREADPRIVATE construct::
* Implementing PRIVATE clause::
* Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses::
* Implementing REDUCTION clause::
* Implementing PARALLEL construct::
* Implementing FOR construct::
* Implementing ORDERED construct::
* Implementing SECTIONS construct::
* Implementing SINGLE construct::
File: libgomp.info, Node: Implementing MASTER construct, Next: Implementing CRITICAL construct, Up: The libgomp ABI
4.1 Implementing MASTER construct
=================================
if (omp_get_thread_num () == 0)
block
Alternately, we generate two copies of the parallel subfunction and
only include this in the version run by the master thread. Surely
that's not worthwhile though...
File: libgomp.info, Node: Implementing CRITICAL construct, Next: Implementing ATOMIC construct, Prev: Implementing MASTER construct, Up: The libgomp ABI
4.2 Implementing CRITICAL construct
===================================
Without a specified name,
void GOMP_critical_start (void);
void GOMP_critical_end (void);
so that we don't get COPY relocations from libgomp to the main
application.
With a specified name, use omp_set_lock and omp_unset_lock with name
being transformed into a variable declared like
omp_lock_t gomp_critical_user_<name> __attribute__((common))
Ideally the ABI would specify that all zero is a valid unlocked
state, and so we wouldn't actually need to initialize this at startup.
File: libgomp.info, Node: Implementing ATOMIC construct, Next: Implementing FLUSH construct, Prev: Implementing CRITICAL construct, Up: The libgomp ABI
4.3 Implementing ATOMIC construct
=================================
The target should implement the `__sync' builtins.
Failing that we could add
void GOMP_atomic_enter (void)
void GOMP_atomic_exit (void)
which reuses the regular lock code, but with yet another lock object
private to the library.
File: libgomp.info, Node: Implementing FLUSH construct, Next: Implementing BARRIER construct, Prev: Implementing ATOMIC construct, Up: The libgomp ABI
4.4 Implementing FLUSH construct
================================
Expands to the `__sync_synchronize' builtin.
File: libgomp.info, Node: Implementing BARRIER construct, Next: Implementing THREADPRIVATE construct, Prev: Implementing FLUSH construct, Up: The libgomp ABI
4.5 Implementing BARRIER construct
==================================
void GOMP_barrier (void)
File: libgomp.info, Node: Implementing THREADPRIVATE construct, Next: Implementing PRIVATE clause, Prev: Implementing BARRIER construct, Up: The libgomp ABI
4.6 Implementing THREADPRIVATE construct
========================================
In _most_ cases we can map this directly to `__thread'. Except that
OMP allows constructors for C++ objects. We can either refuse to
support this (how often is it used?) or we can implement something akin
to .ctors.
Even more ideally, this ctor feature is handled by extensions to the
main pthreads library. Failing that, we can have a set of entry points
to register ctor functions to be called.
File: libgomp.info, Node: Implementing PRIVATE clause, Next: Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses, Prev: Implementing THREADPRIVATE construct, Up: The libgomp ABI
4.7 Implementing PRIVATE clause
===============================
In association with a PARALLEL, or within the lexical extent of a
PARALLEL block, the variable becomes a local variable in the parallel
subfunction.
In association with FOR or SECTIONS blocks, create a new automatic
variable within the current function. This preserves the semantic of
new variable creation.
File: libgomp.info, Node: Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses, Next: Implementing REDUCTION clause, Prev: Implementing PRIVATE clause, Up: The libgomp ABI
4.8 Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses
========================================================================
Seems simple enough for PARALLEL blocks. Create a private struct for
communicating between parent and subfunction. In the parent, copy in
values for scalar and "small" structs; copy in addresses for others
TREE_ADDRESSABLE types. In the subfunction, copy the value into the
local variable.
Not clear at all what to do with bare FOR or SECTION blocks. The
only thing I can figure is that we do something like
#pragma omp for firstprivate(x) lastprivate(y)
for (int i = 0; i < n; ++i)
body;
which becomes
{
int x = x, y;
// for stuff
if (i == n)
y = y;
}
where the "x=x" and "y=y" assignments actually have different uids
for the two variables, i.e. not something you could write directly in
C. Presumably this only makes sense if the "outer" x and y are global
variables.
COPYPRIVATE would work the same way, except the structure broadcast
would have to happen via SINGLE machinery instead.
File: libgomp.info, Node: Implementing REDUCTION clause, Next: Implementing PARALLEL construct, Prev: Implementing FIRSTPRIVATE LASTPRIVATE COPYIN and COPYPRIVATE clauses, Up: The libgomp ABI
4.9 Implementing REDUCTION clause
=================================
The private struct mentioned in the previous section should have a
pointer to an array of the type of the variable, indexed by the