Skip to content

Commit 7c17a38

Browse files
committed
timings: Fix timings when 'prefix' is used
Signed-off-by: Artem Polyakov <[email protected]>
1 parent 836cc5b commit 7c17a38

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

ompi/util/timings.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ typedef struct ompi_timing_t {
120120
} \
121121
} while(0)
122122

123-
#define OMPI_TIMING_APPEND(filename,func,desc,ts) \
123+
#define OMPI_TIMING_APPEND_PREFIX(filename, _prefix, func,desc,ts) \
124124
do { \
125125
if (OMPI_TIMING.cur_timing->use >= OMPI_TIMING.size){ \
126126
OMPI_TIMING_ITEM_EXTEND; \
@@ -130,7 +130,12 @@ typedef struct ompi_timing_t {
130130
if (len >= OPAL_TIMING_STR_LEN) { \
131131
OMPI_TIMING.error = 1; \
132132
} \
133-
OMPI_TIMING.cur_timing->val[OMPI_TIMING.cur_timing->use].prefix = func; \
133+
if( _prefix[0] ) { \
134+
OMPI_TIMING.cur_timing->val[OMPI_TIMING.cur_timing->use].prefix = \
135+
func "/" _prefix; \
136+
} else { \
137+
OMPI_TIMING.cur_timing->val[OMPI_TIMING.cur_timing->use].prefix = func;\
138+
} \
134139
OMPI_TIMING.cur_timing->val[OMPI_TIMING.cur_timing->use].file = filename; \
135140
OMPI_TIMING.cur_timing->val[OMPI_TIMING.cur_timing->use++].ts = ts; \
136141
OMPI_TIMING.cnt++; \
@@ -143,14 +148,14 @@ typedef struct ompi_timing_t {
143148
int i; \
144149
double ts; \
145150
OMPI_TIMING.import_cnt++; \
146-
OPAL_TIMING_ENV_CNT(func, cnt); \
151+
OPAL_TIMING_ENV_CNT_PREFIX(_prefix, func, cnt); \
147152
OPAL_TIMING_ENV_ERROR_PREFIX(_prefix, func, OMPI_TIMING.error); \
148153
for(i = 0; i < cnt; i++){ \
149154
char *desc, *filename; \
150155
OMPI_TIMING.cur_timing->val[OMPI_TIMING.cur_timing->use].imported= \
151156
OMPI_TIMING.import_cnt; \
152157
OPAL_TIMING_ENV_GETDESC_PREFIX(_prefix, &filename, func, i, &desc, ts); \
153-
OMPI_TIMING_APPEND(filename, func, desc, ts); \
158+
OMPI_TIMING_APPEND_PREFIX(filename, _prefix, func, desc, ts); \
154159
} \
155160
} \
156161
} while(0)
@@ -275,6 +280,8 @@ typedef struct ompi_timing_t {
275280

276281
#define OMPI_TIMING_IMPORT_OPAL(func)
277282

283+
#define OMPI_TIMING_IMPORT_OPAL_PREFIX(_prefix, func)
284+
278285
#define OMPI_TIMING_FINALIZE
279286

280287
#define OMPI_TIMING_ENABLED 0

opal/util/timings.h

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ opal_timing_ts_func_t opal_timing_ts_func(opal_timer_type_t type);
4949
_prefix = ""; \
5050
} \
5151
(_nm)->error = 0; \
52-
n = snprintf((_nm)->id, OPAL_TIMING_STR_LEN, "%s%s", _prefix, func); \
52+
n = snprintf((_nm)->id, OPAL_TIMING_STR_LEN, "%s_%s", _prefix, func); \
5353
if( n > OPAL_TIMING_STR_LEN ){ \
5454
(_nm)->error = 1; \
5555
} \
56-
n = sprintf((_nm)->cntr_env,"OMPI_TIMING_%s%s_CNT", prefix, (_nm)->id); \
56+
n = sprintf((_nm)->cntr_env,"OMPI_TIMING_%s_CNT", (_nm)->id); \
5757
if( n > OPAL_TIMING_STR_LEN ){ \
5858
(_nm)->error = 1; \
5959
} \
@@ -77,22 +77,17 @@ opal_timing_ts_func_t opal_timing_ts_func(opal_timer_type_t type);
7777
} \
7878
} while(0)
7979

80-
#define OPAL_TIMING_ENV_INIT(name) \
81-
opal_timing_env_t name ## _val, *name = &(name ## _val); \
82-
OPAL_TIMING_ENV_START_TYPE(__func__, name, OPAL_TIMING_AUTOMATIC_TIMER, "");
83-
84-
8580
/* We use function names for identification
8681
* however this might be a problem for the private
8782
* functions declared as static as their names may
8883
* conflict.
8984
* Use prefix to do a finer-grained identification if needed
9085
*/
9186
#define OPAL_TIMING_ENV_INIT_PREFIX(prefix, name) \
92-
do { \
93-
opal_timing_env_t name ## _val, *name = &(name ## _val); \
94-
*name = OPAL_TIMING_ENV_START_TYPE(__func__, name, OPAL_TIMING_AUTOMATIC_TIMER, prefix); \
95-
} while(0)
87+
opal_timing_env_t name ## _val, *name = &(name ## _val); \
88+
OPAL_TIMING_ENV_START_TYPE(__func__, name, OPAL_TIMING_AUTOMATIC_TIMER, prefix);
89+
90+
#define OPAL_TIMING_ENV_INIT(name) OPAL_TIMING_ENV_INIT_PREFIX("", name)
9691

9792
#define OPAL_TIMING_ENV_NEXT(h, ...) \
9893
do { \
@@ -161,7 +156,7 @@ opal_timing_ts_func_t opal_timing_ts_func(opal_timer_type_t type);
161156
do { \
162157
char ename[OPAL_TIMING_STR_LEN]; \
163158
char *ptr = NULL; \
164-
int n = snprintf(ename, OPAL_TIMING_STR_LEN, "OMPI_TIMING_%s%s_CNT", prefix, func); \
159+
int n = snprintf(ename, OPAL_TIMING_STR_LEN, "OMPI_TIMING_%s_%s_CNT", prefix, func); \
165160
(_cnt) = 0; \
166161
if ( n <= OPAL_TIMING_STR_LEN ){ \
167162
ptr = getenv(ename); \
@@ -181,18 +176,15 @@ opal_timing_ts_func_t opal_timing_ts_func(opal_timer_type_t type);
181176
} \
182177
} while(0)
183178

184-
#define OPAL_TIMING_ENV_CNT(func, _cnt) \
185-
OPAL_TIMING_ENV_CNT_PREFIX("", func, _cnt)
186-
187179
#define OPAL_TIMING_ENV_GETDESC_PREFIX(prefix, filename, func, i, desc, _t) \
188180
do { \
189181
char vname[OPAL_TIMING_STR_LEN]; \
190182
(_t) = 0.0; \
191-
sprintf(vname, "OMPI_TIMING_%s%s_FILE_%d", prefix, func, i); \
183+
sprintf(vname, "OMPI_TIMING_%s_%s_FILE_%d", prefix, func, i); \
192184
*filename = getenv(vname); \
193-
sprintf(vname, "OMPI_TIMING_%s%s_DESC_%d", prefix, func, i); \
185+
sprintf(vname, "OMPI_TIMING_%s_%s_DESC_%d", prefix, func, i); \
194186
*desc = getenv(vname); \
195-
sprintf(vname, "OMPI_TIMING_%s%s_VAL_%d", prefix, func, i); \
187+
sprintf(vname, "OMPI_TIMING_%s_%s_VAL_%d", prefix, func, i); \
196188
char *ptr = getenv(vname); \
197189
if ( NULL != ptr ) { \
198190
sscanf(ptr,"%lf", &(_t)); \

0 commit comments

Comments
 (0)