This repository has been archived by the owner on Apr 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 128
/
kmp_gsupport.cpp
1992 lines (1789 loc) · 89.2 KB
/
kmp_gsupport.cpp
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
/*
* kmp_gsupport.cpp
*/
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "kmp.h"
#include "kmp_atomic.h"
#if OMPT_SUPPORT
#include "ompt-specific.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#define MKLOC(loc, routine) \
static ident_t loc = {0, KMP_IDENT_KMPC, 0, 0, ";unknown;unknown;0;0;;"};
#include "kmp_ftn_os.h"
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_BARRIER)(void) {
int gtid = __kmp_entry_gtid();
MKLOC(loc, "GOMP_barrier");
KA_TRACE(20, ("GOMP_barrier: T#%d\n", gtid));
#if OMPT_SUPPORT && OMPT_OPTIONAL
ompt_frame_t *ompt_frame;
if (ompt_enabled.enabled) {
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
OMPT_STORE_RETURN_ADDRESS(gtid);
}
#endif
__kmpc_barrier(&loc, gtid);
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (ompt_enabled.enabled) {
ompt_frame->enter_frame = ompt_data_none;
}
#endif
}
// Mutual exclusion
// The symbol that icc/ifort generates for unnamed for unnamed critical sections
// - .gomp_critical_user_ - is defined using .comm in any objects reference it.
// We can't reference it directly here in C code, as the symbol contains a ".".
//
// The RTL contains an assembly language definition of .gomp_critical_user_
// with another symbol __kmp_unnamed_critical_addr initialized with it's
// address.
extern kmp_critical_name *__kmp_unnamed_critical_addr;
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CRITICAL_START)(void) {
int gtid = __kmp_entry_gtid();
MKLOC(loc, "GOMP_critical_start");
KA_TRACE(20, ("GOMP_critical_start: T#%d\n", gtid));
#if OMPT_SUPPORT && OMPT_OPTIONAL
OMPT_STORE_RETURN_ADDRESS(gtid);
#endif
__kmpc_critical(&loc, gtid, __kmp_unnamed_critical_addr);
}
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CRITICAL_END)(void) {
int gtid = __kmp_get_gtid();
MKLOC(loc, "GOMP_critical_end");
KA_TRACE(20, ("GOMP_critical_end: T#%d\n", gtid));
#if OMPT_SUPPORT && OMPT_OPTIONAL
OMPT_STORE_RETURN_ADDRESS(gtid);
#endif
__kmpc_end_critical(&loc, gtid, __kmp_unnamed_critical_addr);
}
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CRITICAL_NAME_START)(void **pptr) {
int gtid = __kmp_entry_gtid();
MKLOC(loc, "GOMP_critical_name_start");
KA_TRACE(20, ("GOMP_critical_name_start: T#%d\n", gtid));
__kmpc_critical(&loc, gtid, (kmp_critical_name *)pptr);
}
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_CRITICAL_NAME_END)(void **pptr) {
int gtid = __kmp_get_gtid();
MKLOC(loc, "GOMP_critical_name_end");
KA_TRACE(20, ("GOMP_critical_name_end: T#%d\n", gtid));
__kmpc_end_critical(&loc, gtid, (kmp_critical_name *)pptr);
}
// The Gnu codegen tries to use locked operations to perform atomic updates
// inline. If it can't, then it calls GOMP_atomic_start() before performing
// the update and GOMP_atomic_end() afterward, regardless of the data type.
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ATOMIC_START)(void) {
int gtid = __kmp_entry_gtid();
KA_TRACE(20, ("GOMP_atomic_start: T#%d\n", gtid));
#if OMPT_SUPPORT
__ompt_thread_assign_wait_id(0);
#endif
__kmp_acquire_atomic_lock(&__kmp_atomic_lock, gtid);
}
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ATOMIC_END)(void) {
int gtid = __kmp_get_gtid();
KA_TRACE(20, ("GOMP_atomic_end: T#%d\n", gtid));
__kmp_release_atomic_lock(&__kmp_atomic_lock, gtid);
}
int KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_START)(void) {
int gtid = __kmp_entry_gtid();
MKLOC(loc, "GOMP_single_start");
KA_TRACE(20, ("GOMP_single_start: T#%d\n", gtid));
if (!TCR_4(__kmp_init_parallel))
__kmp_parallel_initialize();
__kmp_resume_if_soft_paused();
// 3rd parameter == FALSE prevents kmp_enter_single from pushing a
// workshare when USE_CHECKS is defined. We need to avoid the push,
// as there is no corresponding GOMP_single_end() call.
kmp_int32 rc = __kmp_enter_single(gtid, &loc, FALSE);
#if OMPT_SUPPORT && OMPT_OPTIONAL
kmp_info_t *this_thr = __kmp_threads[gtid];
kmp_team_t *team = this_thr->th.th_team;
int tid = __kmp_tid_from_gtid(gtid);
if (ompt_enabled.enabled) {
if (rc) {
if (ompt_enabled.ompt_callback_work) {
ompt_callbacks.ompt_callback(ompt_callback_work)(
ompt_work_single_executor, ompt_scope_begin,
&(team->t.ompt_team_info.parallel_data),
&(team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_data),
1, OMPT_GET_RETURN_ADDRESS(0));
}
} else {
if (ompt_enabled.ompt_callback_work) {
ompt_callbacks.ompt_callback(ompt_callback_work)(
ompt_work_single_other, ompt_scope_begin,
&(team->t.ompt_team_info.parallel_data),
&(team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_data),
1, OMPT_GET_RETURN_ADDRESS(0));
ompt_callbacks.ompt_callback(ompt_callback_work)(
ompt_work_single_other, ompt_scope_end,
&(team->t.ompt_team_info.parallel_data),
&(team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_data),
1, OMPT_GET_RETURN_ADDRESS(0));
}
}
}
#endif
return rc;
}
void *KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_COPY_START)(void) {
void *retval;
int gtid = __kmp_entry_gtid();
MKLOC(loc, "GOMP_single_copy_start");
KA_TRACE(20, ("GOMP_single_copy_start: T#%d\n", gtid));
if (!TCR_4(__kmp_init_parallel))
__kmp_parallel_initialize();
__kmp_resume_if_soft_paused();
// If this is the first thread to enter, return NULL. The generated code will
// then call GOMP_single_copy_end() for this thread only, with the
// copyprivate data pointer as an argument.
if (__kmp_enter_single(gtid, &loc, FALSE))
return NULL;
// Wait for the first thread to set the copyprivate data pointer,
// and for all other threads to reach this point.
#if OMPT_SUPPORT && OMPT_OPTIONAL
ompt_frame_t *ompt_frame;
if (ompt_enabled.enabled) {
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
OMPT_STORE_RETURN_ADDRESS(gtid);
}
#endif
__kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
// Retrieve the value of the copyprivate data point, and wait for all
// threads to do likewise, then return.
retval = __kmp_team_from_gtid(gtid)->t.t_copypriv_data;
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (ompt_enabled.enabled) {
OMPT_STORE_RETURN_ADDRESS(gtid);
}
#endif
__kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (ompt_enabled.enabled) {
ompt_frame->enter_frame = ompt_data_none;
}
#endif
return retval;
}
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_SINGLE_COPY_END)(void *data) {
int gtid = __kmp_get_gtid();
KA_TRACE(20, ("GOMP_single_copy_end: T#%d\n", gtid));
// Set the copyprivate data pointer fo the team, then hit the barrier so that
// the other threads will continue on and read it. Hit another barrier before
// continuing, so that the know that the copyprivate data pointer has been
// propagated to all threads before trying to reuse the t_copypriv_data field.
__kmp_team_from_gtid(gtid)->t.t_copypriv_data = data;
#if OMPT_SUPPORT && OMPT_OPTIONAL
ompt_frame_t *ompt_frame;
if (ompt_enabled.enabled) {
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
OMPT_STORE_RETURN_ADDRESS(gtid);
}
#endif
__kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (ompt_enabled.enabled) {
OMPT_STORE_RETURN_ADDRESS(gtid);
}
#endif
__kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (ompt_enabled.enabled) {
ompt_frame->enter_frame = ompt_data_none;
}
#endif
}
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ORDERED_START)(void) {
int gtid = __kmp_entry_gtid();
MKLOC(loc, "GOMP_ordered_start");
KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
#if OMPT_SUPPORT && OMPT_OPTIONAL
OMPT_STORE_RETURN_ADDRESS(gtid);
#endif
__kmpc_ordered(&loc, gtid);
}
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ORDERED_END)(void) {
int gtid = __kmp_get_gtid();
MKLOC(loc, "GOMP_ordered_end");
KA_TRACE(20, ("GOMP_ordered_start: T#%d\n", gtid));
#if OMPT_SUPPORT && OMPT_OPTIONAL
OMPT_STORE_RETURN_ADDRESS(gtid);
#endif
__kmpc_end_ordered(&loc, gtid);
}
// Dispatch macro defs
//
// They come in two flavors: 64-bit unsigned, and either 32-bit signed
// (IA-32 architecture) or 64-bit signed (Intel(R) 64).
#if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS
#define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_4
#define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_4
#define KMP_DISPATCH_NEXT __kmpc_dispatch_next_4
#else
#define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_8
#define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_8
#define KMP_DISPATCH_NEXT __kmpc_dispatch_next_8
#endif /* KMP_ARCH_X86 */
#define KMP_DISPATCH_INIT_ULL __kmp_aux_dispatch_init_8u
#define KMP_DISPATCH_FINI_CHUNK_ULL __kmp_aux_dispatch_fini_chunk_8u
#define KMP_DISPATCH_NEXT_ULL __kmpc_dispatch_next_8u
// The parallel contruct
#ifndef KMP_DEBUG
static
#endif /* KMP_DEBUG */
void
__kmp_GOMP_microtask_wrapper(int *gtid, int *npr, void (*task)(void *),
void *data) {
#if OMPT_SUPPORT
kmp_info_t *thr;
ompt_frame_t *ompt_frame;
ompt_state_t enclosing_state;
if (ompt_enabled.enabled) {
// get pointer to thread data structure
thr = __kmp_threads[*gtid];
// save enclosing task state; set current state for task
enclosing_state = thr->th.ompt_thread_info.state;
thr->th.ompt_thread_info.state = ompt_state_work_parallel;
// set task frame
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
ompt_frame->exit_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
}
#endif
task(data);
#if OMPT_SUPPORT
if (ompt_enabled.enabled) {
// clear task frame
ompt_frame->exit_frame = ompt_data_none;
// restore enclosing state
thr->th.ompt_thread_info.state = enclosing_state;
}
#endif
}
#ifndef KMP_DEBUG
static
#endif /* KMP_DEBUG */
void
__kmp_GOMP_parallel_microtask_wrapper(int *gtid, int *npr,
void (*task)(void *), void *data,
unsigned num_threads, ident_t *loc,
enum sched_type schedule, long start,
long end, long incr,
long chunk_size) {
// Intialize the loop worksharing construct.
KMP_DISPATCH_INIT(loc, *gtid, schedule, start, end, incr, chunk_size,
schedule != kmp_sch_static);
#if OMPT_SUPPORT
kmp_info_t *thr;
ompt_frame_t *ompt_frame;
ompt_state_t enclosing_state;
if (ompt_enabled.enabled) {
thr = __kmp_threads[*gtid];
// save enclosing task state; set current state for task
enclosing_state = thr->th.ompt_thread_info.state;
thr->th.ompt_thread_info.state = ompt_state_work_parallel;
// set task frame
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
ompt_frame->exit_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
}
#endif
// Now invoke the microtask.
task(data);
#if OMPT_SUPPORT
if (ompt_enabled.enabled) {
// clear task frame
ompt_frame->exit_frame = ompt_data_none;
// reset enclosing state
thr->th.ompt_thread_info.state = enclosing_state;
}
#endif
}
#ifndef KMP_DEBUG
static
#endif /* KMP_DEBUG */
void
__kmp_GOMP_fork_call(ident_t *loc, int gtid, void (*unwrapped_task)(void *),
microtask_t wrapper, int argc, ...) {
int rc;
kmp_info_t *thr = __kmp_threads[gtid];
kmp_team_t *team = thr->th.th_team;
int tid = __kmp_tid_from_gtid(gtid);
va_list ap;
va_start(ap, argc);
rc = __kmp_fork_call(loc, gtid, fork_context_gnu, argc, wrapper,
__kmp_invoke_task_func,
#if (KMP_ARCH_X86_64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64) && KMP_OS_LINUX
&ap
#else
ap
#endif
);
va_end(ap);
if (rc) {
__kmp_run_before_invoked_task(gtid, tid, thr, team);
}
#if OMPT_SUPPORT
int ompt_team_size;
if (ompt_enabled.enabled) {
ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
ompt_task_info_t *task_info = __ompt_get_task_info_object(0);
// implicit task callback
if (ompt_enabled.ompt_callback_implicit_task) {
ompt_team_size = __kmp_team_from_gtid(gtid)->t.t_nproc;
ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
ompt_scope_begin, &(team_info->parallel_data),
&(task_info->task_data), ompt_team_size, __kmp_tid_from_gtid(gtid), ompt_task_implicit); // TODO: Can this be ompt_task_initial?
task_info->thread_num = __kmp_tid_from_gtid(gtid);
}
thr->th.ompt_thread_info.state = ompt_state_work_parallel;
}
#endif
}
static void __kmp_GOMP_serialized_parallel(ident_t *loc, kmp_int32 gtid,
void (*task)(void *)) {
#if OMPT_SUPPORT
OMPT_STORE_RETURN_ADDRESS(gtid);
#endif
__kmp_serialized_parallel(loc, gtid);
}
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_START)(void (*task)(void *),
void *data,
unsigned num_threads) {
int gtid = __kmp_entry_gtid();
#if OMPT_SUPPORT
ompt_frame_t *parent_frame, *frame;
if (ompt_enabled.enabled) {
__ompt_get_task_info_internal(0, NULL, NULL, &parent_frame, NULL, NULL);
parent_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
OMPT_STORE_RETURN_ADDRESS(gtid);
}
#endif
MKLOC(loc, "GOMP_parallel_start");
KA_TRACE(20, ("GOMP_parallel_start: T#%d\n", gtid));
if (__kmpc_ok_to_fork(&loc) && (num_threads != 1)) {
if (num_threads != 0) {
__kmp_push_num_threads(&loc, gtid, num_threads);
}
__kmp_GOMP_fork_call(&loc, gtid, task,
(microtask_t)__kmp_GOMP_microtask_wrapper, 2, task,
data);
} else {
__kmp_GOMP_serialized_parallel(&loc, gtid, task);
}
#if OMPT_SUPPORT
if (ompt_enabled.enabled) {
__ompt_get_task_info_internal(0, NULL, NULL, &frame, NULL, NULL);
frame->exit_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
}
#endif
}
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_END)(void) {
int gtid = __kmp_get_gtid();
kmp_info_t *thr;
thr = __kmp_threads[gtid];
MKLOC(loc, "GOMP_parallel_end");
KA_TRACE(20, ("GOMP_parallel_end: T#%d\n", gtid));
if (!thr->th.th_team->t.t_serialized) {
__kmp_run_after_invoked_task(gtid, __kmp_tid_from_gtid(gtid), thr,
thr->th.th_team);
#if OMPT_SUPPORT
if (ompt_enabled.enabled) {
// Implicit task is finished here, in the barrier we might schedule
// deferred tasks,
// these don't see the implicit task on the stack
OMPT_CUR_TASK_INFO(thr)->frame.exit_frame = ompt_data_none;
}
#endif
__kmp_join_call(&loc, gtid
#if OMPT_SUPPORT
,
fork_context_gnu
#endif
);
} else {
__kmpc_end_serialized_parallel(&loc, gtid);
}
}
// Loop worksharing constructs
// The Gnu codegen passes in an exclusive upper bound for the overall range,
// but the libguide dispatch code expects an inclusive upper bound, hence the
// "end - incr" 5th argument to KMP_DISPATCH_INIT (and the " ub - str" 11th
// argument to __kmp_GOMP_fork_call).
//
// Conversely, KMP_DISPATCH_NEXT returns and inclusive upper bound in *p_ub,
// but the Gnu codegen expects an excluside upper bound, so the adjustment
// "*p_ub += stride" compenstates for the discrepancy.
//
// Correction: the gnu codegen always adjusts the upper bound by +-1, not the
// stride value. We adjust the dispatch parameters accordingly (by +-1), but
// we still adjust p_ub by the actual stride value.
//
// The "runtime" versions do not take a chunk_sz parameter.
//
// The profile lib cannot support construct checking of unordered loops that
// are predetermined by the compiler to be statically scheduled, as the gcc
// codegen will not always emit calls to GOMP_loop_static_next() to get the
// next iteration. Instead, it emits inline code to call omp_get_thread_num()
// num and calculate the iteration space using the result. It doesn't do this
// with ordered static loop, so they can be checked.
#if OMPT_SUPPORT
#define IF_OMPT_SUPPORT(code) code
#else
#define IF_OMPT_SUPPORT(code)
#endif
#define LOOP_START(func, schedule) \
int func(long lb, long ub, long str, long chunk_sz, long *p_lb, \
long *p_ub) { \
int status; \
long stride; \
int gtid = __kmp_entry_gtid(); \
MKLOC(loc, KMP_STR(func)); \
KA_TRACE( \
20, \
(KMP_STR( \
func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz 0x%lx\n", \
gtid, lb, ub, str, chunk_sz)); \
\
if ((str > 0) ? (lb < ub) : (lb > ub)) { \
IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
(str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
(schedule) != kmp_sch_static); \
IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
(kmp_int *)p_ub, (kmp_int *)&stride); \
if (status) { \
KMP_DEBUG_ASSERT(stride == str); \
*p_ub += (str > 0) ? 1 : -1; \
} \
} else { \
status = 0; \
} \
\
KA_TRACE( \
20, \
(KMP_STR( \
func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
gtid, *p_lb, *p_ub, status)); \
return status; \
}
#define LOOP_RUNTIME_START(func, schedule) \
int func(long lb, long ub, long str, long *p_lb, long *p_ub) { \
int status; \
long stride; \
long chunk_sz = 0; \
int gtid = __kmp_entry_gtid(); \
MKLOC(loc, KMP_STR(func)); \
KA_TRACE( \
20, \
(KMP_STR(func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n", \
gtid, lb, ub, str, chunk_sz)); \
\
if ((str > 0) ? (lb < ub) : (lb > ub)) { \
IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
(str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, TRUE); \
IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
(kmp_int *)p_ub, (kmp_int *)&stride); \
if (status) { \
KMP_DEBUG_ASSERT(stride == str); \
*p_ub += (str > 0) ? 1 : -1; \
} \
} else { \
status = 0; \
} \
\
KA_TRACE( \
20, \
(KMP_STR( \
func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
gtid, *p_lb, *p_ub, status)); \
return status; \
}
#define KMP_DOACROSS_FINI(status, gtid) \
if (!status && __kmp_threads[gtid]->th.th_dispatch->th_doacross_flags) { \
__kmpc_doacross_fini(NULL, gtid); \
}
#define LOOP_NEXT(func, fini_code) \
int func(long *p_lb, long *p_ub) { \
int status; \
long stride; \
int gtid = __kmp_get_gtid(); \
MKLOC(loc, KMP_STR(func)); \
KA_TRACE(20, (KMP_STR(func) ": T#%d\n", gtid)); \
\
IF_OMPT_SUPPORT(OMPT_STORE_RETURN_ADDRESS(gtid);) \
fini_code status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
(kmp_int *)p_ub, (kmp_int *)&stride); \
if (status) { \
*p_ub += (stride > 0) ? 1 : -1; \
} \
KMP_DOACROSS_FINI(status, gtid) \
\
KA_TRACE( \
20, \
(KMP_STR(func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, stride 0x%lx, " \
"returning %d\n", \
gtid, *p_lb, *p_ub, stride, status)); \
return status; \
}
LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_STATIC_START), kmp_sch_static)
LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_STATIC_NEXT), {})
LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DYNAMIC_START),
kmp_sch_dynamic_chunked)
LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_DYNAMIC_START),
kmp_sch_dynamic_chunked)
LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DYNAMIC_NEXT), {})
LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_DYNAMIC_NEXT), {})
LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_GUIDED_START),
kmp_sch_guided_chunked)
LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_GUIDED_START),
kmp_sch_guided_chunked)
LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_GUIDED_NEXT), {})
LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_NONMONOTONIC_GUIDED_NEXT), {})
LOOP_RUNTIME_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_RUNTIME_START),
kmp_sch_runtime)
LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_RUNTIME_NEXT), {})
LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_START),
kmp_ord_static)
LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_STATIC_NEXT),
{ KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_START),
kmp_ord_dynamic_chunked)
LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_DYNAMIC_NEXT),
{ KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
LOOP_START(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_START),
kmp_ord_guided_chunked)
LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_GUIDED_NEXT),
{ KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
LOOP_RUNTIME_START(
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_START),
kmp_ord_runtime)
LOOP_NEXT(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ORDERED_RUNTIME_NEXT),
{ KMP_DISPATCH_FINI_CHUNK(&loc, gtid); })
#define LOOP_DOACROSS_START(func, schedule) \
bool func(unsigned ncounts, long *counts, long chunk_sz, long *p_lb, \
long *p_ub) { \
int status; \
long stride, lb, ub, str; \
int gtid = __kmp_entry_gtid(); \
struct kmp_dim *dims = \
(struct kmp_dim *)__kmp_allocate(sizeof(struct kmp_dim) * ncounts); \
MKLOC(loc, KMP_STR(func)); \
for (unsigned i = 0; i < ncounts; ++i) { \
dims[i].lo = 0; \
dims[i].up = counts[i] - 1; \
dims[i].st = 1; \
} \
__kmpc_doacross_init(&loc, gtid, (int)ncounts, dims); \
lb = 0; \
ub = counts[0]; \
str = 1; \
KA_TRACE(20, (KMP_STR(func) ": T#%d, ncounts %u, lb 0x%lx, ub 0x%lx, str " \
"0x%lx, chunk_sz " \
"0x%lx\n", \
gtid, ncounts, lb, ub, str, chunk_sz)); \
\
if ((str > 0) ? (lb < ub) : (lb > ub)) { \
KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
(str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
(schedule) != kmp_sch_static); \
status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
(kmp_int *)p_ub, (kmp_int *)&stride); \
if (status) { \
KMP_DEBUG_ASSERT(stride == str); \
*p_ub += (str > 0) ? 1 : -1; \
} \
} else { \
status = 0; \
} \
KMP_DOACROSS_FINI(status, gtid); \
\
KA_TRACE( \
20, \
(KMP_STR( \
func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
gtid, *p_lb, *p_ub, status)); \
__kmp_free(dims); \
return status; \
}
#define LOOP_DOACROSS_RUNTIME_START(func, schedule) \
int func(unsigned ncounts, long *counts, long *p_lb, long *p_ub) { \
int status; \
long stride, lb, ub, str; \
long chunk_sz = 0; \
int gtid = __kmp_entry_gtid(); \
struct kmp_dim *dims = \
(struct kmp_dim *)__kmp_allocate(sizeof(struct kmp_dim) * ncounts); \
MKLOC(loc, KMP_STR(func)); \
for (unsigned i = 0; i < ncounts; ++i) { \
dims[i].lo = 0; \
dims[i].up = counts[i] - 1; \
dims[i].st = 1; \
} \
__kmpc_doacross_init(&loc, gtid, (int)ncounts, dims); \
lb = 0; \
ub = counts[0]; \
str = 1; \
KA_TRACE( \
20, \
(KMP_STR(func) ": T#%d, lb 0x%lx, ub 0x%lx, str 0x%lx, chunk_sz %d\n", \
gtid, lb, ub, str, chunk_sz)); \
\
if ((str > 0) ? (lb < ub) : (lb > ub)) { \
KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb, \
(str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, TRUE); \
status = KMP_DISPATCH_NEXT(&loc, gtid, NULL, (kmp_int *)p_lb, \
(kmp_int *)p_ub, (kmp_int *)&stride); \
if (status) { \
KMP_DEBUG_ASSERT(stride == str); \
*p_ub += (str > 0) ? 1 : -1; \
} \
} else { \
status = 0; \
} \
KMP_DOACROSS_FINI(status, gtid); \
\
KA_TRACE( \
20, \
(KMP_STR( \
func) " exit: T#%d, *p_lb 0x%lx, *p_ub 0x%lx, returning %d\n", \
gtid, *p_lb, *p_ub, status)); \
__kmp_free(dims); \
return status; \
}
LOOP_DOACROSS_START(
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_STATIC_START),
kmp_sch_static)
LOOP_DOACROSS_START(
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_DYNAMIC_START),
kmp_sch_dynamic_chunked)
LOOP_DOACROSS_START(
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_GUIDED_START),
kmp_sch_guided_chunked)
LOOP_DOACROSS_RUNTIME_START(
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_DOACROSS_RUNTIME_START),
kmp_sch_runtime)
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_END)(void) {
int gtid = __kmp_get_gtid();
KA_TRACE(20, ("GOMP_loop_end: T#%d\n", gtid))
#if OMPT_SUPPORT && OMPT_OPTIONAL
ompt_frame_t *ompt_frame;
if (ompt_enabled.enabled) {
__ompt_get_task_info_internal(0, NULL, NULL, &ompt_frame, NULL, NULL);
ompt_frame->enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
OMPT_STORE_RETURN_ADDRESS(gtid);
}
#endif
__kmp_barrier(bs_plain_barrier, gtid, FALSE, 0, NULL, NULL);
#if OMPT_SUPPORT && OMPT_OPTIONAL
if (ompt_enabled.enabled) {
ompt_frame->enter_frame = ompt_data_none;
}
#endif
KA_TRACE(20, ("GOMP_loop_end exit: T#%d\n", gtid))
}
void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_END_NOWAIT)(void) {
KA_TRACE(20, ("GOMP_loop_end_nowait: T#%d\n", __kmp_get_gtid()))
}
// Unsigned long long loop worksharing constructs
//
// These are new with gcc 4.4
#define LOOP_START_ULL(func, schedule) \
int func(int up, unsigned long long lb, unsigned long long ub, \
unsigned long long str, unsigned long long chunk_sz, \
unsigned long long *p_lb, unsigned long long *p_ub) { \
int status; \
long long str2 = up ? ((long long)str) : -((long long)str); \
long long stride; \
int gtid = __kmp_entry_gtid(); \
MKLOC(loc, KMP_STR(func)); \
\
KA_TRACE(20, (KMP_STR(func) ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str " \
"0x%llx, chunk_sz 0x%llx\n", \
gtid, up, lb, ub, str, chunk_sz)); \
\
if ((str > 0) ? (lb < ub) : (lb > ub)) { \
KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
(str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, \
(schedule) != kmp_sch_static); \
status = \
KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
(kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
if (status) { \
KMP_DEBUG_ASSERT(stride == str2); \
*p_ub += (str > 0) ? 1 : -1; \
} \
} else { \
status = 0; \
} \
\
KA_TRACE( \
20, \
(KMP_STR( \
func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
gtid, *p_lb, *p_ub, status)); \
return status; \
}
#define LOOP_RUNTIME_START_ULL(func, schedule) \
int func(int up, unsigned long long lb, unsigned long long ub, \
unsigned long long str, unsigned long long *p_lb, \
unsigned long long *p_ub) { \
int status; \
long long str2 = up ? ((long long)str) : -((long long)str); \
unsigned long long stride; \
unsigned long long chunk_sz = 0; \
int gtid = __kmp_entry_gtid(); \
MKLOC(loc, KMP_STR(func)); \
\
KA_TRACE(20, (KMP_STR(func) ": T#%d, up %d, lb 0x%llx, ub 0x%llx, str " \
"0x%llx, chunk_sz 0x%llx\n", \
gtid, up, lb, ub, str, chunk_sz)); \
\
if ((str > 0) ? (lb < ub) : (lb > ub)) { \
KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
(str2 > 0) ? (ub - 1) : (ub + 1), str2, chunk_sz, \
TRUE); \
status = \
KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
(kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
if (status) { \
KMP_DEBUG_ASSERT((long long)stride == str2); \
*p_ub += (str > 0) ? 1 : -1; \
} \
} else { \
status = 0; \
} \
\
KA_TRACE( \
20, \
(KMP_STR( \
func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
gtid, *p_lb, *p_ub, status)); \
return status; \
}
#define LOOP_NEXT_ULL(func, fini_code) \
int func(unsigned long long *p_lb, unsigned long long *p_ub) { \
int status; \
long long stride; \
int gtid = __kmp_get_gtid(); \
MKLOC(loc, KMP_STR(func)); \
KA_TRACE(20, (KMP_STR(func) ": T#%d\n", gtid)); \
\
fini_code status = \
KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
(kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
if (status) { \
*p_ub += (stride > 0) ? 1 : -1; \
} \
\
KA_TRACE( \
20, \
(KMP_STR( \
func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, stride 0x%llx, " \
"returning %d\n", \
gtid, *p_lb, *p_ub, stride, status)); \
return status; \
}
LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_START),
kmp_sch_static)
LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_STATIC_NEXT), {})
LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_START),
kmp_sch_dynamic_chunked)
LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_DYNAMIC_NEXT), {})
LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_START),
kmp_sch_guided_chunked)
LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_GUIDED_NEXT), {})
LOOP_START_ULL(
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_DYNAMIC_START),
kmp_sch_dynamic_chunked)
LOOP_NEXT_ULL(
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_DYNAMIC_NEXT), {})
LOOP_START_ULL(
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_GUIDED_START),
kmp_sch_guided_chunked)
LOOP_NEXT_ULL(
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_NONMONOTONIC_GUIDED_NEXT), {})
LOOP_RUNTIME_START_ULL(
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_START), kmp_sch_runtime)
LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_RUNTIME_NEXT), {})
LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_START),
kmp_ord_static)
LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_STATIC_NEXT),
{ KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
LOOP_START_ULL(
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_START),
kmp_ord_dynamic_chunked)
LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_DYNAMIC_NEXT),
{ KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
LOOP_START_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_START),
kmp_ord_guided_chunked)
LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_GUIDED_NEXT),
{ KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
LOOP_RUNTIME_START_ULL(
KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_START),
kmp_ord_runtime)
LOOP_NEXT_ULL(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_LOOP_ULL_ORDERED_RUNTIME_NEXT),
{ KMP_DISPATCH_FINI_CHUNK_ULL(&loc, gtid); })
#define LOOP_DOACROSS_START_ULL(func, schedule) \
int func(unsigned ncounts, unsigned long long *counts, \
unsigned long long chunk_sz, unsigned long long *p_lb, \
unsigned long long *p_ub) { \
int status; \
long long stride, str, lb, ub; \
int gtid = __kmp_entry_gtid(); \
struct kmp_dim *dims = \
(struct kmp_dim *)__kmp_allocate(sizeof(struct kmp_dim) * ncounts); \
MKLOC(loc, KMP_STR(func)); \
for (unsigned i = 0; i < ncounts; ++i) { \
dims[i].lo = 0; \
dims[i].up = counts[i] - 1; \
dims[i].st = 1; \
} \
__kmpc_doacross_init(&loc, gtid, (int)ncounts, dims); \
lb = 0; \
ub = counts[0]; \
str = 1; \
\
KA_TRACE(20, (KMP_STR(func) ": T#%d, lb 0x%llx, ub 0x%llx, str " \
"0x%llx, chunk_sz 0x%llx\n", \
gtid, lb, ub, str, chunk_sz)); \
\
if ((str > 0) ? (lb < ub) : (lb > ub)) { \
KMP_DISPATCH_INIT_ULL(&loc, gtid, (schedule), lb, \
(str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz, \
(schedule) != kmp_sch_static); \
status = \
KMP_DISPATCH_NEXT_ULL(&loc, gtid, NULL, (kmp_uint64 *)p_lb, \
(kmp_uint64 *)p_ub, (kmp_int64 *)&stride); \
if (status) { \
KMP_DEBUG_ASSERT(stride == str); \
*p_ub += (str > 0) ? 1 : -1; \
} \
} else { \
status = 0; \
} \
KMP_DOACROSS_FINI(status, gtid); \
\
KA_TRACE( \
20, \
(KMP_STR( \
func) " exit: T#%d, *p_lb 0x%llx, *p_ub 0x%llx, returning %d\n", \
gtid, *p_lb, *p_ub, status)); \
__kmp_free(dims); \
return status; \
}
#define LOOP_DOACROSS_RUNTIME_START_ULL(func, schedule) \
int func(unsigned ncounts, unsigned long long *counts, \
unsigned long long *p_lb, unsigned long long *p_ub) { \
int status; \
unsigned long long stride, str, lb, ub; \
unsigned long long chunk_sz = 0; \
int gtid = __kmp_entry_gtid(); \
struct kmp_dim *dims = \
(struct kmp_dim *)__kmp_allocate(sizeof(struct kmp_dim) * ncounts); \
MKLOC(loc, KMP_STR(func)); \
for (unsigned i = 0; i < ncounts; ++i) { \
dims[i].lo = 0; \
dims[i].up = counts[i] - 1; \
dims[i].st = 1; \
} \
__kmpc_doacross_init(&loc, gtid, (int)ncounts, dims); \
lb = 0; \
ub = counts[0]; \