Legion Runtime
Loading...
Searching...
No Matches
registrars.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_REGISTRARS_H__
17#define __LEGION_REGISTRARS_H__
18
25#include "legion/api/data.h"
26
27namespace Legion {
28
40 public:
43 FieldSpace handle, const char* layout_name = nullptr);
44 public:
45 inline LayoutConstraintRegistrar& add_constraint(
46 const SpecializedConstraint& constraint);
47 inline LayoutConstraintRegistrar& add_constraint(
48 const MemoryConstraint& constraint);
49 inline LayoutConstraintRegistrar& add_constraint(
50 const OrderingConstraint& constraint);
51 inline LayoutConstraintRegistrar& add_constraint(
52 const TilingConstraint& constraint);
53 inline LayoutConstraintRegistrar& add_constraint(
54 const FieldConstraint& constraint);
55 inline LayoutConstraintRegistrar& add_constraint(
56 const DimensionConstraint& constraint);
57 inline LayoutConstraintRegistrar& add_constraint(
58 const AlignmentConstraint& constraint);
59 inline LayoutConstraintRegistrar& add_constraint(
60 const OffsetConstraint& constraint);
61 inline LayoutConstraintRegistrar& add_constraint(
62 const PointerConstraint& constraint);
63 inline LayoutConstraintRegistrar& add_constraint(
64 const PaddingConstraint& constraint);
65 public:
66 FieldSpace handle;
67 LayoutConstraintSet layout_constraints;
68 const char* layout_name;
69 };
70
76 struct PoolBounds {
77 public:
78 PoolBounds(UnboundPoolScope u, size_t s = 0)
79 : size(s), alignment(0), scope(u)
80 { }
81 PoolBounds(size_t s = 0, uint32_t a = 16)
82 : size(s), alignment(a), scope(LEGION_BOUNDED_POOL)
83 { }
84 PoolBounds(const PoolBounds&) = default;
85 PoolBounds(PoolBounds&&) = default;
86 PoolBounds& operator=(const PoolBounds&) = default;
87 PoolBounds& operator=(PoolBounds&&) = default;
88 inline bool is_bounded(void) const
89 {
90 return (scope == LEGION_BOUNDED_POOL);
91 }
92 public:
93 // If this is a bounded pool then size is the number of bytes in the pool
94 // If it is an unbounded pool then size is how many free bytes the pool
95 // is allowed to keep locally from freed instances without returning
96 // them back to the Realm allocator, zero means that all freed instances
97 // are immediately sent back to the Realm allocator
98 size_t size; // upper bound of the pool in bytes
99 uint32_t alignment; // maximum alignment supported
100 UnboundPoolScope scope; // scope for unbound pools
101 };
102
112 public:
115 TaskID task_id, bool global = true, const char* variant_name = nullptr);
117 TaskID task_id, const char* variant_name, bool global = true);
118 public: // Add execution constraints
119 inline TaskVariantRegistrar& add_constraint(
120 const ISAConstraint& constraint);
121 inline TaskVariantRegistrar& add_constraint(
122 const ProcessorConstraint& constraint);
123 inline TaskVariantRegistrar& add_constraint(
124 const ResourceConstraint& constraint);
125 inline TaskVariantRegistrar& add_constraint(
126 const LaunchConstraint& constraint);
127 inline TaskVariantRegistrar& add_constraint(
128 const ColocationConstraint& constraint);
129 public: // Add layout constraint sets
130 inline TaskVariantRegistrar& add_layout_constraint_set(
131 unsigned index, LayoutConstraintID desc);
132 public: // Set properties
133 inline void set_leaf(bool is_leaf = true);
134 inline void set_inner(bool is_inner = true);
135 inline void set_idempotent(bool is_idempotent = true);
136 inline void set_replicable(bool is_replicable = true);
137 inline void set_concurrent(bool is_concurrent = true);
138 inline void set_concurrent_barrier(bool needs_barrier = true);
139 public: // Generator Task IDs
140 inline void add_generator_task(TaskID tid);
141 public:
142 TaskID task_id;
143 bool global_registration;
144 const char* task_variant_name;
145 public: // constraints
146 ExecutionConstraintSet execution_constraints;
147 TaskLayoutConstraintSet layout_constraints;
148 public:
149 // If this is a leaf task variant then the application can
150 // request that the runtime preserve a pool in the memory of
151 // the corresponding kind with the closest affinity to the target
152 // processor for handling dynamic memory allocations during the
153 // execution of the task. Pool bounds can also be set to request
154 // an unbounded pool allocation. Note that requesting an unbound
155 // memory allocation will likely result in severe performance degradation.
156 // All these pool bounds are escaping meaning that allocations performed
157 // in the resulting pools can outlive the lifetime of the task.
158 std::map<Memory::Kind, PoolBounds> leaf_pool_bounds;
159 // If the leaf task wants to make pools for non-escaping allocations
160 // it can specify non-escaping leaf pool bounds. These must be
161 // concrete pools as unbounded pools are always escaping.
162 std::map<Memory::Kind, PoolBounds> non_escaping_leaf_pool_bounds;
163 public:
164 // TaskIDs for which this variant can serve as a generator
165 std::set<TaskID> generator_tasks;
166 public: // properties
167 bool leaf_variant;
168 bool inner_variant;
169 bool idempotent_variant;
170 bool replicable_variant;
171 bool concurrent_variant;
172 bool concurrent_barrier;
173 };
174
175} // namespace Legion
176
177#include "legion/api/registrars.inl"
178
179#endif // __LEGION_REGISTRARS_H__
Definition constraints.h:689
Definition constraints.h:202
Definition constraints.h:640
Definition constraints.h:240
Definition constraints.h:475
Definition data.h:152
Definition constraints.h:61
Definition constraints.h:167
Definition constraints.h:881
Definition constraints.h:422
Definition constraints.h:737
Definition constraints.h:538
Definition constraints.h:830
Definition constraints.h:783
Definition constraints.h:95
Definition constraints.h:132
Definition constraints.h:357
Definition constraints.h:942
Definition constraints.h:592
Definition accessors.h:29
Definition registrars.h:39
Definition registrars.h:76
Definition registrars.h:111