message size not set; debug printing

This commit is contained in:
mattijs
2009-11-13 16:10:11 +00:00
parent 8349d89110
commit 03d777f594
3 changed files with 136 additions and 2 deletions

View File

@ -66,6 +66,14 @@ Foam::UIPstream::UIPstream
label wantedSize = externalBuf_.capacity(); label wantedSize = externalBuf_.capacity();
if (debug)
{
Pout<< "UIPstream::UIPstream : read from:" << fromProcNo
<< " tag:" << tag << " wanted size:" << wantedSize
<< Foam::endl;
}
// If the buffer size is not specified, probe the incomming message // If the buffer size is not specified, probe the incomming message
// and set it // and set it
if (!wantedSize) if (!wantedSize)
@ -75,6 +83,12 @@ Foam::UIPstream::UIPstream
externalBuf_.setCapacity(messageSize_); externalBuf_.setCapacity(messageSize_);
wantedSize = messageSize_; wantedSize = messageSize_;
if (debug)
{
Pout<< "UIPstream::UIPstream : probed size:" << wantedSize
<< Foam::endl;
}
} }
messageSize_ = UIPstream::read messageSize_ = UIPstream::read
@ -127,6 +141,7 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
if (commsType() == UPstream::nonBlocking) if (commsType() == UPstream::nonBlocking)
{ {
// Message is already received into externalBuf // Message is already received into externalBuf
messageSize_ = buffers.recvBuf_[fromProcNo].size();
} }
else else
{ {
@ -134,6 +149,14 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
label wantedSize = externalBuf_.capacity(); label wantedSize = externalBuf_.capacity();
if (debug)
{
Pout<< "UIPstream::UIPstream PstreamBuffers :"
<< " read from:" << fromProcNo
<< " tag:" << tag_ << " wanted size:" << wantedSize
<< Foam::endl;
}
// If the buffer size is not specified, probe the incomming message // If the buffer size is not specified, probe the incomming message
// and set it // and set it
if (!wantedSize) if (!wantedSize)
@ -143,6 +166,12 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
externalBuf_.setCapacity(messageSize_); externalBuf_.setCapacity(messageSize_);
wantedSize = messageSize_; wantedSize = messageSize_;
if (debug)
{
Pout<< "UIPstream::UIPstream PstreamBuffers : probed size:"
<< wantedSize << Foam::endl;
}
} }
messageSize_ = UIPstream::read messageSize_ = UIPstream::read
@ -180,6 +209,14 @@ Foam::label Foam::UIPstream::read
const int tag const int tag
) )
{ {
if (debug)
{
Pout<< "UIPstream::read : starting read from:" << fromProcNo
<< " tag:" << tag << " wanted size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< Foam::endl;
}
if (commsType == blocking || commsType == scheduled) if (commsType == blocking || commsType == scheduled)
{ {
MPI_Status status; MPI_Status status;
@ -214,6 +251,14 @@ Foam::label Foam::UIPstream::read
label messageSize; label messageSize;
MPI_Get_count(&status, MPI_BYTE, &messageSize); MPI_Get_count(&status, MPI_BYTE, &messageSize);
if (debug)
{
Pout<< "UIPstream::read : finished read from:" << fromProcNo
<< " tag:" << tag << " read size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< Foam::endl;
}
if (messageSize > bufSize) if (messageSize > bufSize)
{ {
FatalErrorIn FatalErrorIn
@ -256,6 +301,15 @@ Foam::label Foam::UIPstream::read
return 0; return 0;
} }
if (debug)
{
Pout<< "UIPstream::read : started read from:" << fromProcNo
<< " tag:" << tag << " read size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< " request:" << PstreamGlobals::outstandingRequests_.size()
<< Foam::endl;
}
PstreamGlobals::outstandingRequests_.append(request); PstreamGlobals::outstandingRequests_.append(request);
// Assume the message is completely received. // Assume the message is completely received.
@ -267,7 +321,8 @@ Foam::label Foam::UIPstream::read
( (
"UIPstream::read" "UIPstream::read"
"(const int fromProcNo, char* buf, std::streamsize bufSize)" "(const int fromProcNo, char* buf, std::streamsize bufSize)"
) << "Unsupported communications type " << commsType ) << "Unsupported communications type "
<< commsType
<< Foam::abort(FatalError); << Foam::abort(FatalError);
return 0; return 0;

View File

@ -43,6 +43,14 @@ bool Foam::UOPstream::write
const int tag const int tag
) )
{ {
if (debug)
{
Pout<< "UIPstream::write : starting write to:" << toProcNo
<< " tag:" << tag << " size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< Foam::endl;
}
bool transferFailed = true; bool transferFailed = true;
if (commsType == blocking) if (commsType == blocking)
@ -56,6 +64,14 @@ bool Foam::UOPstream::write
tag, tag,
MPI_COMM_WORLD MPI_COMM_WORLD
); );
if (debug)
{
Pout<< "UIPstream::write : finished write to:" << toProcNo
<< " tag:" << tag << " size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< Foam::endl;
}
} }
else if (commsType == scheduled) else if (commsType == scheduled)
{ {
@ -68,6 +84,14 @@ bool Foam::UOPstream::write
tag, tag,
MPI_COMM_WORLD MPI_COMM_WORLD
); );
if (debug)
{
Pout<< "UIPstream::write : finished write to:" << toProcNo
<< " tag:" << tag << " size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< Foam::endl;
}
} }
else if (commsType == nonBlocking) else if (commsType == nonBlocking)
{ {
@ -84,6 +108,15 @@ bool Foam::UOPstream::write
&request &request
); );
if (debug)
{
Pout<< "UIPstream::write : started write to:" << toProcNo
<< " tag:" << tag << " size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< " request:" << PstreamGlobals::outstandingRequests_.size()
<< Foam::endl;
}
PstreamGlobals::outstandingRequests_.append(request); PstreamGlobals::outstandingRequests_.append(request);
} }
else else
@ -93,7 +126,8 @@ bool Foam::UOPstream::write
"UOPstream::write" "UOPstream::write"
"(const int fromProcNo, char* buf, std::streamsize bufSize" "(const int fromProcNo, char* buf, std::streamsize bufSize"
", const int)" ", const int)"
) << "Unsupported communications type " << commsType ) << "Unsupported communications type "
<< UPstream::commsTypeNames[commsType]
<< Foam::abort(FatalError); << Foam::abort(FatalError);
} }

View File

@ -70,6 +70,12 @@ bool Foam::UPstream::init(int& argc, char**& argv)
MPI_Comm_size(MPI_COMM_WORLD, &numprocs); MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &myProcNo_); MPI_Comm_rank(MPI_COMM_WORLD, &myProcNo_);
if (debug)
{
Pout<< "UPstream::init : initialised with numProcs:" << numprocs
<< " myProcNo:" << myProcNo_ << endl;
}
if (numprocs <= 1) if (numprocs <= 1)
{ {
FatalErrorIn("UPstream::init(int& argc, char**& argv)") FatalErrorIn("UPstream::init(int& argc, char**& argv)")
@ -124,6 +130,11 @@ bool Foam::UPstream::init(int& argc, char**& argv)
void Foam::UPstream::exit(int errnum) void Foam::UPstream::exit(int errnum)
{ {
if (debug)
{
Pout<< "UPstream::exit." << endl;
}
# ifndef SGIMPI # ifndef SGIMPI
int size; int size;
char* buff; char* buff;
@ -164,6 +175,11 @@ void Foam::UPstream::abort()
void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) void Foam::reduce(scalar& Value, const sumOp<scalar>& bop)
{ {
if (Pstream::debug)
{
Pout<< "UPstream::reduce : value:" << Value << endl;
}
if (!UPstream::parRun()) if (!UPstream::parRun())
{ {
return; return;
@ -433,11 +449,23 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop)
} }
*/ */
} }
if (Pstream::debug)
{
Pout<< "UPstream::reduce : reduced value:" << Value << endl;
}
} }
void Foam::UPstream::waitRequests() void Foam::UPstream::waitRequests()
{ {
if (debug)
{
Pout<< "UPstream::waitRequests : starting wait for "
<< PstreamGlobals::outstandingRequests_.size()
<< " outstanding requests." << endl;
}
if (PstreamGlobals::outstandingRequests_.size()) if (PstreamGlobals::outstandingRequests_.size())
{ {
if if
@ -458,11 +486,22 @@ void Foam::UPstream::waitRequests()
PstreamGlobals::outstandingRequests_.clear(); PstreamGlobals::outstandingRequests_.clear();
} }
if (debug)
{
Pout<< "UPstream::waitRequests : finished wait." << endl;
}
} }
bool Foam::UPstream::finishedRequest(const label i) bool Foam::UPstream::finishedRequest(const label i)
{ {
if (debug)
{
Pout<< "UPstream::waitRequests : starting wait for request:" << i
<< endl;
}
if (i >= PstreamGlobals::outstandingRequests_.size()) if (i >= PstreamGlobals::outstandingRequests_.size())
{ {
FatalErrorIn FatalErrorIn
@ -483,6 +522,12 @@ bool Foam::UPstream::finishedRequest(const label i)
MPI_STATUS_IGNORE MPI_STATUS_IGNORE
); );
if (debug)
{
Pout<< "UPstream::waitRequests : finished wait for request:" << i
<< endl;
}
return flag != 0; return flag != 0;
} }