diff --git a/doc/API_design/API_example_use.cpp b/doc/API_design/API_example_use.cpp index a35146935cf564dea610accee6ad67efdfbe6ce6..701bb8994bf973330fb61381b2d2d5fa84741563 100644 --- a/doc/API_design/API_example_use.cpp +++ b/doc/API_design/API_example_use.cpp @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) // Global class/object that serves for init, finalize and provides ADIOS // functions - adios::ADIOS adios("config.xml", comm, /*verbose=*/adios::INFO, + adios::ADIOS adios("config.xml", comm, /*verbose=*/adios::Verbose::INFO, /*debugflag=*/false); /************* @@ -83,8 +83,8 @@ int main(int argc, char *argv[]) "Ragged", adios::Dims{nproc, adios::VARYING_DIMENSION}); // ragged array // add transform to variable - adios::Transform zfp = adios::transform::ZFP(); - var2D.AddTransform(zfp, "accuracy=0.001"); + adios::Transform compress = adios::transform::BZip2(); + var2D.AddTransform(compress, "level=5"); // open...write.write.write...advance...write.write.write...advance... // ...close cycle @@ -120,7 +120,7 @@ int main(int argc, char *argv[]) // write and // its offsets in the global spaces. This could have been done in // adios.DefineVariable() - adios::Selection sel = adios.SelectionBoundingBox( + adios::SelectionBoundingBox sel = adios::SelectionBoundingBox( {1, NX}, {rank, NX}); // local dims and offsets; both as list var2D.SetSelection( sel); // Shall we call it SetSpaceSelection, SetOutputSelection? @@ -135,7 +135,7 @@ int main(int argc, char *argv[]) // Size of the bounding box should match the // "space" selection which was given above. Default memspace is the full // selection. - adios::Selection memspace = adios.SelectionBoundingBox( + adios::SelectionBoundingBox memspace = adios::SelectionBoundingBox( {1, NX}, {0, 1}); // local dims and offsets; both as list var2D.SetMemorySelection(memspace); @@ -226,10 +226,10 @@ int main(int argc, char *argv[]) // we // READ and // its offsets in the global spaces - adios::Selection bbsel = adios.SelectionBoundingBox( + adios::SelectionBoundingBox bbsel = adios::SelectionBoundingBox( {1, NX}, {0, 0}); // local dims and offsets; both as list var2D.SetSelection(bbsel); - adios::Selection memspace = adios.SelectionBoundingBox( + adios::SelectionBoundingBox memspace = adios::SelectionBoundingBox( {1, NX}, {0, 1}); // local dims and offsets; both as list var2D.SetMemorySelection(memspace); reader->Read<double>(var2D, *Temperature); @@ -292,9 +292,9 @@ int main(int argc, char *argv[]) // we // READ and // its offsets in the global spaces if we know this somehow - adios::Selection bbsel = adios.SelectionBoundingBox( + adios::SelectionBoundingBox bbsel = adios::SelectionBoundingBox( {1, NX}, {0, 0}); // local dims and offsets; both as list - var2D->SetSelection(bbsel); + var2D.SetSelection(bbsel); reader->Read<double>(var2D, *Temperature); // Let ADIOS allocate space for the incoming (per-writer) item @@ -399,7 +399,7 @@ int main(int argc, char *argv[]) // Open a file with all steps immediately available std::shared_ptr<adios::Engine> reader = adios.OpenFileReader( - "filename.bp", comm, rmethod, adios::COLLECTIVE_IO); + "filename.bp", comm, rmethod, adios::IOMode::COLLECTIVE); /* NX */ /* There is a single value for each step. We can read all into a 1D diff --git a/examples/heatTransfer/IO_adios2.cpp b/examples/heatTransfer/IO_adios2.cpp deleted file mode 100644 index aea0493ca7dfbbea62f9568f63c4a289bbaa1bba..0000000000000000000000000000000000000000 --- a/examples/heatTransfer/IO_adios2.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * IO_ADIOS2.cpp - * - * Created on: Feb 2017 - * Author: Norbert Podhorszki - */ - -#include "IO.h" -#include "ADIOS_CPP.h" - -#include <string> - -static int rank_saved; -adios::ADIOS *ad = nullptr; -std::shared_ptr<adios::Engine> bpWriter; -adios::Variable<double> *varT = nullptr; - -IO::IO(const Settings &s, MPI_Comm comm) -{ - rank_saved = s.rank; - m_outputfilename = s.outputfile + ".bp"; - ad = new adios::ADIOS("adios2.xml", comm, adios::Verbose::INFO); - - // Define method for engine creation - // 1. Get method def from config file or define new one - - adios::Method &bpWriterSettings = ad->DeclareMethod("output"); - if (!bpWriterSettings.IsUserDefined()) - { - // if not defined by user, we can change the default settings - bpWriterSettings.SetEngine("BP"); // BP is the default engine - bpWriterSettings.AllowThreads( - 1); // allow 1 extra thread for data processing - bpWriterSettings.AddTransport( - "File", "lucky=yes"); // ISO-POSIX file is the default transport - // Passing parameters to the transport - bpWriterSettings.SetParameters( - "have_metadata_file", - "yes"); // Passing parameters to the engine - bpWriterSettings.SetParameters( - "Aggregation", - std::to_string((s.nproc + 1) / 2)); // number of aggregators - } - - // define T as 2D global array - varT = &ad->DefineVariable<double>( - "T", {s.gndx, s.gndy}, // Global dimensions - {s.ndx, - s.ndy}, // local size, could be defined later using SetSelection() - {s.offsx, s.offsy} // offset of the local array in the global space - ); - - // add transform to variable - // adios::Transform tr = adios::transform::BZIP2( ); - // varT.AddTransform( tr, "" ); - // varT.AddTransform( tr,"accuracy=0.001" ); // for ZFP - - bpWriter = ad->Open(m_outputfilename, "w", comm, bpWriterSettings); - - // ad->Open(m_outputfilename, "w", comm, bpWriterSettings); - - if (bpWriter == nullptr) - throw std::ios_base::failure("ERROR: failed to open ADIOS bpWriter\n"); -} - -IO::~IO() -{ - bpWriter->Close(); - delete ad; -} - -void /*IO::*/ old_style_write(int step, const HeatTransfer &ht, - const Settings &s, MPI_Comm comm) -{ - bpWriter->Write<double>(*varT, ht.data_noghost().data()); - bpWriter->Advance(); -} - -void IO::write(int step, const HeatTransfer &ht, const Settings &s, - MPI_Comm comm) -{ - /* This selection is redundant and not required, since we defined - * the selection already in DefineVariable(). It is here just as an example. - */ - // Make a selection to describe the local dimensions of the variable we - // write - // and - // its offsets in the global spaces. This could have been done in - // adios.DefineVariable() - adios::Selection sel = adios.SelectionBoundingBox( - {s.ndx, s.ndy}, - {s.offsx, s.offsy}); // local dims and offsets; both as list - var2D.SetSelection(sel); - - /* Select the area that we want to write from the data pointer we pass to - the - writer. - Think HDF5 memspace, just not hyperslabs, only a bounding box selection. - Engine will copy this bounding box from the data pointer into the output - buffer. - Size of the bounding box should match the "space" selection which was - given - above. - Default memspace is always the full selection. - */ - adios::Selection memspace = - adios.SelectionBoundingBox({s.ndx, s.ndy}, {1, 1}); - var2D.SetMemorySelection(memspace); - - bpWriter->Write<double>(*varT, ht.data()); - bpWriter->Advance(); -} diff --git a/examples/heatTransfer/write/IO_adios2.cpp b/examples/heatTransfer/write/IO_adios2.cpp index 72d118ea15748e2d9852879ccc7f519f184ba72f..0f0c06bb795e0972564d8f5884b52955a08207c9 100644 --- a/examples/heatTransfer/write/IO_adios2.cpp +++ b/examples/heatTransfer/write/IO_adios2.cpp @@ -31,12 +31,13 @@ IO::IO(const Settings &s, MPI_Comm comm) if (!bpWriterSettings.IsUserDefined()) { // if not defined by user, we can change the default settings - bpWriterSettings.SetEngine("BPFileWriter"); // BP is the default engine - bpWriterSettings.AllowThreads(1); // for data processing - - bpWriterSettings.AddTransport( - "File", "lucky=yes"); // ISO-POSIX file is the default transport - // Passing parameters to the transport + // BPFileWriter is the default engine + bpWriterSettings.SetEngine("BPFileWriter"); + // Allow an extra thread for data processing + bpWriterSettings.AllowThreads(1); + // ISO-POSIX file is the default transport + // Passing parameters to the transport + bpWriterSettings.AddTransport("File", "lucky=yes"); const std::string aggregatorsParam("Aggregators=" + std::to_string((s.nproc + 1) / 2)); diff --git a/examples/hello/adios1Writer/helloADIOS1Writer.cpp b/examples/hello/adios1Writer/helloADIOS1Writer.cpp index 87101533b4795379e3b2c94966c44d01fea83403..fc6064b27b8fa5ee50be1a86f9c1b001a3227684 100644 --- a/examples/hello/adios1Writer/helloADIOS1Writer.cpp +++ b/examples/hello/adios1Writer/helloADIOS1Writer.cpp @@ -64,10 +64,10 @@ int main(int argc, char *argv[]) // Define method for engine creation, it is basically straight-forward // parameters - adios::Method &bpWriterSettings = adios.DeclareMethod( - "SingleFile"); // default method type is BPWriter + adios::Method &bpWriterSettings = adios.DeclareMethod("hello"); bpWriterSettings.SetEngine("ADIOS1Writer"); bpWriterSettings.SetParameters("profile_units=mus"); + bpWriterSettings.SetIOMode(adios::IOMode::COLLECTIVE); bpWriterSettings.AddTransport( "File", "profile_units=mus", "have_metadata_file=no"); // uses default POSIX library @@ -75,8 +75,7 @@ int main(int argc, char *argv[]) // Create engine smart pointer due to polymorphism, // Open returns a smart pointer to Engine containing the Derived class // Writer - auto bpWriter = adios.Open("myDoubles.bp", "w", bpWriterSettings, - adios::IOMode::COLLECTIVE); + auto bpWriter = adios.Open("myDoubles.bp", "w", bpWriterSettings); if (bpWriter == nullptr) throw std::ios_base::failure( diff --git a/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp b/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp index 5955b33436df32cd835391a75c85bf2bc8f7f53b..2b850253a997c94106cd472043f05d4e7050372e 100644 --- a/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp +++ b/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp @@ -42,8 +42,8 @@ int main(int argc, char *argv[]) // Define method for engine creation, it is basically straight-forward // parameters - adios::Method &bpWriterSettings = adios.DeclareMethod( - "SinglePOSIXFile"); // default method type is Writer + adios::Method &bpWriterSettings = adios.DeclareMethod("hello"); + bpWriterSettings.SetIOMode(adios::IOMode::COLLECTIVE); bpWriterSettings.SetParameters("profile_units=mus"); bpWriterSettings.AddTransport("File", "have_metadata_file=yes", "profile_units=mus"); @@ -52,8 +52,7 @@ int main(int argc, char *argv[]) // Open returns a smart pointer to Engine containing the Derived class // Writer auto bpFileWriter = - adios.Open("myDoubles_nompi.bp", "w", bpWriterSettings, - adios::IOMode::COLLECTIVE); + adios.Open("myDoubles_nompi.bp", "w", bpWriterSettings); if (bpFileWriter == nullptr) throw std::ios_base::failure( diff --git a/include/core/Method.h b/include/core/Method.h index dc40806126f6da99aac4cc03be2479c62f00eecc..e2f06a6f4857348cdbfcff10e7b3c9fad74f48a5 100644 --- a/include/core/Method.h +++ b/include/core/Method.h @@ -48,7 +48,6 @@ public: /// unsafe std::string m_Type; ///< Method's engine type unsigned int m_nThreads = 1; - adios::IOMode m_IOMode = adios::IOMode::INDEPENDENT; std::map<std::string, std::string> m_Parameters; ///< method parameters std::vector<std::map<std::string, std::string>> @@ -78,6 +77,12 @@ public: */ void SetEngine(const std::string type); + /** + * Set the IO mode (collective or independent) + * @param IO mode + */ + void SetIOMode(const IOMode mode); + /** * Set how many threads the engine can use for its operations (e.g. file io, * compression, staging). @@ -135,6 +140,7 @@ public: private: Verbose m_Verbose = Verbose::WARN; + adios::IOMode m_IOMode = adios::IOMode::INDEPENDENT; void AddTransportParameters(const std::string type, const std::vector<std::string> ¶meters); diff --git a/include/engine/adios1/ADIOS1Reader.h b/include/engine/adios1/ADIOS1Reader.h index 53fb32bec3f8cf8c09ef7584c4f06213ed47bfba..baf55f4166b70ef934b077de1d79e569cc43ed3b 100644 --- a/include/engine/adios1/ADIOS1Reader.h +++ b/include/engine/adios1/ADIOS1Reader.h @@ -101,6 +101,8 @@ public: private: void Init(); ///< called from constructor, gets the selected ADIOS1 /// transport method from settings + void InitParameters(); + void InitTransports(); template <class T> Variable<T> *InquireVariableCommon(const std::string &name, diff --git a/source/core/Method.cpp b/source/core/Method.cpp index 720382cc26074a531918f3c6d21c210ad56dae1f..0c91ed23a3d35da0b5b776954d07eccf84a2233a 100644 --- a/source/core/Method.cpp +++ b/source/core/Method.cpp @@ -29,6 +29,7 @@ bool Method::IsUserDefined() } void Method::SetEngine(const std::string type) { m_Type = type; } +void Method::SetIOMode(const IOMode mode) { m_IOMode = mode; }; void Method::AllowThreads(const unsigned int nThreads) { diff --git a/source/engine/adios1/ADIOS1Reader.cpp b/source/engine/adios1/ADIOS1Reader.cpp index 55a745a0e7370a437665321105cc3ecafd5e9f26..f938277af392b605f7fffa082d61e2f2a7cd7ee7 100644 --- a/source/engine/adios1/ADIOS1Reader.cpp +++ b/source/engine/adios1/ADIOS1Reader.cpp @@ -2,14 +2,14 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * BPFileReader.cpp + * ADIOS1Reader.cpp * * Created on: Feb 27, 2017 * Author: wfg */ +#include "engine/adios1/ADIOS1Reader.h" #include "core/Support.h" -#include "engine/bp/BPFileReader.h" #include "functions/adiosFunctions.h" // CSVToVector #include "transport/file/FStream.h" // uses C++ fstream #include "transport/file/FileDescriptor.h" // uses POSIX @@ -21,127 +21,128 @@ namespace adios ADIOS1Reader::ADIOS1Reader(ADIOS &adios, const std::string &name, const std::string accessMode, MPI_Comm mpiComm, const Method &method) -: Engine(adios, "BPFileReader", name, accessMode, mpiComm, method, - " BPFileReader constructor (or call to ADIOS Open).\n") +: Engine(adios, "ADIOS1Reader", name, accessMode, mpiComm, method, + " ADIOS1Reader constructor (or call to ADIOS Open).\n") { Init(); + adios_read_init_method(read_method, mpiComm, ""); } -BPFileReader::~BPFileReader() {} +ADIOS1Reader::~ADIOS1Reader() {} Variable<void> * -BPFileReader::InquireVariable(const std::string &variableName, +ADIOS1Reader::InquireVariable(const std::string &variableName, const bool readIn) // not yet implemented { return nullptr; } Variable<char> * -BPFileReader::InquireVariableChar(const std::string &variableName, +ADIOS1Reader::InquireVariableChar(const std::string &variableName, const bool readIn) { return InquireVariableCommon<char>(variableName, readIn); } Variable<unsigned char> * -BPFileReader::InquireVariableUChar(const std::string &variableName, +ADIOS1Reader::InquireVariableUChar(const std::string &variableName, const bool readIn) { return InquireVariableCommon<unsigned char>(variableName, readIn); } Variable<short> * -BPFileReader::InquireVariableShort(const std::string &variableName, +ADIOS1Reader::InquireVariableShort(const std::string &variableName, const bool readIn) { return InquireVariableCommon<short>(variableName, readIn); } Variable<unsigned short> * -BPFileReader::InquireVariableUShort(const std::string &variableName, +ADIOS1Reader::InquireVariableUShort(const std::string &variableName, const bool readIn) { return InquireVariableCommon<unsigned short>(variableName, readIn); } -Variable<int> *BPFileReader::InquireVariableInt(const std::string &variableName, +Variable<int> *ADIOS1Reader::InquireVariableInt(const std::string &variableName, const bool readIn) { return InquireVariableCommon<int>(variableName, readIn); } Variable<unsigned int> * -BPFileReader::InquireVariableUInt(const std::string &variableName, +ADIOS1Reader::InquireVariableUInt(const std::string &variableName, const bool readIn) { return InquireVariableCommon<unsigned int>(variableName, readIn); } Variable<long int> * -BPFileReader::InquireVariableLInt(const std::string &variableName, +ADIOS1Reader::InquireVariableLInt(const std::string &variableName, const bool readIn) { return InquireVariableCommon<long int>(variableName, readIn); } Variable<unsigned long int> * -BPFileReader::InquireVariableULInt(const std::string &variableName, +ADIOS1Reader::InquireVariableULInt(const std::string &variableName, const bool readIn) { return InquireVariableCommon<unsigned long int>(variableName, readIn); } Variable<long long int> * -BPFileReader::InquireVariableLLInt(const std::string &variableName, +ADIOS1Reader::InquireVariableLLInt(const std::string &variableName, const bool readIn) { return InquireVariableCommon<long long int>(variableName, readIn); } Variable<unsigned long long int> * -BPFileReader::InquireVariableULLInt(const std::string &variableName, +ADIOS1Reader::InquireVariableULLInt(const std::string &variableName, const bool readIn) { return InquireVariableCommon<unsigned long long int>(variableName, readIn); } Variable<float> * -BPFileReader::InquireVariableFloat(const std::string &variableName, +ADIOS1Reader::InquireVariableFloat(const std::string &variableName, const bool readIn) { return InquireVariableCommon<float>(variableName, readIn); } Variable<double> * -BPFileReader::InquireVariableDouble(const std::string &variableName, +ADIOS1Reader::InquireVariableDouble(const std::string &variableName, const bool readIn) { return InquireVariableCommon<double>(variableName, readIn); } Variable<long double> * -BPFileReader::InquireVariableLDouble(const std::string &variableName, +ADIOS1Reader::InquireVariableLDouble(const std::string &variableName, const bool readIn) { return InquireVariableCommon<long double>(variableName, readIn); } Variable<std::complex<float>> * -BPFileReader::InquireVariableCFloat(const std::string &variableName, +ADIOS1Reader::InquireVariableCFloat(const std::string &variableName, const bool readIn) { return InquireVariableCommon<std::complex<float>>(variableName, readIn); } Variable<std::complex<double>> * -BPFileReader::InquireVariableCDouble(const std::string &variableName, +ADIOS1Reader::InquireVariableCDouble(const std::string &variableName, const bool readIn) { return InquireVariableCommon<std::complex<double>>(variableName, readIn); } Variable<std::complex<long double>> * -BPFileReader::InquireVariableCLDouble(const std::string &variableName, +ADIOS1Reader::InquireVariableCLDouble(const std::string &variableName, const bool readIn) { return InquireVariableCommon<std::complex<long double>>(variableName, @@ -149,31 +150,34 @@ BPFileReader::InquireVariableCLDouble(const std::string &variableName, } VariableCompound * -BPFileReader::InquireVariableCompound(const std::string &variableName, +ADIOS1Reader::InquireVariableCompound(const std::string &variableName, const bool readIn) { return nullptr; } -void BPFileReader::Close(const int transportIndex) {} +void ADIOS1Reader::Close(const int transportIndex) {} // PRIVATE -void BPFileReader::Init() +void ADIOS1Reader::Init() { if (m_DebugMode == true) { if (m_AccessMode != "r" && m_AccessMode != "read") throw std::invalid_argument( - "ERROR: BPFileReader doesn't support access mode " + + "ERROR: ADIOS1Reader doesn't support access mode " + m_AccessMode + - ", in call to ADIOS Open or BPFileReader constructor\n"); + ", in call to ADIOS Open or ADIOS1Reader constructor\n"); } - + InitParameters(); InitTransports(); } -void BPFileReader::InitTransports() // maybe move this? +void ADIOS1Reader::InitParameters() {} + +void ADIOS1Reader::InitTransports() { + if (m_DebugMode == true) { if (TransportNamesUniqueness() == false) @@ -188,43 +192,10 @@ void BPFileReader::InitTransports() // maybe move this? for (const auto ¶meters : m_Method.m_TransportParameters) { auto itTransport = parameters.find("transport"); - if (itTransport->second == "file" || itTransport->second == "File") + if (itTransport->second == "file" || itTransport->second == "File" || + itTransport->second == "bp" || itTransport->second == "BP") { - auto itLibrary = parameters.find("library"); - if (itLibrary == parameters.end() || - itLibrary->second == "POSIX") // use default POSIX - { - auto file = std::make_shared<transport::FileDescriptor>( - m_MPIComm, m_DebugMode); - // m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); - m_Transports.push_back(std::move(file)); - } - else if (itLibrary->second == "FILE*" || - itLibrary->second == "stdio.h") - { - auto file = std::make_shared<transport::FilePointer>( - m_MPIComm, m_DebugMode); - // m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); - m_Transports.push_back(std::move(file)); - } - else if (itLibrary->second == "fstream" || - itLibrary->second == "std::fstream") - { - auto file = std::make_shared<transport::FStream>(m_MPIComm, - m_DebugMode); - // m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); - m_Transports.push_back(std::move(file)); - } - else if (itLibrary->second == "MPI-IO") - { - } - else - { - if (m_DebugMode == true) - throw std::invalid_argument( - "ERROR: file transport library " + itLibrary->second + - " not supported, in " + m_Name + m_EndMessage); - } + read_method = ADIOS_READ_METHOD_BP; } else {