22 return inputT.linearSize();
26 void linearIn(T& a_outputT,
const void*
const inBuf)
28 a_outputT.linearIn(inBuf);
32 void linearOut(
void*
const a_outBuf,
const T& inputT)
34 inputT.linearOut(a_outBuf);
67 void* sendBuf =
static_cast<void*
>(&isize);
71 vectSize =
new int[nProcess];
72 vectDisp =
new int[nProcess];
75 int result1 = MPI_Gather(sendBuf, sendCount, MPI_INT,
76 vectSize,recdCount, MPI_INT,
77 a_dest, Chombo_MPI::comm);
79 if (result1 != MPI_SUCCESS)
87 for (
int iproc = 0; iproc < nProcess; iproc++)
89 vectDisp[iproc] = itotsize;
90 itotsize += vectSize[iproc];
98 int result2 = MPI_Gatherv(loclBuf, isize, MPI_BYTE,
99 recdBuf, vectSize, vectDisp, MPI_BYTE,
100 a_dest, Chombo_MPI::comm);
101 if (result2 != MPI_SUCCESS)
108 a_outVec.
resize(nProcess);
110 char* arithPtr = (
char*)recdBuf;
111 for (
int iproc = 0; iproc < nProcess; iproc++)
113 ioffset = vectDisp[iproc];
114 char* thisProcBuf = arithPtr + ioffset;
115 linearIn(a_outVec[iproc], thisProcBuf);
143 MPI_Bcast(&isize, 1, MPI_INT, a_src, Chombo_MPI::comm);
147 if (broadBuf == NULL)
159 MPI_Bcast(broadBuf, isize, MPI_BYTE, a_src, Chombo_MPI::comm);
185 MPI_Barrier(Chombo_MPI::comm);
197 a_outVec[0] = a_input;
217 #endif //the mpi thing 229 const int*
const intBuf = (
int*)a_inBuf;
230 int vecsize = intBuf[0];
233 for (
int ivec = 0; ivec < vecsize; ivec++)
235 vecOffset[ivec] = intBuf[ivec+1];
243 a_outputT.
resize(vecsize);
244 const char*
const charbuf = (
char*)a_inBuf;
245 for (
int ivec = 0; ivec < vecsize; ivec++)
247 const char*
const dataLoc = charbuf + vecOffset[ivec];
258 int*
const intBuf = (
int*)a_outBuf;
259 intBuf[0] = a_input.
size();
260 int vecsize = intBuf[0];
264 int ioffset = (vecsize+1)*
sizeof(
int);
265 for (
int ivec = 0; ivec < vecsize; ivec++)
267 intBuf[ivec+1] = ioffset;
268 vecOffset[ivec] = ioffset;
276 char*
const charBuf = (
char*)a_outBuf;
277 for (
int ivec = 0; ivec < vecsize; ivec++)
279 char*
const dataLoc = charBuf + vecOffset[ivec];
292 int itotsize = (a_input.
size() + 1)*
sizeof(
int);
293 for (
int ivec = 0; ivec < a_input.
size(); ivec++)
#define freeMT(a_a)
Definition: memtrack.H:159
#define CH_assert(cond)
Definition: CHArray.H:37
void linearOut(void *const a_outBuf, const T &inputT)
Definition: SPMDI.H:32
void barrier(void)
all ranks wait here to sync-up
Definition: SPMDI.H:212
one dimensional dynamic array
Definition: Vector.H:52
long long CH_MaxMPISendSize
#define mallocMT(a_a)
Definition: memtrack.H:158
long long CH_MaxMPIRecvSize
void AttachDebugger(int a_sig=4)
void linearIn(T &a_outputT, const void *const inBuf)
Definition: SPMDI.H:26
unsigned int numProc()
number of parallel processes
int linearSize(const T &inputT)
Definition: SPMDI.H:20
void resize(unsigned int isize)
Definition: Vector.H:323
void gather(Vector< T > &a_outVec, const T &a_input, int a_dest)
Definition: SPMDI.H:194
void linearListIn(Vector< T > &a_outputT, const void *const a_inBuf)
Definition: SPMDI.H:226
size_t size() const
Definition: Vector.H:177
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code.
void linearListOut(void *const a_outBuf, const Vector< T > &a_input)
Definition: SPMDI.H:255
int linearListSize(const Vector< T > &a_input)
Definition: SPMDI.H:287
int procID()
local process ID
void broadcast(T &a_inAndOut, int a_src)
broadcast to every process
Definition: SPMDI.H:204