13
13
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
14
14
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
15
15
* Copyright (c) 2020 FUJITSU LIMITED. All rights reserved.
16
+ * Copyright (c) 2020 High Performance Computing Center Stuttgart,
17
+ * University of Stuttgart. All rights reserved.
16
18
* $COPYRIGHT$
17
19
*
18
20
* Additional copyrights may follow
30
32
#include "opal/include/opal/align.h"
31
33
#include "opal/util/info_subscriber.h"
32
34
#include "opal/util/printf.h"
35
+ #include "opal/mca/mpool/base/base.h"
33
36
34
37
#include "osc_sm.h"
35
38
@@ -193,6 +196,8 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
193
196
int comm_size = ompi_comm_size (comm );
194
197
bool unlink_needed = false;
195
198
int ret = OMPI_ERROR ;
199
+ int flag ;
200
+ size_t memory_alignment = OPAL_ALIGN_MIN ;
196
201
197
202
if (OMPI_SUCCESS != (ret = check_win_ok (comm , flavor ))) {
198
203
return ret ;
@@ -208,9 +213,20 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
208
213
OBJ_CONSTRUCT (& module -> lock , opal_mutex_t );
209
214
210
215
ret = opal_infosubscribe_subscribe (& (win -> super ), "alloc_shared_noncontig" , "false" , component_set_alloc_shared_noncontig_info );
211
-
212
216
if (OPAL_SUCCESS != ret ) goto error ;
213
217
218
+ if (NULL != info ) {
219
+ opal_cstring_t * align_info_str ;
220
+ ret = opal_info_get (info , "mpi_minimum_memory_alignment" , & align_info_str , & flag );
221
+ if (flag ) {
222
+ ssize_t tmp_align = atoll (align_info_str -> string );
223
+ OBJ_RELEASE (align_info_str );
224
+ if (OPAL_ALIGN_MIN < tmp_align ) {
225
+ memory_alignment = tmp_align ;
226
+ }
227
+ }
228
+ }
229
+
214
230
/* fill in the function pointer part */
215
231
memcpy (module , & ompi_osc_sm_module_template ,
216
232
sizeof (ompi_osc_base_module_t ));
@@ -230,7 +246,8 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
230
246
if (NULL == module -> bases ) return OMPI_ERR_TEMP_OUT_OF_RESOURCE ;
231
247
232
248
module -> sizes [0 ] = size ;
233
- module -> bases [0 ] = malloc (size );
249
+ module -> bases [0 ] = mca_mpool_base_default_module -> mpool_alloc (mca_mpool_base_default_module , size ,
250
+ memory_alignment , 0 );
234
251
if (NULL == module -> bases [0 ]) return OMPI_ERR_TEMP_OUT_OF_RESOURCE ;
235
252
236
253
module -> global_state = malloc (sizeof (ompi_osc_sm_global_state_t ));
@@ -246,6 +263,7 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
246
263
size_t pagesize ;
247
264
size_t state_size ;
248
265
size_t posts_size , post_size = (comm_size + OSC_SM_POST_MASK ) / (OSC_SM_POST_MASK + 1 );
266
+ size_t data_base_size ;
249
267
250
268
OPAL_OUTPUT_VERBOSE ((1 , ompi_osc_base_framework .framework_output ,
251
269
"allocating shared memory region of size %ld\n" , (long ) size ));
@@ -283,6 +301,8 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
283
301
state_size += OPAL_ALIGN_PAD_AMOUNT (state_size , 64 );
284
302
posts_size = comm_size * post_size * sizeof (module -> posts [0 ][0 ]);
285
303
posts_size += OPAL_ALIGN_PAD_AMOUNT (posts_size , 64 );
304
+ data_base_size = state_size + posts_size ;
305
+ data_base_size += OPAL_ALIGN_PAD_AMOUNT (data_base_size , pagesize );
286
306
if (0 == ompi_comm_rank (module -> comm )) {
287
307
char * data_file ;
288
308
ret = opal_asprintf (& data_file , "%s" OPAL_PATH_SEP "osc_sm.%s.%x.%d.%d" ,
@@ -293,7 +313,7 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
293
313
return OMPI_ERR_OUT_OF_RESOURCE ;
294
314
}
295
315
296
- ret = opal_shmem_segment_create (& module -> seg_ds , data_file , total + pagesize + state_size + posts_size );
316
+ ret = opal_shmem_segment_create (& module -> seg_ds , data_file , total + data_base_size );
297
317
free (data_file );
298
318
if (OPAL_SUCCESS != ret ) {
299
319
free (rbuf );
@@ -340,7 +360,7 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
340
360
module -> global_state = (ompi_osc_sm_global_state_t * ) (module -> posts [0 ] + comm_size * post_size );
341
361
module -> node_states = (ompi_osc_sm_node_state_t * ) (module -> global_state + 1 );
342
362
343
- for (i = 0 , total = state_size + posts_size ; i < comm_size ; ++ i ) {
363
+ for (i = 0 , total = data_base_size ; i < comm_size ; ++ i ) {
344
364
if (i > 0 ) {
345
365
module -> posts [i ] = module -> posts [i - 1 ] + post_size ;
346
366
}
@@ -523,12 +543,13 @@ ompi_osc_sm_free(struct ompi_win_t *win)
523
543
module -> comm -> c_coll -> coll_barrier (module -> comm ,
524
544
module -> comm -> c_coll -> coll_barrier_module );
525
545
526
- opal_shmem_segment_detach (& module -> seg_ds );
546
+ opal_shmem_segment_detach (& module -> seg_ds );
527
547
} else {
528
548
free (module -> node_states );
529
549
free (module -> global_state );
530
550
if (NULL != module -> bases ) {
531
- free (module -> bases [0 ]);
551
+ mca_mpool_base_default_module -> mpool_free (mca_mpool_base_default_module ,
552
+ module -> bases [0 ]);
532
553
}
533
554
}
534
555
free (module -> disp_units );
@@ -565,9 +586,9 @@ static const char*
565
586
component_set_blocking_fence_info (opal_infosubscriber_t * obj , const char * key , const char * val )
566
587
{
567
588
ompi_osc_sm_module_t * module = (ompi_osc_sm_module_t * ) ((struct ompi_win_t * ) obj )-> w_osc_module ;
568
- /*
569
- * Assuming that you can't change the default.
570
- */
589
+ /*
590
+ * Assuming that you can't change the default.
591
+ */
571
592
return module -> global_state -> use_barrier_for_fence ? "true" : "false" ;
572
593
}
573
594
@@ -577,9 +598,9 @@ component_set_alloc_shared_noncontig_info(opal_infosubscriber_t *obj, const char
577
598
{
578
599
579
600
ompi_osc_sm_module_t * module = (ompi_osc_sm_module_t * ) ((struct ompi_win_t * ) obj )-> w_osc_module ;
580
- /*
581
- * Assuming that you can't change the default.
582
- */
601
+ /*
602
+ * Assuming that you can't change the default.
603
+ */
583
604
return module -> noncontig ? "true" : "false" ;
584
605
}
585
606
0 commit comments