Skip to content

Commit 1a4df7a

Browse files
authored
Merge pull request #4518 from edgargabriel/topic/disable-amode-overwrite
io/ompio: add a new option to disable amode overwriting
2 parents 096edf9 + 75ab006 commit 1a4df7a

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

ompi/mca/common/ompio/common_ompio_file_open.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ int mca_common_ompio_file_open (ompi_communicator_t *comm,
112112

113113
/* This fix is needed for data seiving to work with
114114
two-phase collective I/O */
115-
if ((amode & MPI_MODE_WRONLY)){
116-
amode -= MPI_MODE_WRONLY;
117-
amode += MPI_MODE_RDWR;
118-
}
115+
if ( mca_io_ompio_overwrite_amode ) {
116+
if ((amode & MPI_MODE_WRONLY)){
117+
amode -= MPI_MODE_WRONLY;
118+
amode += MPI_MODE_RDWR;
119+
}
120+
}
119121
/*--------------------------------------------------*/
120122

121123

ompi/mca/fcoll/two_phase/fcoll_two_phase_file_write_all.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ mca_fcoll_two_phase_file_write_all (mca_io_ompio_file_t *fh,
239239
two_phase_num_io_procs = fh->f_size;
240240
}
241241

242-
243242
#if DEBUG_ON
244243
printf("Number of aggregators : %ld\n", two_phase_num_io_procs);
245244
#endif
@@ -1074,6 +1073,18 @@ static int two_phase_exchage_data(mca_io_ompio_file_t *fh,
10741073
fh->f_io_array[0].length = size;
10751074
fh->f_io_array[0].memory_address = write_buf;
10761075
if (fh->f_num_of_io_entries){
1076+
if ( fh->f_amode & MPI_MODE_WRONLY &&
1077+
!mca_io_ompio_overwrite_amode ){
1078+
if ( 0 == fh->f_rank ) {
1079+
printf("\n File not opened in RDWR mode, can not continue."
1080+
"\n To resolve this problem, you can either \n"
1081+
" a. open the file with MPI_MODE_RDWR instead of MPI_MODE_WRONLY\n"
1082+
" b. ensure that the mca parameter mca_io_ompio_amode_overwrite is set to 1\n"
1083+
" c. use an fcoll component that does not use data sieving (e.g. dynamic)\n");
1084+
}
1085+
ret = MPI_ERR_FILE;
1086+
goto exit;
1087+
}
10771088
if ( 0 > fh->f_fbtl->fbtl_preadv (fh)) {
10781089
opal_output(1, "READ FAILED\n");
10791090
ret = OMPI_ERROR;

ompi/mca/io/ompio/io_ompio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ extern int mca_io_ompio_sharedfp_lazy_open;
5151
extern int mca_io_ompio_grouping_option;
5252
extern int mca_io_ompio_max_aggregators_ratio;
5353
extern int mca_io_ompio_aggregators_cutoff_threshold;
54+
extern int mca_io_ompio_overwrite_amode;
5455

5556
OMPI_DECLSPEC extern int mca_io_ompio_coll_timing_info;
5657

ompi/mca/io/ompio/io_ompio_component.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ int mca_io_ompio_coll_timing_info = 0;
4141
int mca_io_ompio_sharedfp_lazy_open = 0;
4242
int mca_io_ompio_max_aggregators_ratio=8;
4343
int mca_io_ompio_aggregators_cutoff_threshold=3;
44+
int mca_io_ompio_overwrite_amode = 1;
4445

4546
int mca_io_ompio_grouping_option=5;
4647

@@ -242,6 +243,16 @@ static int register_component(void)
242243
MCA_BASE_VAR_SCOPE_READONLY,
243244
&mca_io_ompio_aggregators_cutoff_threshold);
244245

246+
mca_io_ompio_overwrite_amode = 1;
247+
(void) mca_base_component_var_register(&mca_io_ompio_component.io_version,
248+
"overwrite_amode",
249+
"Overwrite WRONLY amode to RDWR to enable data sieving "
250+
"1: allow overwrite (default) "
251+
"0: do not overwrite amode provided by application ",
252+
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
253+
OPAL_INFO_LVL_9,
254+
MCA_BASE_VAR_SCOPE_READONLY,
255+
&mca_io_ompio_overwrite_amode);
245256

246257
return OMPI_SUCCESS;
247258
}

0 commit comments

Comments
 (0)