Skip to content

Commit 0f51ea3

Browse files
committed
timings: Update/extend OSHMEM timings
Signed-off-by: Artem Polyakov <[email protected]>
1 parent 7c17a38 commit 0f51ea3

File tree

5 files changed

+112
-9
lines changed

5 files changed

+112
-9
lines changed

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)