Skip to content

Commit 9ffee98

Browse files
authored
Merge pull request #7512 from artpol84/topic/master/timings_update
Topic/master/timings update
2 parents f973381 + 0f51ea3 commit 9ffee98

File tree

7 files changed

+133
-31
lines changed

7 files changed

+133
-31
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)); \

oshmem/mca/memheap/base/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ typedef struct mca_memheap_map {
6262
extern mca_memheap_map_t mca_memheap_base_map;
6363
extern mca_memheap_base_config_t mca_memheap_base_config;
6464

65-
int mca_memheap_base_alloc_init(mca_memheap_map_t *, size_t, long);
65+
int mca_memheap_base_alloc_init(mca_memheap_map_t *, size_t, long, char *);
6666
void mca_memheap_base_alloc_exit(mca_memheap_map_t *);
6767
int mca_memheap_base_static_init(mca_memheap_map_t *);
6868
void mca_memheap_base_static_exit(mca_memheap_map_t *);

oshmem/mca/memheap/base/memheap_base_alloc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717
#include "oshmem/mca/sshmem/base/base.h"
1818
#include "oshmem/mca/memheap/memheap.h"
1919
#include "oshmem/mca/memheap/base/base.h"
20+
#include "ompi/util/timings.h"
2021

2122

22-
int mca_memheap_base_alloc_init(mca_memheap_map_t *map, size_t size, long hint)
23+
int mca_memheap_base_alloc_init(mca_memheap_map_t *map, size_t size, long hint,
24+
char *timing_prefix)
2325
{
2426
int ret = OSHMEM_SUCCESS;
2527
char * seg_filename = NULL;
2628

29+
OPAL_TIMING_ENV_INIT_PREFIX(timing_prefix, timing);
30+
2731
assert(map);
2832
if (hint == 0) {
2933
assert(HEAP_SEG_INDEX == map->n_segments);
@@ -33,8 +37,13 @@ int mca_memheap_base_alloc_init(mca_memheap_map_t *map, size_t size, long hint)
3337

3438
map_segment_t *s = &map->mem_segs[map->n_segments];
3539
seg_filename = oshmem_get_unique_file_name(oshmem_my_proc_id());
40+
41+
OPAL_TIMING_ENV_NEXT(timing, "oshmem_get_unique_file_name()");
42+
3643
ret = mca_sshmem_segment_create(s, seg_filename, size, hint);
3744

45+
OPAL_TIMING_ENV_NEXT(timing, "mca_sshmem_segment_create()");
46+
3847
if (OSHMEM_SUCCESS == ret) {
3948
map->n_segments++;
4049
MEMHEAP_VERBOSE(1,
@@ -43,6 +52,7 @@ int mca_memheap_base_alloc_init(mca_memheap_map_t *map, size_t size, long hint)
4352
}
4453

4554
free(seg_filename);
55+
OPAL_TIMING_ENV_NEXT(timing, "DONE");
4656

4757
return ret;
4858
}

oshmem/mca/memheap/base/memheap_base_mkey.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "oshmem/mca/memheap/memheap.h"
2828
#include "oshmem/mca/memheap/base/base.h"
2929
#include "oshmem/mca/spml/spml.h"
30+
#include "opal/util/timings.h"
3031

3132
/* Turn ON/OFF debug output from build (default 0) */
3233
#ifndef MEMHEAP_BASE_DEBUG
@@ -529,14 +530,16 @@ void mca_memheap_modex_recv_all(void)
529530
int rc = OSHMEM_SUCCESS;
530531
size_t buffer_size;
531532

533+
OPAL_TIMING_ENV_INIT(recv_all);
534+
532535
if (!mca_memheap_base_key_exchange) {
533536
oshmem_shmem_barrier();
534537
return;
535538
}
536-
539+
OPAL_TIMING_ENV_NEXT(recv_all, "barrier");
537540
nprocs = oshmem_num_procs();
538541
my_pe = oshmem_my_proc_id();
539-
542+
OPAL_TIMING_ENV_NEXT(recv_all, "proc position");
540543
/* buffer allocation for num_transports
541544
* message sizes and offsets */
542545

@@ -560,6 +563,7 @@ void mca_memheap_modex_recv_all(void)
560563
rc = OSHMEM_ERR_OUT_OF_RESOURCE;
561564
goto exit_fatal;
562565
}
566+
OPAL_TIMING_ENV_NEXT(recv_all, "alloc bufs");
563567

564568
/* serialize our own mkeys */
565569
msg = OBJ_NEW(opal_buffer_t);
@@ -582,6 +586,9 @@ void mca_memheap_modex_recv_all(void)
582586
opal_dss.unload(msg, &send_buffer, &size);
583587
MEMHEAP_VERBOSE(1, "local keys packed into %d bytes, %d segments", size, memheap_map->n_segments);
584588

589+
OPAL_TIMING_ENV_NEXT(recv_all, "serialize data");
590+
591+
585592
/* we need to send num_transports and message sizes separately
586593
* since message sizes depend on types of btl used */
587594

@@ -591,12 +598,17 @@ void mca_memheap_modex_recv_all(void)
591598
goto exit_fatal;
592599
}
593600

601+
OPAL_TIMING_ENV_NEXT(recv_all, "allgather: transport cnt");
602+
603+
594604
rc = oshmem_shmem_allgather(&size, rcv_size, sizeof(int));
595605
if (MPI_SUCCESS != rc) {
596606
MEMHEAP_ERROR("allgather failed");
597607
goto exit_fatal;
598608
}
599609

610+
OPAL_TIMING_ENV_NEXT(recv_all, "allgather: size info");
611+
600612
/* calculating offsets (displacements) for allgatherv */
601613

602614
rcv_offsets[0] = 0;
@@ -613,13 +625,17 @@ void mca_memheap_modex_recv_all(void)
613625
goto exit_fatal;
614626
}
615627

628+
OPAL_TIMING_ENV_NEXT(recv_all, "alloc data buf");
629+
616630
rc = oshmem_shmem_allgatherv(send_buffer, rcv_buffer, size, rcv_size, rcv_offsets);
617631
if (MPI_SUCCESS != rc) {
618632
free (rcv_buffer);
619633
MEMHEAP_ERROR("allgatherv failed");
620634
goto exit_fatal;
621635
}
622636

637+
OPAL_TIMING_ENV_NEXT(recv_all, "Perform mkey exchange");
638+
623639
opal_dss.load(msg, rcv_buffer, buffer_size);
624640

625641
/* deserialize mkeys */
@@ -651,6 +667,8 @@ void mca_memheap_modex_recv_all(void)
651667
}
652668
}
653669

670+
OPAL_TIMING_ENV_NEXT(recv_all, "Unpack data");
671+
654672
OPAL_THREAD_UNLOCK(&memheap_oob.lck);
655673

656674
exit_fatal:
@@ -670,6 +688,7 @@ void mca_memheap_modex_recv_all(void)
670688
OBJ_RELEASE(msg);
671689
}
672690

691+
OPAL_TIMING_ENV_NEXT(recv_all, "Cleanup");
673692
/* This function requires abort in any error case */
674693
if (OSHMEM_SUCCESS != rc) {
675694
oshmem_shmem_abort(rc);

oshmem/mca/memheap/base/memheap_base_select.c

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "oshmem/mca/memheap/base/base.h"
2424
#include "oshmem/include/shmemx.h"
2525
#include "oshmem/mca/sshmem/base/base.h"
26-
26+
#include "ompi/util/timings.h"
2727

2828
mca_memheap_base_config_t mca_memheap_base_config = {
2929
.device_nic_mem_seg_size = 0
@@ -56,6 +56,8 @@ int mca_memheap_base_select()
5656
mca_memheap_base_component_t *best_component = NULL;
5757
mca_memheap_base_module_t *best_module = NULL;
5858

59+
OPAL_TIMING_ENV_INIT(timing);
60+
5961
if( OPAL_SUCCESS != mca_base_select("memheap", oshmem_memheap_base_framework.framework_output,
6062
&oshmem_memheap_base_framework.framework_components,
6163
(mca_base_module_t **) &best_module,
@@ -64,11 +66,15 @@ int mca_memheap_base_select()
6466
return OSHMEM_ERROR;
6567
}
6668

69+
OPAL_TIMING_ENV_NEXT(timing, "env");
70+
6771
context = _memheap_create();
6872
if (NULL == context) {
6973
return OSHMEM_ERROR;
7074
}
7175

76+
OPAL_TIMING_ENV_NEXT(timing, "_memheap_create()");
77+
7278
if (OSHMEM_SUCCESS != best_component->memheap_init(context)) {
7379
opal_show_help("help-oshmem-memheap.txt",
7480
"find-available:none-found",
@@ -77,6 +83,8 @@ int mca_memheap_base_select()
7783
return OSHMEM_ERROR;
7884
}
7985

86+
OPAL_TIMING_ENV_NEXT(timing, "best_component->memheap_init()");
87+
8088
/* Calculate memheap size in case it was not set during component initialization */
8189
best_module->memheap_size = context->user_size;
8290
setenv(SHMEM_HEAP_TYPE,
@@ -89,6 +97,7 @@ int mca_memheap_base_select()
8997
best_component->memheap_version.mca_type_name,
9098
best_component->memheap_version.mca_component_name);
9199

100+
OPAL_TIMING_ENV_NEXT(timing, "DONE");
92101
return OSHMEM_SUCCESS;
93102
}
94103

@@ -103,43 +112,60 @@ static memheap_context_t* _memheap_create(void)
103112
static memheap_context_t context;
104113
size_t user_size, size;
105114

115+
OPAL_TIMING_ENV_INIT(timing);
116+
106117
user_size = _memheap_size();
107118
if (user_size < MEMHEAP_BASE_MIN_SIZE) {
108119
MEMHEAP_ERROR("Requested memheap size is less than minimal meamheap size (%llu < %llu)",
109120
(unsigned long long)user_size, MEMHEAP_BASE_MIN_SIZE);
110121
return NULL ;
111122
}
123+
124+
OPAL_TIMING_ENV_NEXT(timing, "_memheap_size()");
125+
112126
/* Inititialize symmetric area */
113127
if (OSHMEM_SUCCESS == rc) {
114128
rc = mca_memheap_base_alloc_init(&mca_memheap_base_map,
115-
user_size + MEMHEAP_BASE_PRIVATE_SIZE, 0);
129+
user_size + MEMHEAP_BASE_PRIVATE_SIZE, 0,
130+
"regular_mem");
116131
}
117132

133+
OPAL_TIMING_ENV_NEXT(timing, "mca_memheap_base_alloc_init()");
134+
118135
/* Initialize atomic symmetric area */
119136
size = mca_memheap_base_config.device_nic_mem_seg_size;
120137
if ((OSHMEM_SUCCESS == rc) && (size > 0)) {
121138
rc = mca_memheap_base_alloc_init(&mca_memheap_base_map, size,
122-
SHMEM_HINT_DEVICE_NIC_MEM);
139+
SHMEM_HINT_DEVICE_NIC_MEM,
140+
"device_mem");
123141
if (rc == OSHMEM_ERR_NOT_IMPLEMENTED) {
124142
/* do not treat NOT_IMPLEMENTED as error */
125143
rc = OSHMEM_SUCCESS;
126144
}
127145
}
128146

147+
OPAL_TIMING_ENV_NEXT(timing, "mca_memheap_base_alloc_init(DEVICE_MEM)");
148+
149+
129150
/* Inititialize static/global variables area */
130151
if (OSHMEM_SUCCESS == rc) {
131152
rc = mca_memheap_base_static_init(&mca_memheap_base_map);
132153
}
133154

155+
OPAL_TIMING_ENV_NEXT(timing, "mca_memheap_base_static_init()");
156+
134157
/* Memory Registration */
135158
if (OSHMEM_SUCCESS == rc) {
136159
rc = mca_memheap_base_reg(&mca_memheap_base_map);
137160
}
138161

162+
OPAL_TIMING_ENV_NEXT(timing, "mca_memheap_base_reg()");
163+
139164
/* Init OOB channel */
140165
if (OSHMEM_SUCCESS == rc) {
141166
rc = memheap_oob_init(&mca_memheap_base_map);
142167
}
168+
OPAL_TIMING_ENV_NEXT(timing, "memheap_oob_init()");
143169

144170
if (OSHMEM_SUCCESS == rc) {
145171
context.user_size = user_size;
@@ -151,6 +177,7 @@ static memheap_context_t* _memheap_create(void)
151177
(void*) ((unsigned char*) mca_memheap_base_map.mem_segs[HEAP_SEG_INDEX].super.va_base
152178
+ context.user_size);
153179
}
180+
OPAL_TIMING_ENV_NEXT(timing, "DONE");
154181

155182
return ((OSHMEM_SUCCESS == rc) ? &context : NULL );
156183
}

0 commit comments

Comments
 (0)