Skip to content

Commit f56ea5d

Browse files
authored
Merge pull request #2786 from edgargabriel/pr/sharedfp-append-fix-v2.x
Pr/sharedfp append fix v2.x
2 parents 3126db8 + cfda4b8 commit f56ea5d

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

ompi/mca/io/ompio/io_ompio_component.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int mca_io_ompio_bytes_per_agg = OMPIO_PREALLOC_MAX_BUF_SIZE;
4949
int mca_io_ompio_num_aggregators = -1;
5050
int mca_io_ompio_record_offset_info = 0;
5151
int mca_io_ompio_coll_timing_info = 0;
52-
int mca_io_ompio_sharedfp_lazy_open = 1;
52+
int mca_io_ompio_sharedfp_lazy_open = 0;
5353

5454
int mca_io_ompio_grouping_option=5;
5555

@@ -206,7 +206,7 @@ static int register_component(void)
206206
&mca_io_ompio_num_aggregators);
207207

208208

209-
mca_io_ompio_sharedfp_lazy_open = 1;
209+
mca_io_ompio_sharedfp_lazy_open = 0;
210210
(void) mca_base_component_var_register(&mca_io_ompio_component.io_version,
211211
"sharedfp_lazy_open",
212212
"lazy allocation of internal shared file pointer structures",

ompi/mca/io/ompio/io_ompio_file_open.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2017 University of Houston. All rights reserved.
1313
* Copyright (c) 2015 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
@@ -197,14 +197,8 @@ ompio_io_ompio_file_open (ompi_communicator_t *comm,
197197
}
198198

199199
/* open the file once more for the shared file pointer if required.
200-
** Per default, the shared file pointer specific actions are however
201-
** only performed on first access of the shared file pointer, except
202-
** for the addproc sharedfp component.
203-
**
204-
** Lazy open does not work for the addproc sharedfp
205-
** component since it starts by spawning a process using MPI_Comm_spawn.
206-
** For this, the first operation has to be collective which we can
207-
** not guarantuee outside of the MPI_File_open operation.
200+
** Can be disabled by the user if no shared file pointer operations
201+
** are used by his application.
208202
*/
209203
if ( NULL != ompio_fh->f_sharedfp &&
210204
true == use_sharedfp &&
@@ -250,10 +244,27 @@ ompio_io_ompio_file_open (ompi_communicator_t *comm,
250244
file pointer of OMPIO to the very end of the file. */
251245
if ( ompio_fh->f_amode & MPI_MODE_APPEND ) {
252246
OMPI_MPI_OFFSET_TYPE current_size;
247+
mca_sharedfp_base_module_t * shared_fp_base_module;
253248

254249
ompio_fh->f_fs->fs_file_get_size( ompio_fh,
255250
&current_size);
256251
ompi_io_ompio_set_explicit_offset (ompio_fh, current_size);
252+
if ( true == use_sharedfp ) {
253+
if ( NULL != ompio_fh->f_sharedfp &&
254+
(!mca_io_ompio_sharedfp_lazy_open ||
255+
!strcmp (ompio_fh->f_sharedfp_component->mca_component_name,
256+
"addproc") )) {
257+
258+
shared_fp_base_module = ompio_fh->f_sharedfp;
259+
ret = shared_fp_base_module->sharedfp_seek(ompio_fh,current_size, MPI_SEEK_SET);
260+
}
261+
else {
262+
opal_output(1, "mca_common_ompio_file_open: Could not adjust position of "
263+
"shared file pointer whith MPI_MODE_APPEND\n");
264+
ret = MPI_ERR_OTHER;
265+
goto fn_fail;
266+
}
267+
}
257268
}
258269

259270

0 commit comments

Comments
 (0)