MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / FindOffsets

Method FindOffsets

Src/Base/AMReX_VisMF.cpp:1215–1369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1213
1214
1215void
1216VisMF::FindOffsets (const FabArray<FArrayBox> &mf,
1217 const std::string &filePrefix,
1218 VisMF::Header &hdr,
1219 VisMF::Header::Version /*whichVersion*/,
1220 NFilesIter &nfi, MPI_Comm comm)
1221{
1222// BL_PROFILE("VisMF::FindOffsets");
1223
1224 const int myProc(ParallelDescriptor::MyProc(comm));
1225 const int nProcs(ParallelDescriptor::NProcs(comm));
1226 int coordinatorProc(ParallelDescriptor::IOProcessorNumber(comm));
1227 if(nfi.GetDynamic()) {
1228 coordinatorProc = nfi.CoordinatorProc();
1229 }
1230
1231 if(FArrayBox::getFormat() == FABio::FAB_ASCII ||
1232 FArrayBox::getFormat() == FABio::FAB_8BIT)
1233 {
1234
1235#ifdef BL_USE_MPI
1236 Vector<int> nmtags(nProcs,0);
1237 Vector<int> offset(nProcs,0);
1238
1239 const Vector<int> &pmap = mf.DistributionMap().ProcessorMap();
1240
1241 for(int i = 0, N = static_cast<int>(mf.size()); i < N; ++i) {
1242 ++nmtags[pmap[i]];
1243 }
1244
1245 for(int i = 1, N = static_cast<int>(offset.size()); i < N; ++i) {
1246 offset[i] = offset[i-1] + nmtags[i-1];
1247 }
1248
1249 Vector<Long> senddata(nmtags[myProc]);
1250
1251 if(senddata.empty()) {
1252 // Can't let senddata be empty as senddata.dataPtr() will fail.
1253 senddata.resize(1);
1254 }
1255
1256 int ioffset(0);
1257
1258 for(MFIter mfi(mf); mfi.isValid(); ++mfi) {
1259 senddata[ioffset++] = hdr.m_fod[mfi.index()].m_head;
1260 }
1261
1262 BL_ASSERT(ioffset == nmtags[myProc]);
1263
1264 Vector<Long> recvdata(mf.size());
1265
1266 BL_COMM_PROFILE(BLProfiler::Gatherv, recvdata.size() * sizeof(Long),
1267 myProc, BLProfiler::BeforeCall());
1268
1269 BL_MPI_REQUIRE( MPI_Gatherv(senddata.dataPtr(),
1270 nmtags[myProc],
1271 ParallelDescriptor::Mpi_typemap<Long>::type(),
1272 recvdata.dataPtr(),

Callers

nothing calls this directly

Calls 15

IOProcessorNumberFunction · 0.85
GetDynamicMethod · 0.80
CoordinatorProcMethod · 0.80
DistributionMapMethod · 0.80
numBytesMethod · 0.80
FileNumbersWrittenMethod · 0.80
GetSparseFPPMethod · 0.80
MyProcFunction · 0.70
NProcsFunction · 0.70
sizeMethod · 0.45
emptyMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected