mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: comunicators: have solver with user-defined communicator
(originating from polyMesh::comm() and processorPolyPatch::comm())
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -70,7 +70,7 @@ Foam::UIPstream::UIPstream
|
||||
|
||||
label wantedSize = externalBuf_.capacity();
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UIPstream::UIPstream : read from:" << fromProcNo
|
||||
<< " tag:" << tag << " wanted size:" << wantedSize
|
||||
@ -88,7 +88,7 @@ Foam::UIPstream::UIPstream
|
||||
externalBuf_.setCapacity(messageSize_);
|
||||
wantedSize = messageSize_;
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UIPstream::UIPstream : probed size:" << wantedSize
|
||||
<< Foam::endl;
|
||||
@ -145,7 +145,7 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
|
||||
// Message is already received into externalBuf
|
||||
messageSize_ = buffers.recvBuf_[fromProcNo].size();
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UIPstream::UIPstream PstreamBuffers :"
|
||||
<< " fromProcNo:" << fromProcNo
|
||||
@ -159,7 +159,7 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
|
||||
|
||||
label wantedSize = externalBuf_.capacity();
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UIPstream::UIPstream PstreamBuffers :"
|
||||
<< " read from:" << fromProcNo
|
||||
@ -177,7 +177,7 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
|
||||
externalBuf_.setCapacity(messageSize_);
|
||||
wantedSize = messageSize_;
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UIPstream::UIPstream PstreamBuffers : probed size:"
|
||||
<< wantedSize << Foam::endl;
|
||||
@ -217,7 +217,7 @@ Foam::label Foam::UIPstream::read
|
||||
const label communicator
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UIPstream::read : starting read from:" << fromProcNo
|
||||
<< " tag:" << tag << " comm:" << communicator
|
||||
@ -225,6 +225,15 @@ Foam::label Foam::UIPstream::read
|
||||
<< " commsType:" << UPstream::commsTypeNames[commsType]
|
||||
<< Foam::endl;
|
||||
}
|
||||
if (UPstream::warnComm != -1 && communicator != UPstream::warnComm)
|
||||
{
|
||||
Pout<< "UIPstream::read : starting read from:" << fromProcNo
|
||||
<< " tag:" << tag << " comm:" << communicator
|
||||
<< " wanted size:" << label(bufSize)
|
||||
<< " commsType:" << UPstream::commsTypeNames[commsType]
|
||||
<< Foam::endl;
|
||||
error::printStack(Pout);
|
||||
}
|
||||
|
||||
if (commsType == blocking || commsType == scheduled)
|
||||
{
|
||||
@ -260,7 +269,7 @@ Foam::label Foam::UIPstream::read
|
||||
int messageSize;
|
||||
MPI_Get_count(&status, MPI_BYTE, &messageSize);
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UIPstream::read : finished read from:" << fromProcNo
|
||||
<< " tag:" << tag << " read size:" << label(bufSize)
|
||||
@ -310,7 +319,7 @@ Foam::label Foam::UIPstream::read
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UIPstream::read : started read from:" << fromProcNo
|
||||
<< " tag:" << tag << " read size:" << label(bufSize)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -43,7 +43,7 @@ bool Foam::UOPstream::write
|
||||
const label communicator
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UOPstream::write : starting write to:" << toProcNo
|
||||
<< " tag:" << tag
|
||||
@ -51,6 +51,16 @@ bool Foam::UOPstream::write
|
||||
<< " commsType:" << UPstream::commsTypeNames[commsType]
|
||||
<< Foam::endl;
|
||||
}
|
||||
if (UPstream::warnComm != -1 && communicator != UPstream::warnComm)
|
||||
{
|
||||
Pout<< "UOPstream::write : starting write to:" << toProcNo
|
||||
<< " tag:" << tag
|
||||
<< " comm:" << communicator << " size:" << label(bufSize)
|
||||
<< " commsType:" << UPstream::commsTypeNames[commsType]
|
||||
<< Foam::endl;
|
||||
error::printStack(Pout);
|
||||
}
|
||||
|
||||
|
||||
PstreamGlobals::checkCommunicator(communicator, toProcNo);
|
||||
|
||||
@ -69,7 +79,7 @@ bool Foam::UOPstream::write
|
||||
PstreamGlobals::MPICommunicators_[communicator] //MPI_COMM_WORLD
|
||||
);
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UOPstream::write : finished write to:" << toProcNo
|
||||
<< " tag:" << tag << " size:" << label(bufSize)
|
||||
@ -89,7 +99,7 @@ bool Foam::UOPstream::write
|
||||
PstreamGlobals::MPICommunicators_[communicator] //MPI_COMM_WORLD
|
||||
);
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UOPstream::write : finished write to:" << toProcNo
|
||||
<< " tag:" << tag << " size:" << label(bufSize)
|
||||
@ -112,7 +122,7 @@ bool Foam::UOPstream::write
|
||||
&request
|
||||
);
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UOPstream::write : started write to:" << toProcNo
|
||||
<< " tag:" << tag << " size:" << label(bufSize)
|
||||
|
||||
@ -68,7 +68,7 @@ bool Foam::UPstream::init(int& argc, char**& argv)
|
||||
int myRank;
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UPstream::init : initialised with numProcs:" << numprocs
|
||||
<< " myRank:" << myRank << endl;
|
||||
@ -107,13 +107,12 @@ bool Foam::UPstream::init(int& argc, char**& argv)
|
||||
}
|
||||
# endif
|
||||
|
||||
int processorNameLen;
|
||||
char processorName[MPI_MAX_PROCESSOR_NAME];
|
||||
|
||||
MPI_Get_processor_name(processorName, &processorNameLen);
|
||||
processorName[processorNameLen] = '\0';
|
||||
|
||||
Pout<< "Processor name:" << processorName << endl;
|
||||
//int processorNameLen;
|
||||
//char processorName[MPI_MAX_PROCESSOR_NAME];
|
||||
//
|
||||
//MPI_Get_processor_name(processorName, &processorNameLen);
|
||||
//processorName[processorNameLen] = '\0';
|
||||
//Pout<< "Processor name:" << processorName << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -121,7 +120,7 @@ bool Foam::UPstream::init(int& argc, char**& argv)
|
||||
|
||||
void Foam::UPstream::exit(int errnum)
|
||||
{
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UPstream::exit." << endl;
|
||||
}
|
||||
@ -181,6 +180,12 @@ void Foam::reduce
|
||||
const label communicator
|
||||
)
|
||||
{
|
||||
if (UPstream::warnComm != -1 && communicator != UPstream::warnComm)
|
||||
{
|
||||
Pout<< "** reducing:" << Value << " with comm:" << communicator
|
||||
<< endl;
|
||||
error::printStack(Pout);
|
||||
}
|
||||
allReduce(Value, 1, MPI_SCALAR, MPI_SUM, bop, tag, communicator);
|
||||
}
|
||||
|
||||
@ -193,6 +198,12 @@ void Foam::reduce
|
||||
const label communicator
|
||||
)
|
||||
{
|
||||
if (UPstream::warnComm != -1 && communicator != UPstream::warnComm)
|
||||
{
|
||||
Pout<< "** reducing:" << Value << " with comm:" << communicator
|
||||
<< endl;
|
||||
error::printStack(Pout);
|
||||
}
|
||||
allReduce(Value, 1, MPI_SCALAR, MPI_MIN, bop, tag, communicator);
|
||||
}
|
||||
|
||||
@ -205,6 +216,12 @@ void Foam::reduce
|
||||
const label communicator
|
||||
)
|
||||
{
|
||||
if (UPstream::warnComm != -1 && communicator != UPstream::warnComm)
|
||||
{
|
||||
Pout<< "** reducing:" << Value << " with comm:" << communicator
|
||||
<< endl;
|
||||
error::printStack(Pout);
|
||||
}
|
||||
allReduce(Value, 2, MPI_SCALAR, MPI_SUM, bop, tag, communicator);
|
||||
}
|
||||
|
||||
@ -217,6 +234,12 @@ void Foam::sumReduce
|
||||
const label communicator
|
||||
)
|
||||
{
|
||||
if (UPstream::warnComm != -1 && communicator != UPstream::warnComm)
|
||||
{
|
||||
Pout<< "** reducing:" << Value << " with comm:" << communicator
|
||||
<< endl;
|
||||
error::printStack(Pout);
|
||||
}
|
||||
vector2D twoScalars(Value, scalar(Count));
|
||||
reduce(twoScalars, sumOp<vector2D>(), tag, communicator);
|
||||
|
||||
@ -407,7 +430,7 @@ void Foam::UPstream::resetRequests(const label i)
|
||||
|
||||
void Foam::UPstream::waitRequests(const label start)
|
||||
{
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UPstream::waitRequests : starting wait for "
|
||||
<< PstreamGlobals::outstandingRequests_.size()-start
|
||||
@ -442,7 +465,7 @@ void Foam::UPstream::waitRequests(const label start)
|
||||
resetRequests(start);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UPstream::waitRequests : finished wait." << endl;
|
||||
}
|
||||
@ -451,7 +474,7 @@ void Foam::UPstream::waitRequests(const label start)
|
||||
|
||||
void Foam::UPstream::waitRequest(const label i)
|
||||
{
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UPstream::waitRequest : starting wait for request:" << i
|
||||
<< endl;
|
||||
@ -484,7 +507,7 @@ void Foam::UPstream::waitRequest(const label i)
|
||||
) << "MPI_Wait returned with error" << Foam::endl;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UPstream::waitRequest : finished wait for request:" << i
|
||||
<< endl;
|
||||
@ -494,7 +517,7 @@ void Foam::UPstream::waitRequest(const label i)
|
||||
|
||||
bool Foam::UPstream::finishedRequest(const label i)
|
||||
{
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UPstream::waitRequests : checking finishedRequest:" << i
|
||||
<< endl;
|
||||
@ -520,7 +543,7 @@ bool Foam::UPstream::finishedRequest(const label i)
|
||||
MPI_STATUS_IGNORE
|
||||
);
|
||||
|
||||
if (debug)
|
||||
if (debug&1)
|
||||
{
|
||||
Pout<< "UPstream::waitRequests : finished finishedRequest:" << i
|
||||
<< endl;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -53,7 +53,7 @@ void allReduce
|
||||
MPI_Op op,
|
||||
const BinaryOp& bop,
|
||||
const int tag,
|
||||
const label communicator
|
||||
const int communicator
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Reference in New Issue
Block a user