Skip to content
Snippets Groups Projects
Commit cc1f4235 authored by Podhorszki, Norbert's avatar Podhorszki, Norbert
Browse files

updates to basic example after team discussion

parent c50e6c3b
No related branches found
No related tags found
1 merge request!8Integrate groupless
...@@ -57,10 +57,10 @@ int main( int argc, char* argv [] ) ...@@ -57,10 +57,10 @@ int main( int argc, char* argv [] )
std::cout << "List of variables in file: " << bpReader->VariableNames << "\n"; std::cout << "List of variables in file: " << bpReader->VariableNames << "\n";
/* NX */ /* NX */
bpReader->Read<unsigned int>( "NX", &Nx ); // read a Global scalar which has a single value in a step bpReader->Read<unsigned int>( "NX", Nx ); // read a Global scalar which has a single value in a step
/* nproc */ /* nproc */
bpReader->Read<int>( "nproc", &Nwriters ); // also a global scalar bpReader->Read<int>( "nproc", Nwriters ); // also a global scalar
/* Nparts */ /* Nparts */
...@@ -70,28 +70,30 @@ int main( int argc, char* argv [] ) ...@@ -70,28 +70,30 @@ int main( int argc, char* argv [] )
// 1D array of Nwriters values. // 1D array of Nwriters values.
if( rank < Nwriters ) if( rank < Nwriters )
{ {
std::shared_ptr<adios::Variable<void> > varNparts = bpReader.InquiryVariable("Nparts"); std::shared_ptr<adios::Variable> varNparts = bpReader.InquiryVariable("Nparts");
std::unique_ptr<adios::Selection> selNparts = adios.SelectionBoundingBox( {1}, {rank} ); std::unique_ptr<adios::Selection> selNparts = adios.SelectionBoundingBox( {1}, {rank} );
varNparts->SetSelection( selNparts ); varNparts->SetSelection( selNparts );
bpReader->Read<int>( varNparts, &Nparts ); bpReader->Read<int>( varNparts, Nparts );
} }
// or we could just read the whole array by every process // or we could just read the whole array by every process
std::vector<int> partsV( Nwriters ); std::vector<int> partsV( Nwriters );
bpReader->Read<int>( "Nparts", &partsV ); // read with string name, no selection => read whole array bpReader->Read<int>( "Nparts", partsV.data() ); // read with string name, no selection => read whole array
std::vector<int> partsV;
bpReader->Read<int>( "Nparts", partsV); // read with string name, no selection => read whole array
(Nwriters == partsV.size())
/* Nice */ /* Nice */
// inquiry about a variable, whose name we know // inquiry about a variable, whose name we know
std::shared_ptr<adios::Variable<void> > varNice = bpReader.InquiryVariable("Nice"); std::shared_ptr<adios::Variable> varNice = bpReader.InquiryVariable("Nice");
if( varNice == nullptr ) if( varNice == nullptr )
throw std::ios_base::failure( "ERROR: failed to find variable 'myDoubles' in input file\n" ); throw std::ios_base::failure( "ERROR: failed to find variable 'myDoubles' in input file\n" );
// ? how do we know about the type? std::string varNice->m_Type // ? how do we know about the type? std::string varNice->m_Type
unsigned long long int gdim = varMyDoubles->m_GlobalDimensions[0]; // ?member var or member func? uint64_t gdim = varNice->m_GlobalDimensions[0]; // ?member var or member func?
unsigned long long int ldim = gdim / nproc; uint64_t ldim = gdim / nproc;
unsigned long long int offs = rank * ldim; uint64_t offs = rank * ldim;
if( rank == nproc-1 ) if( rank == nproc-1 )
{ {
ldim = gdim - (ldim * gdim); ldim = gdim - (ldim * gdim);
...@@ -122,7 +124,7 @@ int main( int argc, char* argv [] ) ...@@ -122,7 +124,7 @@ int main( int argc, char* argv [] )
varRagged->InquiryBlocks(); varRagged->InquiryBlocks();
// now we have the dimensions per block // now we have the dimensions per block
unsigned long long int ldim = varRagged->blockinfo[rank].m_Dimensions[0]; unsigned long long int ldim = varRagged->blockinfo[rank].m_Dimensions[1];
RaggedArray.resize( ldim ); RaggedArray.resize( ldim );
std::unique_ptr<adios::Selection> wbsel = adios.SelectionWriteblock( rank ); std::unique_ptr<adios::Selection> wbsel = adios.SelectionWriteblock( rank );
......
...@@ -82,29 +82,30 @@ int main( int argc, char* argv [] ) ...@@ -82,29 +82,30 @@ int main( int argc, char* argv [] )
if( rank == 0 ) if( rank == 0 )
{ {
// Writing a global scalar from only one process // Writing a global scalar from only one process
bpWriter->Write<unsigned int>( varNX, &Nx ); bpWriter->Write<unsigned int>( varNX, Nx );
} }
// Writing a local scalar on every process. Will be shown at reading as a 1D array // Writing a local scalar on every process. Will be shown at reading as a 1D array
bpWriter->Write<int>( varNparts, &Nparts ); bpWriter->Write<int>( varNparts, Nparts );
// Writing a global scalar on every process is useless. Information will be thrown away // Writing a global scalar on every process is useless. Information will be thrown away
// and only rank 0's data will be in the output // and only rank 0's data will be in the output
bpWriter->Write<int>( varNproc, &nproc ); bpWriter->Write<int>( varNproc, nproc );
// Make a 1D selection to describe the local dimensions of the variable we write and // Make a 1D selection to describe the local dimensions of the variable we write and
// its offsets in the global spaces // its offsets in the global spaces
adios::Selection& sel = adios.SelectionBoundingBox( {Nx}, {rank*Nx} ); // local dims and offsets; both as list adios::Selection& sel = adios.SelectionBoundingBox( {Nx}, {rank*Nx} ); // local dims and offsets; both as list
NiceArray.SetSelection( sel ); varNice.SetSelection( sel );
bpWriter->Write<double>( varNice, NiceArray.data() ); // Base class Engine own the Write<T> that will call overloaded Write from Derived bpWriter->Write<double>( varNice, NiceArray.data() ); // Base class Engine own the Write<T> that will call overloaded Write from Derived
adios::Selection& lsel = adios.SelectionBoundingBox( {1,Nparts}, {rank,0} ); adios::Selection& lsel = adios.SelectionBoundingBox( {1,Nparts}, {rank,0} );
RaggedArray.SetSelection( sel ); varRagged.SetSelection( sel );
bpWriter->Write<float>( varRagged, RaggedArray.data() ); // Base class Engine own the Write<T> that will call overloaded Write from Derived bpWriter->Write<float>( varRagged, RaggedArray.data() ); // Base class Engine own the Write<T> that will call overloaded Write from Derived
// Indicate we are done for this step // Indicate we are done for this step
// N-to-M Aggregation, disk I/O will be performed during this call, unless // N-to-M Aggregation, disk I/O will be performed during this call, unless
// time aggregation postpones all of that to some later step // time aggregation postpones all of that to some later step
bpWriter->Advance( ); bpWriter->Advance( );
bpWriter->AdvanceAsync( callback_func_to_notify_me );
// Called once: indicate that we are done with this output for the run // Called once: indicate that we are done with this output for the run
bpWriter->Close( ); bpWriter->Close( );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment