Skip to content

Commit db5af26

Browse files
committed
Performance tuning. make sure we catch if the user wants to set the default fileview and replace it with our optimized default file view. Otherwise, performance will suffer. file_get_view should still return the correct filetype, not our optimized default file view. This is the correct version compared to ffa67b9, which unfortunately broke
some test cases in mpi_test_suite. Thanks for @ggouaillardet for reporting this!
1 parent 6f6c01e commit db5af26

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

ompi/mca/io/ompio/io_ompio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ static int mca_io_ompio_merge_groups(mca_io_ompio_file_t *fh,
102102
int num_merge_aggrs);
103103

104104

105-
106105
int ompi_io_ompio_set_file_defaults (mca_io_ompio_file_t *fh)
107106
{
108107

@@ -133,13 +132,14 @@ int ompi_io_ompio_set_file_defaults (mca_io_ompio_file_t *fh)
133132
fh->f_init_num_aggrs = -1;
134133
fh->f_init_aggr_list = NULL;
135134

136-
ompi_datatype_create_contiguous(1048576,
135+
ompi_datatype_create_contiguous(MCA_IO_DEFAULT_FILE_VIEW_SIZE,
137136
&ompi_mpi_byte.dt,
138137
&default_file_view);
139138
ompi_datatype_commit (&default_file_view);
140139

141140
fh->f_etype = &ompi_mpi_byte.dt;
142141
fh->f_filetype = default_file_view;
142+
ompi_datatype_duplicate ( &ompi_mpi_byte.dt, &fh->f_orig_filetype );
143143

144144

145145
/* Default file View */

ompi/mca/io/ompio/io_ompio.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ OMPI_DECLSPEC extern int mca_io_ompio_coll_timing_info;
5757
#define OMPIO_CONTIGUOUS_FVIEW 0x00000010
5858
#define OMPIO_AGGREGATOR_IS_SET 0x00000020
5959
#define OMPIO_SHAREDFP_IS_SET 0x00000040
60+
6061
#define QUEUESIZE 2048
62+
#define MCA_IO_DEFAULT_FILE_VIEW_SIZE 4*1024*1024
6163

6264
#define OMPIO_MIN(a, b) (((a) < (b)) ? (a) : (b))
6365
#define OMPIO_MAX(a, b) (((a) < (b)) ? (b) : (a))
@@ -320,6 +322,7 @@ struct mca_io_ompio_file_t {
320322
size_t f_view_size;
321323
ompi_datatype_t *f_etype;
322324
ompi_datatype_t *f_filetype;
325+
ompi_datatype_t *f_orig_filetype; /* the fileview passed by the user to us */
323326
size_t f_etype_size;
324327

325328
/* contains IO requests that needs to be read/written */

ompi/mca/io/ompio/io_ompio_file_open.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ ompio_io_ompio_file_close (mca_io_ompio_file_t *ompio_fh)
387387
ompi_datatype_destroy (&ompio_fh->f_filetype);
388388
}
389389

390+
if ( MPI_DATATYPE_NULL != ompio_fh->f_orig_filetype ){
391+
ompi_datatype_destroy (&ompio_fh->f_orig_filetype);
392+
}
393+
390394

391395
if (MPI_COMM_NULL != ompio_fh->f_comm && (ompio_fh->f_flags & OMPIO_SHAREDFP_IS_SET) ) {
392396
ompi_comm_free (&ompio_fh->f_comm);

ompi/mca/io/ompio/io_ompio_file_set_view.c

Lines changed: 34 additions & 10 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-2014 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
1313
* Copyright (c) 2015 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
@@ -135,12 +135,15 @@ int mca_io_ompio_file_set_view (ompi_file_t *fp,
135135
{
136136
mca_io_ompio_data_t *data;
137137
mca_io_ompio_file_t *fh;
138+
size_t ftype_size;
139+
OPAL_PTRDIFF_TYPE ftype_extent, lb;
138140

139141
data = (mca_io_ompio_data_t *) fp->f_io_selected_data;
140142
fh = &data->ompio_fh;
141143

142144
ompi_datatype_destroy (&fh->f_etype);
143145
ompi_datatype_destroy (&fh->f_filetype);
146+
ompi_datatype_destroy (&fh->f_orig_filetype);
144147

145148
if (NULL != fh->f_decoded_iov) {
146149
free (fh->f_decoded_iov);
@@ -157,14 +160,35 @@ int mca_io_ompio_file_set_view (ompi_file_t *fp,
157160

158161
fh->f_flags |= OMPIO_FILE_VIEW_IS_SET;
159162
fh->f_datarep = strdup (datarep);
160-
161-
mca_io_ompio_set_view_internal (fh,
162-
disp,
163-
etype,
164-
filetype,
165-
datarep,
166-
info);
167-
163+
ompi_datatype_duplicate (filetype, &fh->f_orig_filetype );
164+
165+
opal_datatype_get_extent(&filetype->super, &lb, &ftype_extent);
166+
opal_datatype_type_size (&filetype->super, &ftype_size);
167+
168+
if ( etype == filetype &&
169+
ompi_datatype_is_predefined (filetype ) &&
170+
ftype_extent == (OPAL_PTRDIFF_TYPE)ftype_size ){
171+
ompi_datatype_t *newfiletype;
172+
ompi_datatype_create_contiguous(MCA_IO_DEFAULT_FILE_VIEW_SIZE,
173+
&ompi_mpi_byte.dt,
174+
&newfiletype);
175+
ompi_datatype_commit (&newfiletype);
176+
mca_io_ompio_set_view_internal (fh,
177+
disp,
178+
etype,
179+
newfiletype,
180+
datarep,
181+
info);
182+
ompi_datatype_destroy ( &newfiletype );
183+
}
184+
else {
185+
mca_io_ompio_set_view_internal (fh,
186+
disp,
187+
etype,
188+
filetype,
189+
datarep,
190+
info);
191+
}
168192

169193
if (OMPI_SUCCESS != mca_fcoll_base_file_select (&data->ompio_fh,
170194
NULL)) {
@@ -189,7 +213,7 @@ int mca_io_ompio_file_get_view (struct ompi_file_t *fp,
189213

190214
*disp = fh->f_disp;
191215
ompi_datatype_duplicate (fh->f_etype, etype);
192-
ompi_datatype_duplicate (fh->f_filetype, filetype);
216+
ompi_datatype_duplicate (fh->f_orig_filetype, filetype);
193217
strcpy (datarep, fh->f_datarep);
194218

195219
return OMPI_SUCCESS;

0 commit comments

Comments
 (0)