Commit 36ac1a9d authored by Rob Latham's avatar Rob Latham
Browse files

move window creation out of common code



Instead of creating window at open time (depending on hints), let's
deferr the window creation until we need it.
Signed-off-by: default avatarPaul Coffman <pkcoff@us.ibm.com>
parent 5c4f21d0
......@@ -7,9 +7,6 @@
#include "adio.h"
#include "adio_extern.h"
extern int gpfsmpio_aggmethod;
extern int gpfsmpio_onesided_no_rmw;
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
......@@ -117,15 +114,7 @@ void ADIO_Close(ADIO_File fd, int *error_code)
MPI_Info_free(&(fd->info));
if (fd->io_buf != NULL) ADIOI_Free(fd->io_buf);
/* If one-sided aggregation is chosen then free the window over the io_buf.
*/
if ((gpfsmpio_aggmethod == 1) || (gpfsmpio_aggmethod == 2)) {
MPI_Win_free(&fd->io_buf_window);
if (!gpfsmpio_onesided_no_rmw) {
MPI_Win_free(&fd->io_buf_put_amounts_window);
ADIOI_Free(fd->io_buf_put_amounts);
}
}
ADIOI_OneSidedCleanup(fd);
/* memory for fd is freed in MPI_File_close */
}
......@@ -10,8 +10,6 @@
#include "adio_cb_config_list.h"
#include "mpio.h"
extern int gpfsmpio_aggmethod;
extern int gpfsmpio_onesided_no_rmw;
static int is_aggregator(int rank, ADIO_File fd);
static int uses_generic_read(ADIO_File fd);
static int uses_generic_write(ADIO_File fd);
......@@ -72,6 +70,9 @@ MPI_File ADIO_Open(MPI_Comm orig_comm,
fd->err_handler = ADIOI_DFLT_ERR_HANDLER;
fd->io_buf_window = MPI_WIN_NULL;
fd->io_buf_put_amounts_window = MPI_WIN_NULL;
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &procs);
/* create and initialize info object */
......@@ -127,15 +128,6 @@ MPI_File ADIO_Open(MPI_Comm orig_comm,
* (e.g. Blue Gene) more efficent */
fd->io_buf = ADIOI_Malloc(fd->hints->cb_buffer_size);
/* If one-sided aggregation is chosen then create the window over the io_buf.
*/
if ((gpfsmpio_aggmethod == 1) || (gpfsmpio_aggmethod == 2)) {
MPI_Win_create(fd->io_buf,fd->hints->cb_buffer_size,1,MPI_INFO_NULL,fd->comm, &fd->io_buf_window);
if (!gpfsmpio_onesided_no_rmw) {
fd->io_buf_put_amounts = (int *) ADIOI_Malloc(procs*sizeof(int));
MPI_Win_create(fd->io_buf_put_amounts,procs*sizeof(int),sizeof(int),MPI_INFO_NULL,fd->comm, &fd->io_buf_put_amounts_window);
}
}
/* deferred open:
* we can only do this optimization if 'fd->hints->deferred_open' is set
* (which means the user hinted 'no_indep_rw' and collective buffering).
......
#include "adio.h"
#include "adio_extern.h"
#ifdef ROMIO_GPFS
/* right now this is GPFS only but TODO: extend this to all file systems */
#include "../ad_gpfs/ad_gpfs_tuning.h"
#else
int gpfsmpio_onesided_no_rmw = 0;
int gpfsmpio_aggmethod = 0;
#endif
#include <pthread.h>
......@@ -20,6 +26,32 @@ typedef struct NonContigSourceBufOffset {
ADIO_Offset indiceOffset;
} NonContigSourceBufOffset;
static int ADIOI_OneSidedSetup(ADIO_File fd, int procs) {
int ret = MPI_SUCCESS;
ret = MPI_Win_create(fd->io_buf,fd->hints->cb_buffer_size,1,
MPI_INFO_NULL,fd->comm, &fd->io_buf_window);
if (ret != MPI_SUCCESS) goto fn_exit;
fd->io_buf_put_amounts = (int *) ADIOI_Malloc(procs*sizeof(int));
ret =MPI_Win_create(fd->io_buf_put_amounts,procs*sizeof(int),sizeof(int),
MPI_INFO_NULL,fd->comm, &fd->io_buf_put_amounts_window);
fn_exit:
return ret;
}
int ADIOI_OneSidedCleanup(ADIO_File fd)
{
int ret = MPI_SUCCESS;
if (fd->io_buf_window != MPI_WIN_NULL)
ret = MPI_Win_free(&fd->io_buf_window);
if (fd->io_buf_put_amounts_window != MPI_WIN_NULL)
ret = MPI_Win_free(&fd->io_buf_put_amounts_window);
if (fd->io_buf_put_amounts != NULL)
ADIOI_Free(fd->io_buf_put_amounts);
return ret;
}
void ADIOI_OneSidedWriteAggregation(ADIO_File fd,
ADIO_Offset *offset_list,
ADIO_Offset *len_list,
......@@ -51,6 +83,12 @@ void ADIOI_OneSidedWriteAggregation(ADIO_File fd,
MPI_Comm_size(fd->comm, &nprocs);
MPI_Comm_rank(fd->comm, &myrank);
if (fd->io_buf_window == MPI_WIN_NULL ||
fd->io_buf_put_amounts_window == MPI_WIN_NULL)
{
ADIOI_OneSidedSetup(fd, nprocs);
}
/* This flag denotes whether the source datatype is contiguous, which is referenced throughout the algorithm
* and defines how the source buffer offsets and data chunks are determined. If the value is 1 (true - contiguous data)
* things are profoundly simpler in that the source buffer offset for a given target offset simply linearly increases
......@@ -1063,6 +1101,11 @@ void ADIOI_OneSidedReadAggregation(ADIO_File fd,
MPI_Comm_size(fd->comm, &nprocs);
MPI_Comm_rank(fd->comm, &myrank);
if (fd->io_buf_window == MPI_WIN_NULL ||
fd->io_buf_put_amounts_window == MPI_WIN_NULL)
{
ADIOI_OneSidedSetup(fd, nprocs);
}
/* This flag denotes whether the source datatype is contiguus, which is referenced throughout the algorithm
* and defines how the source buffer offsets and data chunks are determined. If the value is 1 (true - contiguous data)
* things are profoundly simpler in that the source buffer offset for a given source offset simply linearly increases
......
......@@ -686,6 +686,7 @@ void ADIOI_P2PContigReadAggregation(ADIO_File fd,
ADIO_Offset *fd_start,
ADIO_Offset *fd_end);
int ADIOI_OneSidedCleanup(ADIO_File fd);
void ADIOI_OneSidedWriteAggregation(ADIO_File fd,
ADIO_Offset *offset_list,
ADIO_Offset *len_list,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment