@@ -94,6 +94,9 @@ mca_fcoll_static_file_read_all (mca_io_ompio_file_t *fh,
9494 ompi_datatype_t * * sendtype = NULL ;
9595 MPI_Request * send_req = NULL , recv_req = NULL ;
9696 int my_aggregator = -1 ;
97+ bool recvbuf_is_contiguous = false;
98+ size_t ftype_size ;
99+ OPAL_PTRDIFF_TYPE ftype_extent , lb ;
97100
98101#if OMPIO_FCOLL_WANT_TIME_BREAKDOWN
99102 double read_time = 0.0 , start_read_time = 0.0 , end_read_time = 0.0 ;
@@ -104,14 +107,21 @@ mca_fcoll_static_file_read_all (mca_io_ompio_file_t *fh,
104107#if DEBUG_ON
105108 MPI_Aint gc_in ;
106109#endif
110+ opal_datatype_type_size ( & datatype -> super , & ftype_size );
111+ opal_datatype_get_extent ( & datatype -> super , & lb , & ftype_extent );
107112
108- // if (opal_datatype_is_contiguous_memory_layout(&datatype->super,1)) {
109- // fh->f_flags |= OMPIO_CONTIGUOUS_MEMORY;
110- // }
113+ /**************************************************************************
114+ ** 1. In case the data is not contigous in memory, decode it into an iovec
115+ **************************************************************************/
116+ if ( ( ftype_extent == (OPAL_PTRDIFF_TYPE ) ftype_size ) &&
117+ opal_datatype_is_contiguous_memory_layout (& datatype -> super ,1 ) &&
118+ 0 == lb ) {
119+ recvbuf_is_contiguous = true;
120+ }
111121
112122
113123 /* In case the data is not contigous in memory, decode it into an iovec */
114- if (! ( fh -> f_flags & OMPIO_CONTIGUOUS_MEMORY ) ) {
124+ if (!recvbuf_is_contiguous ) {
115125 fh -> f_decode_datatype ( (struct mca_io_ompio_file_t * )fh ,
116126 datatype ,
117127 count ,
@@ -507,7 +517,7 @@ mca_fcoll_static_file_read_all (mca_io_ompio_file_t *fh,
507517 rcomm_time += end_rcomm_time - start_rcomm_time ;
508518#endif
509519
510- if (fh -> f_flags & OMPIO_CONTIGUOUS_MEMORY ) {
520+ if (recvbuf_is_contiguous ) {
511521 receive_buf = & ((char * )buf )[position ];
512522 }
513523 else if (bytes_to_read_in_cycle ) {
@@ -867,7 +877,7 @@ mca_fcoll_static_file_read_all (mca_io_ompio_file_t *fh,
867877
868878 position += bytes_to_read_in_cycle ;
869879
870- if (!( fh -> f_flags & OMPIO_CONTIGUOUS_MEMORY ) ) {
880+ if (!recvbuf_is_contiguous ) {
871881 OPAL_PTRDIFF_TYPE mem_address ;
872882 size_t remaining = 0 ;
873883 size_t temp_position = 0 ;
@@ -1017,9 +1027,11 @@ mca_fcoll_static_file_read_all (mca_io_ompio_file_t *fh,
10171027 sendtype = NULL ;
10181028 }
10191029
1020- if (NULL != receive_buf ){
1021- free (receive_buf );
1022- receive_buf = NULL ;
1030+ if ( !recvbuf_is_contiguous ) {
1031+ if (NULL != receive_buf ){
1032+ free (receive_buf );
1033+ receive_buf = NULL ;
1034+ }
10231035 }
10241036
10251037 if (NULL != global_buf ) {
0 commit comments