Skip to content

Commit 7e5b58a

Browse files
committed
Re-enable the contiguous buffer optimization to the read_all and the write_all routines.
After long debugging, I found last week the reason this optimization originally broke some hdf5 tests. We now pass the hdf5 test suite with the optimization being actively used.
1 parent 349f4fe commit 7e5b58a

File tree

2 files changed

+37
-16
lines changed

2 files changed

+37
-16
lines changed

ompi/mca/fcoll/dynamic/fcoll_dynamic_file_read_all.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ mca_fcoll_dynamic_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;
100+
97101

98102
#if OMPIO_FCOLL_WANT_TIME_BREAKDOWN
99103
double read_time = 0.0, start_read_time = 0.0, end_read_time = 0.0;
@@ -105,11 +109,18 @@ mca_fcoll_dynamic_file_read_all (mca_io_ompio_file_t *fh,
105109
/**************************************************************************
106110
** 1. In case the data is not contigous in memory, decode it into an iovec
107111
**************************************************************************/
112+
113+
opal_datatype_type_size ( &datatype->super, &ftype_size );
114+
opal_datatype_get_extent ( &datatype->super, &lb, &ftype_extent );
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+
}
121+
108122

109-
// if (opal_datatype_is_contiguous_memory_layout(&datatype->super,1)) {
110-
// fh->f_flags |= OMPIO_CONTIGUOUS_MEMORY;
111-
// }
112-
if (! (fh->f_flags & OMPIO_CONTIGUOUS_MEMORY)) {
123+
if (! recvbuf_is_contiguous ) {
113124
ret = fh->f_decode_datatype ((struct mca_io_ompio_file_t *)fh,
114125
datatype,
115126
count,
@@ -760,7 +771,7 @@ mca_fcoll_dynamic_file_read_all (mca_io_ompio_file_t *fh,
760771
/**********************************************************
761772
*** 7f. Scatter the Data from the readers
762773
*********************************************************/
763-
if (fh->f_flags & OMPIO_CONTIGUOUS_MEMORY) {
774+
if ( recvbuf_is_contiguous ) {
764775
receive_buf = &((char*)buf)[position];
765776
}
766777
else if (bytes_received) {
@@ -807,7 +818,7 @@ mca_fcoll_dynamic_file_read_all (mca_io_ompio_file_t *fh,
807818

808819
/* If data is not contigous in memory, copy the data from the
809820
receive buffer into the buffer passed in */
810-
if (!(fh->f_flags & OMPIO_CONTIGUOUS_MEMORY)) {
821+
if (!recvbuf_is_contiguous ) {
811822
OPAL_PTRDIFF_TYPE mem_address;
812823
size_t remaining = 0;
813824
size_t temp_position = 0;
@@ -868,7 +879,7 @@ mca_fcoll_dynamic_file_read_all (mca_io_ompio_file_t *fh,
868879
#endif
869880

870881
exit:
871-
if (!(fh->f_flags & OMPIO_CONTIGUOUS_MEMORY)) {
882+
if (!recvbuf_is_contiguous) {
872883
if (NULL != receive_buf) {
873884
free (receive_buf);
874885
receive_buf = NULL;

ompi/mca/fcoll/dynamic/fcoll_dynamic_file_write_all.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,33 @@ mca_fcoll_dynamic_file_write_all (mca_io_ompio_file_t *fh,
9696
MPI_Aint *total_bytes_per_process = NULL;
9797
MPI_Request send_req=NULL, *recv_req=NULL;
9898
int my_aggregator=-1;
99+
bool sendbuf_is_contiguous = false;
100+
size_t ftype_size;
101+
OPAL_PTRDIFF_TYPE ftype_extent, lb;
102+
99103

100104
#if OMPIO_FCOLL_WANT_TIME_BREAKDOWN
101105
double write_time = 0.0, start_write_time = 0.0, end_write_time = 0.0;
102106
double comm_time = 0.0, start_comm_time = 0.0, end_comm_time = 0.0;
103107
double exch_write = 0.0, start_exch = 0.0, end_exch = 0.0;
104108
mca_io_ompio_print_entry nentry;
105109
#endif
106-
107-
108-
// if (opal_datatype_is_contiguous_memory_layout(&datatype->super,1)) {
109-
// fh->f_flags |= OMPIO_CONTIGUOUS_MEMORY;
110-
// }
110+
111+
opal_datatype_type_size ( &datatype->super, &ftype_size );
112+
opal_datatype_get_extent ( &datatype->super, &lb, &ftype_extent );
111113

112114
/**************************************************************************
113115
** 1. In case the data is not contigous in memory, decode it into an iovec
114116
**************************************************************************/
115-
if (! (fh->f_flags & OMPIO_CONTIGUOUS_MEMORY)) {
117+
if ( ( ftype_extent == (OPAL_PTRDIFF_TYPE) ftype_size) &&
118+
opal_datatype_is_contiguous_memory_layout(&datatype->super,1) &&
119+
0 == lb ) {
120+
sendbuf_is_contiguous = true;
121+
}
122+
123+
124+
125+
if (! sendbuf_is_contiguous ) {
116126
ret = fh->f_decode_datatype ((struct mca_io_ompio_file_t *) fh,
117127
datatype,
118128
count,
@@ -791,7 +801,7 @@ mca_fcoll_dynamic_file_write_all (mca_io_ompio_file_t *fh,
791801
} /* end if (my_aggregator == fh->f_rank ) */
792802

793803

794-
if (fh->f_flags & OMPIO_CONTIGUOUS_MEMORY) {
804+
if ( sendbuf_is_contiguous ) {
795805
send_buf = &((char*)buf)[total_bytes_written];
796806
}
797807
else if (bytes_sent) {
@@ -880,7 +890,7 @@ mca_fcoll_dynamic_file_write_all (mca_io_ompio_file_t *fh,
880890
}
881891
#endif
882892

883-
if (! (fh->f_flags & OMPIO_CONTIGUOUS_MEMORY)) {
893+
if (! sendbuf_is_contiguous) {
884894
if (NULL != send_buf) {
885895
free (send_buf);
886896
send_buf = NULL;
@@ -1050,7 +1060,7 @@ exit :
10501060

10511061
}
10521062

1053-
if (! (fh->f_flags & OMPIO_CONTIGUOUS_MEMORY)) {
1063+
if (! sendbuf_is_contiguous) {
10541064
if (NULL != send_buf) {
10551065
free (send_buf);
10561066
send_buf = NULL;

0 commit comments

Comments
 (0)