git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11323 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2014-01-25 16:11:46 +00:00
parent d94ff39c8f
commit 8ef19992c2
8 changed files with 28 additions and 54 deletions

View File

@ -38,9 +38,7 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
DumpAtomMPIIO::DumpAtomMPIIO(LAMMPS *lmp, int narg, char **arg) : DumpAtomMPIIO::DumpAtomMPIIO(LAMMPS *lmp, int narg, char **arg) :
DumpAtom(lmp, narg, arg) DumpAtom(lmp, narg, arg) {}
{
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -11,13 +11,9 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Paul Coffman (IBM)
------------------------------------------------------------------------- */
#ifdef DUMP_CLASS #ifdef DUMP_CLASS
DumpStyle(atom_mpiio,DumpAtomMPIIO) DumpStyle(atom/mpiio,DumpAtomMPIIO)
#else #else

View File

@ -59,22 +59,19 @@ enum{INT,DOUBLE,STRING}; // same as in DumpCFG
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
DumpCustomMPIIO::DumpCustomMPIIO(LAMMPS *lmp, int narg, char **arg) : DumpCustomMPIIO::DumpCustomMPIIO(LAMMPS *lmp, int narg, char **arg) :
DumpCustom(lmp, narg, arg) DumpCustom(lmp, narg, arg) {}
{
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
DumpCustomMPIIO::~DumpCustomMPIIO() DumpCustomMPIIO::~DumpCustomMPIIO()
{ {
if (multifile == 0) MPI_File_close(&mpifh); if (multifile == 0) MPI_File_close(&mpifh);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void DumpCustomMPIIO::openfile() void DumpCustomMPIIO::openfile()
{ {
if (singlefile_opened) { // single file already opened, so just return after resetting filesize if (singlefile_opened) { // single file already opened, so just return after resetting filesize
mpifo = currentFileSize; mpifo = currentFileSize;
MPI_File_set_size(mpifh,mpifo+headerSize+sumFileSize); MPI_File_set_size(mpifh,mpifo+headerSize+sumFileSize);
@ -140,7 +137,6 @@ void DumpCustomMPIIO::openfile()
void DumpCustomMPIIO::write() void DumpCustomMPIIO::write()
{ {
if (domain->triclinic == 0) { if (domain->triclinic == 0) {
boxxlo = domain->boxlo[0]; boxxlo = domain->boxlo[0];
boxxhi = domain->boxhi[0]; boxxhi = domain->boxhi[0];
@ -504,7 +500,6 @@ void DumpCustomMPIIO::header_item_triclinic(bigint ndump)
void DumpCustomMPIIO::write_data(int n, double *mybuf) void DumpCustomMPIIO::write_data(int n, double *mybuf)
{ {
(this->*write_choice)(n,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) void DumpCustomMPIIO::write_binary(int n, double *mybuf)
{ {
MPI_Status mpiStatus; MPI_Status mpiStatus;
n *= size_one; n *= size_one;

View File

@ -11,13 +11,9 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Paul Coffman (IBM)
------------------------------------------------------------------------- */
#ifdef DUMP_CLASS #ifdef DUMP_CLASS
DumpStyle(custom_mpiio,DumpCustomMPIIO) DumpStyle(custom/mpiio,DumpCustomMPIIO)
#else #else
@ -42,6 +38,7 @@ class DumpCustomMPIIO : public DumpCustom {
MPI_Offset mpifo,offsetFromHeader,headerSize, currentFileSize; 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 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) char *filecurrent; // name of file for this round (with % and * replaced)
#if defined(_OPENMP) #if defined(_OPENMP)
int convert_string_omp(int, double *); // multithreaded version of convert_string int convert_string_omp(int, double *); // multithreaded version of convert_string
#endif #endif
@ -63,8 +60,6 @@ class DumpCustomMPIIO : public DumpCustom {
FnPtrData write_choice; // ptr to write data functions FnPtrData write_choice; // ptr to write data functions
void write_binary(int, double *); void write_binary(int, double *);
void write_string(int, double *); void write_string(int, double *);
}; };
} }

View File

@ -59,15 +59,13 @@ enum{INT,DOUBLE,STRING}; // same as in DumpCFG
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
DumpXYZMPIIO::DumpXYZMPIIO(LAMMPS *lmp, int narg, char **arg) : DumpXYZMPIIO::DumpXYZMPIIO(LAMMPS *lmp, int narg, char **arg) :
DumpXYZ(lmp, narg, arg) DumpXYZ(lmp, narg, arg) {}
{
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
DumpXYZMPIIO::~DumpXYZMPIIO() 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) void DumpXYZMPIIO::write_header(bigint n)
{ {
MPI_Status mpiStatus; MPI_Status mpiStatus;
if (performEstimate) { if (performEstimate) {
@ -275,7 +272,6 @@ void DumpXYZMPIIO::write_header(bigint n)
void DumpXYZMPIIO::write_data(int n, double *mybuf) void DumpXYZMPIIO::write_data(int n, double *mybuf)
{ {
(this->*write_choice)(n,mybuf); (this->*write_choice)(n,mybuf);
} }
@ -287,7 +283,6 @@ void DumpXYZMPIIO::write_string(int n, double *mybuf)
if (performEstimate) { if (performEstimate) {
#if defined(_OPENMP) #if defined(_OPENMP)
int nthreads = omp_get_max_threads(); int nthreads = omp_get_max_threads();
if (nthreads > 1) if (nthreads > 1)

View File

@ -11,13 +11,9 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Paul Coffman (IBM)
------------------------------------------------------------------------- */
#ifdef DUMP_CLASS #ifdef DUMP_CLASS
DumpStyle(xyz_mpiio,DumpXYZMPIIO) DumpStyle(xyz/mpiio,DumpXYZMPIIO)
#else #else

View File

@ -38,7 +38,7 @@ RestartMPIIO::RestartMPIIO(LAMMPS *lmp) : Pointers(lmp)
void RestartMPIIO::openForRead(char *filename) 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); MPI_INFO_NULL, &mpifh);
if (err != MPI_SUCCESS) { if (err != MPI_SUCCESS) {
char str[MPI_MAX_ERROR_STRING+128]; char str[MPI_MAX_ERROR_STRING+128];
@ -58,7 +58,7 @@ void RestartMPIIO::openForRead(char *filename)
void RestartMPIIO::openForWrite(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); MPI_INFO_NULL, &mpifh);
if (err != MPI_SUCCESS) { if (err != MPI_SUCCESS) {
char str[MPI_MAX_ERROR_STRING+128]; 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 MPI_Scan of the send sizes
compute the file size based off the MPI_Scan send size value on the last rank 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 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) void RestartMPIIO::write(MPI_Offset headerOffset, int send_size, double *buf)
{ {
MPI_Status mpiStatus; MPI_Status mpiStatus;
long incPrefix = 0; bigint incPrefix = 0;
long longSendSize = (long) send_size; bigint bigintSendSize = (bigint) send_size;
MPI_Scan(&longSendSize,&incPrefix,1,MPI_LONG,MPI_SUM,world); MPI_Scan(&bigintSendSize,&incPrefix,1,MPI_LMP_BIGINT,MPI_SUM,world);
long largestIncPrefix = incPrefix; bigint largestIncPrefix = incPrefix;
MPI_Bcast(&largestIncPrefix, 1, MPI_LONG, (nprocs-1), world); MPI_Bcast(&largestIncPrefix, 1, MPI_LMP_BIGINT, (nprocs-1), world);
int err = MPI_File_set_size(mpifh, int err = MPI_File_set_size(mpifh,
(headerOffset+(largestIncPrefix*sizeof(double)))); (headerOffset+(largestIncPrefix*sizeof(double))));
if (err != MPI_SUCCESS) { if (err != MPI_SUCCESS) {
@ -100,9 +100,9 @@ void RestartMPIIO::write(MPI_Offset headerOffset, int send_size, double *buf)
mpiErrorString); mpiErrorString);
error->one(FLERR,str); error->one(FLERR,str);
} }
err = MPI_File_write_at_all(mpifh,headerOffset + err = MPI_File_write_at_all(mpifh,headerOffset +
((incPrefix-longSendSize)*sizeof(double)), ((incPrefix-bigintSendSize)*sizeof(double)),
buf,send_size,MPI_DOUBLE,&mpiStatus); buf,send_size,MPI_DOUBLE,&mpiStatus);
if (err != MPI_SUCCESS) { if (err != MPI_SUCCESS) {
char str[MPI_MAX_ERROR_STRING+128]; 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 read the data into buf via collective MPI-IO by calling MPI_File_read_at_all
with the chunkOffset and chunkSize provided 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 can only happen in extreme situation of reading restart file on
much fewer ranks than written and with relatively large data sizes much fewer ranks than written and with relatively large data sizes
follow the collective IO call with rank independant IO to read remaining data 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; MPI_Status mpiStatus;
int intChunkSize; int intChunkSize;
long remainingSize = 0; bigint remainingSize = 0;
if (chunkSize > INT_MAX) { if (chunkSize > INT_MAX) {
intChunkSize = INT_MAX; intChunkSize = INT_MAX;
remainingSize = chunkSize - INT_MAX; remainingSize = chunkSize - INT_MAX;
} }
else intChunkSize = (int) chunkSize; else intChunkSize = (int) chunkSize;
int err = MPI_File_read_at_all(mpifh,chunkOffset,buf,intChunkSize, int err = MPI_File_read_at_all(mpifh,chunkOffset,buf,intChunkSize,
MPI_DOUBLE,&mpiStatus); MPI_DOUBLE,&mpiStatus);
if (err != MPI_SUCCESS) { if (err != MPI_SUCCESS) {
@ -147,7 +147,7 @@ void RestartMPIIO::read(MPI_Offset chunkOffset, long chunkSize, double *buf)
mpiErrorString); mpiErrorString);
error->one(FLERR,str); error->one(FLERR,str);
} }
MPI_Offset currentOffset = chunkOffset+intChunkSize; MPI_Offset currentOffset = chunkOffset+intChunkSize;
MPI_Offset bufOffset = intChunkSize; MPI_Offset bufOffset = intChunkSize;
while (remainingSize > 0) { while (remainingSize > 0) {

View File

@ -31,7 +31,7 @@ class RestartMPIIO : protected Pointers {
void openForRead(char *); void openForRead(char *);
void openForWrite(char *); void openForWrite(char *);
void write(MPI_Offset, int, double *); void write(MPI_Offset, int, double *);
void read(MPI_Offset, long, double *); void read(MPI_Offset, bigint, double *);
void close(); void close();
}; };