1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Write primitive and binary block from OPstream gamma-mpi
28 \*---------------------------------------------------------------------------*/
32 #include "PstreamGlobals.H"
36 #include <linux/gamma/libgamma.h>
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
47 // Largest message sent so far. This tracks the size of the receive
48 // buffer on the receiving end. Done so we only send out resize messages
51 labelList maxSendSize;
52 //! @endcond fileScope
55 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
61 Pout<< "OPstream::~OPstream() to processor " << toProcNo_
76 FatalErrorIn("OPstream::~OPstream()")
77 << "GAMMA cannot send outgoing message"
78 << Foam::abort(FatalError);
83 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 const commsTypes commsType,
90 const std::streamsize bufSize
93 if (PstreamGlobals::getSizeFromHeader(buf, bufSize) != -1)
95 FatalErrorIn("OPstream::write")
96 << "Problem: Trying to send message of size " << bufSize
97 << " that corresponds to the special resizeMessage."
98 << Foam::abort(FatalError);
101 if (maxSendSize.empty())
103 // Intialize maxSendSize to the initial size of the receive buffers.
104 maxSendSize.setSize(Pstream::nProcs());
105 maxSendSize = PstreamGlobals::initialBufferLen;
106 maxSendSize[Pstream::myProcNo()] = 0;
110 forAll(maxSendSize, procNo)
112 Pout<< "OPstream::write() : for toProcNo:" << procNo
113 << " set maxSendSize to " << maxSendSize[procNo]
121 Pout<< "OPstream::write() : proc:" << toProcNo
122 << " maxSendSize:" << maxSendSize[toProcNo]
126 if (bufSize > maxSendSize[toProcNo])
128 // Send resize message.
131 Pout<< "OPstream::write() : Sending resize message to proc "
133 << " for size:" << bufSize
137 PstreamGlobals::setResizeMessage(bufSize);
141 reinterpret_cast<char*>(PstreamGlobals::resizeMessage),
142 PstreamGlobals::resizeMessageLen*sizeof(uint64_t)
145 maxSendSize[toProcNo] = bufSize;
152 // Note: could be put into allocation of buf.
153 //gamma_mlock(const_cast<char*>(buf), bufSize);
157 Pout<< "OPstream::write() : Sending to proc " << toProcNo
158 << " bytes:" << bufSize << Foam::endl;
164 const_cast<char*>(buf),
168 //gamma_munlock(const_cast<char*>(buf), bufSize);
172 Pout<< "OPstream::write() : Sent " << bufSize
173 << " to proc " << toProcNo
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 } // End namespace Foam
186 // ************************************************************************* //