OPwrite.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "OPstream.H"
00031 #include "long.H"
00032 #include "PstreamGlobals.H"
00033
00034 extern "C" {
00035
00036 #include <linux/gamma/libgamma.h>
00037
00038 }
00039
00040
00041
00042 namespace Foam
00043 {
00044
00045
00046
00047
00048
00049
00051 labelList maxSendSize;
00053
00054
00055
00056
00057 OPstream::~OPstream()
00058 {
00059 if (Pstream::debug)
00060 {
00061 Pout<< "OPstream::~OPstream() to processor " << toProcNo_
00062 << Foam::endl;
00063 }
00064
00065 if
00066 (
00067 !write
00068 (
00069 commsType_,
00070 toProcNo_,
00071 buf_.begin(),
00072 bufPosition_
00073 )
00074 )
00075 {
00076 FatalErrorIn("OPstream::~OPstream()")
00077 << "GAMMA cannot send outgoing message"
00078 << Foam::abort(FatalError);
00079 }
00080 }
00081
00082
00083
00084
00085 bool OPstream::write
00086 (
00087 const commsTypes commsType,
00088 const int toProcNo,
00089 const char* buf,
00090 const std::streamsize bufSize
00091 )
00092 {
00093 if (PstreamGlobals::getSizeFromHeader(buf, bufSize) != -1)
00094 {
00095 FatalErrorIn("OPstream::write")
00096 << "Problem: Trying to send message of size " << bufSize
00097 << " that corresponds to the special resizeMessage."
00098 << Foam::abort(FatalError);
00099 }
00100
00101 if (maxSendSize.empty())
00102 {
00103
00104 maxSendSize.setSize(Pstream::nProcs());
00105 maxSendSize = PstreamGlobals::initialBufferLen;
00106 maxSendSize[Pstream::myProcNo()] = 0;
00107
00108 if (Pstream::debug)
00109 {
00110 forAll(maxSendSize, procNo)
00111 {
00112 Pout<< "OPstream::write() : for toProcNo:" << procNo
00113 << " set maxSendSize to " << maxSendSize[procNo]
00114 << Foam::endl;
00115 }
00116 }
00117 }
00118
00119 if (Pstream::debug)
00120 {
00121 Pout<< "OPstream::write() : proc:" << toProcNo
00122 << " maxSendSize:" << maxSendSize[toProcNo]
00123 << Foam::endl;
00124 }
00125
00126 if (bufSize > maxSendSize[toProcNo])
00127 {
00128
00129 if (Pstream::debug)
00130 {
00131 Pout<< "OPstream::write() : Sending resize message to proc "
00132 << toProcNo
00133 << " for size:" << bufSize
00134 << Foam::endl;
00135 }
00136
00137 PstreamGlobals::setResizeMessage(bufSize);
00138 gamma_send_flowctl
00139 (
00140 toProcNo,
00141 reinterpret_cast<char*>(PstreamGlobals::resizeMessage),
00142 PstreamGlobals::resizeMessageLen*sizeof(uint64_t)
00143 );
00144
00145 maxSendSize[toProcNo] = bufSize;
00146 }
00147
00148
00149
00150
00151
00152
00153
00154
00155 if (Pstream::debug)
00156 {
00157 Pout<< "OPstream::write() : Sending to proc " << toProcNo
00158 << " bytes:" << bufSize << Foam::endl;
00159 }
00160
00161 gamma_send_flowctl
00162 (
00163 toProcNo,
00164 const_cast<char*>(buf),
00165 bufSize
00166 );
00167
00168
00169
00170 if (Pstream::debug)
00171 {
00172 Pout<< "OPstream::write() : Sent " << bufSize
00173 << " to proc " << toProcNo
00174 << Foam::endl;
00175 }
00176
00177
00178 return true;
00179 }
00180
00181
00182
00183
00184 }
00185
00186
Copyright © 2000-2009 OpenCFD Ltd