openPMD-api
ParallelADIOS1IOHandlerImpl.hpp
1 /* Copyright 2017-2021 Fabian Koller
2  *
3  * This file is part of openPMD-api.
4  *
5  * openPMD-api is free software: you can redistribute it and/or modify
6  * it under the terms of of either the GNU General Public License or
7  * the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * openPMD-api is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License and the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * and the GNU Lesser General Public License along with openPMD-api.
19  * If not, see <http://www.gnu.org/licenses/>.
20  */
21 #pragma once
22 
23 #include "openPMD/config.hpp"
24 #include "openPMD/auxiliary/Export.hpp"
25 #include "openPMD/IO/AbstractIOHandler.hpp"
26 
27 #if openPMD_HAVE_ADIOS1 && openPMD_HAVE_MPI
28 # include "openPMD/IO/AbstractIOHandlerImpl.hpp"
29 # include <adios.h>
30 # include <adios_read.h>
31 #endif
32 
33 #include <future>
34 #include <memory>
35 #include <string>
36 #if openPMD_HAVE_ADIOS1
37 # include <unordered_map>
38 # include <unordered_set>
39 #endif
40 
41 
42 namespace openPMD
43 {
44 #if openPMD_HAVE_ADIOS1 && openPMD_HAVE_MPI
45  class OPENPMDAPI_EXPORT ParallelADIOS1IOHandlerImpl : public AbstractIOHandlerImpl
46  {
47  public:
48  ParallelADIOS1IOHandlerImpl(AbstractIOHandler*, MPI_Comm);
49  virtual ~ParallelADIOS1IOHandlerImpl();
50 
51  virtual void init();
52 
53  std::future< void > flush() override;
54 
55  void createFile(Writable*, Parameter< Operation::CREATE_FILE > const&) override;
56  void createPath(Writable*, Parameter< Operation::CREATE_PATH > const&) override;
57  void createDataset(Writable*, Parameter< Operation::CREATE_DATASET > const&) override;
58  void extendDataset(Writable*, Parameter< Operation::EXTEND_DATASET > const&) override;
59  void openFile(Writable*, Parameter< Operation::OPEN_FILE > const&) override;
60  void closeFile(Writable*, Parameter< Operation::CLOSE_FILE > const&) override;
61  void availableChunks(Writable*, Parameter< Operation::AVAILABLE_CHUNKS > &) override;
62  void openPath(Writable*, Parameter< Operation::OPEN_PATH > const&) override;
63  void openDataset(Writable*, Parameter< Operation::OPEN_DATASET > &) override;
64  void deleteFile(Writable*, Parameter< Operation::DELETE_FILE > const&) override;
65  void deletePath(Writable*, Parameter< Operation::DELETE_PATH > const&) override;
66  void deleteDataset(Writable*, Parameter< Operation::DELETE_DATASET > const&) override;
67  void deleteAttribute(Writable*, Parameter< Operation::DELETE_ATT > const&) override;
68  void writeDataset(Writable*, Parameter< Operation::WRITE_DATASET > const&) override;
69  void writeAttribute(Writable*, Parameter< Operation::WRITE_ATT > const&) override;
70  void readDataset(Writable*, Parameter< Operation::READ_DATASET > &) override;
71  void readAttribute(Writable*, Parameter< Operation::READ_ATT > &) override;
72  void listPaths(Writable*, Parameter< Operation::LIST_PATHS > &) override;
73  void listDatasets(Writable*, Parameter< Operation::LIST_DATASETS > &) override;
74  void listAttributes(Writable*, Parameter< Operation::LIST_ATTS > &) override;
75 
76  virtual int64_t open_write(Writable *);
77  virtual ADIOS_FILE* open_read(std::string const & name);
78  void close(int64_t);
79  void close(ADIOS_FILE*);
80  int64_t initialize_group(std::string const& name);
81  void flush_attribute(int64_t group, std::string const& name, Attribute const&);
82 
83  protected:
84  ADIOS_READ_METHOD m_readMethod;
85  std::unordered_map< Writable*, std::shared_ptr< std::string > > m_filePaths;
86  std::unordered_map< std::shared_ptr< std::string >, int64_t > m_groups;
87  std::unordered_map< std::shared_ptr< std::string >, bool > m_existsOnDisk;
88  std::unordered_map< std::shared_ptr< std::string >, int64_t > m_openWriteFileHandles;
89  std::unordered_map< std::shared_ptr< std::string >, ADIOS_FILE* > m_openReadFileHandles;
90  std::unordered_map< ADIOS_FILE*, std::vector< ADIOS_SELECTION* > > m_scheduledReads;
91  std::unordered_map< int64_t, std::unordered_map< std::string, Attribute > > m_attributeWrites;
96  int64_t GetFileHandle(Writable*);
97  MPI_Comm m_mpiComm;
98  MPI_Info m_mpiInfo;
99  }; // ParallelADIOS1IOHandlerImpl
100 #else
101  class OPENPMDAPI_EXPORT ParallelADIOS1IOHandlerImpl
102  {
103  }; // ParallelADIOS1IOHandlerImpl
104 #endif
105 
106 } // openPMD
openPMD
Public definitions of openPMD-api.
Definition: Date.cpp:29
openPMD::ParallelADIOS1IOHandlerImpl
Definition: ParallelADIOS1IOHandlerImpl.hpp:101