@@ -38,6 +38,29 @@ char const *traits_t<long>::spec = "ld";
38
38
// -------------------------------------------------------------------------
39
39
#endif
40
40
41
+ #if KMP_STATS_ENABLED
42
+ #define KMP_STATS_LOOP_END (stat ) \
43
+ { \
44
+ kmp_int64 t; \
45
+ kmp_int64 u = (kmp_int64)(*pupper); \
46
+ kmp_int64 l = (kmp_int64)(*plower); \
47
+ kmp_int64 i = (kmp_int64)incr; \
48
+ if (i == 1 ) { \
49
+ t = u - l + 1 ; \
50
+ } else if (i == -1 ) { \
51
+ t = l - u + 1 ; \
52
+ } else if (i > 0 ) { \
53
+ t = (u - l) / i + 1 ; \
54
+ } else { \
55
+ t = (l - u) / (-i) + 1 ; \
56
+ } \
57
+ KMP_COUNT_VALUE (stat, t); \
58
+ KMP_POP_PARTITIONED_TIMER (); \
59
+ }
60
+ #else
61
+ #define KMP_STATS_LOOP_END (stat ) /* Nothing */
62
+ #endif
63
+
41
64
template <typename T>
42
65
static void __kmp_for_static_init (ident_t *loc, kmp_int32 global_tid,
43
66
kmp_int32 schedtype, kmp_int32 *plastiter,
@@ -151,6 +174,7 @@ static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid,
151
174
&(task_info->task_data ), 0 , codeptr);
152
175
}
153
176
#endif
177
+ KMP_STATS_LOOP_END (OMP_loop_static_iterations);
154
178
return ;
155
179
}
156
180
@@ -202,6 +226,7 @@ static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid,
202
226
&(task_info->task_data ), *pstride, codeptr);
203
227
}
204
228
#endif
229
+ KMP_STATS_LOOP_END (OMP_loop_static_iterations);
205
230
return ;
206
231
}
207
232
nth = team->t .t_nproc ;
@@ -231,6 +256,7 @@ static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid,
231
256
&(task_info->task_data ), *pstride, codeptr);
232
257
}
233
258
#endif
259
+ KMP_STATS_LOOP_END (OMP_loop_static_iterations);
234
260
return ;
235
261
}
236
262
@@ -246,6 +272,12 @@ static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid,
246
272
trip_count = (UT)(*plower - *pupper) / (-incr) + 1 ;
247
273
}
248
274
275
+ #if KMP_STATS_ENABLED
276
+ if (KMP_MASTER_GTID (gtid)) {
277
+ KMP_COUNT_VALUE (OMP_loop_static_total_iterations, trip_count);
278
+ }
279
+ #endif
280
+
249
281
if (__kmp_env_consistency_check) {
250
282
/* tripcount overflow? */
251
283
if (trip_count == 0 && *pupper != *plower) {
@@ -388,26 +420,7 @@ static void __kmp_for_static_init(ident_t *loc, kmp_int32 global_tid,
388
420
}
389
421
#endif
390
422
391
- #if KMP_STATS_ENABLED
392
- {
393
- kmp_int64 t;
394
- kmp_int64 u = (kmp_int64)(*pupper);
395
- kmp_int64 l = (kmp_int64)(*plower);
396
- kmp_int64 i = (kmp_int64)incr;
397
- /* compute trip count */
398
- if (i == 1 ) {
399
- t = u - l + 1 ;
400
- } else if (i == -1 ) {
401
- t = l - u + 1 ;
402
- } else if (i > 0 ) {
403
- t = (u - l) / i + 1 ;
404
- } else {
405
- t = (l - u) / (-i) + 1 ;
406
- }
407
- KMP_COUNT_VALUE (OMP_loop_static_iterations, t);
408
- KMP_POP_PARTITIONED_TIMER ();
409
- }
410
- #endif
423
+ KMP_STATS_LOOP_END (OMP_loop_static_iterations);
411
424
return ;
412
425
}
413
426
@@ -419,6 +432,8 @@ static void __kmp_dist_for_static_init(ident_t *loc, kmp_int32 gtid,
419
432
typename traits_t <T>::signed_t incr,
420
433
typename traits_t <T>::signed_t chunk) {
421
434
KMP_COUNT_BLOCK (OMP_DISTRIBUTE);
435
+ KMP_PUSH_PARTITIONED_TIMER (OMP_distribute);
436
+ KMP_PUSH_PARTITIONED_TIMER (OMP_distribute_scheduling);
422
437
typedef typename traits_t <T>::unsigned_t UT;
423
438
typedef typename traits_t <T>::signed_t ST;
424
439
kmp_uint32 tid;
@@ -648,6 +663,7 @@ end:;
648
663
}
649
664
#endif
650
665
KE_TRACE (10 , (" __kmpc_dist_for_static_init: T#%d return\n " , gtid));
666
+ KMP_STATS_LOOP_END (OMP_distribute_iterations);
651
667
return ;
652
668
}
653
669
0 commit comments