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
2828mca_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