From 8ef19992c26b3e7f66c01d3ddf0a6563f46c2ab1 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Sat, 25 Jan 2014 16:11:46 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11323 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/MPIIO/dump_atom_mpiio.cpp | 4 +--- src/MPIIO/dump_atom_mpiio.h | 6 +----- src/MPIIO/dump_custom_mpiio.cpp | 10 ++------- src/MPIIO/dump_custom_mpiio.h | 9 ++------- src/MPIIO/dump_xyz_mpiio.cpp | 9 ++------- src/MPIIO/dump_xyz_mpiio.h | 6 +----- src/MPIIO/restart_mpiio.cpp | 36 ++++++++++++++++----------------- src/MPIIO/restart_mpiio.h | 2 +- 8 files changed, 28 insertions(+), 54 deletions(-) diff --git a/src/MPIIO/dump_atom_mpiio.cpp b/src/MPIIO/dump_atom_mpiio.cpp index 23ff70856b..ca51a66f0d 100644 --- a/src/MPIIO/dump_atom_mpiio.cpp +++ b/src/MPIIO/dump_atom_mpiio.cpp @@ -38,9 +38,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ DumpAtomMPIIO::DumpAtomMPIIO(LAMMPS *lmp, int narg, char **arg) : - DumpAtom(lmp, narg, arg) -{ -} + DumpAtom(lmp, narg, arg) {} /* ---------------------------------------------------------------------- */ diff --git a/src/MPIIO/dump_atom_mpiio.h b/src/MPIIO/dump_atom_mpiio.h index c3a05c6aee..aad196dae0 100644 --- a/src/MPIIO/dump_atom_mpiio.h +++ b/src/MPIIO/dump_atom_mpiio.h @@ -11,13 +11,9 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing author: Paul Coffman (IBM) -------------------------------------------------------------------------- */ - #ifdef DUMP_CLASS -DumpStyle(atom_mpiio,DumpAtomMPIIO) +DumpStyle(atom/mpiio,DumpAtomMPIIO) #else diff --git a/src/MPIIO/dump_custom_mpiio.cpp b/src/MPIIO/dump_custom_mpiio.cpp index 4ba0f3e852..d668fa0a0a 100644 --- a/src/MPIIO/dump_custom_mpiio.cpp +++ b/src/MPIIO/dump_custom_mpiio.cpp @@ -59,22 +59,19 @@ enum{INT,DOUBLE,STRING}; // same as in DumpCFG /* ---------------------------------------------------------------------- */ DumpCustomMPIIO::DumpCustomMPIIO(LAMMPS *lmp, int narg, char **arg) : - DumpCustom(lmp, narg, arg) -{ -} + DumpCustom(lmp, narg, arg) {} /* ---------------------------------------------------------------------- */ DumpCustomMPIIO::~DumpCustomMPIIO() { - if (multifile == 0) MPI_File_close(&mpifh); + if (multifile == 0) MPI_File_close(&mpifh); } /* ---------------------------------------------------------------------- */ void DumpCustomMPIIO::openfile() { - if (singlefile_opened) { // single file already opened, so just return after resetting filesize mpifo = currentFileSize; MPI_File_set_size(mpifh,mpifo+headerSize+sumFileSize); @@ -140,7 +137,6 @@ void DumpCustomMPIIO::openfile() void DumpCustomMPIIO::write() { - if (domain->triclinic == 0) { boxxlo = domain->boxlo[0]; boxxhi = domain->boxhi[0]; @@ -504,7 +500,6 @@ void DumpCustomMPIIO::header_item_triclinic(bigint ndump) void DumpCustomMPIIO::write_data(int n, double *mybuf) { - (this->*write_choice)(n,mybuf); } @@ -512,7 +507,6 @@ void DumpCustomMPIIO::write_data(int n, double *mybuf) void DumpCustomMPIIO::write_binary(int n, double *mybuf) { - MPI_Status mpiStatus; n *= size_one; diff --git a/src/MPIIO/dump_custom_mpiio.h b/src/MPIIO/dump_custom_mpiio.h index 9bf263f066..1e4c6de667 100644 --- a/src/MPIIO/dump_custom_mpiio.h +++ b/src/MPIIO/dump_custom_mpiio.h @@ -11,13 +11,9 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing author: Paul Coffman (IBM) -------------------------------------------------------------------------- */ - #ifdef DUMP_CLASS -DumpStyle(custom_mpiio,DumpCustomMPIIO) +DumpStyle(custom/mpiio,DumpCustomMPIIO) #else @@ -42,6 +38,7 @@ class DumpCustomMPIIO : public DumpCustom { MPI_Offset mpifo,offsetFromHeader,headerSize, currentFileSize; int performEstimate; // switch for write_data and write_header methods to use for gathering data and detemining filesize for preallocation vs actually writing the data char *filecurrent; // name of file for this round (with % and * replaced) + #if defined(_OPENMP) int convert_string_omp(int, double *); // multithreaded version of convert_string #endif @@ -63,8 +60,6 @@ class DumpCustomMPIIO : public DumpCustom { FnPtrData write_choice; // ptr to write data functions void write_binary(int, double *); void write_string(int, double *); - - }; } diff --git a/src/MPIIO/dump_xyz_mpiio.cpp b/src/MPIIO/dump_xyz_mpiio.cpp index e8534354c1..a0f5b45bba 100644 --- a/src/MPIIO/dump_xyz_mpiio.cpp +++ b/src/MPIIO/dump_xyz_mpiio.cpp @@ -59,15 +59,13 @@ enum{INT,DOUBLE,STRING}; // same as in DumpCFG /* ---------------------------------------------------------------------- */ DumpXYZMPIIO::DumpXYZMPIIO(LAMMPS *lmp, int narg, char **arg) : - DumpXYZ(lmp, narg, arg) -{ -} + DumpXYZ(lmp, narg, arg) {} /* ---------------------------------------------------------------------- */ DumpXYZMPIIO::~DumpXYZMPIIO() { - if (multifile == 0) MPI_File_close(&mpifh); + if (multifile == 0) MPI_File_close(&mpifh); } /* ---------------------------------------------------------------------- */ @@ -251,7 +249,6 @@ void DumpXYZMPIIO::init_style() void DumpXYZMPIIO::write_header(bigint n) { - MPI_Status mpiStatus; if (performEstimate) { @@ -275,7 +272,6 @@ void DumpXYZMPIIO::write_header(bigint n) void DumpXYZMPIIO::write_data(int n, double *mybuf) { - (this->*write_choice)(n,mybuf); } @@ -287,7 +283,6 @@ void DumpXYZMPIIO::write_string(int n, double *mybuf) if (performEstimate) { - #if defined(_OPENMP) int nthreads = omp_get_max_threads(); if (nthreads > 1) diff --git a/src/MPIIO/dump_xyz_mpiio.h b/src/MPIIO/dump_xyz_mpiio.h index 56aa408c57..281bf0b999 100644 --- a/src/MPIIO/dump_xyz_mpiio.h +++ b/src/MPIIO/dump_xyz_mpiio.h @@ -11,13 +11,9 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing author: Paul Coffman (IBM) -------------------------------------------------------------------------- */ - #ifdef DUMP_CLASS -DumpStyle(xyz_mpiio,DumpXYZMPIIO) +DumpStyle(xyz/mpiio,DumpXYZMPIIO) #else diff --git a/src/MPIIO/restart_mpiio.cpp b/src/MPIIO/restart_mpiio.cpp index 40f9327821..1e10bd3b6a 100644 --- a/src/MPIIO/restart_mpiio.cpp +++ b/src/MPIIO/restart_mpiio.cpp @@ -38,7 +38,7 @@ RestartMPIIO::RestartMPIIO(LAMMPS *lmp) : Pointers(lmp) void RestartMPIIO::openForRead(char *filename) { - int err = MPI_File_open(world, filename, MPI_MODE_RDONLY , + int err = MPI_File_open(world, filename, MPI_MODE_RDONLY , MPI_INFO_NULL, &mpifh); if (err != MPI_SUCCESS) { char str[MPI_MAX_ERROR_STRING+128]; @@ -58,7 +58,7 @@ void RestartMPIIO::openForRead(char *filename) void RestartMPIIO::openForWrite(char *filename) { - int err = MPI_File_open(world, filename, MPI_MODE_APPEND | MPI_MODE_WRONLY, + int err = MPI_File_open(world, filename, MPI_MODE_APPEND | MPI_MODE_WRONLY, MPI_INFO_NULL, &mpifh); if (err != MPI_SUCCESS) { char str[MPI_MAX_ERROR_STRING+128]; @@ -72,7 +72,7 @@ void RestartMPIIO::openForWrite(char *filename) } /* ---------------------------------------------------------------------- - determine the absolute offset for the data to be written with + determine the absolute offset for the data to be written with MPI_Scan of the send sizes compute the file size based off the MPI_Scan send size value on the last rank set the filesize with ftruncate via MPI_File_set_size @@ -82,13 +82,13 @@ void RestartMPIIO::openForWrite(char *filename) void RestartMPIIO::write(MPI_Offset headerOffset, int send_size, double *buf) { MPI_Status mpiStatus; - long incPrefix = 0; - long longSendSize = (long) send_size; - MPI_Scan(&longSendSize,&incPrefix,1,MPI_LONG,MPI_SUM,world); - - long largestIncPrefix = incPrefix; - MPI_Bcast(&largestIncPrefix, 1, MPI_LONG, (nprocs-1), world); - + bigint incPrefix = 0; + bigint bigintSendSize = (bigint) send_size; + MPI_Scan(&bigintSendSize,&incPrefix,1,MPI_LMP_BIGINT,MPI_SUM,world); + + bigint largestIncPrefix = incPrefix; + MPI_Bcast(&largestIncPrefix, 1, MPI_LMP_BIGINT, (nprocs-1), world); + int err = MPI_File_set_size(mpifh, (headerOffset+(largestIncPrefix*sizeof(double)))); if (err != MPI_SUCCESS) { @@ -100,9 +100,9 @@ void RestartMPIIO::write(MPI_Offset headerOffset, int send_size, double *buf) mpiErrorString); error->one(FLERR,str); } - - err = MPI_File_write_at_all(mpifh,headerOffset + - ((incPrefix-longSendSize)*sizeof(double)), + + err = MPI_File_write_at_all(mpifh,headerOffset + + ((incPrefix-bigintSendSize)*sizeof(double)), buf,send_size,MPI_DOUBLE,&mpiStatus); if (err != MPI_SUCCESS) { char str[MPI_MAX_ERROR_STRING+128]; @@ -118,24 +118,24 @@ void RestartMPIIO::write(MPI_Offset headerOffset, int send_size, double *buf) /* ---------------------------------------------------------------------- read the data into buf via collective MPI-IO by calling MPI_File_read_at_all with the chunkOffset and chunkSize provided - if the consolidated chunksize is greater than INT_MAX + if the consolidated chunksize is greater than INT_MAX can only happen in extreme situation of reading restart file on much fewer ranks than written and with relatively large data sizes follow the collective IO call with rank independant IO to read remaining data ------------------------------------------------------------------------- */ -void RestartMPIIO::read(MPI_Offset chunkOffset, long chunkSize, double *buf) +void RestartMPIIO::read(MPI_Offset chunkOffset, bigint chunkSize, double *buf) { MPI_Status mpiStatus; int intChunkSize; - long remainingSize = 0; + bigint remainingSize = 0; if (chunkSize > INT_MAX) { intChunkSize = INT_MAX; remainingSize = chunkSize - INT_MAX; } else intChunkSize = (int) chunkSize; - + int err = MPI_File_read_at_all(mpifh,chunkOffset,buf,intChunkSize, MPI_DOUBLE,&mpiStatus); if (err != MPI_SUCCESS) { @@ -147,7 +147,7 @@ void RestartMPIIO::read(MPI_Offset chunkOffset, long chunkSize, double *buf) mpiErrorString); error->one(FLERR,str); } - + MPI_Offset currentOffset = chunkOffset+intChunkSize; MPI_Offset bufOffset = intChunkSize; while (remainingSize > 0) { diff --git a/src/MPIIO/restart_mpiio.h b/src/MPIIO/restart_mpiio.h index 87478af588..ed4354effd 100644 --- a/src/MPIIO/restart_mpiio.h +++ b/src/MPIIO/restart_mpiio.h @@ -31,7 +31,7 @@ class RestartMPIIO : protected Pointers { void openForRead(char *); void openForWrite(char *); void write(MPI_Offset, int, double *); - void read(MPI_Offset, long, double *); + void read(MPI_Offset, bigint, double *); void close(); };