24#define USE_NGO_STORES 1
27#if KMP_MIC && USE_NGO_STORES
29#define ngo_load(src) __m512d Vt = _mm512_load_pd((void *)(src))
30#define ngo_store_icvs(dst, src) _mm512_storenrngo_pd((void *)(dst), Vt)
31#define ngo_store_go(dst, src) _mm512_storenrngo_pd((void *)(dst), Vt)
32#define ngo_sync() __asm__ volatile("lock; addl $0,0(%%rsp)" ::: "memory")
34#define ngo_load(src) ((void)0)
35#define ngo_store_icvs(dst, src) copy_icvs((dst), (src))
36#define ngo_store_go(dst, src) KMP_MEMCPY((dst), (src), CACHE_LINE)
37#define ngo_sync() ((void)0)
47void distributedBarrier::computeVarsForN(
size_t n) {
52 int ncores_per_socket =
58 if (ncores_per_socket <= 0)
59 ncores_per_socket = 1;
78 if (nsockets == 1 ||
num_gos == 1)
109void distributedBarrier::computeGo(
size_t n) {
128void distributedBarrier::resize(
size_t nthr) {
166 go[
j].go.store(next_go);
174 flags[
i][
j].stillNeed.store(1, std::memory_order_relaxed);
183void distributedBarrier::init(
size_t nthr) {
191 flags[
j][
i].stillNeed.store(1, std::memory_order_relaxed);
200 computeVarsForN(nthr);
236 size_t start,
size_t stop,
size_t inc,
243 for (
size_t thr = start; thr <
stop; thr += inc) {
245 int gtid = other_threads[thr]->th.th_info.ds.ds_gtid;
262 team = this_thr->th.th_team;
263 nproc = this_thr->th.th_team_nproc;
264 other_threads = team->
t.t_threads;
266 my_current_iter =
b->iter[tid].iter;
268 group_leader = ((tid %
b->threads_per_group) == 0);
271 (
"__kmp_dist_barrier_gather: T#%d(%d:%d) enter; barrier type %d\n",
272 gtid, team->
t.t_id, tid, bt));
274#if USE_ITT_BUILD && USE_ITT_NOTIFY
276 if (__kmp_forkjoin_frames_mode == 3 || __kmp_forkjoin_frames_mode == 2) {
277 this_thr->th.th_bar_arrive_time = this_thr->th.th_bar_min_time =
278 __itt_get_timestamp();
284 size_t group_start = tid + 1;
285 size_t group_end = tid +
b->threads_per_group;
286 size_t threads_pending = 0;
288 if (group_end > nproc)
293 for (
size_t thr = group_start; thr < group_end; thr++) {
297 threads_pending +=
b->flags[my_current_iter][thr].stillNeed.load(
298 std::memory_order_relaxed);
303 if (task_team != NULL) {
306 int tasks_completed =
FALSE;
325 }
while (threads_pending > 0);
328 std::atomic_thread_fence(std::memory_order_acquire);
334 for (
size_t thr = group_start; thr < group_end; thr++) {
335 (*reduce)(this_thr->th.th_local.reduce_data,
336 other_threads[thr]->th.th_local.reduce_data);
342 b->flags[my_next_iter][tid].stillNeed.store(1, std::memory_order_relaxed);
346 b->flags[my_current_iter][tid].stillNeed.store(0,
347 std::memory_order_release);
351 for (
size_t thr = 0; thr < nproc; thr +=
b->threads_per_group) {
352 threads_pending +=
b->flags[my_current_iter][thr].stillNeed.load(
353 std::memory_order_relaxed);
358 if (task_team != NULL) {
361 int tasks_completed =
FALSE;
380 }
while (threads_pending > 0);
382 std::atomic_thread_fence(std::memory_order_acquire);
388 for (
size_t thr =
b->threads_per_group; thr < nproc;
389 thr +=
b->threads_per_group) {
390 (*reduce)(this_thr->th.th_local.reduce_data,
391 other_threads[thr]->th.th_local.reduce_data);
398 b->flags[my_next_iter][tid].stillNeed.store(1, std::memory_order_relaxed);
402 b->flags[my_current_iter][tid].stillNeed.store(0,
403 std::memory_order_release);
409 (
"__kmp_dist_barrier_gather: T#%d(%d:%d) exit for barrier type %d\n",
410 gtid, team->
t.t_id, tid, bt));
424 KA_TRACE(20, (
"__kmp_dist_barrier_release: T#%d(%d) enter; barrier type %d\n",
427 thr_bar = &this_thr->th.th_bar[bt].bb;
432 if (this_thr->th.th_used_in_team.load() != 1 &&
433 this_thr->th.th_used_in_team.load() != 3) {
441 this_thr->th.th_used_in_team.load() == 0) {
444#if USE_ITT_BUILD && USE_ITT_NOTIFY
445 if ((__itt_sync_create_ptr && itt_sync_obj == NULL) || KMP_ITT_DEBUG) {
450 __kmp_itt_task_starting(itt_sync_obj);
456 if (itt_sync_obj != NULL)
458 __kmp_itt_task_finished(itt_sync_obj);
464 if (this_thr->th.th_used_in_team.load() != 1 &&
465 this_thr->th.th_used_in_team.load() != 3)
477 team = this_thr->th.th_team;
481 my_current_iter =
b->iter[tid].iter;
483 my_go_index = tid /
b->threads_per_go;
484 if (this_thr->th.th_used_in_team.load() == 3) {
489 if (
b->go[my_go_index].go.load() != next_go) {
492 &(
b->go[my_go_index].go), next_go, &(
b->sleep[tid].sleep));
495 b->iter[tid].iter == 0);
506 if (this_thr->th.th_used_in_team.load() == 1)
513 group_leader = ((tid %
b->threads_per_group) == 0);
516 for (
size_t go_idx = my_go_index + 1;
517 go_idx < my_go_index +
b->gos_per_group; go_idx++) {
518 b->go[go_idx].go.store(next_go);
524#if KMP_BARRIER_ICV_PUSH
525 if (propagate_icvs) {
528 copy_icvs(&team->
t.t_implicit_task_taskdata[tid].td_icvs,
531 &team->
t.t_implicit_task_taskdata[tid].td_icvs);
537 size_t nproc = this_thr->th.th_team_nproc;
538 size_t group_end = tid +
b->threads_per_group;
539 if (nproc < group_end)
544 team = this_thr->th.th_team;
546 my_current_iter =
b->iter[tid].iter;
548#if KMP_BARRIER_ICV_PUSH
549 if (propagate_icvs) {
552 &team->
t.t_implicit_task_taskdata[tid].td_icvs);
556 for (
size_t go_idx = 0; go_idx <
b->num_gos; go_idx +=
b->gos_per_group) {
557 b->go[go_idx].go.store(next_go);
562 size_t nproc = this_thr->th.th_team_nproc;
564 b->threads_per_group, tid);
568 for (
size_t go_idx = 1; go_idx <
b->gos_per_group; go_idx++) {
569 b->go[go_idx].go.store(next_go);
577 size_t nproc = this_thr->th.th_team_nproc;
578 size_t group_end = tid +
b->threads_per_group;
579 if (nproc < group_end)
589 20, (
"__kmp_dist_barrier_release: T#%d(%d:%d) exit for barrier type %d\n",
590 gtid, team->
t.t_id, tid, bt));
594template <
bool cancellable = false>
605 (
"__kmp_linear_barrier_gather: T#%d(%d:%d) enter for barrier type %d\n",
606 gtid, team->
t.t_id, tid, bt));
607 KMP_DEBUG_ASSERT(this_thr == other_threads[this_thr->th.th_info.ds.ds_tid]);
609#if USE_ITT_BUILD && USE_ITT_NOTIFY
611 if (__kmp_forkjoin_frames_mode == 3 || __kmp_forkjoin_frames_mode == 2) {
612 this_thr->th.th_bar_arrive_time = this_thr->th.th_bar_min_time =
613 __itt_get_timestamp();
620 (
"__kmp_linear_barrier_gather: T#%d(%d:%d) releasing T#%d(%d:%d)"
621 "arrived(%p): %llu => %llu\n",
623 team->
t.t_id, 0, &thr_bar->b_arrived, thr_bar->b_arrived,
633 int nproc = this_thr->th.th_team_nproc;
639 for (
i = 1;
i < nproc; ++
i) {
645 KA_TRACE(20, (
"__kmp_linear_barrier_gather: T#%d(%d:%d) wait T#%d(%d:%d) "
646 "arrived(%p) == %llu\n",
649 &other_threads[
i]->th.th_bar[bt].bb.b_arrived, new_state));
654 &other_threads[
i]->th.th_bar[bt].bb.b_arrived, new_state);
662#if USE_ITT_BUILD && USE_ITT_NOTIFY
665 if (__kmp_forkjoin_frames_mode == 2) {
666 this_thr->th.th_bar_min_time =
KMP_MIN(
667 this_thr->th.th_bar_min_time, other_threads[
i]->th.th_bar_min_time);
672 (
"__kmp_linear_barrier_gather: T#%d(%d:%d) += T#%d(%d:%d)\n",
677 (*reduce)(this_thr->th.th_local.reduce_data,
678 other_threads[
i]->th.th_local.reduce_data);
684 KA_TRACE(20, (
"__kmp_linear_barrier_gather: T#%d(%d:%d) set team %d "
685 "arrived(%p) = %llu\n",
686 gtid, team->
t.t_id, tid, team->
t.t_id, &team_bar->
b_arrived,
691 (
"__kmp_linear_barrier_gather: T#%d(%d:%d) exit for barrier type %d\n",
692 gtid, team->
t.t_id, tid, bt));
696template <
bool cancellable = false>
706 kmp_uint32 nproc = this_thr->th.th_team_nproc;
711 other_threads = team->
t.t_threads;
713 KA_TRACE(20, (
"__kmp_linear_barrier_release: T#%d(%d:%d) primary enter for "
715 gtid, team->
t.t_id, tid, bt));
718#if KMP_BARRIER_ICV_PUSH
721 if (propagate_icvs) {
722 ngo_load(&team->
t.t_implicit_task_taskdata[0].td_icvs);
723 for (
i = 1;
i < nproc; ++
i) {
727 &team->
t.t_implicit_task_taskdata[0].td_icvs);
735 for (
i = 1;
i < nproc; ++
i) {
743 (
"__kmp_linear_barrier_release: T#%d(%d:%d) releasing T#%d(%d:%d) "
744 "go(%p): %u => %u\n",
745 gtid, team->
t.t_id, tid, other_threads[
i]->th.th_info.ds.ds_gtid,
746 team->
t.t_id,
i, &other_threads[
i]->th.th_bar[bt].bb.b_go,
747 other_threads[
i]->th.th_bar[bt].bb.b_go,
755 KA_TRACE(20, (
"__kmp_linear_barrier_release: T#%d wait go(%p) == %u\n",
765#if USE_ITT_BUILD && USE_ITT_NOTIFY
766 if ((__itt_sync_create_ptr && itt_sync_obj == NULL) || KMP_ITT_DEBUG) {
771 __kmp_itt_task_starting(itt_sync_obj);
777 if (itt_sync_obj != NULL)
779 __kmp_itt_task_finished(itt_sync_obj);
793 (
"__kmp_linear_barrier_release: T#%d(%d:%d) set go(%p) = %u\n",
799 (
"__kmp_linear_barrier_release: T#%d(%d:%d) exit for barrier type %d\n",
800 gtid, team->
t.t_id, tid, bt));
840 kmp_uint32 nproc = this_thr->th.th_team_nproc;
848 20, (
"__kmp_tree_barrier_gather: T#%d(%d:%d) enter for barrier type %d\n",
849 gtid, team->
t.t_id, tid, bt));
850 KMP_DEBUG_ASSERT(this_thr == other_threads[this_thr->th.th_info.ds.ds_tid]);
852#if USE_ITT_BUILD && USE_ITT_NOTIFY
854 if (__kmp_forkjoin_frames_mode == 3 || __kmp_forkjoin_frames_mode == 2) {
855 this_thr->th.th_bar_arrive_time = this_thr->th.th_bar_min_time =
856 __itt_get_timestamp();
861 child_tid = (tid << branch_bits) + 1;
862 if (child_tid < nproc) {
867 kmp_info_t *child_thr = other_threads[child_tid];
871 if (child + 1 <= branch_factor && child_tid + 1 < nproc)
873 &other_threads[child_tid + 1]->th.th_bar[bt].bb.b_arrived);
876 (
"__kmp_tree_barrier_gather: T#%d(%d:%d) wait T#%d(%d:%u) "
877 "arrived(%p) == %llu\n",
879 team->
t.t_id, child_tid, &child_bar->b_arrived, new_state));
883#if USE_ITT_BUILD && USE_ITT_NOTIFY
886 if (__kmp_forkjoin_frames_mode == 2) {
887 this_thr->th.th_bar_min_time =
KMP_MIN(this_thr->th.th_bar_min_time,
888 child_thr->th.th_bar_min_time);
893 (
"__kmp_tree_barrier_gather: T#%d(%d:%d) += T#%d(%d:%u)\n",
895 team->
t.t_id, child_tid));
898 (*reduce)(this_thr->th.th_local.reduce_data,
899 child_thr->th.th_local.reduce_data);
904 }
while (child <= branch_factor && child_tid < nproc);
908 kmp_int32 parent_tid = (tid - 1) >> branch_bits;
911 (
"__kmp_tree_barrier_gather: T#%d(%d:%d) releasing T#%d(%d:%d) "
912 "arrived(%p): %llu => %llu\n",
914 team->
t.t_id, parent_tid, &thr_bar->b_arrived, thr_bar->b_arrived,
926 team->
t.t_bar[bt].b_arrived = new_state;
929 KA_TRACE(20, (
"__kmp_tree_barrier_gather: T#%d(%d:%d) set team %d "
930 "arrived(%p) = %llu\n",
931 gtid, team->
t.t_id, tid, team->
t.t_id,
932 &team->
t.t_bar[bt].b_arrived, team->
t.t_bar[bt].b_arrived));
935 (
"__kmp_tree_barrier_gather: T#%d(%d:%d) exit for barrier type %d\n",
936 gtid, team->
t.t_id, tid, bt));
954 KA_TRACE(20, (
"__kmp_tree_barrier_release: T#%d wait go(%p) == %u\n", gtid,
959#if USE_ITT_BUILD && USE_ITT_NOTIFY
960 if ((__itt_sync_create_ptr && itt_sync_obj == NULL) || KMP_ITT_DEBUG) {
965 __kmp_itt_task_starting(itt_sync_obj);
971 if (itt_sync_obj != NULL)
973 __kmp_itt_task_finished(itt_sync_obj);
987 (
"__kmp_tree_barrier_release: T#%d(%d:%d) set go(%p) = %u\n", gtid,
993 KA_TRACE(20, (
"__kmp_tree_barrier_release: T#%d(%d:%d) primary enter for "
995 gtid, team->
t.t_id, tid, bt));
997 nproc = this_thr->th.th_team_nproc;
998 child_tid = (tid << branch_bits) + 1;
1000 if (child_tid < nproc) {
1005 kmp_info_t *child_thr = other_threads[child_tid];
1006 kmp_bstate_t *child_bar = &child_thr->th.th_bar[bt].bb;
1009 if (child + 1 <= branch_factor && child_tid + 1 < nproc)
1011 &other_threads[child_tid + 1]->th.th_bar[bt].bb.b_go);
1014#if KMP_BARRIER_ICV_PUSH
1017 if (propagate_icvs) {
1019 team->
t.t_threads[child_tid], team,
1021 copy_icvs(&team->
t.t_implicit_task_taskdata[child_tid].td_icvs,
1022 &team->
t.t_implicit_task_taskdata[0].td_icvs);
1027 (
"__kmp_tree_barrier_release: T#%d(%d:%d) releasing T#%d(%d:%u)"
1028 "go(%p): %u => %u\n",
1030 team->
t.t_id, child_tid, &child_bar->b_go, child_bar->b_go,
1037 }
while (child <= branch_factor && child_tid < nproc);
1040 20, (
"__kmp_tree_barrier_release: T#%d(%d:%d) exit for barrier type %d\n",
1041 gtid, team->
t.t_id, tid, bt));
1053 kmp_uint32 num_threads = this_thr->th.th_team_nproc;
1061 (
"__kmp_hyper_barrier_gather: T#%d(%d:%d) enter for barrier type %d\n",
1062 gtid, team->
t.t_id, tid, bt));
1063 KMP_DEBUG_ASSERT(this_thr == other_threads[this_thr->th.th_info.ds.ds_tid]);
1065#if USE_ITT_BUILD && USE_ITT_NOTIFY
1067 if (__kmp_forkjoin_frames_mode == 3 || __kmp_forkjoin_frames_mode == 2) {
1068 this_thr->th.th_bar_arrive_time = this_thr->th.th_bar_min_time =
1069 __itt_get_timestamp();
1075 for (
level = 0, offset = 1; offset < num_threads;
1076 level += branch_bits, offset <<= branch_bits) {
1080 if (((tid >>
level) & (branch_factor - 1)) != 0) {
1081 kmp_int32 parent_tid = tid & ~((1 << (
level + branch_bits)) - 1);
1085 (
"__kmp_hyper_barrier_gather: T#%d(%d:%d) releasing T#%d(%d:%d) "
1086 "arrived(%p): %llu => %llu\n",
1088 team->
t.t_id, parent_tid, &thr_bar->b_arrived,
1095 p_flag.
set_waiter(other_threads[parent_tid]);
1103 for (child = 1, child_tid = tid + (1 <<
level);
1104 child < branch_factor && child_tid < num_threads;
1105 child++, child_tid += (1 <<
level)) {
1106 kmp_info_t *child_thr = other_threads[child_tid];
1107 kmp_bstate_t *child_bar = &child_thr->th.th_bar[bt].bb;
1111 if (child + 1 < branch_factor && next_child_tid < num_threads)
1113 &other_threads[next_child_tid]->th.th_bar[bt].bb.b_arrived);
1116 (
"__kmp_hyper_barrier_gather: T#%d(%d:%d) wait T#%d(%d:%u) "
1117 "arrived(%p) == %llu\n",
1119 team->
t.t_id, child_tid, &child_bar->b_arrived, new_state));
1124#if USE_ITT_BUILD && USE_ITT_NOTIFY
1127 if (__kmp_forkjoin_frames_mode == 2) {
1128 this_thr->th.th_bar_min_time =
KMP_MIN(this_thr->th.th_bar_min_time,
1129 child_thr->th.th_bar_min_time);
1134 (
"__kmp_hyper_barrier_gather: T#%d(%d:%d) += T#%d(%d:%u)\n",
1136 team->
t.t_id, child_tid));
1139 (*reduce)(this_thr->th.th_local.reduce_data,
1140 child_thr->th.th_local.reduce_data);
1151 team->
t.t_bar[bt].b_arrived = new_state;
1152 KA_TRACE(20, (
"__kmp_hyper_barrier_gather: T#%d(%d:%d) set team %d "
1153 "arrived(%p) = %llu\n",
1154 gtid, team->
t.t_id, tid, team->
t.t_id,
1155 &team->
t.t_bar[bt].b_arrived, team->
t.t_bar[bt].b_arrived));
1158 20, (
"__kmp_hyper_barrier_gather: T#%d(%d:%d) exit for barrier type %d\n",
1159 gtid, team->
t.t_id, tid, bt));
1163#define KMP_REVERSE_HYPER_BAR
1186 KA_TRACE(20, (
"__kmp_hyper_barrier_release: T#%d(%d:%d) primary enter for "
1187 "barrier type %d\n",
1188 gtid, team->
t.t_id, tid, bt));
1189#if KMP_BARRIER_ICV_PUSH
1190 if (propagate_icvs) {
1192 &team->
t.t_implicit_task_taskdata[tid].td_icvs);
1196 KA_TRACE(20, (
"__kmp_hyper_barrier_release: T#%d wait go(%p) == %u\n", gtid,
1201#if USE_ITT_BUILD && USE_ITT_NOTIFY
1202 if ((__itt_sync_create_ptr && itt_sync_obj == NULL) || KMP_ITT_DEBUG) {
1206 __kmp_itt_task_starting(itt_sync_obj);
1212 if (itt_sync_obj != NULL)
1214 __kmp_itt_task_finished(itt_sync_obj);
1228 (
"__kmp_hyper_barrier_release: T#%d(%d:%d) set go(%p) = %u\n",
1232 num_threads = this_thr->th.th_team_nproc;
1233 other_threads = team->
t.t_threads;
1235#ifdef KMP_REVERSE_HYPER_BAR
1237 for (
level = 0, offset = 1;
1238 offset < num_threads && (((tid >>
level) & (branch_factor - 1)) == 0);
1239 level += branch_bits, offset <<= branch_bits)
1243 for (
level -= branch_bits, offset >>= branch_bits; offset != 0;
1244 level -= branch_bits, offset >>= branch_bits)
1247 for (
level = 0, offset = 1; offset < num_threads;
1248 level += branch_bits, offset <<= branch_bits)
1251#ifdef KMP_REVERSE_HYPER_BAR
1255 for (child = (child < branch_factor - 1) ? child : branch_factor - 1,
1256 child_tid = tid + (child <<
level);
1257 child >= 1; child--, child_tid -= (1 <<
level))
1259 if (((tid >>
level) & (branch_factor - 1)) != 0)
1264 for (child = 1, child_tid = tid + (1 <<
level);
1265 child < branch_factor && child_tid < num_threads;
1266 child++, child_tid += (1 <<
level))
1269 if (child_tid >= num_threads)
1272 kmp_info_t *child_thr = other_threads[child_tid];
1273 kmp_bstate_t *child_bar = &child_thr->th.th_bar[bt].bb;
1277#ifdef KMP_REVERSE_HYPER_BAR
1278 if (child - 1 >= 1 && next_child_tid < num_threads)
1280 if (child + 1 < branch_factor && next_child_tid < num_threads)
1283 &other_threads[next_child_tid]->th.th_bar[bt].bb.b_go);
1286#if KMP_BARRIER_ICV_PUSH
1288 copy_icvs(&child_bar->th_fixed_icvs, &thr_bar->th_fixed_icvs);
1293 (
"__kmp_hyper_barrier_release: T#%d(%d:%d) releasing T#%d(%d:%u)"
1294 "go(%p): %u => %u\n",
1296 team->
t.t_id, child_tid, &child_bar->b_go, child_bar->b_go,
1304#if KMP_BARRIER_ICV_PUSH
1305 if (propagate_icvs &&
1309 copy_icvs(&team->
t.t_implicit_task_taskdata[tid].td_icvs,
1310 &thr_bar->th_fixed_icvs);
1315 (
"__kmp_hyper_barrier_release: T#%d(%d:%d) exit for barrier type %d\n",
1316 gtid, team->
t.t_id, tid, bt));
1336#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
1337#define __kmp_msb_byteoffset(offset) (offset)
1339#define __kmp_msb_byteoffset(offset) (7 - (offset))
1343 bool uninitialized = thr_bar->team == NULL;
1344 bool team_changed = team != thr_bar->team;
1345 bool team_sz_changed = nproc != thr_bar->nproc;
1346 bool tid_changed = tid != thr_bar->old_tid;
1347 bool retval =
false;
1349 if (uninitialized || team_sz_changed) {
1353 if (uninitialized || team_sz_changed || tid_changed) {
1354 thr_bar->my_level = thr_bar->depth - 1;
1355 thr_bar->parent_tid = -1;
1356 thr_bar->offset = -1;
1363 if (
d == thr_bar->depth - 2) {
1364 thr_bar->parent_tid = 0;
1365 thr_bar->my_level =
d;
1367 }
else if ((rem = tid % thr_bar->skip_per_level[
d + 1]) != 0) {
1370 thr_bar->parent_tid = tid - rem;
1371 thr_bar->my_level =
d;
1378 thr_bar->skip_per_level[thr_bar->my_level];
1379 offset = offset - 1;
1384 thr_bar->old_tid = tid;
1386 thr_bar->team = team;
1387 thr_bar->parent_bar =
1388 &team->
t.t_threads[thr_bar->parent_tid]->th.th_bar[bt].bb;
1390 if (uninitialized || team_changed || tid_changed) {
1391 thr_bar->team = team;
1392 thr_bar->parent_bar =
1393 &team->
t.t_threads[thr_bar->parent_tid]->th.th_bar[bt].bb;
1396 if (uninitialized || team_sz_changed || tid_changed) {
1397 thr_bar->nproc = nproc;
1398 thr_bar->leaf_kids = thr_bar->base_leaf_kids;
1399 if (thr_bar->my_level == 0)
1400 thr_bar->leaf_kids = 0;
1401 if (thr_bar->leaf_kids && (
kmp_uint32)tid + thr_bar->leaf_kids + 1 > nproc)
1403 thr_bar->leaf_state = 0;
1404 for (
int i = 0;
i < thr_bar->leaf_kids; ++
i)
1409#undef __kmp_msb_byteoffset
1418 kmp_uint32 nproc = this_thr->th.th_team_nproc;
1422 int level = team->
t.t_level;
1423 if (other_threads[0]
1424 ->th.th_teams_microtask)
1425 if (this_thr->th.th_teams_size.nteams > 1)
1428 thr_bar->use_oncore_barrier = 1;
1430 thr_bar->use_oncore_barrier = 0;
1432 KA_TRACE(20, (
"__kmp_hierarchical_barrier_gather: T#%d(%d:%d) enter for "
1433 "barrier type %d\n",
1434 gtid, team->
t.t_id, tid, bt));
1435 KMP_DEBUG_ASSERT(this_thr == other_threads[this_thr->th.th_info.ds.ds_tid]);
1437#if USE_ITT_BUILD && USE_ITT_NOTIFY
1439 if (__kmp_forkjoin_frames_mode == 3 || __kmp_forkjoin_frames_mode == 2) {
1440 this_thr->th.th_bar_arrive_time = __itt_get_timestamp();
1447 if (thr_bar->my_level) {
1452 thr_bar->use_oncore_barrier) {
1453 if (thr_bar->leaf_kids) {
1457 ? thr_bar->b_arrived | thr_bar->leaf_state
1458 : team->
t.t_bar[bt].b_arrived | thr_bar->leaf_state;
1459 KA_TRACE(20, (
"__kmp_hierarchical_barrier_gather: T#%d(%d:%d) waiting "
1461 gtid, team->
t.t_id, tid));
1467 for (child_tid = tid + 1; child_tid <= tid + thr_bar->leaf_kids;
1469 KA_TRACE(100, (
"__kmp_hierarchical_barrier_gather: T#%d(%d:%d) += "
1471 gtid, team->
t.t_id, tid,
1474 (*reduce)(this_thr->th.th_local.reduce_data,
1475 other_threads[child_tid]->th.th_local.reduce_data);
1485 kmp_uint32 last = tid + thr_bar->skip_per_level[
d + 1],
1486 skip = thr_bar->skip_per_level[
d];
1489 for (child_tid = tid + skip; child_tid < (
int)last; child_tid += skip) {
1490 kmp_info_t *child_thr = other_threads[child_tid];
1491 kmp_bstate_t *child_bar = &child_thr->th.th_bar[bt].bb;
1492 KA_TRACE(20, (
"__kmp_hierarchical_barrier_gather: T#%d(%d:%d) wait "
1494 "arrived(%p) == %llu\n",
1495 gtid, team->
t.t_id, tid,
1497 child_tid, &child_bar->b_arrived, new_state));
1501 KA_TRACE(100, (
"__kmp_hierarchical_barrier_gather: T#%d(%d:%d) += "
1503 gtid, team->
t.t_id, tid,
1506 (*reduce)(this_thr->th.th_local.reduce_data,
1507 child_thr->th.th_local.reduce_data);
1514 kmp_uint32 last = tid + thr_bar->skip_per_level[
d + 1],
1515 skip = thr_bar->skip_per_level[
d];
1518 for (child_tid = tid + skip; child_tid < (
int)last; child_tid += skip) {
1519 kmp_info_t *child_thr = other_threads[child_tid];
1520 kmp_bstate_t *child_bar = &child_thr->th.th_bar[bt].bb;
1521 KA_TRACE(20, (
"__kmp_hierarchical_barrier_gather: T#%d(%d:%d) wait "
1523 "arrived(%p) == %llu\n",
1524 gtid, team->
t.t_id, tid,
1526 child_tid, &child_bar->b_arrived, new_state));
1530 KA_TRACE(100, (
"__kmp_hierarchical_barrier_gather: T#%d(%d:%d) += "
1532 gtid, team->
t.t_id, tid,
1535 (*reduce)(this_thr->th.th_local.reduce_data,
1536 child_thr->th.th_local.reduce_data);
1545 KA_TRACE(20, (
"__kmp_hierarchical_barrier_gather: T#%d(%d:%d) releasing"
1546 " T#%d(%d:%d) arrived(%p): %llu => %llu\n",
1547 gtid, team->
t.t_id, tid,
1549 thr_bar->parent_tid, &thr_bar->b_arrived, thr_bar->b_arrived,
1555 !thr_bar->use_oncore_barrier) {
1558 other_threads[thr_bar->parent_tid]);
1564 flag.set_waiter(other_threads[thr_bar->parent_tid]);
1568 team->
t.t_bar[bt].b_arrived = new_state;
1569 KA_TRACE(20, (
"__kmp_hierarchical_barrier_gather: T#%d(%d:%d) set team %d "
1570 "arrived(%p) = %llu\n",
1571 gtid, team->
t.t_id, tid, team->
t.t_id,
1572 &team->
t.t_bar[bt].b_arrived, team->
t.t_bar[bt].b_arrived));
1575 KA_TRACE(20, (
"__kmp_hierarchical_barrier_gather: T#%d(%d:%d) exit for "
1576 "barrier type %d\n",
1577 gtid, team->
t.t_id, tid, bt));
1587 bool team_change =
false;
1592 KA_TRACE(20, (
"__kmp_hierarchical_barrier_release: T#%d(%d:%d) primary "
1593 "entered barrier type %d\n",
1594 gtid, team->
t.t_id, tid, bt));
1597 if (!thr_bar->use_oncore_barrier ||
1599 thr_bar->team == NULL) {
1604 TCW_8(thr_bar->b_go,
1611 thr_bar->offset, bt,
1614 if (thr_bar->wait_flag ==
1616 TCW_8(thr_bar->b_go,
1619 (
RCAST(
volatile char *,
1620 &(thr_bar->parent_bar->b_go)))[thr_bar->offset] = 0;
1634 (
"__kmp_hierarchical_barrier_release: T#%d(%d:%d) set go(%p) = %u\n",
1639 nproc = this_thr->th.th_team_nproc;
1640 int level = team->
t.t_level;
1641 if (team->
t.t_threads[0]
1642 ->th.th_teams_microtask) {
1644 this_thr->th.th_teams_level ==
level)
1646 if (this_thr->th.th_teams_size.nteams > 1)
1650 thr_bar->use_oncore_barrier = 1;
1652 thr_bar->use_oncore_barrier = 0;
1656 unsigned short int old_leaf_kids = thr_bar->leaf_kids;
1657 kmp_uint64 old_leaf_state = thr_bar->leaf_state;
1664#if KMP_BARRIER_ICV_PUSH
1665 if (propagate_icvs) {
1671 &team->
t.t_implicit_task_taskdata[tid].td_icvs);
1673 thr_bar->use_oncore_barrier) {
1674 if (!thr_bar->my_level)
1677 copy_icvs(&team->
t.t_implicit_task_taskdata[tid].td_icvs,
1678 &thr_bar->parent_bar->th_fixed_icvs);
1681 if (thr_bar->my_level)
1683 copy_icvs(&thr_bar->th_fixed_icvs, &thr_bar->parent_bar->th_fixed_icvs);
1685 copy_icvs(&team->
t.t_implicit_task_taskdata[tid].td_icvs,
1686 &thr_bar->parent_bar->th_fixed_icvs);
1692 if (thr_bar->my_level) {
1696 thr_bar->use_oncore_barrier) {
1706 for (child_tid = thr_bar->skip_per_level[1]; child_tid < (
int)nproc;
1707 child_tid += thr_bar->skip_per_level[1]) {
1709 &team->
t.t_threads[child_tid]->th.th_bar[bt].bb;
1710 KA_TRACE(20, (
"__kmp_hierarchical_barrier_release: T#%d(%d:%d) "
1711 "releasing T#%d(%d:%d)"
1712 " go(%p): %u => %u\n",
1713 gtid, team->
t.t_id, tid,
1715 child_tid, &child_bar->b_go, child_bar->b_go,
1719 ngo_store_go(&child_bar->th_fixed_icvs, &thr_bar->th_fixed_icvs);
1723 TCW_8(thr_bar->b_go,
1726 if (thr_bar->leaf_kids) {
1729 old_leaf_kids < thr_bar->leaf_kids) {
1730 if (old_leaf_kids) {
1731 thr_bar->b_go |= old_leaf_state;
1734 last = tid + thr_bar->skip_per_level[1];
1737 for (child_tid = tid + 1 + old_leaf_kids; child_tid < (
int)last;
1739 kmp_info_t *child_thr = team->
t.t_threads[child_tid];
1740 kmp_bstate_t *child_bar = &child_thr->th.th_bar[bt].bb;
1743 (
"__kmp_hierarchical_barrier_release: T#%d(%d:%d) releasing"
1744 " T#%d(%d:%d) go(%p): %u => %u\n",
1746 team->
t.t_id, child_tid, &child_bar->b_go, child_bar->b_go,
1754 thr_bar->b_go |= thr_bar->leaf_state;
1758 for (
int d = thr_bar->my_level - 1;
d >= 0;
1760 last = tid + thr_bar->skip_per_level[
d + 1];
1764 for (child_tid = tid + skip; child_tid < (
int)last; child_tid += skip) {
1765 kmp_info_t *child_thr = team->
t.t_threads[child_tid];
1766 kmp_bstate_t *child_bar = &child_thr->th.th_bar[bt].bb;
1767 KA_TRACE(20, (
"__kmp_hierarchical_barrier_release: T#%d(%d:%d) "
1768 "releasing T#%d(%d:%d) go(%p): %u => %u\n",
1769 gtid, team->
t.t_id, tid,
1771 child_tid, &child_bar->b_go, child_bar->b_go,
1779#if KMP_BARRIER_ICV_PUSH
1782 copy_icvs(&team->
t.t_implicit_task_taskdata[tid].td_icvs,
1783 &thr_bar->th_fixed_icvs);
1786 KA_TRACE(20, (
"__kmp_hierarchical_barrier_release: T#%d(%d:%d) exit for "
1787 "barrier type %d\n",
1788 gtid, team->
t.t_id, tid, bt));
1809 constexpr operator bool()
const {
return false; }
1820template <
bool cancellable = false>
1822 size_t reduce_size,
void *reduce_data,
1823 void (*reduce)(
void *,
void *)) {
1831#if OMPT_SUPPORT && OMPT_OPTIONAL
1832 ompt_data_t *my_task_data;
1833 ompt_data_t *my_parallel_data;
1834 void *return_address;
1835 ompt_sync_region_t barrier_kind;
1838 KA_TRACE(15, (
"__kmp_barrier: T#%d(%d:%d) has arrived\n", gtid,
1844 my_task_data = OMPT_CUR_TASK_DATA(this_thr);
1845 my_parallel_data = OMPT_CUR_TEAM_DATA(this_thr);
1846 return_address = OMPT_LOAD_RETURN_ADDRESS(gtid);
1850 barrier_kind, ompt_scope_begin, my_parallel_data, my_task_data,
1855 barrier_kind, ompt_scope_begin, my_parallel_data, my_task_data,
1862 auto *ompt_thr_info = &this_thr->th.ompt_thread_info;
1863 switch (barrier_kind) {
1864 case ompt_sync_region_barrier_explicit:
1865 ompt_thr_info->state = ompt_state_wait_barrier_explicit;
1867 case ompt_sync_region_barrier_implicit_workshare:
1868 ompt_thr_info->state = ompt_state_wait_barrier_implicit_workshare;
1870 case ompt_sync_region_barrier_implicit_parallel:
1871 ompt_thr_info->state = ompt_state_wait_barrier_implicit_parallel;
1873 case ompt_sync_region_barrier_teams:
1874 ompt_thr_info->state = ompt_state_wait_barrier_teams;
1876 case ompt_sync_region_barrier_implementation:
1879 ompt_thr_info->state = ompt_state_wait_barrier_implementation;
1884#if ENABLE_LIBOMPTARGET
1887 if (
UNLIKELY(kmp_target_sync_cb != NULL))
1888 (*kmp_target_sync_cb)(
1892 if (!team->
t.t_serialized) {
1895 void *itt_sync_obj = NULL;
1897 if (__itt_sync_create_ptr || KMP_ITT_DEBUG)
1898 itt_sync_obj = __kmp_itt_barrier_object(gtid, bt, 1);
1904 (
"__kmp_barrier: T#%d(%d:%d) past tasking barrier\n", gtid,
1914 this_thr->th.th_team_bt_intervals =
1915 team->
t.t_implicit_task_taskdata[tid].td_icvs.bt_intervals;
1916 this_thr->th.th_team_bt_set =
1917 team->
t.t_implicit_task_taskdata[tid].td_icvs.bt_set;
1924 if (__itt_sync_create_ptr || KMP_ITT_DEBUG)
1925 __kmp_itt_barrier_starting(gtid, itt_sync_obj);
1930 team->
t.t_bar[bt].b_master_arrived += 1;
1932 this_thr->th.th_bar[bt].bb.b_worker_arrived += 1;
1935 if (reduce != NULL) {
1937 this_thr->th.th_local.reduce_data = reduce_data;
1985 team->
t.t_bar[bt].b_team_arrived += 1;
2001 if (__itt_sync_create_ptr || KMP_ITT_DEBUG)
2002 __kmp_itt_barrier_middle(gtid, itt_sync_obj);
2004#if USE_ITT_BUILD && USE_ITT_NOTIFY
2006 if ((__itt_frame_submit_v3_ptr || KMP_ITT_DEBUG) &&
2007 __kmp_forkjoin_frames_mode &&
2008 (this_thr->th.th_teams_microtask == NULL ||
2009 this_thr->th.th_teams_size.nteams == 1) &&
2010 team->
t.t_active_level == 1) {
2014 int nproc = this_thr->th.th_team_nproc;
2016 switch (__kmp_forkjoin_frames_mode) {
2018 __kmp_itt_frame_submit(gtid, this_thr->th.th_frame_time, cur_time, 0,
2020 this_thr->th.th_frame_time = cur_time;
2024 __kmp_itt_frame_submit(gtid, this_thr->th.th_bar_min_time, cur_time,
2028 if (__itt_metadata_add_ptr) {
2030 kmp_uint64 delta = cur_time - this_thr->th.th_bar_arrive_time;
2033 this_thr->th.th_bar_arrive_time = 0;
2034 for (
i = 1;
i < nproc; ++
i) {
2035 delta += (cur_time - other_threads[
i]->th.th_bar_arrive_time);
2036 other_threads[
i]->th.th_bar_arrive_time = 0;
2038 __kmp_itt_metadata_imbalance(gtid, this_thr->th.th_frame_time,
2042 __kmp_itt_frame_submit(gtid, this_thr->th.th_frame_time, cur_time, 0,
2044 this_thr->th.th_frame_time = cur_time;
2052 if (__itt_sync_create_ptr || KMP_ITT_DEBUG)
2053 __kmp_itt_barrier_middle(gtid, itt_sync_obj);
2056 if ((
status == 1 || !is_split) && !cancelled) {
2100 if (__itt_sync_create_ptr || KMP_ITT_DEBUG)
2101 __kmp_itt_barrier_finished(gtid, itt_sync_obj);
2106 if (this_thr->th.th_task_team != NULL) {
2108 void *itt_sync_obj = NULL;
2109 if (__itt_sync_create_ptr || KMP_ITT_DEBUG) {
2110 itt_sync_obj = __kmp_itt_barrier_object(gtid, bt, 1);
2111 __kmp_itt_barrier_starting(gtid, itt_sync_obj);
2116 this_thr->th.th_task_team->tt.tt_found_proxy_tasks ==
TRUE ||
2117 this_thr->th.th_task_team->tt.tt_hidden_helper_task_encountered ==
2123 if (__itt_sync_create_ptr || KMP_ITT_DEBUG)
2124 __kmp_itt_barrier_finished(gtid, itt_sync_obj);
2129 KA_TRACE(15, (
"__kmp_barrier: T#%d(%d:%d) is leaving with return value %d\n",
2138 barrier_kind, ompt_scope_end, my_parallel_data, my_task_data,
2143 barrier_kind, ompt_scope_end, my_parallel_data, my_task_data,
2147 this_thr->th.ompt_thread_info.state = ompt_state_work_parallel;
2152 return (
int)cancelled;
2158 size_t reduce_size,
void *reduce_data,
2159 void (*reduce)(
void *,
void *)) {
2164#if defined(KMP_GOMP_COMPAT)
2196 if (!team->
t.t_serialized) {
2246 void *itt_sync_obj = NULL;
2248 if (__itt_sync_create_ptr || KMP_ITT_DEBUG)
2253#if ((USE_ITT_BUILD && USE_ITT_NOTIFY) || defined KMP_DEBUG)
2254 int nproc = this_thr->th.th_team_nproc;
2259 team = this_thr->th.th_team;
2263 team_id = team->
t.t_id;
2264 kmp_info_t *master_thread = this_thr->th.th_team_master;
2265 if (master_thread != team->
t.t_threads[0]) {
2276 KA_TRACE(10, (
"__kmp_join_barrier: T#%d(%d:%d) arrived at join barrier\n",
2277 gtid, team_id, tid));
2282 ompt_data_t *my_task_data;
2283 ompt_data_t *my_parallel_data;
2284 void *codeptr = NULL;
2285 int ds_tid = this_thr->th.th_info.ds.ds_tid;
2289 codeptr = team->
t.ompt_team_info.master_return_address;
2290 my_task_data = OMPT_CUR_TASK_DATA(this_thr);
2291 my_parallel_data = OMPT_CUR_TEAM_DATA(this_thr);
2292 ompt_sync_region_t sync_kind = ompt_sync_region_barrier_implicit_parallel;
2293 ompt_state_t ompt_state = ompt_state_wait_barrier_implicit_parallel;
2294 if (this_thr->th.ompt_thread_info.parallel_flags & ompt_parallel_league) {
2295 sync_kind = ompt_sync_region_barrier_teams;
2296 ompt_state = ompt_state_wait_barrier_teams;
2300 sync_kind, ompt_scope_begin, my_parallel_data, my_task_data, codeptr);
2304 sync_kind, ompt_scope_begin, my_parallel_data, my_task_data, codeptr);
2307 this_thr->th.ompt_thread_info.task_data = *OMPT_CUR_TASK_DATA(this_thr);
2309 this_thr->th.ompt_thread_info.state = ompt_state;
2315 KA_TRACE(10, (
"__kmp_join_barrier: T#%d(%d:%d) past tasking barrier\n",
2316 gtid, team_id, tid));
2320 KA_TRACE(20, (
"__kmp_join_barrier: T#%d, old team = %d, old task_team = "
2321 "%p, th_task_team = %p\n",
2323 team->
t.t_task_team[this_thr->th.th_task_state],
2324 this_thr->th.th_task_team));
2336 this_thr->th.th_team_bt_intervals =
2337 team->
t.t_implicit_task_taskdata[tid].td_icvs.bt_intervals;
2338 this_thr->th.th_team_bt_set =
2339 team->
t.t_implicit_task_taskdata[tid].td_icvs.bt_set;
2346 if (__itt_sync_create_ptr || KMP_ITT_DEBUG)
2347 __kmp_itt_barrier_starting(gtid, itt_sync_obj);
2388#if KMP_STATS_ENABLED
2392 for (
int i = 0;
i < team->
t.t_nproc; ++
i) {
2394 if (team_thread == this_thr)
2396 team_thread->th.th_stats->setIdleFlag();
2398 team_thread->th.th_sleep_loc != NULL)
2403 if (__itt_sync_create_ptr || KMP_ITT_DEBUG)
2404 __kmp_itt_barrier_middle(gtid, itt_sync_obj);
2407#if USE_ITT_BUILD && USE_ITT_NOTIFY
2409 if ((__itt_frame_submit_v3_ptr || KMP_ITT_DEBUG) &&
2410 __kmp_forkjoin_frames_mode &&
2411 (this_thr->th.th_teams_microtask == NULL ||
2412 this_thr->th.th_teams_size.nteams == 1) &&
2413 team->
t.t_active_level == 1) {
2417 switch (__kmp_forkjoin_frames_mode) {
2419 __kmp_itt_frame_submit(gtid, this_thr->th.th_frame_time, cur_time, 0,
2423 __kmp_itt_frame_submit(gtid, this_thr->th.th_bar_min_time, cur_time, 1,
2427 if (__itt_metadata_add_ptr) {
2429 kmp_uint64 delta = cur_time - this_thr->th.th_bar_arrive_time;
2432 this_thr->th.th_bar_arrive_time = 0;
2433 for (
int i = 1;
i < nproc; ++
i) {
2434 delta += (cur_time - other_threads[
i]->th.th_bar_arrive_time);
2435 other_threads[
i]->th.th_bar_arrive_time = 0;
2437 __kmp_itt_metadata_imbalance(gtid, this_thr->th.th_frame_time,
2438 cur_time, delta, 0);
2440 __kmp_itt_frame_submit(gtid, this_thr->th.th_frame_time, cur_time, 0,
2442 this_thr->th.th_frame_time = cur_time;
2450 if (__itt_sync_create_ptr || KMP_ITT_DEBUG)
2451 __kmp_itt_barrier_middle(gtid, itt_sync_obj);
2459 (
"__kmp_join_barrier: T#%d(%d:%d) says all %d team threads arrived\n",
2460 gtid, team_id, tid, nproc));
2467 (
"__kmp_join_barrier: T#%d(%d:%d) leaving\n", gtid, team_id, tid));
2477 kmp_team_t *team = (tid == 0) ? this_thr->th.th_team : NULL;
2479 void *itt_sync_obj = NULL;
2483 KA_TRACE(10, (
"__kmp_fork_barrier: T#%d(%d:%d) has arrived\n", gtid,
2484 (team != NULL) ? team->
t.t_id : -1, tid));
2488#if USE_ITT_BUILD && USE_ITT_NOTIFY
2489 if (__itt_sync_create_ptr || KMP_ITT_DEBUG) {
2492 __kmp_itt_barrier_middle(gtid, itt_sync_obj);
2504 for (
i = 1;
i < team->
t.t_nproc; ++
i) {
2506 (
"__kmp_fork_barrier: T#%d(%d:0) checking T#%d(%d:%d) fork go "
2508 gtid, team->
t.t_id, other_threads[
i]->th.th_info.ds.ds_gtid,
2509 team->
t.t_id, other_threads[
i]->th.th_info.ds.ds_tid,
2529 this_thr->th.th_team_bt_intervals =
2530 team->
t.t_implicit_task_taskdata[tid].td_icvs.bt_intervals;
2531 this_thr->th.th_team_bt_set =
2532 team->
t.t_implicit_task_taskdata[tid].td_icvs.bt_set;
2569 ompt_state_t ompt_state = this_thr->th.ompt_thread_info.state;
2571 (ompt_state == ompt_state_wait_barrier_teams ||
2572 ompt_state == ompt_state_wait_barrier_implicit_parallel)) {
2573 int ds_tid = this_thr->th.th_info.ds.ds_tid;
2574 ompt_data_t *task_data = (team)
2575 ? OMPT_CUR_TASK_DATA(this_thr)
2576 : &(this_thr->th.ompt_thread_info.task_data);
2577 this_thr->th.ompt_thread_info.state = ompt_state_overhead;
2579 void *codeptr = NULL;
2583 codeptr = team ? team->
t.ompt_team_info.master_return_address : NULL;
2584 ompt_sync_region_t sync_kind = ompt_sync_region_barrier_implicit_parallel;
2585 if (this_thr->th.ompt_thread_info.parallel_flags & ompt_parallel_league)
2586 sync_kind = ompt_sync_region_barrier_teams;
2589 sync_kind, ompt_scope_end, NULL, task_data, codeptr);
2593 sync_kind, ompt_scope_end, NULL, task_data, codeptr);
2598 ompt_scope_end, NULL, task_data, 0, ds_tid,
2599 ompt_task_implicit);
2606 this_thr->th.th_task_team = NULL;
2608#if USE_ITT_BUILD && USE_ITT_NOTIFY
2609 if (__itt_sync_create_ptr || KMP_ITT_DEBUG) {
2613 __kmp_itt_barrier_finished(gtid, itt_sync_obj);
2617 KA_TRACE(10, (
"__kmp_fork_barrier: T#%d is leaving early\n", gtid));
2629#if KMP_BARRIER_ICV_PULL
2642 (
"__kmp_fork_barrier: T#%d(%d) is PULLing ICVs\n", gtid, tid));
2645 copy_icvs(&team->
t.t_implicit_task_taskdata[tid].td_icvs,
2646 &team->
t.t_threads[0]
2657#if KMP_AFFINITY_SUPPORTED
2661 if (__kmp_affinity.type == affinity_balanced && team->
t.t_size_changed) {
2662 __kmp_balanced_affinity(this_thr, team->
t.t_nproc);
2665 if (this_thr->th.th_new_place == this_thr->th.th_current_place) {
2666 KA_TRACE(100, (
"__kmp_fork_barrier: T#%d already in correct place %d\n",
2668 this_thr->th.th_current_place));
2670 __kmp_affinity_bind_place(gtid);
2676 if (team->
t.t_display_affinity
2678 || (__kmp_affinity.type == affinity_balanced && team->
t.t_size_changed)
2683 this_thr->th.th_prev_num_threads = team->
t.t_nproc;
2684 this_thr->th.th_prev_level = team->
t.t_level;
2690#if USE_ITT_BUILD && USE_ITT_NOTIFY
2691 if (__itt_sync_create_ptr || KMP_ITT_DEBUG) {
2695 __kmp_itt_barrier_finished(gtid, itt_sync_obj);
2699 KA_TRACE(10, (
"__kmp_fork_barrier: T#%d(%d:%d) is leaving\n", gtid,
2700 team->
t.t_id, tid));
2713#if KMP_BARRIER_ICV_PULL
2722 KF_TRACE(10, (
"__kmp_setup_icv_copy: PULL: T#%d this_thread=%p team=%p\n", 0,
2723 team->
t.t_threads[0], team));
2724#elif KMP_BARRIER_ICV_PUSH
2727 KF_TRACE(10, (
"__kmp_setup_icv_copy: PUSH: T#%d this_thread=%p team=%p\n", 0,
2728 team->
t.t_threads[0], team));
2735 for (
int f = 1;
f < new_nproc; ++
f) {
2737 KF_TRACE(10, (
"__kmp_setup_icv_copy: LINEAR: T#%d this_thread=%p team=%p\n",
2738 f, team->
t.t_threads[
f], team));
2741 KF_TRACE(10, (
"__kmp_setup_icv_copy: LINEAR: T#%d this_thread=%p team=%p\n",
2742 f, team->
t.t_threads[
f], team));
size_t KMP_ALIGN_CACHE gos_per_group
size_t KMP_ALIGN_CACHE num_groups
size_t KMP_ALIGN_CACHE threads_per_group
size_t KMP_ALIGN_CACHE num_gos
size_t KMP_ALIGN_CACHE threads_per_go
size_t KMP_ALIGN_CACHE num_threads
size_t KMP_ALIGN_CACHE max_threads
static void deallocate(distributedBarrier *db)
flags_s * flags[MAX_ITERS]
distributedBarrier()=delete
bool KMP_ALIGN_CACHE fix_threads_per_go
bool wait(kmp_info_t *this_thr, int final_spin USE_ITT_BUILD_ARG(void *itt_sync_obj))
bool wait(kmp_info_t *this_thr, int final_spin USE_ITT_BUILD_ARG(void *itt_sync_obj))
bool wait(kmp_info_t *this_thr, int final_spin USE_ITT_BUILD_ARG(void *itt_sync_obj))
void set_waiter(kmp_info_t *thr)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id __itt_relation __itt_id ITT_FORMAT p const wchar_t int ITT_FORMAT __itt_group_mark d int
#define KMP_INTERNAL_MALLOC(sz)
kmp_global_t __kmp_global
union kmp_task_team kmp_task_team_t
void __kmp_teams_master(int gtid)
#define KMP_MAX_BLOCKTIME
#define KMP_INTERNAL_REALLOC(p, sz)
void __kmp_task_team_sync(kmp_info_t *this_thr, kmp_team_t *team)
#define KMP_TASKDATA_TO_TASK(taskdata)
#define KMP_NOT_SAFE_TO_REAP
static kmp_team_t * __kmp_team_from_gtid(int gtid)
kmp_bar_pat_e __kmp_barrier_gather_pattern[bs_last_barrier]
kmp_tasking_mode_t __kmp_tasking_mode
void __kmp_abort_thread(void)
void __kmp_get_hierarchy(kmp_uint32 nproc, kmp_bstate_t *thr_bar)
int __kmp_omp_cancellation
#define KMP_BARRIER_UNUSED_STATE
int __kmp_barrier_gomp_cancel(int gtid)
#define KMP_BARRIER_SLEEP_STATE
struct kmp_internal_control kmp_internal_control_t
static int __kmp_tid_from_gtid(int gtid)
#define KMP_DEBUG_ASSERT_TASKTEAM_INVARIANT(team, thr)
#define KMP_CHECK_UPDATE(a, b)
#define KMP_MASTER_TID(tid)
kmp_uint32 __kmp_barrier_release_branch_bits[bs_last_barrier]
#define KMP_BARRIER_OWN_FLAG
void __kmp_init_implicit_task(ident_t *loc_ref, kmp_info_t *this_thr, kmp_team_t *team, int tid, int set_curr_task)
static void copy_icvs(kmp_internal_control_t *dst, kmp_internal_control_t *src)
#define KMP_TASKING_ENABLED(task_team)
kmp_info_t ** __kmp_threads
#define KMP_BARRIER_PARENT_FLAG
union kmp_team kmp_team_t
#define KMP_MASTER_GTID(gtid)
volatile int __kmp_init_parallel
#define __kmp_allocate(size)
void __kmp_tasking_barrier(kmp_team_t *team, kmp_info_t *thread, int gtid)
void __kmp_aux_display_affinity(int gtid, const char *format)
union kmp_barrier_team_union kmp_balign_team_t
#define KMP_INIT_BARRIER_STATE
kmp_uint32 __kmp_barrier_gather_branch_bits[bs_last_barrier]
#define KMP_BARRIER_NOT_WAITING
#define KMP_INTERNAL_FREE(p)
static int __kmp_gtid_from_tid(int tid, const kmp_team_t *team)
#define KMP_BARRIER_SWITCHING
int __kmp_display_affinity
#define KMP_BLOCKTIME_INTERVAL(team, tid)
void __kmp_task_team_setup(kmp_info_t *this_thr, kmp_team_t *team)
int __kmp_atomic_execute_tasks_64(kmp_info_t *thread, kmp_int32 gtid, kmp_atomic_flag_64< C, S > *flag, int final_spin, int *thread_finished, kmp_int32 is_constrained)
#define KMP_BARRIER_STATE_BUMP
void __kmp_atomic_resume_64(int target_gtid, kmp_atomic_flag_64< C, S > *flag)
static int __kmp_gtid_from_thread(const kmp_info_t *thr)
static void __kmp_type_convert(T1 src, T2 *dest)
struct KMP_ALIGN_CACHE kmp_bstate kmp_bstate_t
kmp_bar_pat_e __kmp_barrier_release_pattern[bs_last_barrier]
union KMP_ALIGN_CACHE kmp_info kmp_info_t
void __kmp_task_team_wait(kmp_info_t *this_thr, kmp_team_t *team, int wait=1)
kmp_topology_t * __kmp_topology
KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86 KMP_ARCH_X86<<, 2i, 1, KMP_ARCH_X86) ATOMIC_CMPXCHG(fixed2, shr, kmp_int16, 16, > KMP_ARCH_X86 KMP_ARCH_X86 kmp_uint32
static bool __kmp_linear_barrier_gather_template(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, void(*reduce)(void *, void *) USE_ITT_BUILD_ARG(void *itt_sync_obj))
static void __kmp_dist_barrier_release(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, int propagate_icvs USE_ITT_BUILD_ARG(void *itt_sync_obj))
static void __kmp_tree_barrier_release(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, int propagate_icvs USE_ITT_BUILD_ARG(void *itt_sync_obj))
#define ngo_store_icvs(dst, src)
static bool __kmp_linear_barrier_release_template(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, int propagate_icvs USE_ITT_BUILD_ARG(void *itt_sync_obj))
#define ngo_store_go(dst, src)
int __kmp_barrier(enum barrier_type bt, int gtid, int is_split, size_t reduce_size, void *reduce_data, void(*reduce)(void *, void *))
void __kmp_setup_icv_copy(kmp_team_t *team, int new_nproc, kmp_internal_control_t *new_icvs, ident_t *loc)
static void __kmp_hyper_barrier_gather(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, void(*reduce)(void *, void *) USE_ITT_BUILD_ARG(void *itt_sync_obj))
void __kmp_join_barrier(int gtid)
static void __kmp_tree_barrier_gather(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, void(*reduce)(void *, void *) USE_ITT_BUILD_ARG(void *itt_sync_obj))
void __kmp_end_split_barrier(enum barrier_type bt, int gtid)
static bool __kmp_linear_barrier_release_cancellable(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, int propagate_icvs USE_ITT_BUILD_ARG(void *itt_sync_obj))
static bool __kmp_linear_barrier_gather_cancellable(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, void(*reduce)(void *, void *) USE_ITT_BUILD_ARG(void *itt_sync_obj))
static int __kmp_barrier_template(enum barrier_type bt, int gtid, int is_split, size_t reduce_size, void *reduce_data, void(*reduce)(void *, void *))
static void __kmp_linear_barrier_gather(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, void(*reduce)(void *, void *) USE_ITT_BUILD_ARG(void *itt_sync_obj))
void __kmp_print_structure(void)
static void __kmp_hyper_barrier_release(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, int propagate_icvs USE_ITT_BUILD_ARG(void *itt_sync_obj))
void __kmp_dist_barrier_wakeup(enum barrier_type bt, kmp_team_t *team, size_t start, size_t stop, size_t inc, size_t tid)
static void __kmp_hierarchical_barrier_release(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, int propagate_icvs USE_ITT_BUILD_ARG(void *itt_sync_obj))
static bool __kmp_init_hierarchical_barrier_thread(enum barrier_type bt, kmp_bstate_t *thr_bar, kmp_uint32 nproc, int gtid, int tid, kmp_team_t *team)
#define __kmp_msb_byteoffset(offset)
void __kmp_fork_barrier(int gtid, int tid)
static void __kmp_dist_barrier_gather(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, void(*reduce)(void *, void *) USE_ITT_BUILD_ARG(void *itt_sync_obj))
static void __kmp_hierarchical_barrier_gather(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, void(*reduce)(void *, void *) USE_ITT_BUILD_ARG(void *itt_sync_obj))
static void __kmp_linear_barrier_release(enum barrier_type bt, kmp_info_t *this_thr, int gtid, int tid, int propagate_icvs USE_ITT_BUILD_ARG(void *itt_sync_obj))
#define KMP_OPTIMIZE_FOR_REDUCTIONS
#define KMP_ALIGNED_FREE(ptr)
#define KMP_DEBUG_ASSERT(cond)
unsigned long long kmp_uint64
static volatile kmp_i18n_cat_status_t status
#define USE_ITT_BUILD_ARG(x)
void(* microtask_t)(int *gtid, int *npr,...)
#define KMP_TEST_THEN_AND64(p, v)
#define KMP_CACHE_PREFETCH(ADDR)
#define KMP_ATOMIC_ST_RLX(p, v)
#define KMP_ATOMIC_LD_RLX(p)
#define KMP_AFFINITY_SUPPORTED
#define KMP_COMPARE_AND_STORE_ACQ32(p, cv, sv)
Functions for collecting statistics.
#define KMP_SET_THREAD_STATE_BLOCK(state_name)
#define KMP_TIME_PARTITIONED_BLOCK(name)
#define KMP_TIME_DEVELOPER_PARTITIONED_BLOCK(n)
static void __kmp_null_resume_wrapper(kmp_info_t *thr)
ompt_callbacks_active_t ompt_enabled
ompt_callbacks_internal_t ompt_callbacks
ompt_sync_region_t __ompt_get_barrier_kind(enum barrier_type bt, kmp_info_t *thr)
#define OMPT_REDUCTION_BEGIN
#define OMPT_REDUCTION_DECL(this_thr, gtid)
#define OMPT_REDUCTION_END
is_cancellable & operator=(bool b)
is_cancellable & operator=(bool b)
KMP_ALIGN_CACHE volatile kmp_uint32 tt_active