mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: check if MPI buffer really was attached before deattaching
- can occur if MPI has be initialized for communication but OpenFOAM itself is operating in serial mode and thus did not attach any MPI buffers.
This commit is contained in:
@ -187,6 +187,9 @@ bool Foam::UPstream::init(int& argc, char**& argv, const bool needsThread)
|
|||||||
Pout<< "UPstream::init : mpi-buffer-size " << bufSize << endl;
|
Pout<< "UPstream::init : mpi-buffer-size " << bufSize << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TBD: could add error handling here.
|
||||||
|
// Delete allocated and leave if we fail to attach the buffer?
|
||||||
|
|
||||||
MPI_Buffer_attach(new char[bufSize], bufSize);
|
MPI_Buffer_attach(new char[bufSize], bufSize);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -225,10 +228,19 @@ void Foam::UPstream::exit(int errnum)
|
|||||||
|
|
||||||
#ifndef SGIMPI
|
#ifndef SGIMPI
|
||||||
{
|
{
|
||||||
int size;
|
// Some MPI notes suggest that the return code is MPI_SUCCESS when
|
||||||
char* buff;
|
// no buffer is attached.
|
||||||
MPI_Buffer_detach(&buff, &size);
|
// Be extra careful and require a non-zero size as well.
|
||||||
delete[] buff;
|
|
||||||
|
int bufSize = 0;
|
||||||
|
char* buf = nullptr;
|
||||||
|
|
||||||
|
flag = MPI_Buffer_detach(&buf, &bufSize);
|
||||||
|
|
||||||
|
if (MPI_SUCCESS == flag && bufSize)
|
||||||
|
{
|
||||||
|
delete[] buf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user