Legion Runtime
Loading...
Searching...
No Matches
functors.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_FUNCTORS_H__
17#define __LEGION_FUNCTORS_H__
18
24#include "legion/api/geometry.h"
25
26namespace Legion {
27
46 public:
49 virtual ~ProjectionFunctor(void);
50 public:
68 const Mappable* mappable, unsigned index, LogicalRegion upper_bound,
69 const DomainPoint& point);
79 const Mappable* mappable, unsigned index, LogicalPartition upper_bound,
80 const DomainPoint& point);
81
93 LogicalRegion upper_bound, const DomainPoint& point,
94 const Domain& launch_domain);
95
107 LogicalPartition upper_bound, const DomainPoint& point,
108 const Domain& launch_domain);
109
123 LogicalRegion upper_bound, const DomainPoint& point,
124 const Domain& launch_domain, const void* args, size_t size);
125
139 LogicalPartition upper_bound, const DomainPoint& point,
140 const Domain& launch_domain, const void* args, size_t size);
141
153 LEGION_DEPRECATED(
154 "The interface for projection functors has been "
155 "updated. Please use the new 'project' methods.")
157 Context ctx, Task* task, unsigned index, LogicalRegion upper_bound,
158 const DomainPoint& point);
170 LEGION_DEPRECATED(
171 "The interface for projection functors has been "
172 "updated. Please use the new 'project' methods.")
174 Context ctx, Task* task, unsigned index, LogicalPartition upper_bound,
175 const DomainPoint& point);
177
188 virtual void invert(
189 LogicalRegion region, LogicalRegion upper_bound,
190 const Domain& launch_domain, std::vector<DomainPoint>& ordered_points);
191 virtual void invert(
192 LogicalRegion region, LogicalPartition upper_bound,
193 const Domain& launch_domain, std::vector<DomainPoint>& ordered_points);
195
197
217 virtual bool is_complete(
218 LogicalRegion upper_bound, const Domain& launch_domain);
219 virtual bool is_complete(
220 LogicalPartition upper_bound, const Domain& launch_domain);
221 virtual bool is_complete(
222 Mappable* mappable, unsigned index, LogicalRegion upper_bound,
223 const Domain& launch_domain);
224 virtual bool is_complete(
225 Mappable* mappable, unsigned index, LogicalPartition upper_bound,
226 const Domain& launch_domain);
228
235 virtual bool is_exclusive(void) const { return false; }
236
237 /*
238 * Indicate whether this is a functional projection
239 * functor or whether it depends on the operation being
240 * launched. This will determine which project method
241 * is invoked by the runtime.
242 */
243 virtual bool is_functional(void) const { return false; }
244
250 virtual bool is_invertible(void) const { return false; }
251
263 virtual unsigned get_depth(void) const = 0;
264 private:
265 friend class Internal::Runtime;
266 // For pre-registered projection functors the runtime will
267 // use this to initialize the runtime pointer
268 inline void set_runtime(Runtime* rt) { runtime = rt; }
269 protected:
270 Runtime* runtime;
271 };
272
287 public:
288 ShardingFunctor(void);
289 virtual ~ShardingFunctor(void);
290 public:
291 // Indicate whether this functor wants to use the ShardID or
292 // DomainPoint versions of these methods
293 virtual bool use_points(void) const { return false; }
294 public:
295 // The ShardID version of this method
296 virtual ShardID shard(
297 const DomainPoint& index_point, const Domain& index_domain,
298 const size_t total_shards);
299 // The DomainPoint version of this method
300 virtual DomainPoint shard_points(
301 const DomainPoint& index_point, const Domain& index_domain,
302 const std::vector<DomainPoint>& shard_points,
303 const Domain& shard_domain);
304 public:
305 virtual bool is_invertible(void) const { return false; }
306 // The ShardID version of this method
307 virtual void invert(
308 ShardID shard, const Domain& sharding_domain,
309 const Domain& index_domain, const size_t total_shards,
310 std::vector<DomainPoint>& points);
311 // The DomainPoint version of this method
312 virtual void invert_points(
313 const DomainPoint& shard_point,
314 const std::vector<DomainPoint>& shard_points,
315 const Domain& shard_domain, const Domain& index_domain,
316 const Domain& sharding_domain, std::vector<DomainPoint>& index_points);
317 };
318
329 public:
331 virtual ~ConcurrentColoringFunctor(void);
332 public:
333 virtual Color color(
334 const DomainPoint& index_point, const Domain& index_domain) = 0;
335 public:
336 // You can optionally implement these methods for better performance,
337 // but they are not required for correctness. If 'has_max_color'
338 // returns 'true' then you must implement the 'max_color' method.
339 virtual bool supports_max_color(void) { return false; }
340 virtual Color max_color(const Domain& index_domain)
341 {
342 return std::numeric_limits<Color>::max();
343 }
344 };
345
362 public:
363 virtual ~FutureFunctor(void) { }
364 public:
365 virtual const void* callback_get_future(
366 size_t& size, bool& owned,
367 const Realm::ExternalInstanceResource*& resource,
368 void (*&freefunc)(const Realm::ExternalInstanceResource&),
369 const void*& metadata, size_t& metasize) = 0;
370 virtual void callback_release_future(void) = 0;
371 };
372
382 public:
383 virtual ~PointTransformFunctor(void) { }
384 public:
385 virtual bool is_invertible(void) const { return false; }
386 // Transform a point from the domain into a point in the range
387 virtual DomainPoint transform_point(
388 const DomainPoint& point, const Domain& domain,
389 const Domain& range) = 0;
390 // Invert a point from range and convert it into a point in the domain
391 // This is only called if is_invertible returns true
392 virtual DomainPoint invert_point(
393 const DomainPoint& point, const Domain& domain, const Domain& range)
394 {
395 return DomainPoint();
396 }
397 };
398
399} // namespace Legion
400
401#endif // __LEGION_FUNCTORS_H__
Definition functors.h:328
Definition geometry.h:159
Definition geometry.h:34
Definition functors.h:361
Definition data.h:260
Definition data.h:189
Definition mapping.h:42
Definition functors.h:381
Definition functors.h:45
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:235
virtual bool is_complete(LogicalRegion upper_bound, const Domain &launch_domain)
virtual bool is_invertible(void) const
Definition functors.h:250
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:108
Definition functors.h:286
Definition mapping.h:112
Definition accessors.h:29