void Foam::processorLduInterface::send ( const Pstream::commsTypes commsType, const UList<Type>& f ) const { label nBytes = f.byteSize(); if ( commsType == Pstream::commsTypes::blocking || commsType == Pstream::commsTypes::scheduled ) { OPstream::write ( commsType, neighbProcNo(), reinterpret_cast<const char*>(f.begin()), nBytes, tag(), comm() ); } else if (commsType == Pstream::commsTypes::nonBlocking) { resizeBuf(receiveBuf_, nBytes); IPstream::read ( commsType, neighbProcNo(), receiveBuf_.begin(), nBytes, tag(), comm() ); resizeBuf(sendBuf_, nBytes); memcpy(sendBuf_.begin(), f.begin(), nBytes); OPstream::write ( commsType, neighbProcNo(), sendBuf_.begin(), nBytes, tag(), comm() ); } else { FatalErrorInFunction << "Unsupported communications type " << int(commsType) << exit(FatalError); } }
void Foam::processorLduInterface::compressedReceive ( const Pstream::commsTypes commsType, UList<Type>& f ) const { if (sizeof(scalar) != sizeof(float) && Pstream::floatTransfer && f.size()) { static const label nCmpts = sizeof(Type)/sizeof(scalar); label nm1 = (f.size() - 1)*nCmpts; label nlast = sizeof(Type)/sizeof(float); label nFloats = nm1 + nlast; label nBytes = nFloats*sizeof(float); if ( commsType == Pstream::commsTypes::blocking || commsType == Pstream::commsTypes::scheduled ) { resizeBuf(receiveBuf_, nBytes); IPstream::read ( commsType, neighbProcNo(), receiveBuf_.begin(), nBytes, tag(), comm() ); } else if (commsType != Pstream::commsTypes::nonBlocking) { FatalErrorInFunction << "Unsupported communications type " << int(commsType) << exit(FatalError); } const float *fArray = reinterpret_cast<const float*>(receiveBuf_.begin()); f.last() = reinterpret_cast<const Type&>(fArray[nm1]); scalar *sArray = reinterpret_cast<scalar*>(f.begin()); const scalar *slast = &sArray[nm1]; for (label i=0; i<nm1; i++) { sArray[i] = fArray[i] + slast[i%nCmpts]; } } else { this->receive<Type>(commsType, f); } }
void Foam::processorLduInterface::compressedSend ( const Pstream::commsTypes commsType, const UList<Type>& f ) const { if (sizeof(scalar) != sizeof(float) && Pstream::floatTransfer && f.size()) { static const label nCmpts = sizeof(Type)/sizeof(scalar); label nm1 = (f.size() - 1)*nCmpts; label nlast = sizeof(Type)/sizeof(float); label nFloats = nm1 + nlast; label nBytes = nFloats*sizeof(float); const scalar *sArray = reinterpret_cast<const scalar*>(f.begin()); const scalar *slast = &sArray[nm1]; resizeBuf(sendBuf_, nBytes); float *fArray = reinterpret_cast<float*>(sendBuf_.begin()); for (register label i=0; i<nm1; i++) { fArray[i] = sArray[i] - slast[i%nCmpts]; } reinterpret_cast<Type&>(fArray[nm1]) = f.last(); if (commsType == Pstream::blocking || commsType == Pstream::scheduled) { OPstream::write ( commsType, neighbProcNo(), sendBuf_.begin(), nBytes, tag() ); } else if (commsType == Pstream::nonBlocking) { resizeBuf(receiveBuf_, nBytes); IPstream::read ( commsType, neighbProcNo(), receiveBuf_.begin(), receiveBuf_.size(), tag() ); OPstream::write ( commsType, neighbProcNo(), sendBuf_.begin(), nBytes, tag() ); } else { FatalErrorIn("processorLduInterface::compressedSend") << "Unsupported communications type " << commsType << exit(FatalError); } } else { this->send(commsType, f); } }
void ProcessorPointPatchField <PatchField, Mesh, PointPatch, ProcessorPointPatch, MatrixType, Type>:: sendField ( const tmp<Field<Type2> >& tf, const Pstream::commsTypes commsType ) const { const Field<Type2>& f = tf(); //HJ: This needs complete rewrite: // - move communications into a patch // - allow for various types of communication // HJ, 15/Apr/2009 if (commsType == Pstream::blocking || commsType == Pstream::scheduled) { OPstream::write ( commsType, procPatch_.neighbProcNo(), reinterpret_cast<const char*>(f.begin()), f.byteSize() ); } else if (commsType == Pstream::nonBlocking) { resizeBuf(receiveBuf_, f.size()*sizeof(Type)); IPstream::read ( commsType, procPatch_.neighbProcNo(), receiveBuf_.begin(), receiveBuf_.size() ); resizeBuf(sendBuf_, f.byteSize()); memcpy(sendBuf_.begin(), f.begin(), f.byteSize()); OPstream::write ( commsType, procPatch_.neighbProcNo(), sendBuf_.begin(), f.byteSize() ); } else { FatalErrorIn("ProcessorPointPatchField::send") << "Unsupported communications type " << commsType << exit(FatalError); } // Not using non-blocking comms // if (commsType == Pstream::nonBlocking) // { // FatalErrorIn("void ProcessorPointPatchField::sendField") // << "Non-blocking comms not implemented" // << abort(FatalError); // } // OPstream::write // ( // commsType, // procPatch_.neighbProcNo(), // reinterpret_cast<const char*>(f.begin()), // f.byteSize() // ); tf.clear(); }