From bb50c7e5050d35b57660f47374976d83318dcd87 Mon Sep 17 00:00:00 2001 From: Norbert Podhorszki <pnorbert@ornl.gov> Date: Mon, 3 Apr 2017 11:17:42 -0400 Subject: [PATCH] Fixes to ADIOS1 Reader class just to make it compile. --- .../hello/adios1Writer/helloADIOS1Writer.cpp | 2 + .../adios1Writer/helloADIOS1Writer_nompi.cpp | 2 +- include/engine/adios1/ADIOS1Reader.h | 35 +++-- source/engine/adios1/ADIOS1Reader.cpp | 132 ++++++------------ 4 files changed, 58 insertions(+), 113 deletions(-) diff --git a/examples/hello/adios1Writer/helloADIOS1Writer.cpp b/examples/hello/adios1Writer/helloADIOS1Writer.cpp index 9543ec43b..dcfc43457 100644 --- a/examples/hello/adios1Writer/helloADIOS1Writer.cpp +++ b/examples/hello/adios1Writer/helloADIOS1Writer.cpp @@ -11,7 +11,9 @@ #include <iostream> #include <vector> +#define OMPI_SKIP_MPICXX 1 // workaround for OpenMPI forcing C++ bindings #include <mpi.h> +#undef OMPI_SKIP_MPICXX #include "ADIOS_CPP.h" diff --git a/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp b/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp index eb282251d..f68529812 100644 --- a/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp +++ b/examples/hello/adios1Writer/helloADIOS1Writer_nompi.cpp @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) { const bool adiosDebug = true; - adios::ADIOS adios(adiosDebug); + adios::ADIOS adios( adios::Verbose::INFO,adiosDebug ); // Application variable std::vector<double> myDoubles = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; diff --git a/include/engine/adios1/ADIOS1Reader.h b/include/engine/adios1/ADIOS1Reader.h index 70b89700a..1f92a1078 100644 --- a/include/engine/adios1/ADIOS1Reader.h +++ b/include/engine/adios1/ADIOS1Reader.h @@ -10,8 +10,8 @@ * Author: pnb */ -#ifndef BPFILEREADER_H_ -#define BPFILEREADER_H_ +#ifndef ADIOS1READER_H_ +#define ADIOS1READER_H_ #include <iostream> //this must go away @@ -23,7 +23,13 @@ namespace adios { -class BPFileReader : public Engine +#ifdef ADIOS_NOMPI +#define _NOMPI 1 +#endif +#include "adios_read_v2.h" // this is adios 1.x header file + + +class ADIOS1Reader : public Engine { public: @@ -37,13 +43,13 @@ public: * @param debugMode * @param hostLanguage */ - BPFileReader(ADIOS &adios, const std::string name, + ADIOS1Reader(ADIOS &adios, const std::string name, const std::string accessMode, MPI_Comm mpiComm, const Method &method, const IOMode iomode, const float timeout_sec, const bool debugMode = false, const unsigned int nthreads = 1); - ~BPFileReader(); + ~ADIOS1Reader(); Variable<void> *InquireVariable(const std::string name, const bool readIn = true); @@ -92,24 +98,13 @@ public: void Close(const int transportIndex = -1); private: - capsule::STLVector - m_Buffer; ///< heap capsule, contains data and metadata buffers - // format::BP1Writer m_BP1Writer; ///< format object will provide the required - // BP functionality to be applied on m_Buffer and m_Transports - void Init(); ///< calls InitCapsules and InitTransports based on Method, - /// called from constructor - void InitCapsules(); - void InitTransports(); ///< from Transports - - std::string - GetMdtmParameter(const std::string parameter, - const std::map<std::string, std::string> &mdtmParameters); + void Init(); ///< called from constructor, gets the selected ADIOS1 transport method from settings template <class T> Variable<T> *InquireVariableCommon(const std::string name, const bool readIn) { - std::cout << "Hello BPReaderCommon\n"; + std::cout << "Hello ADIOS1Reader::InquireVariableCommon\n"; // here read variable metadata (dimensions, type, etc.)...then create a // Variable like below: @@ -117,8 +112,10 @@ private: // return &variable; //return address if success return nullptr; // on failure } + + enum ADIOS_READ_METHOD read_method = ADIOS_READ_METHOD_BP; }; } // end namespace adios -#endif /* BPFILEREADER_H_ */ +#endif /* ADIOS1READER_H_ */ diff --git a/source/engine/adios1/ADIOS1Reader.cpp b/source/engine/adios1/ADIOS1Reader.cpp index 406c752d3..5472099fc 100644 --- a/source/engine/adios1/ADIOS1Reader.cpp +++ b/source/engine/adios1/ADIOS1Reader.cpp @@ -2,222 +2,168 @@ * 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/bp/BPFileReader.h" +#include "engine/adios1/ADIOS1Reader.h" +#include "ADIOS.h" -#include "core/Support.h" -#include "functions/adiosFunctions.h" //CSVToVector -#include "transport/file/FileDescriptor.h" // uses POSIX -#include "transport/file/FilePointer.h" // uses C FILE* - -// supported transports -#include "transport/file/FStream.h" // uses C++ fstream +extern int adios_verbose_level; +extern int adios_errno; namespace adios { -BPFileReader::BPFileReader(ADIOS &adios, const std::string name, +ADIOS1Reader::ADIOS1Reader(ADIOS &adios, const std::string name, const std::string accessMode, MPI_Comm mpiComm, const Method &method, const IOMode iomode, const float timeout_sec, const bool debugMode, const unsigned int nthreads) -: Engine(adios, "BPFileReader", name, accessMode, mpiComm, method, debugMode, - nthreads, " BPFileReader constructor (or call to ADIOS Open).\n"), - m_Buffer(accessMode, m_RankMPI, m_DebugMode) +: Engine(adios, "ADIOS1Reader", name, accessMode, mpiComm, method, + debugMode, nthreads, + " ADIOS1Reader constructor (or call to ADIOS Open).\n") { Init(); + adios_read_init_method(read_method, m_MPIComm, ""); } -BPFileReader::~BPFileReader() {} +ADIOS1Reader::~ADIOS1Reader() +{ + adios_read_finalize_method(read_method); +} Variable<void> * -BPFileReader::InquireVariable(const std::string name, +ADIOS1Reader::InquireVariable(const std::string name, const bool readIn) // not yet implemented { return nullptr; } -Variable<char> *BPFileReader::InquireVariableChar(const std::string name, +Variable<char> *ADIOS1Reader::InquireVariableChar(const std::string name, const bool readIn) { return InquireVariableCommon<char>(name, readIn); } Variable<unsigned char> * -BPFileReader::InquireVariableUChar(const std::string name, const bool readIn) +ADIOS1Reader::InquireVariableUChar(const std::string name, const bool readIn) { return InquireVariableCommon<unsigned char>(name, readIn); } -Variable<short> *BPFileReader::InquireVariableShort(const std::string name, +Variable<short> *ADIOS1Reader::InquireVariableShort(const std::string name, const bool readIn) { return InquireVariableCommon<short>(name, readIn); } Variable<unsigned short> * -BPFileReader::InquireVariableUShort(const std::string name, const bool readIn) +ADIOS1Reader::InquireVariableUShort(const std::string name, const bool readIn) { return InquireVariableCommon<unsigned short>(name, readIn); } -Variable<int> *BPFileReader::InquireVariableInt(const std::string name, +Variable<int> *ADIOS1Reader::InquireVariableInt(const std::string name, const bool readIn) { return InquireVariableCommon<int>(name, readIn); } Variable<unsigned int> * -BPFileReader::InquireVariableUInt(const std::string name, const bool readIn) +ADIOS1Reader::InquireVariableUInt(const std::string name, const bool readIn) { return InquireVariableCommon<unsigned int>(name, readIn); } -Variable<long int> *BPFileReader::InquireVariableLInt(const std::string name, +Variable<long int> *ADIOS1Reader::InquireVariableLInt(const std::string name, const bool readIn) { return InquireVariableCommon<long int>(name, readIn); } Variable<unsigned long int> * -BPFileReader::InquireVariableULInt(const std::string name, const bool readIn) +ADIOS1Reader::InquireVariableULInt(const std::string name, const bool readIn) { return InquireVariableCommon<unsigned long int>(name, readIn); } Variable<long long int> * -BPFileReader::InquireVariableLLInt(const std::string name, const bool readIn) +ADIOS1Reader::InquireVariableLLInt(const std::string name, const bool readIn) { return InquireVariableCommon<long long int>(name, readIn); } Variable<unsigned long long int> * -BPFileReader::InquireVariableULLInt(const std::string name, const bool readIn) +ADIOS1Reader::InquireVariableULLInt(const std::string name, const bool readIn) { return InquireVariableCommon<unsigned long long int>(name, readIn); } -Variable<float> *BPFileReader::InquireVariableFloat(const std::string name, +Variable<float> *ADIOS1Reader::InquireVariableFloat(const std::string name, const bool readIn) { return InquireVariableCommon<float>(name, readIn); } -Variable<double> *BPFileReader::InquireVariableDouble(const std::string name, +Variable<double> *ADIOS1Reader::InquireVariableDouble(const std::string name, const bool readIn) { return InquireVariableCommon<double>(name, readIn); } Variable<long double> * -BPFileReader::InquireVariableLDouble(const std::string name, const bool readIn) +ADIOS1Reader::InquireVariableLDouble(const std::string name, const bool readIn) { return InquireVariableCommon<long double>(name, readIn); } Variable<std::complex<float>> * -BPFileReader::InquireVariableCFloat(const std::string name, const bool readIn) +ADIOS1Reader::InquireVariableCFloat(const std::string name, const bool readIn) { return InquireVariableCommon<std::complex<float>>(name, readIn); } Variable<std::complex<double>> * -BPFileReader::InquireVariableCDouble(const std::string name, const bool readIn) +ADIOS1Reader::InquireVariableCDouble(const std::string name, const bool readIn) { return InquireVariableCommon<std::complex<double>>(name, readIn); } Variable<std::complex<long double>> * -BPFileReader::InquireVariableCLDouble(const std::string name, const bool readIn) +ADIOS1Reader::InquireVariableCLDouble(const std::string name, const bool readIn) { return InquireVariableCommon<std::complex<long double>>(name, readIn); } -VariableCompound *BPFileReader::InquireVariableCompound(const std::string name, +VariableCompound *ADIOS1Reader::InquireVariableCompound(const std::string name, 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 " + m_AccessMode + - ", in call to ADIOS Open or BPFileReader constructor\n"); - } - - InitCapsules(); - InitTransports(); -} - -void BPFileReader::InitCapsules() -{ - // here init memory capsules -} - -void BPFileReader::InitTransports() // maybe move this? -{ - if (m_DebugMode == true) - { - if (TransportNamesUniqueness() == false) - { - throw std::invalid_argument( - "ERROR: two transports of the same kind (e.g file IO) " - "can't have the same name, modify with name= in Method " - "AddTransport\n"); - } + "ERROR: ADIOS1Reader doesn't support access mode " + m_AccessMode + + ", in call to ADIOS Open or ADIOS1Reader constructor\n"); } 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 { -- GitLab