forked from openPMD/openPMD-api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCommonADIOS1IOHandler.hpp
105 lines (93 loc) · 4.77 KB
/
CommonADIOS1IOHandler.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* Copyright 2017-2021 Fabian Koller and Franz Poeschel
*
* This file is part of openPMD-api.
*
* openPMD-api is free software: you can redistribute it and/or modify
* it under the terms of of either the GNU General Public License or
* the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* openPMD-api is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License and the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* and the GNU Lesser General Public License along with openPMD-api.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "openPMD/config.hpp"
#if openPMD_HAVE_ADIOS1
#include "openPMD/IO/AbstractIOHandler.hpp"
#include "openPMD/auxiliary/Filesystem.hpp"
#include "openPMD/auxiliary/DerefDynamicCast.hpp"
#include "openPMD/auxiliary/JSON_internal.hpp"
#include "openPMD/auxiliary/Memory.hpp"
#include "openPMD/auxiliary/StringManip.hpp"
#include "openPMD/IO/AbstractIOHandlerImpl.hpp"
#include "openPMD/IO/ADIOS/ADIOS1Auxiliary.hpp"
#include "openPMD/IO/ADIOS/ADIOS1FilePosition.hpp"
#include <adios.h>
#include <adios_read.h>
#include <future>
#include <memory>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
namespace openPMD
{
template< typename ChildClass > // CRT pattern
class CommonADIOS1IOHandlerImpl : public AbstractIOHandlerImpl
{
public:
void createFile(Writable*, Parameter< Operation::CREATE_FILE > const&) override;
void createPath(Writable*, Parameter< Operation::CREATE_PATH > const&) override;
void createDataset(Writable*, Parameter< Operation::CREATE_DATASET > const&) override;
void extendDataset(Writable*, Parameter< Operation::EXTEND_DATASET > const&) override;
void openFile(Writable*, Parameter< Operation::OPEN_FILE > const&) override;
void closeFile(Writable*, Parameter< Operation::CLOSE_FILE > const&) override;
void availableChunks(Writable*, Parameter< Operation::AVAILABLE_CHUNKS > &) override;
void openPath(Writable*, Parameter< Operation::OPEN_PATH > const&) override;
void openDataset(Writable*, Parameter< Operation::OPEN_DATASET > &) override;
void deleteFile(Writable*, Parameter< Operation::DELETE_FILE > const&) override;
void deletePath(Writable*, Parameter< Operation::DELETE_PATH > const&) override;
void deleteDataset(Writable*, Parameter< Operation::DELETE_DATASET > const&) override;
void deleteAttribute(Writable*, Parameter< Operation::DELETE_ATT > const&) override;
void writeDataset(Writable*, Parameter< Operation::WRITE_DATASET > const&) override;
void writeAttribute(Writable*, Parameter< Operation::WRITE_ATT > const&) override;
void readDataset(Writable*, Parameter< Operation::READ_DATASET > &) override;
void readAttribute(Writable*, Parameter< Operation::READ_ATT > &) override;
void listPaths(Writable*, Parameter< Operation::LIST_PATHS > &) override;
void listDatasets(Writable*, Parameter< Operation::LIST_DATASETS > &) override;
void listAttributes(Writable*, Parameter< Operation::LIST_ATTS > &) override;
void close(int64_t);
void close(ADIOS_FILE*);
void flush_attribute(int64_t group, std::string const& name, Attribute const&);
protected:
template< typename... Args >
CommonADIOS1IOHandlerImpl( Args &&... args)
: AbstractIOHandlerImpl{ std::forward< Args >( args )... }
{}
ADIOS_READ_METHOD m_readMethod;
std::unordered_map< Writable*, std::shared_ptr< std::string > > m_filePaths;
std::unordered_map< std::shared_ptr< std::string >, int64_t > m_groups;
std::unordered_map< std::shared_ptr< std::string >, bool > m_existsOnDisk;
std::unordered_map< std::shared_ptr< std::string >, int64_t > m_openWriteFileHandles;
std::unordered_map< std::shared_ptr< std::string >, ADIOS_FILE* > m_openReadFileHandles;
std::unordered_map< ADIOS_FILE*, std::vector< ADIOS_SELECTION* > > m_scheduledReads;
std::unordered_map< int64_t, std::unordered_map< std::string, Attribute > > m_attributeWrites;
// config options
std::string m_defaultTransform;
/**
* Call this function to get adios file id for a Writable. Will create one if does not exist
* @return returns an adios file id.
*/
int64_t GetFileHandle(Writable*);
void initJson( json::TracingJSON );
}; // ParallelADIOS1IOHandlerImpl
} // openPMD
#endif