Skip to content

Commit 069084e

Browse files
authored
Merge pull request #5907 from edgargabriel/topic/testmpio-fixes
Topic/testmpio fixes
2 parents d188151 + ba95588 commit 069084e

File tree

6 files changed

+50
-10
lines changed

6 files changed

+50
-10
lines changed

ompi/mca/common/ompio/common_ompio_file_read.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,19 @@ int mca_common_ompio_file_read (ompio_file_t *fh,
7777
int i = 0; /* index into the decoded iovec of the buffer */
7878
int j = 0; /* index into the file vie iovec */
7979

80+
if (fh->f_amode & MPI_MODE_WRONLY){
81+
// opal_output(10, "Improper use of FILE Mode, Using WRONLY for Read!\n");
82+
ret = MPI_ERR_ACCESS;
83+
return ret;
84+
}
85+
8086
if ( 0 == count ) {
8187
if ( MPI_STATUS_IGNORE != status ) {
8288
status->_ucount = 0;
8389
}
8490
return ret;
8591
}
8692

87-
if (fh->f_amode & MPI_MODE_WRONLY){
88-
printf("Improper use of FILE Mode, Using WRONLY for Read!\n");
89-
ret = OMPI_ERROR;
90-
return ret;
91-
}
9293

9394
#if OPAL_CUDA_SUPPORT
9495
int is_gpu, is_managed;
@@ -226,6 +227,12 @@ int mca_common_ompio_file_iread (ompio_file_t *fh,
226227
mca_ompio_request_t *ompio_req=NULL;
227228
size_t spc=0;
228229

230+
if (fh->f_amode & MPI_MODE_WRONLY){
231+
// opal_output(10, "Improper use of FILE Mode, Using WRONLY for Read!\n");
232+
ret = MPI_ERR_ACCESS;
233+
return ret;
234+
}
235+
229236
mca_common_ompio_request_alloc ( &ompio_req, MCA_OMPIO_REQUEST_READ);
230237

231238
if ( 0 == count ) {

ompi/mca/common/ompio/common_ompio_file_view.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ int mca_common_ompio_set_view (ompio_file_t *fh,
141141
// in orig_file type, No need to set args on this one.
142142
ompi_datatype_duplicate (newfiletype, &fh->f_filetype);
143143

144+
if ( (fh->f_view_size % fh->f_etype_size) ) {
145+
// File view is not a multiple of the etype.
146+
return MPI_ERR_ARG;
147+
}
144148

145149
if( SIMPLE_PLUS == OMPIO_MCA_GET(fh, grouping_option) ) {
146150
fh->f_cc_size = get_contiguous_chunk_size (fh, 1);

ompi/mca/common/ompio/common_ompio_file_write.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ int mca_common_ompio_file_write (ompio_file_t *fh,
5858
int i = 0; /* index into the decoded iovec of the buffer */
5959
int j = 0; /* index into the file view iovec */
6060

61+
if (fh->f_amode & MPI_MODE_RDONLY){
62+
// opal_output(10, "Improper use of FILE Mode, Using RDONLY for write!\n");
63+
ret = MPI_ERR_READ_ONLY;
64+
return ret;
65+
}
66+
67+
6168
if ( 0 == count ) {
6269
if ( MPI_STATUS_IGNORE != status ) {
6370
status->_ucount = 0;
@@ -194,6 +201,12 @@ int mca_common_ompio_file_iwrite (ompio_file_t *fh,
194201
mca_ompio_request_t *ompio_req=NULL;
195202
size_t spc=0;
196203

204+
if (fh->f_amode & MPI_MODE_RDONLY){
205+
// opal_output(10, "Improper use of FILE Mode, Using RDONLY for write!\n");
206+
ret = MPI_ERR_READ_ONLY;
207+
return ret;
208+
}
209+
197210
mca_common_ompio_request_alloc ( &ompio_req, MCA_OMPIO_REQUEST_WRITE);
198211

199212
if ( 0 == count ) {

ompi/mca/io/ompio/io_ompio_file_open.c

Lines changed: 11 additions & 3 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-2018 University of Houston. All rights reserved.
1313
* Copyright (c) 2015-2018 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
@@ -372,6 +372,13 @@ int mca_io_ompio_file_sync (ompi_file_t *fh)
372372
OPAL_THREAD_UNLOCK(&fh->f_lock);
373373
return MPI_ERR_ACCESS;
374374
}
375+
// Make sure all processes reach this point before syncing the file.
376+
ret = data->ompio_fh.f_comm->c_coll->coll_barrier (data->ompio_fh.f_comm,
377+
data->ompio_fh.f_comm->c_coll->coll_barrier_module);
378+
if ( MPI_SUCCESS != ret ) {
379+
OPAL_THREAD_UNLOCK(&fh->f_lock);
380+
return ret;
381+
}
375382
ret = data->ompio_fh.f_fs->fs_file_sync (&data->ompio_fh);
376383
OPAL_THREAD_UNLOCK(&fh->f_lock);
377384

@@ -400,8 +407,9 @@ int mca_io_ompio_file_seek (ompi_file_t *fh,
400407
}
401408
break;
402409
case MPI_SEEK_CUR:
403-
offset += data->ompio_fh.f_position_in_file_view;
404-
offset += data->ompio_fh.f_disp;
410+
ret = mca_common_ompio_file_get_position (&data->ompio_fh,
411+
&temp_offset);
412+
offset += temp_offset;
405413
if (offset < 0) {
406414
OPAL_THREAD_UNLOCK(&fh->f_lock);
407415
return OMPI_ERROR;

ompi/mca/io/ompio/io_ompio_file_set_view.c

Lines changed: 6 additions & 2 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-2018 University of Houston. All rights reserved.
1313
* Copyright (c) 2015-2018 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
@@ -66,13 +66,17 @@ int mca_io_ompio_file_set_view (ompi_file_t *fp,
6666
mca_common_ompio_data_t *data;
6767
ompio_file_t *fh;
6868

69+
if ( (strcmp(datarep, "native") && strcmp(datarep, "NATIVE"))) {
70+
return MPI_ERR_UNSUPPORTED_DATAREP;
71+
}
72+
6973
data = (mca_common_ompio_data_t *) fp->f_io_selected_data;
7074

7175
/* we need to call the internal file set view twice: once for the individual
7276
file pointer, once for the shared file pointer (if it is existent)
7377
*/
7478
fh = &data->ompio_fh;
75-
79+
7680
OPAL_THREAD_LOCK(&fp->f_lock);
7781
ret = mca_common_ompio_set_view(fh, disp, etype, filetype, datarep, info);
7882
OPAL_THREAD_UNLOCK(&fp->f_lock);

ompi/mpi/c/file_set_view.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype,
6464
OMPI_CHECK_DATATYPE_FOR_VIEW(rc, filetype, 0);
6565
}
6666
}
67+
if ( NULL == datarep) {
68+
rc = MPI_ERR_UNSUPPORTED_DATAREP;
69+
fh = MPI_FILE_NULL;
70+
}
6771
OMPI_ERRHANDLER_CHECK(rc, fh, rc, FUNC_NAME);
6872
}
6973

0 commit comments

Comments
 (0)