Skip to content

Commit a4113cf

Browse files
committed
re-enable the contiguous buffer optimization similarly to the dynamic component. Passes all hdf5testsi and our own test suite.
Please enter the commit message for your changes. Lines starting
1 parent 2cfb736 commit a4113cf

File tree

2 files changed

+51
-18
lines changed

2 files changed

+51
-18
lines changed

ompi/mca/fcoll/static/fcoll_static_file_read_all.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

ompi/mca/fcoll/static/fcoll_static_file_write_all.c

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ mca_fcoll_static_file_write_all (mca_io_ompio_file_t *fh,
9292
ompi_datatype_t *types[3];
9393
ompi_datatype_t *io_array_type=MPI_DATATYPE_NULL;
9494
int my_aggregator=-1;
95+
bool sendbuf_is_contiguous= false;
96+
size_t ftype_size;
97+
OPAL_PTRDIFF_TYPE ftype_extent, lb;
98+
9599

96100
/*----------------------------------------------*/
97101
#if OMPIO_FCOLL_WANT_TIME_BREAKDOWN
@@ -105,13 +109,22 @@ mca_fcoll_static_file_write_all (mca_io_ompio_file_t *fh,
105109
#if DEBUG_ON
106110
MPI_Aint gc_in;
107111
#endif
112+
113+
opal_datatype_type_size ( &datatype->super, &ftype_size );
114+
opal_datatype_get_extent ( &datatype->super, &lb, &ftype_extent );
108115

109-
// if (opal_datatype_is_contiguous_memory_layout(&datatype->super,1)) {
110-
// fh->f_flags |= OMPIO_CONTIGUOUS_MEMORY;
111-
// }
116+
/**************************************************************************
117+
** 1. In case the data is not contigous in memory, decode it into an iovec
118+
**************************************************************************/
119+
if ( ( ftype_extent == (OPAL_PTRDIFF_TYPE) ftype_size) &&
120+
opal_datatype_is_contiguous_memory_layout(&datatype->super,1) &&
121+
0 == lb ) {
122+
sendbuf_is_contiguous = true;
123+
}
124+
112125

113126
/* In case the data is not contigous in memory, decode it into an iovec */
114-
if (! (fh->f_flags & OMPIO_CONTIGUOUS_MEMORY)) {
127+
if (! sendbuf_is_contiguous ) {
115128
fh->f_decode_datatype ((struct mca_io_ompio_file_t *)fh,
116129
datatype,
117130
count,
@@ -767,7 +780,7 @@ mca_fcoll_static_file_write_all (mca_io_ompio_file_t *fh,
767780
}
768781
}
769782

770-
if (fh->f_flags & OMPIO_CONTIGUOUS_MEMORY) {
783+
if ( sendbuf_is_contiguous ) {
771784
send_buf = &((char*)buf)[total_bytes_written];
772785
}
773786
else if (bytes_to_write_in_cycle) {
@@ -831,6 +844,12 @@ mca_fcoll_static_file_write_all (mca_io_ompio_file_t *fh,
831844
if (OMPI_SUCCESS != ret){
832845
goto exit;
833846
}
847+
if ( !sendbuf_is_contiguous ) {
848+
if ( NULL != send_buf ) {
849+
free ( send_buf );
850+
send_buf = NULL;
851+
}
852+
}
834853

835854
if (my_aggregator == fh->f_rank) {
836855
ret = ompi_request_wait_all (fh->f_procs_per_group,
@@ -969,11 +988,13 @@ mca_fcoll_static_file_write_all (mca_io_ompio_file_t *fh,
969988
free ( recv_req );
970989
recv_req = NULL;
971990
}
972-
if (NULL != send_buf){
973-
free(send_buf);
974-
send_buf = NULL;
991+
if ( !sendbuf_is_contiguous ) {
992+
if (NULL != send_buf){
993+
free(send_buf);
994+
send_buf = NULL;
995+
}
975996
}
976-
997+
977998
if (NULL != global_buf){
978999
free(global_buf);
9791000
global_buf = NULL;

0 commit comments

Comments
 (0)