openPMD-api
ParallelADIOS1IOHandlerImpl.hpp
1 /* Copyright 2017-2020 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/IO/AbstractIOHandler.hpp"
25 
26 #if openPMD_HAVE_ADIOS1 && openPMD_HAVE_MPI
27 # include "openPMD/IO/AbstractIOHandlerImpl.hpp"
28 # include <adios.h>
29 # include <adios_read.h>
30 #endif
31 
32 #include <future>
33 #include <memory>
34 #include <string>
35 #if openPMD_HAVE_ADIOS1
36 # include <unordered_map>
37 # include <unordered_set>
38 #endif
39 
40 #ifdef _MSC_VER
41 # define EXPORT __declspec( dllexport )
42 #elif defined(__NVCC__)
43 # define EXPORT
44 #else
45 # define EXPORT __attribute__((visibility("default")))
46 #endif
47 
48 
49 namespace openPMD
50 {
51 #if openPMD_HAVE_ADIOS1 && openPMD_HAVE_MPI
53  {
54  public:
56  virtual ~ParallelADIOS1IOHandlerImpl();
57 
58  virtual void init();
59 
60  std::future< void > flush() override;
61 
62  void createFile(Writable*, Parameter< Operation::CREATE_FILE > const&) override;
63  void createPath(Writable*, Parameter< Operation::CREATE_PATH > const&) override;
64  void createDataset(Writable*, Parameter< Operation::CREATE_DATASET > const&) override;
65  void extendDataset(Writable*, Parameter< Operation::EXTEND_DATASET > const&) override;
66  void openFile(Writable*, Parameter< Operation::OPEN_FILE > const&) override;
67  void openPath(Writable*, Parameter< Operation::OPEN_PATH > const&) override;
68  void openDataset(Writable*, Parameter< Operation::OPEN_DATASET > &) override;
69  void deleteFile(Writable*, Parameter< Operation::DELETE_FILE > const&) override;
70  void deletePath(Writable*, Parameter< Operation::DELETE_PATH > const&) override;
71  void deleteDataset(Writable*, Parameter< Operation::DELETE_DATASET > const&) override;
72  void deleteAttribute(Writable*, Parameter< Operation::DELETE_ATT > const&) override;
73  void writeDataset(Writable*, Parameter< Operation::WRITE_DATASET > const&) override;
74  void writeAttribute(Writable*, Parameter< Operation::WRITE_ATT > const&) override;
75  void readDataset(Writable*, Parameter< Operation::READ_DATASET > &) override;
76  void readAttribute(Writable*, Parameter< Operation::READ_ATT > &) override;
77  void listPaths(Writable*, Parameter< Operation::LIST_PATHS > &) override;
78  void listDatasets(Writable*, Parameter< Operation::LIST_DATASETS > &) override;
79  void listAttributes(Writable*, Parameter< Operation::LIST_ATTS > &) override;
80 
81  virtual int64_t open_write(Writable *);
82  virtual ADIOS_FILE* open_read(std::string const & name);
83  void close(int64_t);
84  void close(ADIOS_FILE*);
85  int64_t initialize_group(std::string const& name);
86  void flush_attribute(int64_t group, std::string const& name, Attribute const&);
87 
88  protected:
89  ADIOS_READ_METHOD m_readMethod;
90  std::unordered_map< Writable*, std::shared_ptr< std::string > > m_filePaths;
91  std::unordered_map< std::shared_ptr< std::string >, int64_t > m_groups;
92  std::unordered_map< std::shared_ptr< std::string >, bool > m_existsOnDisk;
93  std::unordered_map< std::shared_ptr< std::string >, int64_t > m_openWriteFileHandles;
94  std::unordered_map< std::shared_ptr< std::string >, ADIOS_FILE* > m_openReadFileHandles;
95  std::unordered_map< ADIOS_FILE*, std::vector< ADIOS_SELECTION* > > m_scheduledReads;
96  std::unordered_map< int64_t, std::unordered_map< std::string, Attribute > > m_attributeWrites;
101  int64_t GetFileHandle(Writable*);
102  MPI_Comm m_mpiComm;
103  MPI_Info m_mpiInfo;
104  }; // ParallelADIOS1IOHandlerImpl
105 #else
106  class EXPORT ParallelADIOS1IOHandlerImpl
107  {
108  }; // ParallelADIOS1IOHandlerImpl
109 #endif
110 
111 } // openPMD
112 
113 #undef EXPORT
Varidic datatype supporting at least all formats for attributes specified in the openPMD standard...
Definition: Attribute.hpp:49
Interface for communicating between logical and physically persistent data.
Definition: AbstractIOHandler.hpp:68
Public definitions of openPMD-api.
Definition: Date.cpp:28
Layer to mirror structure of logical data and persistent data in file.
Definition: Writable.hpp:55
Definition: AbstractIOHandlerImpl.hpp:34
Definition: ParallelADIOS1IOHandlerImpl.hpp:52