@@ -483,11 +483,8 @@ void BP5Writer::WriteData(format::BufferV *Data)
483483 " is not supported in BP5" );
484484 }
485485 AggTransportData &aggData = m_AggregatorSpecifics.at (GetCacheKey (m_Aggregator));
486- for (auto &t : aggData.m_DataSubstreams )
487- {
488- t->Flush ();
489- t->FinalizeSegment ();
490- }
486+ aggData.m_DataSubstream ->Flush ();
487+ aggData.m_DataSubstream ->FinalizeSegment ();
491488 delete Data;
492489 }
493490}
@@ -534,10 +531,8 @@ void BP5Writer::WriteData_EveryoneWrites(format::BufferV *Data, bool SerializedW
534531 m_DataPos += Data->Size ();
535532 std::vector<core::iovec> DataVec = Data->DataVec ();
536533 AggTransportData &aggData = m_AggregatorSpecifics.at (GetCacheKey (m_Aggregator));
537- for (auto &t : aggData.m_DataSubstreams )
538- {
539- t->WriteV (DataVec.data (), static_cast <int >(DataVec.size ()), m_StartDataPos);
540- }
534+ aggData.m_DataSubstream ->WriteV (DataVec.data (), static_cast <int >(DataVec.size ()),
535+ m_StartDataPos);
541536
542537 if (SerializedWriters && a->m_Comm .Rank () < a->m_Comm .Size () - 1 )
543538 {
@@ -1917,8 +1912,8 @@ void BP5Writer::InitTransports()
19171912 {
19181913 const std::vector<std::string> drainTransportNames =
19191914 transportman::TransportMan::GetFilesBaseNames (m_Name, m_DataTransportsParameters);
1920- aggData.m_DrainSubStreamNames =
1921- GetBPSubStreamNames (drainTransportNames, m_Aggregator->m_SubStreamIndex );
1915+ aggData.m_DrainSubStreamName =
1916+ GetBPSubStreamName (drainTransportNames[ 0 ] , m_Aggregator->m_SubStreamIndex );
19221917 /* start up BB thread */
19231918 // m_FileDrainer.SetVerbose(
19241919 // m_Parameters.BurstBufferVerbose,
@@ -1931,18 +1926,15 @@ void BP5Writer::InitTransports()
19311926 if (m_DrainBB)
19321927 {
19331928 /* Create the directories on target anyway by main thread */
1934- transport::MkDirsBarrier (m_Comm, aggData.m_DrainSubStreamNames , m_DataTransportsParameters,
1929+ transport::MkDirsBarrier (m_Comm, { aggData.m_DrainSubStreamName } , m_DataTransportsParameters,
19351930 m_Parameters.NodeLocal );
19361931 }
19371932
19381933 if (m_IAmDraining)
19391934 {
19401935 if (m_DrainBB)
19411936 {
1942- for (const auto &name : aggData.m_DrainSubStreamNames )
1943- {
1944- m_FileDrainer.AddOperationOpen (name, m_OpenMode);
1945- }
1937+ m_FileDrainer.AddOperationOpen (aggData.m_DrainSubStreamName , m_OpenMode);
19461938 }
19471939 }
19481940
@@ -1978,7 +1970,7 @@ void BP5Writer::OpenSubfile(bool useComm, bool forceAppend)
19781970 AggTransportData &aggData = m_AggregatorSpecifics.at (cacheKey);
19791971
19801972 // /path/name.bp.dir/name.bp.rank
1981- aggData.m_SubStreamNames = GetBPSubStreamNames ({ m_Name} , m_Aggregator->m_SubStreamIndex );
1973+ aggData.m_SubStreamName = GetBPSubStreamName ( m_Name, m_Aggregator->m_SubStreamIndex );
19821974
19831975 helper::Comm openSyncComm;
19841976
@@ -2016,12 +2008,9 @@ void BP5Writer::OpenSubfile(bool useComm, bool forceAppend)
20162008 std::cout << " Rank " << m_Comm.Rank () << " opening data file with Comm"
20172009 << std::endl;
20182010 }
2019- for (const auto &name : aggData.m_SubStreamNames )
2020- {
2021- aggData.m_DataSubstreams .push_back (transport::OpenFileChained (
2022- m_Comm, name, mode, m_IO.m_TransportsParameters [0 ], true ,
2023- *DataWritingComm));
2024- }
2011+ aggData.m_DataSubstream = transport::OpenFileChained (
2012+ m_Comm, aggData.m_SubStreamName , mode, m_IO.m_TransportsParameters [0 ], true ,
2013+ *DataWritingComm);
20252014 }
20262015 else
20272016 {
@@ -2030,11 +2019,8 @@ void BP5Writer::OpenSubfile(bool useComm, bool forceAppend)
20302019 std::cout << " Rank " << m_Comm.Rank () << " opening data file no Comm"
20312020 << std::endl;
20322021 }
2033- for (const auto &name : aggData.m_SubStreamNames )
2034- {
2035- aggData.m_DataSubstreams .push_back (transport::OpenFile (
2036- m_Comm, name, mode, m_IO.m_TransportsParameters [0 ], true ));
2037- }
2022+ aggData.m_DataSubstream = transport::OpenFile (m_Comm, aggData.m_SubStreamName , mode,
2023+ m_IO.m_TransportsParameters [0 ], true );
20382024 }
20392025 }
20402026 }
@@ -2211,19 +2197,16 @@ void BP5Writer::InitBPBuffer()
22112197 const size_t off = m_AppendDataPos[m_Aggregator->m_SubStreamIndex ];
22122198 if (off < MaxSizeT)
22132199 {
2214- for (auto &t : aggData.m_DataSubstreams )
2215- {
2216- t->Truncate (off);
2217- // Seek is needed since truncate does not seek.
2218- // Seek instead of SeekToEnd in case a transport
2219- // does not support actual truncate.
2220- t->Seek (off);
2221- }
2200+ aggData.m_DataSubstream ->Truncate (off);
2201+ // Seek is needed since truncate does not seek.
2202+ // Seek instead of SeekToEnd in case a transport
2203+ // does not support actual truncate.
2204+ aggData.m_DataSubstream ->Seek (off);
22222205 m_DataPos = off;
22232206 }
22242207 else
22252208 {
2226- m_DataPos = aggData.m_DataSubstreams [ 0 ] ->GetSize ();
2209+ m_DataPos = aggData.m_DataSubstream ->GetSize ();
22272210 }
22282211 }
22292212
@@ -2287,10 +2270,7 @@ void BP5Writer::InitBPBuffer()
22872270 // data existed but index was missing
22882271 if (m_Aggregator->m_IsAggregator )
22892272 {
2290- for (auto &t : aggData.m_DataSubstreams )
2291- {
2292- t->Seek (0 );
2293- }
2273+ aggData.m_DataSubstream ->Seek (0 );
22942274 }
22952275 }
22962276
@@ -2446,9 +2426,9 @@ void BP5Writer::DoClose(const int transportIndex)
24462426 (void )transportIndex;
24472427 for (auto &aggPair : m_AggregatorSpecifics)
24482428 {
2449- for ( auto &t : aggPair.second .m_DataSubstreams )
2429+ if ( aggPair.second .m_DataSubstream )
24502430 {
2451- t ->Close ();
2431+ aggPair. second . m_DataSubstream ->Close ();
24522432 }
24532433 }
24542434
@@ -2496,7 +2476,7 @@ void BP5Writer::DoClose(const int transportIndex)
24962476 // cleaned up while those resources are still available.
24972477 for (auto &aggPair : m_AggregatorSpecifics)
24982478 {
2499- aggPair.second .m_DataSubstreams . clear ();
2479+ aggPair.second .m_DataSubstream . reset ();
25002480 }
25012481 m_MetadataFile.reset ();
25022482 m_MetaMetadataFile.reset ();
@@ -2511,8 +2491,9 @@ void BP5Writer::FlushProfiler()
25112491
25122492 for (auto &specs : m_AggregatorSpecifics)
25132493 {
2514- for ( auto &t : specs.second .m_DataSubstreams )
2494+ if ( specs.second .m_DataSubstream )
25152495 {
2496+ auto &t = specs.second .m_DataSubstream ;
25162497 transportTypes.push_back (t->m_Type );
25172498 transportNames.push_back (t->m_Name );
25182499 transportProfilers.push_back (&t->m_Profiler );
0 commit comments