Legion Runtime
Loading...
Searching...
No Matches
data.h
Go to the documentation of this file.
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
24#include "legion/api/types.h"
25
26namespace Legion {
27
35 class IndexSpace {
36 public:
37 static const IndexSpace NO_SPACE;
38 protected:
39 // Only the runtime should be allowed to make these
40 FRIEND_ALL_RUNTIME_CLASSES
41 IndexSpace(DistributedID id, IndexTreeID tid, TypeTag tag);
42 public:
43 IndexSpace(void);
44 public:
45 inline bool operator==(const IndexSpace& rhs) const;
46 inline bool operator!=(const IndexSpace& rhs) const;
47 inline bool operator<(const IndexSpace& rhs) const;
48 inline bool operator>(const IndexSpace& rhs) const;
49 inline std::size_t hash(void) const;
50 inline DistributedID get_id(bool filter = true) const;
51 inline IndexTreeID get_tree_id(void) const { return tid; }
52 inline bool exists(void) const { return (did != 0); }
53 inline TypeTag get_type_tag(void) const { return type_tag; }
54 inline int get_dim(void) const;
55 bool valid(void) const;
56 protected:
57 friend std::ostream& operator<<(std::ostream& os, const IndexSpace& is);
58 DistributedID did;
59 IndexTreeID tid;
60 TypeTag type_tag;
61 };
62
69 template<int DIM, typename COORD_T = coord_t>
70 class IndexSpaceT : public IndexSpace {
71 private:
72 static_assert(DIM > 0, "DIM must be positive");
73 static_assert(DIM <= LEGION_MAX_DIM, "DIM must be <= LEGION_MAX_DIM");
74 static_assert(std::is_integral<COORD_T>::value, "must be integral type");
75 protected:
76 // Only the runtime should be allowed to make these
77 FRIEND_ALL_RUNTIME_CLASSES
78 IndexSpaceT(DistributedID id, IndexTreeID tid);
79 public:
80 IndexSpaceT(void);
81 explicit IndexSpaceT(const IndexSpace& rhs);
82 public:
83 inline IndexSpaceT& operator=(const IndexSpace& rhs);
84 };
85
93 public:
94 static const IndexPartition NO_PART;
95 protected:
96 // Only the runtime should be allowed to make these
97 FRIEND_ALL_RUNTIME_CLASSES
98 IndexPartition(DistributedID id, IndexTreeID tid, TypeTag tag);
99 public:
100 IndexPartition(void);
101 public:
102 inline bool operator==(const IndexPartition& rhs) const;
103 inline bool operator!=(const IndexPartition& rhs) const;
104 inline bool operator<(const IndexPartition& rhs) const;
105 inline bool operator>(const IndexPartition& rhs) const;
106 inline std::size_t hash(void) const;
107 inline DistributedID get_id(bool filter = true) const;
108 inline IndexTreeID get_tree_id(void) const { return tid; }
109 inline bool exists(void) const { return (did != 0); }
110 inline TypeTag get_type_tag(void) const { return type_tag; }
111 inline int get_dim(void) const;
112 bool valid(void) const;
113 protected:
114 friend std::ostream& operator<<(std::ostream& os, const IndexPartition& ip);
115 DistributedID did;
116 IndexTreeID tid;
117 TypeTag type_tag;
118 };
119
126 template<int DIM, typename COORD_T = coord_t>
128 private:
129 static_assert(DIM > 0, "DIM must be positive");
130 static_assert(DIM <= LEGION_MAX_DIM, "DIM must be <= LEGION_MAX_DIM");
131 static_assert(std::is_integral<COORD_T>::value, "must be integral type");
132 protected:
133 // Only the runtime should be allowed to make these
134 FRIEND_ALL_RUNTIME_CLASSES
135 IndexPartitionT(DistributedID id, IndexTreeID tid);
136 public:
137 IndexPartitionT(void);
138 explicit IndexPartitionT(const IndexPartition& rhs);
139 public:
140 inline IndexPartitionT& operator=(const IndexPartition& rhs);
141 };
142
153 public:
154 static const FieldSpace NO_SPACE;
155 protected:
156 // Only the runtime should be allowed to make these
157 FRIEND_ALL_RUNTIME_CLASSES
158 FieldSpace(DistributedID id);
159 public:
160 FieldSpace(void);
161 public:
162 inline bool operator==(const FieldSpace& rhs) const;
163 inline bool operator!=(const FieldSpace& rhs) const;
164 inline bool operator<(const FieldSpace& rhs) const;
165 inline bool operator>(const FieldSpace& rhs) const;
166 inline std::size_t hash(void) const;
167 inline DistributedID get_id(bool filter = true) const;
168 inline bool exists(void) const { return (did != 0); }
169 bool valid(void) const;
170 private:
171 friend std::ostream& operator<<(std::ostream& os, const FieldSpace& fs);
172 DistributedID did;
173 };
174
190 public:
192 protected:
193 // Only the runtime should be allowed to make these
194 FRIEND_ALL_RUNTIME_CLASSES
195 LogicalRegion(DistributedID tid, IndexSpace index, FieldSpace field);
196 public:
197 LogicalRegion(void);
198 public:
199 inline bool operator==(const LogicalRegion& rhs) const;
200 inline bool operator!=(const LogicalRegion& rhs) const;
201 inline bool operator<(const LogicalRegion& rhs) const;
202 std::size_t hash(void) const;
203 public:
204 inline IndexSpace get_index_space(void) const { return index_space; }
205 inline FieldSpace get_field_space(void) const { return field_space; }
206 inline RegionTreeID get_tree_id(bool filter = true) const;
207 inline bool exists(void) const { return (tree_did != 0); }
208 inline TypeTag get_type_tag(void) const
209 {
210 return index_space.get_type_tag();
211 }
212 inline int get_dim(void) const { return index_space.get_dim(); }
213 bool valid(void) const;
214 protected:
215 friend std::ostream& operator<<(std::ostream& os, const LogicalRegion& lr);
216 // These are private so the user can't just arbitrarily change them
217 DistributedID tree_did;
218 IndexSpace index_space;
219 FieldSpace field_space;
220 };
221
228 template<int DIM, typename COORD_T = coord_t>
230 private:
231 static_assert(DIM > 0, "DIM must be positive");
232 static_assert(DIM <= LEGION_MAX_DIM, "DIM must be <= LEGION_MAX_DIM");
233 static_assert(std::is_integral<COORD_T>::value, "must be integral type");
234 protected:
235 // Only the runtime should be allowed to make these
236 FRIEND_ALL_RUNTIME_CLASSES
237 LogicalRegionT(DistributedID tid, IndexSpace index, FieldSpace field);
238 public:
239 LogicalRegionT(void);
240 explicit LogicalRegionT(const LogicalRegion& rhs);
241 public:
242 inline LogicalRegionT& operator=(const LogicalRegion& rhs);
243 };
244
261 public:
263 protected:
264 // Only the runtime should be allowed to make these
265 FRIEND_ALL_RUNTIME_CLASSES
266 LogicalPartition(DistributedID tid, IndexPartition pid, FieldSpace field);
267 public:
268 LogicalPartition(void);
269 public:
270 inline bool operator==(const LogicalPartition& rhs) const;
271 inline bool operator!=(const LogicalPartition& rhs) const;
272 inline bool operator<(const LogicalPartition& rhs) const;
273 std::size_t hash(void) const;
274 public:
275 inline IndexPartition get_index_partition(void) const
276 {
277 return index_partition;
278 }
279 inline FieldSpace get_field_space(void) const { return field_space; }
280 inline RegionTreeID get_tree_id(bool filter = true) const;
281 inline bool exists(void) const { return (tree_did != 0); }
282 inline TypeTag get_type_tag(void) const
283 {
284 return index_partition.get_type_tag();
285 }
286 inline int get_dim(void) const { return index_partition.get_dim(); }
287 bool valid(void) const;
288 protected:
289 friend std::ostream& operator<<(
290 std::ostream& os, const LogicalPartition& lp);
291 // These are private so the user can't just arbitrary change them
292 DistributedID tree_did;
293 IndexPartition index_partition;
294 FieldSpace field_space;
295 };
296
303 template<int DIM, typename COORD_T = coord_t>
305 private:
306 static_assert(DIM > 0, "DIM must be positive");
307 static_assert(DIM <= LEGION_MAX_DIM, "DIM must be <= LEGION_MAX_DIM");
308 static_assert(std::is_integral<COORD_T>::value, "must be integral type");
309 protected:
310 // Only the runtime should be allowed to make these
311 FRIEND_ALL_RUNTIME_CLASSES
312 LogicalPartitionT(DistributedID tid, IndexPartition pid, FieldSpace field);
313 public:
314 LogicalPartitionT(void);
315 explicit LogicalPartitionT(const LogicalPartition& rhs);
316 public:
317 inline LogicalPartitionT& operator=(const LogicalPartition& rhs);
318 };
319
337 public:
338 FieldAllocator(void);
339 FieldAllocator(const FieldAllocator& allocator);
340 FieldAllocator(FieldAllocator&& allocator) noexcept;
341 ~FieldAllocator(void);
342 protected:
343 FRIEND_ALL_RUNTIME_CLASSES
344 // Only the Runtime should be able to make these
345 FieldAllocator(Internal::FieldAllocatorImpl* impl);
346 public:
347 FieldAllocator& operator=(const FieldAllocator& allocator);
348 FieldAllocator& operator=(FieldAllocator&& allocator) noexcept;
349 inline bool operator<(const FieldAllocator& rhs) const;
350 inline bool operator==(const FieldAllocator& rhs) const;
351 inline bool exists(void) const { return (impl != nullptr); }
352 public:
354
374 size_t field_size, FieldID desired_fieldid = LEGION_AUTO_GENERATE_ID,
375 CustomSerdezID serdez_id = 0, bool local_field = false,
376 const char* provenance = nullptr);
377 FieldID allocate_field(
378 const Future& field_size,
379 FieldID desired_fieldid = LEGION_AUTO_GENERATE_ID,
380 CustomSerdezID serdez_id = 0, bool local_field = false,
381 const char* provenance = nullptr);
383
391 LEGION_DEPRECATED(
392 "We are considering removing support for freeing fields"
393 "in a future Legion release. Please contact the Legion developer's "
394 "list if field deletion is important for your application.")
396 FieldID fid, const bool unordered = false,
397 const char* provenance = nullptr);
398
407 size_t field_size, FieldID desired_fieldid = LEGION_AUTO_GENERATE_ID,
408 CustomSerdezID serdez_id = 0, const char* provenance = nullptr);
410
428 const std::vector<size_t>& field_sizes,
429 std::vector<FieldID>& resulting_fields, CustomSerdezID serdez_id = 0,
430 bool local_fields = false, const char* provenance = nullptr);
431 void allocate_fields(
432 const std::vector<Future>& field_sizes,
433 std::vector<FieldID>& resulting_fields, CustomSerdezID serdez_id = 0,
434 bool local_fields = false, const char* provenance = nullptr);
436
444 LEGION_DEPRECATED(
445 "We are considering removing support for freeing fields"
446 "in a future Legion release. Please contact the Legion developer's "
447 "list if field deletion is important for your application.")
449 const std::set<FieldID>& to_free, const bool unordered = false,
450 const char* provenance = nullptr);
459 const std::vector<size_t>& field_sizes,
460 std::vector<FieldID>& resulting_fields, CustomSerdezID serdez_id = 0,
461 const char* provenance = nullptr);
466 private:
467 Internal::FieldAllocatorImpl* impl;
468 };
469
470} // namespace Legion
471
472#include "legion/api/data.inl"
473
474#endif // __LEGION_DATA_H__
Definition data.h:336
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:152
static const FieldSpace NO_SPACE
Definition data.h:154
Definition future.h:50
Definition data.h:92
Definition data.h:127
Definition data.h:35
static const IndexSpace NO_SPACE
Definition data.h:37
Definition data.h:70
Definition data.h:260
static const LogicalPartition NO_PART
Definition data.h:262
Definition data.h:304
Definition data.h:189
static const LogicalRegion NO_REGION
Definition data.h:191
Definition data.h:229
Definition types.h:343
Definition accessors.h:29