ENH: use full scratch buffer capacity for ensight output

- improves overall buffering ability across parts
This commit is contained in:
Mark Olesen
2022-11-17 09:27:07 +01:00
parent 225f548d2d
commit 1dafe5d393

View File

@ -120,24 +120,30 @@ void Foam::ensightOutput::Detail::writeFieldComponents
if (Pstream::master()) if (Pstream::master())
{ {
// Scratch buffer:
// - allocate enough space to process an individual rank
// - potentially enough to process multiple ranks before writing
// - permit use of the full buffer capacity
// Buffer size needed for an individual rank // Buffer size needed for an individual rank
const label minSize(max(localSize, procAddr.maxSize())); const label minSize(max(localSize, procAddr.maxSize()));
// Buffer size needed for all nonLocal ranks
const label nonLocalSize(procAddr.totalSize() - localSize);
// Maximum off-processor transfer size // Maximum off-processor transfer size
const label maxTransfer = const label maxSize =
( (
(ensightOutput::maxChunk_ > 0) (ensightOutput::maxChunk_ > 0)
? min(static_cast<label>(ensightOutput::maxChunk_), nonLocalSize) ? min
: static_cast<label>(0) (
static_cast<label>(ensightOutput::maxChunk_),
(procAddr.totalSize() - localSize)
)
: scratch.capacity()
); );
// Allocate at least enough to process a single rank, but potentially scratch.resize_nocopy
// receive multiple ranks at a time before writing (
max(max(minSize, maxSize), scratch.capacity())
scratch.resize_nocopy(max(minSize, maxTransfer)); );
if (Pstream::master() && debug > 1) if (Pstream::master() && debug > 1)
{ {
@ -150,7 +156,7 @@ void Foam::ensightOutput::Detail::writeFieldComponents
Info<< " total-size:" << procAddr.totalSize() Info<< " total-size:" << procAddr.totalSize()
<< " buf-size:" << scratch.size() << "/" << scratch.capacity() << " buf-size:" << scratch.size() << "/" << scratch.capacity()
<< " any-proc:" << minSize << " any-proc:" << minSize
<< " off-proc:" << nonLocalSize << endl; << " off-proc:" << (procAddr.totalSize() - localSize) << endl;
Info<< "proc-sends: ("; Info<< "proc-sends: (";