openPMD-api
ChunkInfo.hpp
1 /* Copyright 2020-2021 Franz Poeschel
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 
25 #include "openPMD/Dataset.hpp" // Offset, Extent
26 
27 #if openPMD_HAVE_MPI
28 #include <mpi.h>
29 #endif
30 
31 #include <map>
32 #include <string>
33 #include <vector>
34 
35 namespace openPMD
36 {
42 struct ChunkInfo
43 {
44  Offset offset;
45  Extent extent;
46 
47  /*
48  * If rank is smaller than zero, will be converted to zero.
49  */
50  explicit ChunkInfo() = default;
51  ChunkInfo(Offset, Extent);
52 
53  bool operator==(ChunkInfo const &other) const;
54 };
55 
70 {
71  unsigned int sourceID = 0;
72 
73  explicit WrittenChunkInfo() = default;
74  /*
75  * If rank is smaller than zero, will be converted to zero.
76  */
77  WrittenChunkInfo(Offset, Extent, int sourceID);
78  WrittenChunkInfo(Offset, Extent);
79 
80  bool operator==(WrittenChunkInfo const &other) const;
81 };
82 
83 using ChunkTable = std::vector<WrittenChunkInfo>;
84 
85 namespace chunk_assignment
86 {
87  using RankMeta = std::map<unsigned int, std::string>;
88 } // namespace chunk_assignment
89 
90 namespace host_info
91 {
97  enum class Method
98  {
99  POSIX_HOSTNAME,
100  MPI_PROCESSOR_NAME
101  };
102 
109  bool methodAvailable(Method);
110 
118  std::string byMethod(Method);
119 
120 #if openPMD_HAVE_MPI
131  chunk_assignment::RankMeta byMethodCollective(MPI_Comm, Method);
132 #endif
133 } // namespace host_info
134 } // namespace openPMD
135 
136 #undef openPMD_POSIX_AVAILABLE
Public definitions of openPMD-api.
Definition: Date.cpp:29
Represents the meta info around a chunk in a dataset.
Definition: ChunkInfo.hpp:43
Extent extent
size of the chunk
Definition: ChunkInfo.hpp:45
Offset offset
origin of the chunk
Definition: ChunkInfo.hpp:44
Represents the meta info around a chunk that has been written by some data producing application.
Definition: ChunkInfo.hpp:70
unsigned int sourceID
ID of the data source containing the chunk.
Definition: ChunkInfo.hpp:71