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,10 +135,16 @@ 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 ;
141-
143+
144+ ompi_datatype_destroy (& fh -> f_etype );
145+ ompi_datatype_destroy (& fh -> f_filetype );
146+ ompi_datatype_destroy (& fh -> f_orig_filetype );
147+
142148 if (NULL != fh -> f_decoded_iov ) {
143149 free (fh -> f_decoded_iov );
144150 fh -> f_decoded_iov = NULL ;
@@ -154,14 +160,35 @@ int mca_io_ompio_file_set_view (ompi_file_t *fp,
154160
155161 fh -> f_flags |= OMPIO_FILE_VIEW_IS_SET ;
156162 fh -> f_datarep = strdup (datarep );
157-
158- mca_io_ompio_set_view_internal (fh ,
159- disp ,
160- etype ,
161- filetype ,
162- datarep ,
163- info );
163+ ompi_datatype_duplicate (filetype , & fh -> f_orig_filetype );
164164
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+ }
165192
166193 if (OMPI_SUCCESS != mca_fcoll_base_file_select (& data -> ompio_fh ,
167194 NULL )) {
@@ -186,7 +213,7 @@ int mca_io_ompio_file_get_view (struct ompi_file_t *fp,
186213
187214 * disp = fh -> f_disp ;
188215 ompi_datatype_duplicate (fh -> f_etype , etype );
189- ompi_datatype_duplicate (fh -> f_filetype , filetype );
216+ ompi_datatype_duplicate (fh -> f_orig_filetype , filetype );
190217 strcpy (datarep , fh -> f_datarep );
191218
192219 return OMPI_SUCCESS ;
0 commit comments