diff --git a/openmp/runtime/src/kmp_sched.cpp b/openmp/runtime/src/kmp_sched.cpp index 2e0dfac6eeb3b..2b1bb6f595f9a 100644 --- a/openmp/runtime/src/kmp_sched.cpp +++ b/openmp/runtime/src/kmp_sched.cpp @@ -542,6 +542,12 @@ static void __kmp_dist_for_static_init(ident_t *loc, kmp_int32 gtid, nth = th->th.th_team_nproc; team = th->th.th_team; KMP_DEBUG_ASSERT(th->th.th_teams_microtask); // we are in the teams construct + // skip optional serialized teams to prevent this from using the wrong teams + // information when called after __kmp_serialized_parallel + // TODO: make __kmp_serialized_parallel eventually call __kmp_fork_in_teams + // to address this edge case + while (team->t.t_parent && team->t.t_serialized) + team = team->t.t_parent; nteams = th->th.th_teams_size.nteams; team_id = team->t.t_master_tid; KMP_DEBUG_ASSERT(nteams == (kmp_uint32)team->t.t_parent->t.t_nproc);