Legion Runtime
Loading...
Searching...
No Matches
data.h
1/* Copyright 2026 Stanford University, NVIDIA Corporation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef __LEGION_DATA_H__
17#define __LEGION_DATA_H__
18
19#include "legion/api/types.h"
20
21namespace Legion {
22
30 class IndexSpace {
31 public:
32 static const IndexSpace NO_SPACE;
33 protected:
34 // Only the runtime should be allowed to make these
35 FRIEND_ALL_RUNTIME_CLASSES
36 IndexSpace(DistributedID id, IndexTreeID tid, TypeTag tag);
37 public:
38 IndexSpace(void);
39 public:
40 inline bool operator==(const IndexSpace& rhs) const;
41 inline bool operator!=(const IndexSpace& rhs) const;
42 inline bool operator<(const IndexSpace& rhs) const;
43 inline bool operator>(const IndexSpace& rhs) const;
44 inline std::size_t hash(void) const;
45 inline DistributedID get_id(bool filter = true) const;
46 inline IndexTreeID get_tree_id(void) const { return tid; }
47 inline bool exists(void) const { return (did != 0); }
48 inline TypeTag get_type_tag(void) const { return type_tag; }
49 inline int get_dim(void) const;
50 bool valid(void) const;
51 protected:
52 friend std::ostream& operator<<(std::ostream& os, const IndexSpace& is);
53 DistributedID did;
54 IndexTreeID tid;
55 TypeTag type_tag;
56 };
57
64 template<int DIM, typename COORD_T = coord_t>
65 class IndexSpaceT : public IndexSpace {
66 private:
67 static_assert(DIM > 0, "DIM must be positive");
68 static_assert(DIM <= LEGION_MAX_DIM, "DIM must be <= LEGION_MAX_DIM");
69 static_assert(std::is_integral<COORD_T>::value, "must be integral type");
70 protected:
71 // Only the runtime should be allowed to make these
72 FRIEND_ALL_RUNTIME_CLASSES
73 IndexSpaceT(DistributedID id, IndexTreeID tid);
74 public:
75 IndexSpaceT(void);
76 explicit IndexSpaceT(const IndexSpace& rhs);
77 public:
78 inline IndexSpaceT& operator=(const IndexSpace& rhs);
79 };
80
88 public:
89 static const IndexPartition NO_PART;
90 protected:
91 // Only the runtime should be allowed to make these
92 FRIEND_ALL_RUNTIME_CLASSES
93 IndexPartition(DistributedID id, IndexTreeID tid, TypeTag tag);
94 public:
95 IndexPartition(void);
96 public:
97 inline bool operator==(const IndexPartition& rhs) const;
98 inline bool operator!=(const IndexPartition& rhs) const;
99 inline bool operator<(const IndexPartition& rhs) const;
100 inline bool operator>(const IndexPartition& rhs) const;
101 inline std::size_t hash(void) const;
102 inline DistributedID get_id(bool filter = true) const;
103 inline IndexTreeID get_tree_id(void) const { return tid; }
104 inline bool exists(void) const { return (did != 0); }
105 inline TypeTag get_type_tag(void) const { return type_tag; }
106 inline int get_dim(void) const;
107 bool valid(void) const;
108 protected:
109 friend std::ostream& operator<<(std::ostream& os, const IndexPartition& ip);
110 DistributedID did;
111 IndexTreeID tid;
112 TypeTag type_tag;
113 };
114
121 template<int DIM, typename COORD_T = coord_t>
123 private:
124 static_assert(DIM > 0, "DIM must be positive");
125 static_assert(DIM <= LEGION_MAX_DIM, "DIM must be <= LEGION_MAX_DIM");
126 static_assert(std::is_integral<COORD_T>::value, "must be integral type");
127 protected:
128 // Only the runtime should be allowed to make these
129 FRIEND_ALL_RUNTIME_CLASSES
130 IndexPartitionT(DistributedID id, IndexTreeID tid);
131 public:
132 IndexPartitionT(void);
133 explicit IndexPartitionT(const IndexPartition& rhs);
134 public:
135 inline IndexPartitionT& operator=(const IndexPartition& rhs);
136 };
137
148 public:
149 static const FieldSpace NO_SPACE;
150 protected:
151 // Only the runtime should be allowed to make these
152 FRIEND_ALL_RUNTIME_CLASSES
153 FieldSpace(DistributedID id);
154 public:
155 FieldSpace(void);
156 public:
157 inline bool operator==(const FieldSpace& rhs) const;
158 inline bool operator!=(const FieldSpace& rhs) const;
159 inline bool operator<(const FieldSpace& rhs) const;
160 inline bool operator>(const FieldSpace& rhs) const;
161 inline std::size_t hash(void) const;
162 inline DistributedID get_id(bool filter = true) const;
163 inline bool exists(void) const { return (did != 0); }
164 bool valid(void) const;
165 private:
166 friend std::ostream& operator<<(std::ostream& os, const FieldSpace& fs);
167 DistributedID did;
168 };
169
185 public:
187 protected:
188 // Only the runtime should be allowed to make these
189 FRIEND_ALL_RUNTIME_CLASSES
190 LogicalRegion(DistributedID tid, IndexSpace index, FieldSpace field);
191 public:
192 LogicalRegion(void);
193 public:
194 inline bool operator==(const LogicalRegion& rhs) const;
195 inline bool operator!=(const LogicalRegion& rhs) const;
196 inline bool operator<(const LogicalRegion& rhs) const;
197 std::size_t hash(void) const;
198 public:
199 inline IndexSpace get_index_space(void) const { return index_space; }
200 inline FieldSpace get_field_space(void) const { return field_space; }
201 inline RegionTreeID get_tree_id(bool filter = true) const;
202 inline bool exists(void) const { return (tree_did != 0); }
203 inline TypeTag get_type_tag(void) const
204 {
205 return index_space.get_type_tag();
206 }
207 inline int get_dim(void) const { return index_space.get_dim(); }
208 bool valid(void) const;
209 protected:
210 friend std::ostream& operator<<(std::ostream& os, const LogicalRegion& lr);
211 // These are private so the user can't just arbitrarily change them
212 DistributedID tree_did;
213 IndexSpace index_space;
214 FieldSpace field_space;
215 };
216
223 template<int DIM, typename COORD_T = coord_t>
225 private:
226 static_assert(DIM > 0, "DIM must be positive");
227 static_assert(DIM <= LEGION_MAX_DIM, "DIM must be <= LEGION_MAX_DIM");
228 static_assert(std::is_integral<COORD_T>::value, "must be integral type");
229 protected:
230 // Only the runtime should be allowed to make these
231 FRIEND_ALL_RUNTIME_CLASSES
232 LogicalRegionT(DistributedID tid, IndexSpace index, FieldSpace field);
233 public:
234 LogicalRegionT(void);
235 explicit LogicalRegionT(const LogicalRegion& rhs);
236 public:
237 inline LogicalRegionT& operator=(const LogicalRegion& rhs);
238 };
239
256 public:
258 protected:
259 // Only the runtime should be allowed to make these
260 FRIEND_ALL_RUNTIME_CLASSES
261 LogicalPartition(DistributedID tid, IndexPartition pid, FieldSpace field);
262 public:
263 LogicalPartition(void);
264 public:
265 inline bool operator==(const LogicalPartition& rhs) const;
266 inline bool operator!=(const LogicalPartition& rhs) const;
267 inline bool operator<(const LogicalPartition& rhs) const;
268 std::size_t hash(void) const;
269 public:
270 inline IndexPartition get_index_partition(void) const
271 {
272 return index_partition;
273 }
274 inline FieldSpace get_field_space(void) const { return field_space; }
275 inline RegionTreeID get_tree_id(bool filter = true) const;
276 inline bool exists(void) const { return (tree_did != 0); }
277 inline TypeTag get_type_tag(void) const
278 {
279 return index_partition.get_type_tag();
280 }
281 inline int get_dim(void) const { return index_partition.get_dim(); }
282 bool valid(void) const;
283 protected:
284 friend std::ostream& operator<<(
285 std::ostream& os, const LogicalPartition& lp);
286 // These are private so the user can't just arbitrary change them
287 DistributedID tree_did;
288 IndexPartition index_partition;
289 FieldSpace field_space;
290 };
291
298 template<int DIM, typename COORD_T = coord_t>
300 private:
301 static_assert(DIM > 0, "DIM must be positive");
302 static_assert(DIM <= LEGION_MAX_DIM, "DIM must be <= LEGION_MAX_DIM");
303 static_assert(std::is_integral<COORD_T>::value, "must be integral type");
304 protected:
305 // Only the runtime should be allowed to make these
306 FRIEND_ALL_RUNTIME_CLASSES
307 LogicalPartitionT(DistributedID tid, IndexPartition pid, FieldSpace field);
308 public:
309 LogicalPartitionT(void);
310 explicit LogicalPartitionT(const LogicalPartition& rhs);
311 public:
312 inline LogicalPartitionT& operator=(const LogicalPartition& rhs);
313 };
314
332 public:
333 FieldAllocator(void);
334 FieldAllocator(const FieldAllocator& allocator);
335 FieldAllocator(FieldAllocator&& allocator) noexcept;
336 ~FieldAllocator(void);
337 protected:
338 FRIEND_ALL_RUNTIME_CLASSES
339 // Only the Runtime should be able to make these
340 FieldAllocator(Internal::FieldAllocatorImpl* impl);
341 public:
342 FieldAllocator& operator=(const FieldAllocator& allocator);
343 FieldAllocator& operator=(FieldAllocator&& allocator) noexcept;
344 inline bool operator<(const FieldAllocator& rhs) const;
345 inline bool operator==(const FieldAllocator& rhs) const;
346 inline bool exists(void) const { return (impl != nullptr); }
347 public:
349
369 size_t field_size, FieldID desired_fieldid = LEGION_AUTO_GENERATE_ID,
370 CustomSerdezID serdez_id = 0, bool local_field = false,
371 const char* provenance = nullptr);
372 FieldID allocate_field(
373 const Future& field_size,
374 FieldID desired_fieldid = LEGION_AUTO_GENERATE_ID,
375 CustomSerdezID serdez_id = 0, bool local_field = false,
376 const char* provenance = nullptr);
378
386 LEGION_DEPRECATED(
387 "We are considering removing support for freeing fields"
388 "in a future Legion release. Please contact the Legion developer's "
389 "list if field deletion is important for your application.")
391 FieldID fid, const bool unordered = false,
392 const char* provenance = nullptr);
393
402 size_t field_size, FieldID desired_fieldid = LEGION_AUTO_GENERATE_ID,
403 CustomSerdezID serdez_id = 0, const char* provenance = nullptr);
405
423 const std::vector<size_t>& field_sizes,
424 std::vector<FieldID>& resulting_fields, CustomSerdezID serdez_id = 0,
425 bool local_fields = false, const char* provenance = nullptr);
426 void allocate_fields(
427 const std::vector<Future>& field_sizes,
428 std::vector<FieldID>& resulting_fields, CustomSerdezID serdez_id = 0,
429 bool local_fields = false, const char* provenance = nullptr);
431
439 LEGION_DEPRECATED(
440 "We are considering removing support for freeing fields"
441 "in a future Legion release. Please contact the Legion developer's "
442 "list if field deletion is important for your application.")
444 const std::set<FieldID>& to_free, const bool unordered = false,
445 const char* provenance = nullptr);
454 const std::vector<size_t>& field_sizes,
455 std::vector<FieldID>& resulting_fields, CustomSerdezID serdez_id = 0,
456 const char* provenance = nullptr);
461 private:
462 Internal::FieldAllocatorImpl* impl;
463 };
464
465} // namespace Legion
466
467#include "legion/api/data.inl"
468
469#endif // __LEGION_DATA_H__
Definition data.h:331
void free_fields(const std::set< FieldID > &to_free, const bool unordered=false, const char *provenance=nullptr)
void free_field(FieldID fid, const bool unordered=false, const char *provenance=nullptr)
FieldID allocate_field(size_t field_size, FieldID desired_fieldid=LEGION_AUTO_GENERATE_ID, CustomSerdezID serdez_id=0, bool local_field=false, const char *provenance=nullptr)
FieldSpace get_field_space(void) const
void allocate_local_fields(const std::vector< size_t > &field_sizes, std::vector< FieldID > &resulting_fields, CustomSerdezID serdez_id=0, const char *provenance=nullptr)
void allocate_fields(const std::vector< size_t > &field_sizes, std::vector< FieldID > &resulting_fields, CustomSerdezID serdez_id=0, bool local_fields=false, const char *provenance=nullptr)
FieldID allocate_local_field(size_t field_size, FieldID desired_fieldid=LEGION_AUTO_GENERATE_ID, CustomSerdezID serdez_id=0, const char *provenance=nullptr)
Definition data.h:147
static const FieldSpace NO_SPACE
Definition data.h:149
Definition future.h:45
Definition data.h:87
Definition data.h:122
Definition data.h:30
static const IndexSpace NO_SPACE
Definition data.h:32
Definition data.h:65
Definition data.h:255
static const LogicalPartition NO_PART
Definition data.h:257
Definition data.h:299
Definition data.h:184
static const LogicalRegion NO_REGION
Definition data.h:186
Definition data.h:224
Definition types.h:334