diff options
Diffstat (limited to 'openmp/runtime/src/kmp_dispatch.cpp')
| -rw-r--r-- | openmp/runtime/src/kmp_dispatch.cpp | 68 |
1 files changed, 51 insertions, 17 deletions
diff --git a/openmp/runtime/src/kmp_dispatch.cpp b/openmp/runtime/src/kmp_dispatch.cpp index 1306c553db4..5545ff52031 100644 --- a/openmp/runtime/src/kmp_dispatch.cpp +++ b/openmp/runtime/src/kmp_dispatch.cpp @@ -321,7 +321,7 @@ void __kmp_dispatch_init_algorithm(ident_t *loc, int gtid, ntc = (tc % chunk ? 1 : 0) + tc / chunk; if (nproc > 1 && ntc >= nproc) { - KMP_COUNT_BLOCK(OMP_FOR_static_steal); + KMP_COUNT_BLOCK(OMP_LOOP_STATIC_STEAL); T id = tid; T small_chunk, extras; @@ -770,6 +770,15 @@ __kmp_dispatch_init(ident_t *loc, int gtid, enum sched_type schedule, T lb, active = !team->t.t_serialized; th->th.th_ident = loc; + // Any half-decent optimizer will remove this test when the blocks are empty + // since the macros expand to nothing + // when statistics are disabled. + if (schedule == __kmp_static) { + KMP_COUNT_BLOCK(OMP_LOOP_STATIC); + } else { + KMP_COUNT_BLOCK(OMP_LOOP_DYNAMIC); + } + #if KMP_USE_HIER_SCHED // Initialize the scheduling hierarchy if requested in OMP_SCHEDULE envirable // Hierarchical scheduling does not work with ordered, so if ordered is @@ -846,17 +855,6 @@ __kmp_dispatch_init(ident_t *loc, int gtid, enum sched_type schedule, T lb, } } - // Any half-decent optimizer will remove this test when the blocks are empty - // since the macros expand to nothing - // when statistics are disabled. - if (schedule == __kmp_static) { - KMP_COUNT_BLOCK(OMP_FOR_static); - KMP_COUNT_VALUE(FOR_static_iterations, pr->u.p.tc); - } else { - KMP_COUNT_BLOCK(OMP_FOR_dynamic); - KMP_COUNT_VALUE(FOR_dynamic_iterations, pr->u.p.tc); - } - if (active) { /* The name of this buffer should be my_buffer_index when it's free to use * it */ @@ -962,6 +960,7 @@ __kmp_dispatch_init(ident_t *loc, int gtid, enum sched_type schedule, T lb, &(task_info->task_data), pr->u.p.tc, OMPT_LOAD_RETURN_ADDRESS(gtid)); } #endif + KMP_PUSH_PARTITIONED_TIMER(OMP_loop_dynamic); } /* For ordered loops, either __kmp_dispatch_finish() should be called after @@ -1229,11 +1228,11 @@ int __kmp_dispatch_next_algorithm(int gtid, // by 1 if (remaining > 3) { // steal 1/4 of remaining - KMP_COUNT_VALUE(FOR_static_steal_stolen, remaining >> 2); + KMP_COUNT_DEVELOPER_VALUE(FOR_static_steal_stolen, remaining >> 2); init = (victim->u.p.ub -= (remaining >> 2)); } else { // steal 1 chunk of 2 or 3 remaining - KMP_COUNT_VALUE(FOR_static_steal_stolen, 1); + KMP_COUNT_DEVELOPER_VALUE(FOR_static_steal_stolen, 1); init = (victim->u.p.ub -= 1); } __kmp_release_lock(lck, gtid); @@ -1333,7 +1332,8 @@ int __kmp_dispatch_next_algorithm(int gtid, *VOLATILE_CAST(kmp_int64 *) & vold.b, *VOLATILE_CAST(kmp_int64 *) & vnew.b)) { // stealing succedded - KMP_COUNT_VALUE(FOR_static_steal_stolen, vold.p.ub - vnew.p.ub); + KMP_COUNT_DEVELOPER_VALUE(FOR_static_steal_stolen, + vold.p.ub - vnew.p.ub); status = 1; while_index = 0; // now update own count and ub @@ -1361,7 +1361,7 @@ int __kmp_dispatch_next_algorithm(int gtid, init *= chunk; limit = chunk + init - 1; incr = pr->u.p.st; - KMP_COUNT_VALUE(FOR_static_steal_chunks, 1); + KMP_COUNT_DEVELOPER_VALUE(FOR_static_steal_chunks, 1); KMP_DEBUG_ASSERT(init <= trip); if ((last = (limit >= trip)) != 0) @@ -1823,6 +1823,38 @@ int __kmp_dispatch_next_algorithm(int gtid, #define OMPT_LOOP_END // no-op #endif +#if KMP_STATS_ENABLED +#define KMP_STATS_LOOP_END \ + { \ + kmp_int64 u, l, t, i; \ + l = (kmp_int64)(*p_lb); \ + u = (kmp_int64)(*p_ub); \ + i = (kmp_int64)(pr->u.p.st); \ + if (status == 0) { \ + t = 0; \ + KMP_POP_PARTITIONED_TIMER(); \ + } else if (i == 1) { \ + if (u >= l) \ + t = u - l + 1; \ + else \ + t = 0; \ + } else if (i < 0) { \ + if (l >= u) \ + t = (l - u) / (-i) + 1; \ + else \ + t = 0; \ + } else { \ + if (u >= l) \ + t = (u - l) / i + 1; \ + else \ + t = 0; \ + } \ + KMP_COUNT_VALUE(OMP_loop_dynamic_iterations, t); \ + } +#else +#define KMP_STATS_LOOP_END /* Nothing */ +#endif + template <typename T> static int __kmp_dispatch_next(ident_t *loc, int gtid, kmp_int32 *p_last, T *p_lb, T *p_ub, @@ -1840,7 +1872,7 @@ static int __kmp_dispatch_next(ident_t *loc, int gtid, kmp_int32 *p_last, // even if the actual runtme schedule is static. (Which points out a // disadavantage of schedule(runtime): even when static scheduling is used it // costs more than a compile time choice to use static scheduling would.) - KMP_TIME_PARTITIONED_BLOCK(FOR_dynamic_scheduling); + KMP_TIME_PARTITIONED_BLOCK(OMP_loop_dynamic_scheduling); int status; dispatch_private_info_template<T> *pr; @@ -1964,6 +1996,7 @@ static int __kmp_dispatch_next(ident_t *loc, int gtid, kmp_int32 *p_last, SSC_MARK_DISPATCH_NEXT(); #endif OMPT_LOOP_END; + KMP_STATS_LOOP_END; return status; } else { kmp_int32 last = 0; @@ -2081,6 +2114,7 @@ static int __kmp_dispatch_next(ident_t *loc, int gtid, kmp_int32 *p_last, SSC_MARK_DISPATCH_NEXT(); #endif OMPT_LOOP_END; + KMP_STATS_LOOP_END; return status; } |

