Skip to content

Commit cd45371

Browse files
committed
osc/sm: fix MPI_Win_allocate_shared() alignment
add padding so the memory allocated by MPI_Win_allocate_shared() is 64 bytes aligned. Thanks Joseph Schuchart for the bug report Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 404fe32 commit cd45371

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ompi/mca/osc/sm/osc_sm_component.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* reserved.
66
* Copyright (c) 2014 Intel, Inc. All rights reserved.
77
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
8-
* Copyright (c) 2015-2016 Research Organization for Information Science
8+
* Copyright (c) 2015-2017 Research Organization for Information Science
99
* and Technology (RIST). All rights reserved.
1010
* $COPYRIGHT$
1111
*
@@ -21,6 +21,7 @@
2121
#include "ompi/mca/osc/base/osc_base_obj_convert.h"
2222
#include "ompi/request/request.h"
2323
#include "opal/util/sys_limits.h"
24+
#include "opal/include/opal/align.h"
2425

2526
#include "osc_sm.h"
2627

@@ -211,7 +212,7 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
211212
int i, flag;
212213
size_t pagesize;
213214
size_t state_size;
214-
int posts_size, post_size = (comm_size + 63) / 64;
215+
size_t posts_size, post_size = (comm_size + 63) / 64;
215216

216217
OPAL_OUTPUT_VERBOSE((1, ompi_osc_base_framework.framework_output,
217218
"allocating shared memory region of size %ld\n", (long) size));
@@ -246,7 +247,9 @@ component_select(struct ompi_win_t *win, void **base, size_t size, int disp_unit
246247

247248
/* user opal/shmem directly to create a shared memory segment */
248249
state_size = sizeof(ompi_osc_sm_global_state_t) + sizeof(ompi_osc_sm_node_state_t) * comm_size;
250+
state_size += OPAL_ALIGN_PAD_AMOUNT(state_size, 64);
249251
posts_size = comm_size * post_size * sizeof (uint64_t);
252+
posts_size += OPAL_ALIGN_PAD_AMOUNT(posts_size, 64);
250253
if (0 == ompi_comm_rank (module->comm)) {
251254
char *data_file;
252255
if (asprintf(&data_file, "%s"OPAL_PATH_SEP"shared_window_%d.%s",

0 commit comments

Comments
 (0)