Legion Runtime
Loading...
Searching...
No Matches
functors.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_FUNCTORS_H__
17#define __LEGION_FUNCTORS_H__
18
19#include "legion/api/geometry.h"
20
21namespace Legion {
22
41 public:
44 virtual ~ProjectionFunctor(void);
45 public:
63 const Mappable* mappable, unsigned index, LogicalRegion upper_bound,
64 const DomainPoint& point);
74 const Mappable* mappable, unsigned index, LogicalPartition upper_bound,
75 const DomainPoint& point);
76
88 LogicalRegion upper_bound, const DomainPoint& point,
89 const Domain& launch_domain);
90
102 LogicalPartition upper_bound, const DomainPoint& point,
103 const Domain& launch_domain);
104
118 LogicalRegion upper_bound, const DomainPoint& point,
119 const Domain& launch_domain, const void* args, size_t size);
120
134 LogicalPartition upper_bound, const DomainPoint& point,
135 const Domain& launch_domain, const void* args, size_t size);
136
148 LEGION_DEPRECATED(
149 "The interface for projection functors has been "
150 "updated. Please use the new 'project' methods.")
152 Context ctx, Task* task, unsigned index, LogicalRegion upper_bound,
153 const DomainPoint& point);
165 LEGION_DEPRECATED(
166 "The interface for projection functors has been "
167 "updated. Please use the new 'project' methods.")
169 Context ctx, Task* task, unsigned index, LogicalPartition upper_bound,
170 const DomainPoint& point);
172
183 virtual void invert(
184 LogicalRegion region, LogicalRegion upper_bound,
185 const Domain& launch_domain, std::vector<DomainPoint>& ordered_points);
186 virtual void invert(
187 LogicalRegion region, LogicalPartition upper_bound,
188 const Domain& launch_domain, std::vector<DomainPoint>& ordered_points);
190
192
212 virtual bool is_complete(
213 LogicalRegion upper_bound, const Domain& launch_domain);
214 virtual bool is_complete(
215 LogicalPartition upper_bound, const Domain& launch_domain);
216 virtual bool is_complete(
217 Mappable* mappable, unsigned index, LogicalRegion upper_bound,
218 const Domain& launch_domain);
219 virtual bool is_complete(
220 Mappable* mappable, unsigned index, LogicalPartition upper_bound,
221 const Domain& launch_domain);
223
230 virtual bool is_exclusive(void) const { return false; }
231
232 /*
233 * Indicate whether this is a functional projection
234 * functor or whether it depends on the operation being
235 * launched. This will determine which project method
236 * is invoked by the runtime.
237 */
238 virtual bool is_functional(void) const { return false; }
239
245 virtual bool is_invertible(void) const { return false; }
246
258 virtual unsigned get_depth(void) const = 0;
259 private:
260 friend class Internal::Runtime;
261 // For pre-registered projection functors the runtime will
262 // use this to initialize the runtime pointer
263 inline void set_runtime(Runtime* rt) { runtime = rt; }
264 protected:
265 Runtime* runtime;
266 };
267
282 public:
283 ShardingFunctor(void);
284 virtual ~ShardingFunctor(void);
285 public:
286 // Indicate whether this functor wants to use the ShardID or
287 // DomainPoint versions of these methods
288 virtual bool use_points(void) const { return false; }
289 public:
290 // The ShardID version of this method
291 virtual ShardID shard(
292 const DomainPoint& index_point, const Domain& index_domain,
293 const size_t total_shards);
294 // The DomainPoint version of this method
295 virtual DomainPoint shard_points(
296 const DomainPoint& index_point, const Domain& index_domain,
297 const std::vector<DomainPoint>& shard_points,
298 const Domain& shard_domain);
299 public:
300 virtual bool is_invertible(void) const { return false; }
301 // The ShardID version of this method
302 virtual void invert(
303 ShardID shard, const Domain& sharding_domain,
304 const Domain& index_domain, const size_t total_shards,
305 std::vector<DomainPoint>& points);
306 // The DomainPoint version of this method
307 virtual void invert_points(
308 const DomainPoint& shard_point,
309 const std::vector<DomainPoint>& shard_points,
310 const Domain& shard_domain, const Domain& index_domain,
311 const Domain& sharding_domain, std::vector<DomainPoint>& index_points);
312 };
313
324 public:
326 virtual ~ConcurrentColoringFunctor(void);
327 public:
328 virtual Color color(
329 const DomainPoint& index_point, const Domain& index_domain) = 0;
330 public:
331 // You can optionally implement these methods for better performance,
332 // but they are not required for correctness. If 'has_max_color'
333 // returns 'true' then you must implement the 'max_color' method.
334 virtual bool supports_max_color(void) { return false; }
335 virtual Color max_color(const Domain& index_domain)
336 {
337 return std::numeric_limits<Color>::max();
338 }
339 };
340
357 public:
358 virtual ~FutureFunctor(void) { }
359 public:
360 virtual const void* callback_get_future(
361 size_t& size, bool& owned,
362 const Realm::ExternalInstanceResource*& resource,
363 void (*&freefunc)(const Realm::ExternalInstanceResource&),
364 const void*& metadata, size_t& metasize) = 0;
365 virtual void callback_release_future(void) = 0;
366 };
367
377 public:
378 virtual ~PointTransformFunctor(void) { }
379 public:
380 virtual bool is_invertible(void) const { return false; }
381 // Transform a point from the domain into a point in the range
382 virtual DomainPoint transform_point(
383 const DomainPoint& point, const Domain& domain,
384 const Domain& range) = 0;
385 // Invert a point from range and convert it into a point in the domain
386 // This is only called if is_invertible returns true
387 virtual DomainPoint invert_point(
388 const DomainPoint& point, const Domain& domain, const Domain& range)
389 {
390 return DomainPoint();
391 }
392 };
393
394} // namespace Legion
395
396#endif // __LEGION_FUNCTORS_H__
Definition functors.h:323
Definition geometry.h:154
Definition geometry.h:29
Definition functors.h:356
Definition data.h:255
Definition data.h:184
Definition mapping.h:37
Definition functors.h:376
Definition functors.h:40
virtual unsigned get_depth(void) const =0
virtual LogicalRegion project(const Mappable *mappable, unsigned index, LogicalPartition upper_bound, const DomainPoint &point)
virtual void invert(LogicalRegion region, LogicalRegion upper_bound, const Domain &launch_domain, std::vector< DomainPoint > &ordered_points)
virtual LogicalRegion project(LogicalPartition upper_bound, const DomainPoint &point, const Domain &launch_domain, const void *args, size_t size)
virtual LogicalRegion project(const Mappable *mappable, unsigned index, LogicalRegion upper_bound, const DomainPoint &point)
virtual LogicalRegion project(LogicalRegion upper_bound, const DomainPoint &point, const Domain &launch_domain)
virtual bool is_exclusive(void) const
Definition functors.h:230
virtual bool is_complete(LogicalRegion upper_bound, const Domain &launch_domain)
virtual bool is_invertible(void) const
Definition functors.h:245
virtual LogicalRegion project(LogicalPartition upper_bound, const DomainPoint &point, const Domain &launch_domain)
virtual LogicalRegion project(LogicalRegion upper_bound, const DomainPoint &point, const Domain &launch_domain, const void *args, size_t size)
Definition runtime.h:103
Definition functors.h:281
Definition mapping.h:107