Skip to content

Commit 6168dde

Browse files
committed
common_ompio_file_set_view: fix handling of MPI_DISPLACEMENT_CURRENT
If MPI_MODE_SEQUENTIAL was used when opening the file, the special displacement MPI_DISPLACEMENT_CURRENT has to be used during file_set_view. The displacement is set to the current position of the shared file pointer in this case. It is illegal to use MPI_DISPLACEMENT_CURRENT unless amode MPI_MODE_SEQUENTIAL was used. Signed-off-by: Edgar Gabriel <egabriel@central.uh.edu>
1 parent 1faba65 commit 6168dde

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

ompi/mca/common/ompio/common_ompio_file_view.c

Lines changed: 11 additions & 1 deletion
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-2019 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2021 University of Houston. All rights reserved.
1313
* Copyright (c) 2017-2018 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2017 IBM Corporation. All rights reserved.
@@ -72,6 +72,16 @@ int mca_common_ompio_set_view (ompio_file_t *fh,
7272
ptrdiff_t ftype_extent, lb, ub;
7373
ompi_datatype_t *newfiletype;
7474

75+
if ( (MPI_DISPLACEMENT_CURRENT == disp) &&
76+
(fh->f_amode & MPI_MODE_SEQUENTIAL) ) {
77+
mca_sharedfp_base_module_t * shared_fp_base_module = fh->f_sharedfp;
78+
if ( NULL == shared_fp_base_module ){
79+
opal_output(0, "No shared file pointer component found for this file. Can not execute\n");
80+
return OMPI_ERROR;
81+
}
82+
shared_fp_base_module->sharedfp_get_position(fh, &disp);
83+
}
84+
7585
if ( NULL != fh->f_etype ) {
7686
ompi_datatype_destroy (&fh->f_etype);
7787
}

ompi/mca/io/ompio/io_ompio_file_set_view.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ int mca_io_ompio_file_set_view (ompi_file_t *fp,
7777
file pointer, once for the shared file pointer (if it is existent)
7878
*/
7979
fh = &data->ompio_fh;
80-
80+
81+
if ( MPI_DISPLACEMENT_CURRENT == disp &&
82+
!(fh->f_amode & MPI_MODE_SEQUENTIAL ) ) {
83+
// MPI_DISPLACEMENT_CURRENT is only valid if amode is MPI_MODE_SEQUENTIAL
84+
return MPI_ERR_DISP;
85+
}
86+
87+
8188
OPAL_THREAD_LOCK(&fp->f_lock);
8289
ret = mca_common_ompio_set_view(fh, disp, etype, filetype, datarep, info);
8390
OPAL_THREAD_UNLOCK(&fp->f_lock);

0 commit comments

Comments
 (0)