Realm
A distributed, event-based tasking library
Loading...
Searching...
No Matches
hdf5_access.h
Go to the documentation of this file.
1/*
2 * Copyright 2025 Stanford University, NVIDIA Corporation
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18// HDF5-specific instance layouts and accessors
19
20#ifndef REALM_HDF5_ACCESS_H
21#define REALM_HDF5_ACCESS_H
22
23#include "realm/inst_layout.h"
24#include <string>
25#include <vector>
26
27namespace Realm {
28
29 // we avoid including hdf5.h here, but we need a definition for something that'll
30 // be compatible with HDF5's hsize_t
31 typedef unsigned long long hdf5_size_t;
32
33 namespace PieceLayoutTypes {
34 static const LayoutType HDF5LayoutType = 2;
35 };
36
37 // dimension-agnostic form for piece info allows us to get to it without
38 // having to know the template parameters of the HDF5LayoutPiece holding
39 // it
41 std::string dsetname;
42 // TODO: small vectors
43 // this is the offset within the hdf5 dataset, uses its dimensionality
44 std::vector<hdf5_size_t> offset;
45 // this maps from realm dimensions to hdf5 dimensions - the
46 // dimensionalities may differ - use '-1' for realm dimensions that
47 // do not correspond to an hdf5 dimension
48 std::vector<int> dim_order;
50 };
51
52 template <int N, typename T>
54 public HDF5PieceInfo {
55 public:
57
58 template <typename S>
60
61 virtual InstanceLayoutPiece<N, T> *clone(void) const;
62
63 virtual size_t calculate_offset(const Point<N, T> &p) const;
64
65 virtual void relocate(size_t base_offset);
66
67 virtual void print(std::ostream &os) const;
68
69 virtual size_t lookup_inst_size() const;
71 unsigned next_delta) const;
72
76
77 template <typename S>
78 bool serialize(S &serializer) const;
79 };
80
81 namespace PieceLookup {
82
83 namespace Opcodes {
84 static const Opcode OP_HDF5_PIECE = 3; // this is an HDF5Piece<N,T>
85 }
86
87 static const unsigned ALLOW_HDF5_PIECE = 1U << Opcodes::OP_HDF5_PIECE;
88
89 template <int N, typename T>
90 struct HDF5Piece : public Instruction {
91 // data is: { delta[23:0], opcode[7:0] }
92 // top 24 bits of data is jump delta
93 HDF5Piece(unsigned next_delta);
94
95 unsigned delta() const;
96
97 unsigned short dsetname_len;
98 const char *dsetname() const;
99
102 int dim_order[N];
104
105 const Instruction *next() const;
106 };
107
108 }; // namespace PieceLookup
109
111 public:
112 ExternalHDF5Resource(const std::string &_filename, bool _read_only);
113
114 virtual bool satisfies(const InstanceLayoutGeneric &layout) const;
115
116 // returns the suggested memory in which this resource should be created
118
119 virtual ExternalInstanceResource *clone(void) const;
120
121 template <typename S>
122 bool serialize(S &serializer) const;
123
124 template <typename S>
126
127 protected:
129
133
134 virtual void print(std::ostream &os) const;
135
136 public:
137 std::string filename;
139 };
140
141}; // namespace Realm
142
143#include "realm/hdf5/hdf5_access.inl"
144
145#endif // ifndef REALM_HDF5_ACCESS_H
Definition hdf5_access.h:110
static ExternalInstanceResource * deserialize_new(S &deserializer)
virtual ExternalInstanceResource * clone(void) const
virtual bool satisfies(const InstanceLayoutGeneric &layout) const
bool serialize(S &serializer) const
ExternalHDF5Resource(const std::string &_filename, bool _read_only)
bool read_only
Definition hdf5_access.h:138
std::string filename
Definition hdf5_access.h:137
Memory suggested_memory() const
static Serialization::PolymorphicSerdezSubclass< ExternalInstanceResource, ExternalHDF5Resource > serdez_subclass
Definition hdf5_access.h:132
virtual void print(std::ostream &os) const
Definition instance.h:405
Definition hdf5_access.h:54
virtual size_t calculate_offset(const Point< N, T > &p) const
virtual void print(std::ostream &os) const
bool serialize(S &serializer) const
virtual void relocate(size_t base_offset)
virtual PieceLookup::Instruction * create_lookup_inst(void *ptr, unsigned next_delta) const
static InstanceLayoutPiece< N, T > * deserialize_new(S &deserializer)
static Serialization::PolymorphicSerdezSubclass< InstanceLayoutPiece< N, T >, HDF5LayoutPiece< N, T > > serdez_subclass
Definition hdf5_access.h:75
virtual size_t lookup_inst_size() const
virtual InstanceLayoutPiece< N, T > * clone(void) const
Definition inst_layout.h:164
Definition inst_layout.h:289
Definition memory.h:33
#define REALM_PUBLIC_API
Definition compiler_support.h:217
unsigned char LayoutType
Definition inst_layout.h:256
unsigned char Opcode
Definition inst_layout.h:121
Definition activemsg.h:38
unsigned long long hdf5_size_t
Definition hdf5_access.h:31
Definition hdf5_access.h:40
std::vector< int > dim_order
Definition hdf5_access.h:48
bool read_only
Definition hdf5_access.h:49
std::string dsetname
Definition hdf5_access.h:41
std::vector< hdf5_size_t > offset
Definition hdf5_access.h:44
Definition hdf5_access.h:90
Point< N, hdf5_size_t > offset
Definition hdf5_access.h:101
unsigned short dsetname_len
Definition hdf5_access.h:97
bool read_only
Definition hdf5_access.h:103
const char * dsetname() const
const Instruction * next() const
int dim_order[N]
Definition hdf5_access.h:102
Rect< N, T > bounds
Definition hdf5_access.h:100
HDF5Piece(unsigned next_delta)
Definition inst_layout.h:131
Definition point.h:55
Definition point.h:143