Legion Runtime
Loading...
Searching...
No Matches
mapping.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_MAPPING_H__
17#define __LEGION_MAPPING_H__
18
19// Need these since we're handing these to the client
20#include <map>
21#include <set>
22#include <list>
23#include <deque>
24#include <vector>
25
26#include "legion/api/registrars.h"
27#include "legion/api/runtime.h"
28
29namespace Legion {
30
37 class Mappable {
38 public:
39 Mappable(void);
40 public:
41 // Return a globally unique ID for this operation
42 virtual UniqueID get_unique_id(void) const = 0;
43 // Return the number of operations that came before
44 // this operation in the same context (close operations
45 // return number of previous close operations)
46 virtual uint64_t get_context_index(void) const = 0;
47 // Return the depth of this operation in the task tree
48 virtual int get_depth(void) const = 0;
49 // Get the parent task associated with this mappable
50 virtual const Task* get_parent_task(void) const = 0;
51 // Get the provenance string for this mappable
52 // By default we return the human readable component but
53 // you can also get the machine component as well
54 virtual const std::string_view& get_provenance_string(
55 bool human = true) const = 0;
56 public:
57 virtual MappableType get_mappable_type(void) const = 0;
58 virtual const Task* as_task(void) const { return nullptr; }
59 virtual const Copy* as_copy(void) const { return nullptr; }
60 virtual const InlineMapping* as_inline(void) const { return nullptr; }
61 virtual const Acquire* as_acquire(void) const { return nullptr; }
62 virtual const Release* as_release(void) const { return nullptr; }
63 virtual const Close* as_close(void) const { return nullptr; }
64 virtual const Fill* as_fill(void) const { return nullptr; }
65 virtual const Partition* as_partition(void) const { return nullptr; }
66 virtual const MustEpoch* as_must_epoch(void) const { return nullptr; }
67 public:
68 MapperID map_id;
69 MappingTagID tag;
70 public:
71 // The 'parent_task' member is here for backwards compatibility
72 // It's better to use the 'get_parent_task' method
73 // as this may be nullptr until that method is called
74 mutable const Task* parent_task;
75 public:
76 // Mapper annotated data
77 void* mapper_data;
78 size_t mapper_data_size;
79 public:
80 // These are here for backwards compatibility from a time when
81 // the MappableType enum was inside of this class
82#ifndef __GNUC__
83 // GCC doesn't like this line even though it's just creating a
84 // type alias, who knows what their problem is
85 typedef Legion::MappableType MappableType;
86#endif
87 static const MappableType TASK_MAPPABLE = ::LEGION_TASK_MAPPABLE;
88 static const MappableType COPY_MAPPABLE = ::LEGION_COPY_MAPPABLE;
89 static const MappableType INLINE_MAPPABLE = ::LEGION_INLINE_MAPPABLE;
90 static const MappableType ACQUIRE_MAPPABLE = ::LEGION_ACQUIRE_MAPPABLE;
91 static const MappableType RELEASE_MAPPABLE = ::LEGION_RELEASE_MAPPABLE;
92 static const MappableType CLOSE_MAPPABLE = ::LEGION_CLOSE_MAPPABLE;
93 static const MappableType FILL_MAPPABLE = ::LEGION_FILL_MAPPABLE;
94 static const MappableType PARTITION_MAPPABLE = ::LEGION_PARTITION_MAPPABLE;
95 static const MappableType MUST_EPOCH_MAPPABLE =
96 ::LEGION_MUST_EPOCH_MAPPABLE;
97 };
98
107 class Task : public Mappable {
108 public:
109 Task(void);
110 public:
111 // Check whether this task has a parent task.
112 virtual bool has_parent_task(void) const = 0;
113 // Return the name of the task.
114 virtual const char* get_task_name(void) const = 0;
115 // Returns the current slice of the index domain that this
116 // task is operating over. This method will only return a
117 // valid domain if this is part of an index space task.
118 virtual Domain get_slice_domain(void) const = 0;
119 //------------------------------------------------------------------------
120 // Control Replication methods
121 // In general SPMD-style programming in Legion is wrong. If you find
122 // yourself writing SPMD-style code for large fractions of your program
123 // then you're probably doing something wrong. There are a few exceptions:
124 // 1. index attach/detach operations are collective and may need
125 // to do per-shard work
126 // 2. I/O in general often needs to do per-shard work
127 // 3. interaction with collective frameworks like MPI and NCCL
128 // 4. others?
129 // For these reasons we allow users to get access to sharding information
130 // Please, please, please be careful with how you use it
131 //------------------------------------------------------------------------
132 virtual ShardID get_shard_id(void) const = 0;
133 virtual size_t get_total_shards(void) const = 0;
134 virtual DomainPoint get_shard_point(void) const = 0;
135 virtual Domain get_shard_domain(void) const = 0;
136 public:
137 virtual MappableType get_mappable_type(void) const
138 {
139 return LEGION_TASK_MAPPABLE;
140 }
141 virtual const Task* as_task(void) const { return this; }
142 public:
143 // Task argument information
144 TaskID task_id;
145 std::vector<IndexSpaceRequirement> indexes;
146 std::vector<RegionRequirement> regions;
147 std::vector<OutputRequirement> output_regions;
148 std::vector<Future> futures;
149 std::vector<Grant> grants;
150 std::vector<PhaseBarrier> wait_barriers;
151 std::vector<PhaseBarrier> arrive_barriers;
152 const void* args;
153 size_t arglen;
154 public:
155 // Index task argument information
156 bool is_index_space;
157 bool concurrent_task;
158 bool must_epoch_task;
159 Domain index_domain;
160 DomainPoint index_point;
161 IndexSpace sharding_space;
162 const void* local_args;
163 size_t local_arglen;
164 public:
165 // Meta data information from the runtime
166 Processor orig_proc;
167 Processor current_proc;
168 Processor target_proc;
169 unsigned steal_count;
170 bool stealable;
171 bool speculated;
172 bool local_function;
173 };
174
180 class Copy : public Mappable {
181 public:
182 Copy(void);
183 public:
184 virtual MappableType get_mappable_type(void) const
185 {
186 return LEGION_COPY_MAPPABLE;
187 }
188 virtual const Copy* as_copy(void) const { return this; }
189 public:
190 // Copy Launcher arguments
191 std::vector<RegionRequirement> src_requirements;
192 std::vector<RegionRequirement> dst_requirements;
193 std::vector<RegionRequirement> src_indirect_requirements;
194 std::vector<RegionRequirement> dst_indirect_requirements;
195 std::vector<Grant> grants;
196 std::vector<PhaseBarrier> wait_barriers;
197 std::vector<PhaseBarrier> arrive_barriers;
198 public:
199 // Index copy argument information
200 bool is_index_space;
201 Domain index_domain;
202 DomainPoint index_point;
203 IndexSpace sharding_space;
204 };
205
211 class InlineMapping : public Mappable {
212 public:
213 InlineMapping(void);
214 public:
215 virtual MappableType get_mappable_type(void) const
216 {
217 return LEGION_INLINE_MAPPABLE;
218 }
219 virtual const InlineMapping* as_inline(void) const { return this; }
220 virtual ShardID get_parent_shard(void) const { return 0; }
221 public:
222 // Inline Launcher arguments
223 RegionRequirement requirement;
224 std::vector<Grant> grants;
225 std::vector<PhaseBarrier> wait_barriers;
226 std::vector<PhaseBarrier> arrive_barriers;
227 LayoutConstraintID layout_constraint_id;
228 };
229
235 class Acquire : public Mappable {
236 public:
237 Acquire(void);
238 public:
239 virtual MappableType get_mappable_type(void) const
240 {
241 return LEGION_ACQUIRE_MAPPABLE;
242 }
243 virtual const Acquire* as_acquire(void) const { return this; }
244 public:
245 // Acquire Launcher arguments
246 LogicalRegion logical_region;
247 LogicalRegion parent_region;
248 std::set<FieldID> fields;
249 std::vector<Grant> grants;
250 std::vector<PhaseBarrier> wait_barriers;
251 std::vector<PhaseBarrier> arrive_barriers;
252 };
253
259 class Release : public Mappable {
260 public:
261 Release(void);
262 public:
263 virtual MappableType get_mappable_type(void) const
264 {
265 return LEGION_RELEASE_MAPPABLE;
266 }
267 virtual const Release* as_release(void) const { return this; }
268 public:
269 // Release Launcher arguments
270 LogicalRegion logical_region;
271 LogicalRegion parent_region;
272 std::set<FieldID> fields;
273 std::vector<Grant> grants;
274 std::vector<PhaseBarrier> wait_barriers;
275 std::vector<PhaseBarrier> arrive_barriers;
276 };
277
287 class Close : public Mappable {
288 public:
289 Close(void);
290 public:
291 virtual MappableType get_mappable_type(void) const
292 {
293 return LEGION_CLOSE_MAPPABLE;
294 }
295 virtual const Close* as_close(void) const { return this; }
296 public:
297 // Synthesized region requirement
298 RegionRequirement requirement;
299 };
300
307 class Fill : public Mappable {
308 public:
309 Fill(void);
310 public:
311 virtual MappableType get_mappable_type(void) const
312 {
313 return LEGION_FILL_MAPPABLE;
314 }
315 virtual const Fill* as_fill(void) const { return this; }
316 public:
317 // Synthesized region requirement
318 RegionRequirement requirement;
319 std::vector<Grant> grants;
320 std::vector<PhaseBarrier> wait_barriers;
321 std::vector<PhaseBarrier> arrive_barriers;
322 public:
323 // Index fill argument information
324 bool is_index_space;
325 Domain index_domain;
326 DomainPoint index_point;
327 IndexSpace sharding_space;
328 };
329
337 class Partition : public Mappable {
338 public:
339 Partition(void);
340 public:
341 virtual MappableType get_mappable_type(void) const
342 {
343 return LEGION_PARTITION_MAPPABLE;
344 }
345 virtual const Partition* as_partition(void) const { return this; }
346 public:
347 enum PartitionKind {
348 BY_FIELD, // create partition by field
349 BY_IMAGE, // create partition by image
350 BY_IMAGE_RANGE, // create partition by image range
351 BY_PREIMAGE, // create partition by preimage
352 BY_PREIMAGE_RANGE, // create partition by preimage range
353 BY_ASSOCIATION, // create partition by association
354 };
355 virtual PartitionKind get_partition_kind(void) const = 0;
356 public:
357 // Synthesized region requirement
358 RegionRequirement requirement;
359 public:
360 // Index partition argument information
361 bool is_index_space;
362 Domain index_domain;
363 DomainPoint index_point;
364 };
365
372 class MustEpoch : public Mappable {
373 public:
374 MustEpoch(void);
375 public:
376 virtual MappableType get_mappable_type(void) const
377 {
378 return LEGION_MUST_EPOCH_MAPPABLE;
379 }
380 virtual const MustEpoch* as_must_epoch(void) const { return this; }
381 public:
382 std::vector<const Task*> individual_tasks;
383 std::vector<const Task*> index_space_tasks;
384 public:
385 // Index space of points for the must epoch operation
386 Domain launch_domain;
387 IndexSpace sharding_space;
388 };
389
390 namespace Mapping {
391
406 public:
407 PhysicalInstance(void);
408 PhysicalInstance(PhysicalInstance&& rhs) noexcept;
410 ~PhysicalInstance(void);
411 public:
412 PhysicalInstance& operator=(PhysicalInstance&& rhs) noexcept;
413 PhysicalInstance& operator=(const PhysicalInstance& rhs);
414 public:
415 bool operator<(const PhysicalInstance& rhs) const;
416 bool operator==(const PhysicalInstance& rhs) const;
417 bool operator!=(const PhysicalInstance& rhs) const;
418 std::size_t hash(void) const;
419 public:
420 // Get the location of this physical instance
421 Memory get_location(void) const;
422 unsigned long get_instance_id(void) const;
423 size_t get_instance_size(void) const;
424 Domain get_instance_domain(void) const;
425 // Adds all fields that exist in instance to 'fields', unless
426 // instance is virtual
427 void get_fields(std::set<FieldID>& fields) const;
428 public:
429 FieldSpace get_field_space(void) const;
430 RegionTreeID get_tree_id(void) const;
431 LayoutConstraintID get_layout_id(void) const;
432 PointerConstraint get_pointer_constraint(void) const;
433 public:
434 // See if our instance still exists or if it has been
435 // garbage collected, this is just a sample, using the
436 // acquire methods provided by the mapper_rt interface
437 // can prevent it from being collected during the
438 // lifetime of a mapper call.
439 bool exists(bool strong_test = false) const;
440 bool is_normal_instance(void) const;
441 bool is_virtual_instance(void) const;
442 bool is_reduction_instance(void) const;
443 bool is_external_instance(void) const;
444 public:
445 bool has_field(FieldID fid) const;
446 void has_fields(std::map<FieldID, bool>& fids) const;
447 void remove_space_fields(std::set<FieldID>& fids) const;
448 public:
449 // Use these to specify the fields for which this instance
450 // should be used. It is optional to specify this and is only
451 // necessary to disambiguate which fields should be used when
452 // multiple selected instances have the same field(s).
453 void add_use_field(FieldID fid);
454 void add_use_fields(const std::set<FieldID>& fids);
455 public:
456 // Check to see if a whole set of constraints are satisfied
457 bool entails(
458 const LayoutConstraintSet& constraint_set,
459 const LayoutConstraint** failed_constraint = nullptr) const;
460 public:
461 static PhysicalInstance get_virtual_instance(void);
462 private:
463 friend class CollectiveView;
464 FRIEND_ALL_RUNTIME_CLASSES
465 // Only the runtime can make an instance like this
466 PhysicalInstance(PhysicalInstanceImpl impl);
467 private:
468 PhysicalInstanceImpl impl;
469 friend std::ostream& operator<<(
470 std::ostream& os, const PhysicalInstance& p);
471 };
472
482 public:
483 CollectiveView(void);
484 CollectiveView(CollectiveView&& rhs) noexcept;
485 CollectiveView(const CollectiveView& rhs);
486 ~CollectiveView(void);
487 public:
488 CollectiveView& operator=(CollectiveView&& rhs) noexcept;
489 CollectiveView& operator=(const CollectiveView& rhs);
490 public:
491 bool operator<(const CollectiveView& rhs) const;
492 bool operator==(const CollectiveView& rhs) const;
493 bool operator!=(const CollectiveView& rhs) const;
494 std::size_t hash(void) const;
495 public:
496 void find_instances_in_memory(
497 Memory memory, std::vector<PhysicalInstance>& insts) const;
498 void find_instances_nearest_memory(
499 Memory memory, std::vector<PhysicalInstance>& insts,
500 bool bandwidth = true) const;
501 private:
502 FRIEND_ALL_RUNTIME_CLASSES
503 // Only the runtime can make an instance like this
504 CollectiveView(CollectiveViewImpl impl);
505 private:
506 CollectiveViewImpl impl;
507 friend std::ostream& operator<<(
508 std::ostream& os, const CollectiveView& p);
509 };
510
518 public:
519 MapperEvent(void) : impl(Internal::RtUserEvent()) { }
520 FRIEND_ALL_RUNTIME_CLASSES
521 public:
522 inline bool exists(void) const { return impl.exists(); }
523 inline bool operator==(const MapperEvent& rhs) const
524 {
525 return (impl.id == rhs.impl.id);
526 }
527 inline bool operator<(const MapperEvent& rhs) const
528 {
529 return (impl.id < rhs.impl.id);
530 }
531 inline std::size_t hash(void) const
532 {
533 return std::hash<unsigned long long>{}(impl.id);
534 }
535 private:
537 };
538
539 namespace ProfilingMeasurements {
540 // import all the Realm measurements into this namespace too
541 using namespace Realm::ProfilingMeasurements;
542
543 struct RuntimeOverhead {
544 static const ProfilingMeasurementID ID = PMID_RUNTIME_OVERHEAD;
545 RuntimeOverhead(void);
546 // application, runtime, wait times all reported in nanoseconds
547 long long application_time; // time spent in application code
548 long long runtime_time; // time spent in runtime code
549 long long wait_time; // time spent waiting
550 };
551 }; // namespace ProfilingMeasurements
552
560 public:
561 ProfilingRequest(void);
562 ~ProfilingRequest(void);
563
564 template<typename T>
565 inline ProfilingRequest& add_measurement(void);
566
567 inline bool empty(void) const;
568 protected:
569 FRIEND_ALL_RUNTIME_CLASSES
570 void populate_realm_profiling_request(Realm::ProfilingRequest& req);
571
572 std::set<ProfilingMeasurementID> requested_measurements;
573 };
574
581 public:
582 // default constructor used because this appears in the
583 // {...}ProfilingInfo structs below
584 ProfilingResponse(void);
585 ~ProfilingResponse(void);
586
587 // even if a measurement was requested, it may not have been performed -
588 // use this to check
589 template<typename T>
590 inline bool has_measurement(void) const;
591
592 // extracts a measurement (if available), returning a dynamically
593 // allocated result - caller should delete it when done
594 template<typename T>
595 inline T* get_measurement(void) const;
596
597 template<typename T>
598 inline bool get_measurement(T& result) const;
599 protected:
600 FRIEND_ALL_RUNTIME_CLASSES
601 void attach_realm_profiling_response(
602 const Realm::ProfilingResponse& resp);
603 void attach_overhead(ProfilingMeasurements::RuntimeOverhead* overhead);
604
605 const Realm::ProfilingResponse* realm_resp;
606 ProfilingMeasurements::RuntimeOverhead* overhead;
607 };
608
620 public:
621 TaskID task_id;
622 MapperID mapper_id;
623 ExecutionConstraintSet execution_constraints;
624 TaskLayoutConstraintSet layout_constraints;
625 };
626
633 class Mapper {
634 public:
636 virtual ~Mapper(void);
637 public:
638 MapperRuntime* const runtime;
639 public:
650 virtual const char* get_mapper_name(void) const = 0;
651 public:
670 CONCURRENT_MAPPER_MODEL,
671 SERIALIZED_REENTRANT_MAPPER_MODEL,
672 SERIALIZED_NON_REENTRANT_MAPPER_MODEL,
673 };
674 virtual MapperSyncModel get_mapper_sync_model(void) const = 0;
675 public:
691 virtual bool request_valid_instances(void) const { return true; }
692 public: // Task mapping calls
774 struct TaskOptions {
775 Processor initial_proc; // = current
776 bool inline_task = false;
777 bool stealable = false;
778 bool map_locally = false;
779 bool valid_instances = true;
780 bool memoize = false;
781 bool replicate = false;
782 TaskPriority parent_priority; // = current
783 std::set<unsigned> check_collective_regions;
784 };
785 //------------------------------------------------------------------------
786 virtual void select_task_options(
787 MapperContext ctx, const Task& task, TaskOptions& output) = 0;
788 //------------------------------------------------------------------------
789
811 LEGION_DEPRECATED("Premapping regions is no longer supported")
812 std::map<unsigned, std::vector<PhysicalInstance> > valid_instances;
813 PremapTaskInput(void);
814 ~PremapTaskInput(void);
815 };
817 Processor new_target_proc;
818 std::vector<Memory> reduction_futures;
819 LEGION_DEPRECATED("Premapping regions is no longer supported")
820 std::map<unsigned, std::vector<PhysicalInstance> > premapped_instances;
821 LEGION_DEPRECATED("Premapping regions is no longer supported")
822 std::map<unsigned, std::vector<PhysicalInstance> > premapped_sources;
823 LEGION_DEPRECATED("Premapping regions is no longer supported")
824 ProfilingRequest copy_prof_requests;
825 LEGION_DEPRECATED("Premapping regions is no longer supported")
826 TaskPriority profiling_priority;
827 PremapTaskOutput(void);
828 ~PremapTaskOutput(void);
829 };
830 //------------------------------------------------------------------------
831 virtual void premap_task(
832 MapperContext ctx, const Task& task, const PremapTaskInput& input,
833 PremapTaskOutput& output) = 0;
834 //------------------------------------------------------------------------
835
860 struct TaskSlice {
861 public:
862 TaskSlice(void)
863 : domain_is(IndexSpace::NO_SPACE), domain(Domain::NO_DOMAIN),
864 proc(Processor::NO_PROC), recurse(false), stealable(false),
865 take_ownership(false)
866 { }
867 TaskSlice(
868 const Domain& d, Processor p, bool r, bool s, bool own = false)
869 : domain_is(IndexSpace::NO_SPACE), domain(d), proc(p), recurse(r),
870 stealable(s), take_ownership(own)
871 { }
872 TaskSlice(IndexSpace is, Processor p, bool r, bool s)
873 : domain_is(is), domain(Domain::NO_DOMAIN), proc(p), recurse(r),
874 stealable(s), take_ownership(false)
875 { }
876 public:
877 IndexSpace domain_is;
878 Domain domain;
879 Processor proc;
880 bool recurse;
881 bool stealable;
882 bool take_ownership;
883 };
885 IndexSpace domain_is;
886 Domain domain;
887 IndexSpace sharding_is;
888 };
890 std::vector<TaskSlice> slices;
891 bool verify_correctness = false;
892 };
893 //------------------------------------------------------------------------
894 virtual void slice_task(
895 MapperContext ctx, const Task& task, const SliceTaskInput& input,
896 SliceTaskOutput& output) = 0;
897 //------------------------------------------------------------------------
898
986 std::vector<std::vector<PhysicalInstance> > valid_instances;
987 std::vector<std::vector<CollectiveView> > valid_collectives;
988 std::vector<unsigned> premapped_regions;
989 // These only apply when mapping a replicated task
990 DomainPoint shard;
991 Domain shard_domain;
992 Processor shard_processor;
993 VariantID shard_variant;
994 };
996 std::vector<std::vector<PhysicalInstance> > chosen_instances;
997 std::vector<std::vector<PhysicalInstance> > source_instances;
998 std::vector<Memory> output_targets;
999 std::vector<LayoutConstraintSet> output_constraints;
1000 std::set<unsigned> untracked_valid_regions;
1001 std::vector<Memory> future_locations;
1002 std::vector<Processor> target_procs;
1003 std::map<Memory, PoolBounds> leaf_pool_bounds,
1004 non_escaping_leaf_pool_bounds;
1005 VariantID chosen_variant = 0;
1006 TaskPriority task_priority = 0;
1007 RealmPriority copy_fill_priority = 0;
1008 RealmPriority profiling_priority = 0;
1009 ProfilingRequest task_prof_requests;
1010 ProfilingRequest copy_prof_requests;
1011 bool postmap_task = false;
1012 bool abort_mapping = false;
1013 };
1014 //------------------------------------------------------------------------
1015 virtual void map_task(
1016 MapperContext ctx, const Task& task, const MapTaskInput& input,
1017 MapTaskOutput& output) = 0;
1018 //------------------------------------------------------------------------
1019
1054 // Nothing here for now
1055 };
1057 VariantID chosen_variant = 0;
1058 std::vector<Processor> target_processors;
1059 // The following outputs are optional
1060 std::vector<VariantID> leaf_variants;
1061 std::vector<DomainPoint> shard_points;
1062 Domain shard_domain;
1063 };
1064 //------------------------------------------------------------------------
1065 virtual void replicate_task(
1066 MapperContext ctx, const Task& task, const ReplicateTaskInput& input,
1067 ReplicateTaskOutput& output) = 0;
1068 //------------------------------------------------------------------------
1069
1070 // This is here for backwards compatibility
1071 // The mapper call it was used by no longer exists
1072 // It was replaced by replicate_task
1074 std::vector<MapTaskOutput> task_mappings;
1075 std::vector<Processor> control_replication_map;
1076 std::vector<DomainPoint> shard_points;
1077 Domain shard_domain;
1078 };
1079
1091 Processor processor;
1092 std::vector<std::vector<PhysicalInstance> > chosen_instances;
1093 };
1095 VariantID chosen_variant = 0;
1096 };
1097 //------------------------------------------------------------------------
1098 virtual void select_task_variant(
1099 MapperContext ctx, const Task& task, const SelectVariantInput& input,
1100 SelectVariantOutput& output) = 0;
1101 //------------------------------------------------------------------------
1102
1123 std::vector<std::vector<PhysicalInstance> > mapped_regions;
1124 std::vector<std::vector<PhysicalInstance> > valid_instances;
1125 std::vector<std::vector<CollectiveView> > valid_collectives;
1126 };
1128 std::vector<std::vector<PhysicalInstance> > chosen_instances;
1129 std::vector<std::vector<PhysicalInstance> > source_instances;
1130 };
1131 //------------------------------------------------------------------------
1132 virtual void postmap_task(
1133 MapperContext ctx, const Task& task, const PostMapInput& input,
1134 PostMapOutput& output) = 0;
1135 //------------------------------------------------------------------------
1136
1152 PhysicalInstance target;
1153 std::vector<PhysicalInstance> source_instances;
1154 std::vector<CollectiveView> collective_views;
1155 unsigned region_req_index;
1156 };
1158 std::deque<PhysicalInstance> chosen_ranking;
1159 };
1160 //------------------------------------------------------------------------
1161 virtual void select_task_sources(
1162 MapperContext ctx, const Task& task, const SelectTaskSrcInput& input,
1163 SelectTaskSrcOutput& output) = 0;
1164 //------------------------------------------------------------------------
1165
1166 // These are here for backwards compatibility
1167 // The mapper call these were used by no longer exists
1169 unsigned region_requirement_index;
1170 PhysicalInstance destination_instance;
1171 };
1173 PhysicalInstance temporary_instance;
1174 };
1175
1176 // Keep this struct around for backwards compatibility
1178 bool speculate;
1179 bool speculative_value;
1180 bool speculate_mapping_only;
1181 };
1182
1200 ProfilingResponse profiling_responses;
1201 unsigned region_requirement_index;
1202 unsigned total_reports;
1203 bool task_response;
1204 bool fill_response;
1205 };
1206 //------------------------------------------------------------------------
1207 virtual void report_profiling(
1208 MapperContext ctx, const Task& task,
1209 const TaskProfilingInfo& input) = 0;
1210 //------------------------------------------------------------------------
1211
1227 std::vector<Processor> shard_mapping;
1228 };
1230 ShardingID chosen_functor = std::numeric_limits<ShardingID>::max();
1231 bool slice_recurse = true;
1232 };
1233 //------------------------------------------------------------------------
1234 virtual void select_sharding_functor(
1235 MapperContext ctx, const Task& task,
1236 const SelectShardingFunctorInput& input,
1237 SelectShardingFunctorOutput& output) = 0;
1238 //------------------------------------------------------------------------
1239 public: // Inline mapping
1263 std::vector<PhysicalInstance> valid_instances;
1264 std::vector<CollectiveView> valid_collectives;
1265 };
1267 std::vector<PhysicalInstance> chosen_instances;
1268 std::vector<PhysicalInstance> source_instances;
1269 RealmPriority copy_fill_priority = 0;
1270 ProfilingRequest profiling_requests;
1271 RealmPriority profiling_priority = 0;
1272 bool track_valid_region = true;
1273 };
1274 //------------------------------------------------------------------------
1275 virtual void map_inline(
1276 MapperContext ctx, const InlineMapping& inline_op,
1277 const MapInlineInput& input, MapInlineOutput& output) = 0;
1278 //------------------------------------------------------------------------
1279
1294 PhysicalInstance target;
1295 std::vector<PhysicalInstance> source_instances;
1296 std::vector<CollectiveView> collective_views;
1297 };
1299 std::deque<PhysicalInstance> chosen_ranking;
1300 };
1301 //------------------------------------------------------------------------
1302 virtual void select_inline_sources(
1303 MapperContext ctx, const InlineMapping& inline_op,
1304 const SelectInlineSrcInput& input, SelectInlineSrcOutput& output) = 0;
1305 //------------------------------------------------------------------------
1306
1307 // These are here for backwards compatibility
1308 // The mapper call these were used by no longer exists
1310 PhysicalInstance destination_instance;
1311 };
1313 PhysicalInstance temporary_instance;
1314 };
1315
1316 // No speculation for inline mappings
1317
1333 ProfilingResponse profiling_responses;
1334 unsigned total_reports;
1335 bool fill_response;
1336 };
1337 //------------------------------------------------------------------------
1338 virtual void report_profiling(
1339 MapperContext ctx, const InlineMapping& inline_op,
1340 const InlineProfilingInfo& input) = 0;
1341 //------------------------------------------------------------------------
1342 public: // Region-to-region copies
1395 std::vector<std::vector<PhysicalInstance> > src_instances;
1396 std::vector<std::vector<PhysicalInstance> > dst_instances;
1397 std::vector<std::vector<PhysicalInstance> > src_indirect_instances;
1398 std::vector<std::vector<PhysicalInstance> > dst_indirect_instances;
1399 std::vector<std::vector<CollectiveView> > src_collectives;
1400 std::vector<std::vector<CollectiveView> > dst_collectives;
1401 std::vector<std::vector<CollectiveView> > src_indirect_collectives;
1402 std::vector<std::vector<CollectiveView> > dst_indirect_collectives;
1403 };
1405 std::vector<std::vector<PhysicalInstance> > src_instances;
1406 std::vector<std::vector<PhysicalInstance> > dst_instances;
1407 std::vector<PhysicalInstance> src_indirect_instances;
1408 std::vector<PhysicalInstance> dst_indirect_instances;
1409 std::vector<std::vector<PhysicalInstance> > src_source_instances;
1410 std::vector<std::vector<PhysicalInstance> > dst_source_instances;
1411 std::vector<std::vector<PhysicalInstance> >
1412 src_indirect_source_instances;
1413 std::vector<std::vector<PhysicalInstance> >
1414 dst_indirect_source_instances;
1415
1416 std::set<unsigned> untracked_valid_srcs;
1417 std::set<unsigned> untracked_valid_ind_srcs;
1418 std::set<unsigned> untracked_valid_ind_dsts;
1419 ProfilingRequest profiling_requests;
1420 RealmPriority profiling_priority = 0;
1421 RealmPriority copy_fill_priority = 0;
1422 bool compute_preimages = false;
1423 bool shadow_indirections = false;
1424 };
1425 //------------------------------------------------------------------------
1426 virtual void map_copy(
1427 MapperContext ctx, const Copy& copy, const MapCopyInput& input,
1428 MapCopyOutput& output) = 0;
1429 //------------------------------------------------------------------------
1430
1448 PhysicalInstance target;
1449 std::vector<PhysicalInstance> source_instances;
1450 std::vector<CollectiveView> collective_views;
1451 bool is_src;
1452 bool is_dst;
1453 bool is_src_indirect;
1454 bool is_dst_indirect;
1455 unsigned region_req_index;
1456 };
1458 std::deque<PhysicalInstance> chosen_ranking;
1459 };
1460 //------------------------------------------------------------------------
1461 virtual void select_copy_sources(
1462 MapperContext ctx, const Copy& copy, const SelectCopySrcInput& input,
1463 SelectCopySrcOutput& output) = 0;
1464 //------------------------------------------------------------------------
1465
1466 // These are here for backwards compatibility
1467 // The mapper call these were used by no longer exists
1469 unsigned region_requirement_index;
1470 bool src_requirement;
1471 PhysicalInstance destination_instance;
1472 };
1474 PhysicalInstance temporary_instance;
1475 };
1476
1495 ProfilingResponse profiling_responses;
1496 unsigned src_index;
1497 unsigned dst_index;
1498 unsigned total_reports;
1499 bool fill_response;
1500 };
1501 //------------------------------------------------------------------------
1502 virtual void report_profiling(
1503 MapperContext ctx, const Copy& copy,
1504 const CopyProfilingInfo& input) = 0;
1505 //------------------------------------------------------------------------
1506
1519 //------------------------------------------------------------------------
1521 MapperContext ctx, const Copy& copy,
1522 const SelectShardingFunctorInput& input,
1523 SelectShardingFunctorOutput& output) = 0;
1524 //------------------------------------------------------------------------
1525 public: // Close operations
1526 // These are here for backwards compatibility
1527 // The mapper call these were used by no longer exists
1529 std::vector<PhysicalInstance> valid_instances;
1530 };
1532 std::vector<PhysicalInstance> chosen_instances;
1533 ProfilingRequest profiling_requests;
1534 RealmPriority profiling_priority;
1535 };
1536
1549 PhysicalInstance target;
1550 std::vector<PhysicalInstance> source_instances;
1551 std::vector<CollectiveView> collective_views;
1552 };
1554 std::deque<PhysicalInstance> chosen_ranking;
1555 };
1556 //------------------------------------------------------------------------
1557 virtual void select_close_sources(
1558 MapperContext ctx, const Close& close,
1559 const SelectCloseSrcInput& input, SelectCloseSrcOutput& output) = 0;
1560 //------------------------------------------------------------------------
1561
1562 // These are here for backwards compatibility
1563 // The mapper call these were used by no longer exists
1565 PhysicalInstance destination_instance;
1566 };
1568 PhysicalInstance temporary_instance;
1569 };
1570
1571 // No speculation for close operations
1572
1590 ProfilingResponse profiling_responses;
1591 unsigned total_reports;
1592 bool fill_response;
1593 };
1594 //------------------------------------------------------------------------
1595 virtual void report_profiling(
1596 MapperContext ctx, const Close& close,
1597 const CloseProfilingInfo& input) = 0;
1598 //------------------------------------------------------------------------
1599
1612 //------------------------------------------------------------------------
1614 MapperContext ctx, const Close& close,
1615 const SelectShardingFunctorInput& input,
1616 SelectShardingFunctorOutput& output) = 0;
1617 //------------------------------------------------------------------------
1618 public: // Acquire operations
1629 // Nothing
1630 };
1632 ProfilingRequest profiling_requests;
1633 RealmPriority profiling_priority = 0;
1634 RealmPriority copy_fill_priority = 0;
1635 };
1636 //------------------------------------------------------------------------
1637 virtual void map_acquire(
1638 MapperContext ctx, const Acquire& acquire,
1639 const MapAcquireInput& input, MapAcquireOutput& output) = 0;
1640 //------------------------------------------------------------------------
1641
1657 ProfilingResponse profiling_responses;
1658 unsigned total_reports;
1659 bool fill_response;
1660 };
1661 //------------------------------------------------------------------------
1662 virtual void report_profiling(
1663 MapperContext ctx, const Acquire& acquire,
1664 const AcquireProfilingInfo& input) = 0;
1665 //------------------------------------------------------------------------
1666
1679 //------------------------------------------------------------------------
1681 MapperContext ctx, const Acquire& acquire,
1682 const SelectShardingFunctorInput& input,
1683 SelectShardingFunctorOutput& output) = 0;
1684 //------------------------------------------------------------------------
1685 public: // Release operations
1699 // Nothing
1700 };
1702 std::vector<PhysicalInstance> source_instances;
1703 ProfilingRequest profiling_requests;
1704 RealmPriority profiling_priority = 0;
1705 RealmPriority copy_fill_priority = 0;
1706 };
1707 //------------------------------------------------------------------------
1708 virtual void map_release(
1709 MapperContext ctx, const Release& release,
1710 const MapReleaseInput& input, MapReleaseOutput& output) = 0;
1711 //------------------------------------------------------------------------
1712
1725 PhysicalInstance target;
1726 std::vector<PhysicalInstance> source_instances;
1727 std::vector<CollectiveView> collective_views;
1728 };
1730 std::deque<PhysicalInstance> chosen_ranking;
1731 };
1732 //------------------------------------------------------------------------
1733 virtual void select_release_sources(
1734 MapperContext ctx, const Release& release,
1735 const SelectReleaseSrcInput& input,
1736 SelectReleaseSrcOutput& output) = 0;
1737 //------------------------------------------------------------------------
1738
1739 // These are here for backwards compatibility
1740 // The mapper call these were used by no longer exists
1742 PhysicalInstance destination_instance;
1743 };
1745 PhysicalInstance temporary_instance;
1746 };
1747
1763 ProfilingResponse profiling_responses;
1764 unsigned total_reports;
1765 bool fill_response;
1766 };
1767 //------------------------------------------------------------------------
1768 virtual void report_profiling(
1769 MapperContext ctx, const Release& release,
1770 const ReleaseProfilingInfo& input) = 0;
1771 //------------------------------------------------------------------------
1772
1785 //------------------------------------------------------------------------
1787 MapperContext ctx, const Release& release,
1788 const SelectShardingFunctorInput& input,
1789 SelectShardingFunctorOutput& output) = 0;
1790 //------------------------------------------------------------------------
1791 public: // Partition Operations
1815 std::vector<LogicalPartition> open_complete_partitions;
1816 };
1818 LogicalPartition chosen_partition;
1819 };
1820 //------------------------------------------------------------------------
1821 virtual void select_partition_projection(
1822 MapperContext ctx, const Partition& partition,
1823 const SelectPartitionProjectionInput& input,
1825 //------------------------------------------------------------------------
1826
1852 std::vector<PhysicalInstance> valid_instances;
1853 std::vector<CollectiveView> valid_collectives;
1854 };
1856 std::vector<PhysicalInstance> chosen_instances;
1857 std::vector<PhysicalInstance> source_instances;
1858 ProfilingRequest profiling_requests;
1859 RealmPriority profiling_priority = 0;
1860 RealmPriority copy_fill_priority = 0;
1861 bool track_valid_region = true;
1862 };
1863 //------------------------------------------------------------------------
1864 virtual void map_partition(
1865 MapperContext ctx, const Partition& partition,
1866 const MapPartitionInput& input, MapPartitionOutput& output) = 0;
1867 //------------------------------------------------------------------------
1868
1883 PhysicalInstance target;
1884 std::vector<PhysicalInstance> source_instances;
1885 std::vector<CollectiveView> collective_views;
1886 };
1888 std::deque<PhysicalInstance> chosen_ranking;
1889 };
1890 //------------------------------------------------------------------------
1891 virtual void select_partition_sources(
1892 MapperContext ctx, const Partition& partition,
1893 const SelectPartitionSrcInput& input,
1894 SelectPartitionSrcOutput& output) = 0;
1895 //------------------------------------------------------------------------
1896
1897 // These are here for backwards compatibility
1898 // The mapper call these were used by no longer exists
1900 PhysicalInstance destination_instance;
1901 };
1903 PhysicalInstance temporary_instance;
1904 };
1905
1906 // No speculation for dependent partition operations
1907
1923 ProfilingResponse profiling_responses;
1924 unsigned total_reports;
1925 bool fill_response;
1926 };
1927 //------------------------------------------------------------------------
1928 virtual void report_profiling(
1929 MapperContext ctx, const Partition& partition,
1930 const PartitionProfilingInfo& input) = 0;
1931 //------------------------------------------------------------------------
1932
1945 //------------------------------------------------------------------------
1947 MapperContext ctx, const Partition& partition,
1948 const SelectShardingFunctorInput& input,
1949 SelectShardingFunctorOutput& output) = 0;
1950 //------------------------------------------------------------------------
1951 public: // Fill Operations
1964 //------------------------------------------------------------------------
1966 MapperContext ctx, const Fill& fill,
1967 const SelectShardingFunctorInput& input,
1968 SelectShardingFunctorOutput& output) = 0;
1969 //------------------------------------------------------------------------
1970 public: // Future Map Reductions
1993 MappingTagID tag;
1994 };
1996 std::vector<Memory> destination_memories;
1997 size_t serdez_upper_bound = std::numeric_limits<size_t>::max();
1998 };
1999 //------------------------------------------------------------------------
2000 virtual void map_future_map_reduction(
2001 MapperContext ctx, const FutureMapReductionInput& input,
2003 { }
2004 //------------------------------------------------------------------------
2005 public: // Single Task Context
2107 unsigned max_window_size = LEGION_DEFAULT_MAX_TASK_WINDOW;
2108 unsigned hysteresis_percentage = LEGION_DEFAULT_TASK_WINDOW_HYSTERESIS;
2109 unsigned max_outstanding_frames = 0;
2110 unsigned min_tasks_to_schedule = LEGION_DEFAULT_MIN_TASKS_TO_SCHEDULE;
2111 unsigned min_frames_to_schedule = 0;
2112 unsigned meta_task_vector_width = LEGION_DEFAULT_META_TASK_VECTOR_WIDTH;
2113 unsigned max_templates_per_trace =
2114 LEGION_DEFAULT_MAX_TEMPLATES_PER_TRACE;
2115 bool mutable_priority = false;
2116 bool auto_tracing_enabled = true;
2117 unsigned auto_tracing_window_size = 1000;
2118 unsigned auto_tracing_ruler_function = 100;
2119 unsigned auto_tracing_min_trace_length = 5;
2120 unsigned auto_tracing_max_trace_length =
2121 std::numeric_limits<unsigned>::max();
2122 unsigned auto_tracing_visit_threshold = 10;
2123 unsigned auto_tracing_turbo_lag = 16;
2124 };
2125 //------------------------------------------------------------------------
2126 virtual void configure_context(
2127 MapperContext ctx, const Task& task, ContextConfigOutput& output) = 0;
2128 //------------------------------------------------------------------------
2129
2147 TunableID tunable_id;
2148 MappingTagID mapping_tag;
2149 std::vector<Future> futures;
2150 const void* args;
2151 size_t size;
2152 };
2154 void* value = nullptr;
2155 size_t size = 0;
2156 bool take_ownership = true;
2157 };
2158 //------------------------------------------------------------------------
2159 virtual void select_tunable_value(
2160 MapperContext ctx, const Task& task, const SelectTunableInput& input,
2161 SelectTunableOutput& output) = 0;
2162 //------------------------------------------------------------------------
2163 public: // Mapping collections of operations
2184 bool collective_map_must_epoch_call;
2185 };
2186 //------------------------------------------------------------------------
2187 virtual void select_sharding_functor(
2188 MapperContext ctx, const MustEpoch& epoch,
2189 const SelectShardingFunctorInput& input,
2190 MustEpochShardingFunctorOutput& output) = 0;
2191 //------------------------------------------------------------------------
2192
2227 std::vector<const Task*> constrained_tasks;
2228 std::vector<unsigned> requirement_indexes;
2229 // tasks.size() == requirement_indexes.size()
2230 };
2232 std::vector<const Task*> tasks;
2233 std::vector<MappingConstraint> constraints;
2234 MappingTagID mapping_tag;
2235 // For collective map_must_epoch only
2236 std::vector<Processor> shard_mapping;
2237 ShardID local_shard;
2238 };
2240 std::vector<Processor> task_processors;
2241 std::vector<std::vector<PhysicalInstance> > constraint_mappings;
2242 // For collective map_must_epoch only
2243 std::vector<int> weights;
2244 };
2245 //------------------------------------------------------------------------
2246 virtual void map_must_epoch(
2247 MapperContext ctx, const MapMustEpochInput& input,
2248 MapMustEpochOutput& output) = 0;
2249 //------------------------------------------------------------------------
2250
2252#if 0
2253 std::vector<const Task*> nodes;
2254 std::vector<DataflowEdge> edges;
2255 std::vector<Callsite> callsites;
2256#endif
2257 };
2259 //------------------------------------------------------------------------
2260 virtual void map_dataflow_graph(
2261 MapperContext ctx, const MapDataflowGraphInput& input,
2262 MapDataflowGraphOutput& output) = 0;
2263 //------------------------------------------------------------------------
2264 public: // Memoizing physical analyses of operations
2275 TraceID trace_id;
2276 };
2278 bool memoize = true;
2279 };
2280 //------------------------------------------------------------------------
2281 virtual void memoize_operation(
2282 MapperContext ctx, const Mappable& mappable,
2283 const MemoizeInput& input, MemoizeOutput& output) = 0;
2284 //------------------------------------------------------------------------
2285 public: // Mapping control
2310 std::list<const Task*> ready_tasks;
2311 Processor processor;
2312 };
2314 std::set<const Task*> map_tasks;
2315 std::map<const Task*, Processor> relocate_tasks;
2316 MapperEvent deferral_event;
2317 };
2318 //------------------------------------------------------------------------
2319 virtual void select_tasks_to_map(
2320 MapperContext ctx, const SelectMappingInput& input,
2321 SelectMappingOutput& output) = 0;
2322 //------------------------------------------------------------------------
2323 public: // Stealing
2342 std::set<Processor> blacklist;
2343 };
2345 std::set<Processor> targets;
2346 };
2347 //------------------------------------------------------------------------
2348 virtual void select_steal_targets(
2349 MapperContext ctx, const SelectStealingInput& input,
2350 SelectStealingOutput& output) = 0;
2351 //------------------------------------------------------------------------
2352
2369 Processor thief_proc;
2370 std::vector<const Task*> stealable_tasks;
2371 };
2373 std::set<const Task*> stolen_tasks;
2374 };
2375 //------------------------------------------------------------------------
2376 virtual void permit_steal_request(
2377 MapperContext ctx, const StealRequestInput& input,
2378 StealRequestOutput& output) = 0;
2379 //------------------------------------------------------------------------
2380 public: // Handling
2395 Processor sender;
2396 unsigned kind;
2397 const void* message;
2398 size_t size;
2399 bool broadcast;
2400 };
2401 //------------------------------------------------------------------------
2402 virtual void handle_message(
2403 MapperContext ctx, const MapperMessage& message) = 0;
2404 //------------------------------------------------------------------------
2405
2418 MapperEvent mapper_event;
2419 const void* result;
2420 size_t result_size;
2421 };
2422 //------------------------------------------------------------------------
2423 virtual void handle_task_result(
2424 MapperContext ctx, const MapperTaskResult& result) = 0;
2425 //------------------------------------------------------------------------
2426
2435 //------------------------------------------------------------------------
2437 const MapperContext ctx, const PhysicalInstance& inst)
2438 { }
2439 //------------------------------------------------------------------------
2440 };
2441
2450 protected:
2451 // These runtime objects will be created by Legion
2452 friend class Internal::Runtime;
2453 MapperRuntime(Internal::Runtime* runtime);
2454 ~MapperRuntime(void);
2455 private:
2456 Internal::Runtime* const runtime;
2457 public:
2458 //------------------------------------------------------------------------
2459 // Methods for managing access to mapper state in the concurrent model
2460 // These calls are illegal in the serialized mapper model
2461 //------------------------------------------------------------------------
2462 bool is_locked(MapperContext ctx) const;
2463 void lock_mapper(MapperContext ctx, bool read_only = false) const;
2464 void unlock_mapper(MapperContext ctx) const;
2465 public:
2466 //------------------------------------------------------------------------
2467 // Methods for managing the re-entrant state in the serialized model
2468 // These calls are illegal in the concurrent mapper model
2469 //------------------------------------------------------------------------
2470 bool is_reentrant(MapperContext ctx) const;
2471 void enable_reentrant(MapperContext ctx) const;
2472 void disable_reentrant(MapperContext ctx) const;
2473 public:
2474 //------------------------------------------------------------------------
2475 // These two methods allow mappers to define their own profile ranges
2476 // inside of the profiler. Each start call must be matched with a
2477 // corresponding stop call inside of the same mapper context.
2478 void start_profiling_range(MapperContext ctx) const;
2479 void stop_profiling_range(
2480 MapperContext ctx, const char* provenance) const;
2481 public:
2482 //------------------------------------------------------------------------
2483 // Methods for updating mappable data
2484 // The mapper is responsible for atomicity of these calls
2485 // (usually through the choice of mapper synchronization model)
2486 //------------------------------------------------------------------------
2487 void update_mappable_tag(
2488 MapperContext ctx, const Mappable& mappable,
2489 MappingTagID new_tag) const;
2490 // Runtime will make a copy of the data passed into this method
2491 void update_mappable_data(
2492 MapperContext ctx, const Mappable& mappable, const void* mapper_data,
2493 size_t mapper_data_size) const;
2494 public:
2495 //------------------------------------------------------------------------
2496 // Methods for communicating with other mappers of the same kind
2497 //------------------------------------------------------------------------
2498 void send_message(
2499 MapperContext ctx, Processor target, const void* message,
2500 size_t message_size, unsigned message_kind = 0) const;
2501 void broadcast(
2502 MapperContext ctx, const void* message, size_t message_size,
2503 unsigned message_kind = 0, int radix = 4) const;
2504 public:
2505 //------------------------------------------------------------------------
2506 // Methods for packing and unpacking physical instances
2507 //------------------------------------------------------------------------
2508 void pack_physical_instance(
2509 MapperContext ctx, Serializer& rez, PhysicalInstance instance) const;
2510 void unpack_physical_instance(
2511 MapperContext ctx, Deserializer& derez,
2512 PhysicalInstance& instance) const;
2513 public:
2514 //------------------------------------------------------------------------
2515 // Methods for managing the execution of mapper tasks
2516 //------------------------------------------------------------------------
2517 // MapperEvent launch_mapper_task(MapperContext ctx,
2518 // Processor::TaskFuncID tid,
2519 // const UntypedBuffer &arg) const;
2520
2521 // void defer_mapper_call(MapperContext ctx,
2522 // MapperEvent event) const;
2523
2524 // MapperEvent merge_mapper_events(MapperContext ctx,
2525 // const std::set<MapperEvent>
2526 // &events)const;
2527 public:
2528 //------------------------------------------------------------------------
2529 // Methods for managing mapper events
2530 //------------------------------------------------------------------------
2531 MapperEvent create_mapper_event(MapperContext ctx) const;
2532 bool has_mapper_event_triggered(
2533 MapperContext ctx, MapperEvent event) const;
2534 void trigger_mapper_event(MapperContext ctx, MapperEvent event) const;
2535 void wait_on_mapper_event(MapperContext ctx, MapperEvent event) const;
2536 public:
2537 //------------------------------------------------------------------------
2538 // Methods for managing constraint information
2539 //------------------------------------------------------------------------
2540 const ExecutionConstraintSet& find_execution_constraints(
2541 MapperContext ctx, TaskID task_id, VariantID vid) const;
2542 const TaskLayoutConstraintSet& find_task_layout_constraints(
2543 MapperContext ctx, TaskID task_id, VariantID vid) const;
2544 const LayoutConstraintSet& find_layout_constraints(
2545 MapperContext ctx, LayoutConstraintID id) const;
2546 LayoutConstraintID register_layout(
2547 MapperContext ctx, const LayoutConstraintSet& layout_constraints,
2548 FieldSpace handle = FieldSpace::NO_SPACE) const;
2549 void release_layout(
2550 MapperContext ctx, LayoutConstraintID layout_id) const;
2551 bool do_constraints_conflict(
2552 MapperContext ctx, LayoutConstraintID set1, LayoutConstraintID set2,
2553 const LayoutConstraint** conflict_constraint = nullptr) const;
2554 bool do_constraints_entail(
2555 MapperContext ctx, LayoutConstraintID source,
2556 LayoutConstraintID target,
2557 const LayoutConstraint** failed_constraint = nullptr) const;
2558 public:
2559 //------------------------------------------------------------------------
2560 // Methods for manipulating variants
2561 //------------------------------------------------------------------------
2562 void find_valid_variants(
2563 MapperContext ctx, TaskID task_id,
2564 std::vector<VariantID>& valid_variants,
2565 Processor::Kind kind = Processor::NO_KIND) const;
2566 void find_generator_variants(
2567 MapperContext ctx, TaskID task_id,
2568 std::vector<std::pair<TaskID, VariantID> >& generator_variants,
2569 Processor::Kind kind = Processor::NO_KIND) const;
2570 VariantID find_or_create_variant(
2571 MapperContext ctx, TaskID task_id,
2572 const ExecutionConstraintSet& execution_constrains,
2573 const TaskLayoutConstraintSet& layout_constraints,
2574 TaskID generator_tid, VariantID generator_vid,
2575 Processor generator_processor, bool& created) const;
2576 const char* find_task_variant_name(
2577 MapperContext ctx, TaskID task_id, VariantID vid) const;
2578 bool is_leaf_variant(
2579 MapperContext ctx, TaskID task_id, VariantID variant_id) const;
2580 bool is_inner_variant(
2581 MapperContext ctx, TaskID task_id, VariantID variant_id) const;
2582 bool is_idempotent_variant(
2583 MapperContext ctx, TaskID task_id, VariantID variant_id) const;
2584 bool is_replicable_variant(
2585 MapperContext ctx, TaskID task_id, VariantID variant_id) const;
2586 public:
2587 //------------------------------------------------------------------------
2588 // Methods for registering variants
2589 //------------------------------------------------------------------------
2590 template<
2591 typename T, T (*TASK_PTR)(
2592 const Task*, const std::vector<PhysicalRegion>&,
2593 Context, Runtime*)>
2594 VariantID register_task_variant(
2595 MapperContext ctx, const TaskVariantRegistrar& registrar) const;
2596 template<
2597 typename T, typename UDT,
2598 T (*TASK_PTR)(
2599 const Task*, const std::vector<PhysicalRegion>&, Context,
2600 Runtime*, const UDT&)>
2601 VariantID register_task_variant(
2602 MapperContext ctx, const TaskVariantRegistrar& registrar,
2603 const UDT& user_data) const;
2604 template<void (*TASK_PTR)(
2605 const Task*, const std::vector<PhysicalRegion>&, Context, Runtime*)>
2606 VariantID register_task_variant(
2607 MapperContext ctx, const TaskVariantRegistrar& registrar) const;
2608 template<
2609 typename UDT, void (*TASK_PTR)(
2610 const Task*, const std::vector<PhysicalRegion>&,
2611 Context, Runtime*, const UDT&)>
2612 VariantID register_task_variant(
2613 MapperContext ctx, const TaskVariantRegistrar& registrar,
2614 const UDT& user_data) const;
2615 VariantID register_task_variant(
2616 MapperContext ctx, const TaskVariantRegistrar& registrar,
2617 const CodeDescriptor& codedesc, const void* user_data = nullptr,
2618 size_t user_len = 0, size_t return_type_size = LEGION_MAX_RETURN_SIZE,
2619 bool has_return_type = false) const;
2620 public:
2621 //------------------------------------------------------------------------
2622 // Methods for accelerating mapping decisions
2623 //------------------------------------------------------------------------
2624 // Filter variants based on the chosen instances
2625 void filter_variants(
2626 MapperContext ctx, const Task& task,
2627 const std::vector<std::vector<PhysicalInstance> >& chosen_intances,
2628 std::vector<VariantID>& variants) const;
2629 // Filter instances based on a chosen variant
2630 void filter_instances(
2631 MapperContext ctx, const Task& task, VariantID chosen_variant,
2632 std::vector<std::vector<PhysicalInstance> >& instances,
2633 std::vector<std::set<FieldID> >& missing_fields) const;
2634 // Filter a specific set of instances for one region requirement
2635 void filter_instances(
2636 MapperContext ctx, const Task& task, unsigned index,
2637 VariantID chosen_variant, std::vector<PhysicalInstance>& instances,
2638 std::set<FieldID>& missing_fields) const;
2639 public:
2640 //------------------------------------------------------------------------
2641 // Methods for managing physical instances
2642 //------------------------------------------------------------------------
2643 bool create_physical_instance(
2644 MapperContext ctx, Memory target_memory,
2645 const LayoutConstraintSet& constraints,
2646 const std::vector<LogicalRegion>& regions, PhysicalInstance& result,
2647 bool acquire = true, GCPriority priority = 0,
2648 bool tight_region_bounds = false, size_t* footprint = nullptr,
2649 const LayoutConstraint** unsat = nullptr) const;
2650 bool create_physical_instance(
2651 MapperContext ctx, Memory target_memory, LayoutConstraintID layout_id,
2652 const std::vector<LogicalRegion>& regions, PhysicalInstance& result,
2653 bool acquire = true, GCPriority priority = 0,
2654 bool tight_region_bounds = false, size_t* footprint = nullptr,
2655 const LayoutConstraint** unsat = nullptr) const;
2656 bool find_or_create_physical_instance(
2657 MapperContext ctx, Memory target_memory,
2658 const LayoutConstraintSet& constraints,
2659 const std::vector<LogicalRegion>& regions, PhysicalInstance& result,
2660 bool& created, bool acquire = true, GCPriority priority = 0,
2661 bool tight_region_bounds = false, size_t* footprint = nullptr,
2662 const LayoutConstraint** unsat = nullptr) const;
2663 bool find_or_create_physical_instance(
2664 MapperContext ctx, Memory target_memory, LayoutConstraintID layout_id,
2665 const std::vector<LogicalRegion>& regions, PhysicalInstance& result,
2666 bool& created, bool acquire = true, GCPriority priority = 0,
2667 bool tight_region_bounds = false, size_t* footprint = nullptr,
2668 const LayoutConstraint** unsat = nullptr) const;
2669 bool find_physical_instance(
2670 MapperContext ctx, Memory target_memory,
2671 const LayoutConstraintSet& constraints,
2672 const std::vector<LogicalRegion>& regions, PhysicalInstance& result,
2673 bool acquire = true, bool tight_region_bounds = false) const;
2674 bool find_physical_instance(
2675 MapperContext ctx, Memory target_memory, LayoutConstraintID layout_id,
2676 const std::vector<LogicalRegion>& regions, PhysicalInstance& result,
2677 bool acquire = true, bool tight_region_bounds = false) const;
2678 void find_physical_instances(
2679 MapperContext ctx, Memory target_memory,
2680 const LayoutConstraintSet& constraints,
2681 const std::vector<LogicalRegion>& regions,
2682 std::vector<PhysicalInstance>& results, bool acquire = false,
2683 bool tight_region_bounds = false) const;
2684 void find_physical_instances(
2685 MapperContext ctx, Memory target_memory, LayoutConstraintID layout_id,
2686 const std::vector<LogicalRegion>& regions,
2687 std::vector<PhysicalInstance>& results, bool acquire = false,
2688 bool tight_region_bounds = false) const;
2689 void set_garbage_collection_priority(
2690 MapperContext ctx, const PhysicalInstance& instance,
2691 GCPriority priority) const;
2692 // These methods will atomically check to make sure that these instances
2693 // are still valid and then add an implicit reference to them to ensure
2694 // that they aren't collected before this mapping call completes. They
2695 // don't need to be called as part of mapping an instance, but they are
2696 // highly recommended to ensure correctness. Acquiring instances and
2697 // then not using them is also acceptable as the runtime will implicitly
2698 // release the references after the call. Instances can also be released
2699 // as might be expected if a mapper opts to attempt to map a different
2700 // instance, but this is an optional performance improvement.
2701 bool acquire_instance(
2702 MapperContext ctx, const PhysicalInstance& instance) const;
2703 bool acquire_instances(
2704 MapperContext ctx, const std::vector<PhysicalInstance>& insts) const;
2705 bool acquire_and_filter_instances(
2706 MapperContext ctx, std::vector<PhysicalInstance>& instances,
2707 bool filter_acquired_instance = false) const;
2708 bool acquire_instances(
2709 MapperContext ctx,
2710 const std::vector<std::vector<PhysicalInstance> >& instances) const;
2711 bool acquire_and_filter_instances(
2712 MapperContext ctx,
2713 std::vector<std::vector<PhysicalInstance> >& instances,
2714 bool filter_acquired_instances = false) const;
2715 void release_instance(
2716 MapperContext ctx, const PhysicalInstance& instance) const;
2717 void release_instances(
2718 MapperContext ctx,
2719 const std::vector<PhysicalInstance>& instances) const;
2720 void release_instances(
2721 MapperContext ctx,
2722 const std::vector<std::vector<PhysicalInstance> >& instances) const;
2723 // Subscribing to an instance will ensure that a mapper receives a
2724 // mapper invocation when that instance has been deleted. Note that this
2725 // subscription will fail if the instance has already been deleted
2726 // Duplicate subscriptions from the same mapper will be deduplicated
2727 // and only a single callback will be performed
2728 bool subscribe(MapperContext ctx, const PhysicalInstance& instance) const;
2729 void unsubscribe(MapperContext ctx, const PhysicalInstance& inst) const;
2730 // This will try to eagerly collect the physical instance if it does not
2731 // contain any valid data, the runtime returns if the collection was
2732 // successful or not. The only reason it will not succeed is if the
2733 // instance contains valid data.
2734 bool collect_instance(
2735 MapperContext ctx, const PhysicalInstance& inst) const;
2736 // This method will try to collect several instances concurrently and
2737 // will return which instances were successfully collected in a
2738 // vector of booleans.
2739 void collect_instances(
2740 MapperContext ctx, const std::vector<PhysicalInstance>& instances,
2741 std::vector<bool>& collected) const;
2742 // This method will attempt to redistrict an instance from one layout
2743 // to another one, thereby reusing the memory associated with the first
2744 // instance to create the new instance (thereby deleting the original
2745 // instance in the process). This will only be permitted if the original
2746 // instance does not not contain any valid data and if the new layout
2747 // fits within the footprint of the original instance. The runtime will
2748 // return a boolean indicating whether the redistricting was successful.
2749 // If the invocation is successful, the 'instance' will be overwritten
2750 // with a handle to the new instance.
2751 bool redistrict_instance(
2752 MapperContext ctx, PhysicalInstance& instance,
2753 const LayoutConstraintSet& constraints,
2754 const std::vector<LogicalRegion>& regions, bool acquire = true,
2755 GCPriority priority = 0, bool tight_region_bounds = false);
2756 bool redistrict_instance(
2757 MapperContext ctx, PhysicalInstance& instance,
2758 LayoutConstraintID layout_id,
2759 const std::vector<LogicalRegion>& regions, bool acquire = true,
2760 GCPriority priority = 0, bool tight_region_bounds = false);
2761 public:
2762 // Futures can also be acquired to ensure that they are available in
2763 // particular memories prior to running a task.
2764 bool acquire_future(MapperContext ctx, const Future& f, Memory mem) const;
2765 // Users can also acquire memory for unbound memory pools when mapping
2766 // tasks. These pools will be implicitly used to satisfy any leaf_pool
2767 // bounds requested for mapping the task. This interface allows mappers
2768 // to discover if leaf pools can be allocated and potentially switch to
2769 // an alternative mapping strategy if they cannot. Mappers must say
2770 // whether the pool being acquired is escaping or non-escaping. If the
2771 // mapper already acquired a pool for this operation in the same memory
2772 // and with the same escaping property then the prior pool will be
2773 // released if the acquire for the new pool succeeds because Legion
2774 // does not permit operations to have more than one pool in the same
2775 // memory with the same escaping property. Users can decide if they
2776 // want the prior pool (if any) to be released before the acquire
2777 // attempt (optimistically) or only when the acquire succeeds to allocate
2778 // the new pool (pessimistically). The former allows the memory from
2779 // the previous pool to be used to satisfy the new pool being acquired
2780 // while the latter ensures that at least one memory pool is always live.
2781 bool acquire_pool(
2782 MapperContext ctx, Memory memory, const PoolBounds& bounds,
2783 bool escaping = true, bool optimistic = false) const;
2784 void release_pool(MapperContext ctx, Memory memory, bool escaping = true);
2785 public:
2786 //------------------------------------------------------------------------
2787 // Methods for creating index spaces which mappers need to do
2788 // in order to be able to properly slice index space operations
2789 //------------------------------------------------------------------------
2790 IndexSpace create_index_space(
2791 MapperContext ctx, const Domain& bounds, TypeTag type_tag = 0,
2792 const char* provenance = nullptr, bool take_ownership = false) const;
2793 // Template version
2794 template<int DIM, typename COORD_T>
2795 IndexSpaceT<DIM, COORD_T> create_index_space(
2796 MapperContext ctx, Rect<DIM, COORD_T> bounds,
2797 const char* provenance = nullptr) const;
2798
2799 IndexSpace create_index_space(
2800 MapperContext ctx, const std::vector<DomainPoint>& points,
2801 const char* provenance = nullptr) const;
2802 // Template version
2803 template<int DIM, typename COORD_T>
2804 IndexSpaceT<DIM, COORD_T> create_index_space(
2805 MapperContext ctx, const std::vector<Point<DIM, COORD_T> >& points,
2806 const char* provenance = nullptr) const;
2807
2808 IndexSpace create_index_space(
2809 MapperContext ctx, const std::vector<Domain>& rects,
2810 const char* provenance = nullptr) const;
2811 // Template version
2812 template<int DIM, typename COORD_T>
2813 IndexSpaceT<DIM, COORD_T> create_index_space(
2814 MapperContext ctx, const std::vector<Rect<DIM, COORD_T> >& rects,
2815 const char* provenance = nullptr) const;
2816
2817 IndexSpace union_index_spaces(
2818 MapperContext ctx, const std::vector<IndexSpace>& sources,
2819 const char* provenance = nullptr) const;
2820 // Template version
2821 template<int DIM, typename COORD_T>
2822 IndexSpaceT<DIM, COORD_T> union_index_spaces(
2823 MapperContext ctx,
2824 const std::vector<IndexSpaceT<DIM, COORD_T> >& sources,
2825 const char* provenance = nullptr) const;
2826
2827 IndexSpace intersect_index_spaces(
2828 MapperContext ctx, const std::vector<IndexSpace>& sources,
2829 const char* provenance = nullptr) const;
2830 // Template version
2831 template<int DIM, typename COORD_T>
2832 IndexSpaceT<DIM, COORD_T> intersect_index_spaces(
2833 MapperContext ctx,
2834 const std::vector<IndexSpaceT<DIM, COORD_T> >& sources,
2835 const char* provenance = nullptr) const;
2836
2837 IndexSpace subtract_index_spaces(
2838 MapperContext ctx, IndexSpace left, IndexSpace right,
2839 const char* provenance = nullptr) const;
2840 // Template version
2841 template<int DIM, typename COORD_T>
2842 IndexSpaceT<DIM, COORD_T> subtract_index_spaces(
2843 MapperContext ctx, IndexSpaceT<DIM, COORD_T> left,
2844 IndexSpaceT<DIM, COORD_T> right,
2845 const char* provenance = nullptr) const;
2846 public:
2847 //------------------------------------------------------------------------
2848 // Convenience methods for introspecting index spaces
2849 //------------------------------------------------------------------------
2850 bool is_index_space_empty(MapperContext ctx, IndexSpace handle) const;
2851 template<int DIM, typename COORD_T>
2852 bool is_index_space_empty(
2853 MapperContext ctx, IndexSpaceT<DIM, COORD_T> handle) const;
2854
2855 bool index_spaces_overlap(
2856 MapperContext ctx, IndexSpace one, IndexSpace two) const;
2857 template<int DIM, typename COORD_T>
2858 bool index_spaces_overlap(
2859 MapperContext ctx, IndexSpaceT<DIM, COORD_T> one,
2860 IndexSpaceT<DIM, COORD_T> two) const;
2861
2862 bool index_space_dominates(
2863 MapperContext ctx, IndexSpace test, IndexSpace dominator) const;
2864 template<int DIM, typename COORD_T>
2865 bool index_space_dominates(
2866 MapperContext ctx, IndexSpaceT<DIM, COORD_T> test,
2867 IndexSpaceT<DIM, COORD_T> dominator) const;
2868 public:
2869 //------------------------------------------------------------------------
2870 // Methods for introspecting index space trees
2871 // For documentation see methods of the same name in Runtime
2872 //------------------------------------------------------------------------
2873 bool has_index_partition(
2874 MapperContext ctx, IndexSpace parent, Color c) const;
2875
2876 IndexPartition get_index_partition(
2877 MapperContext ctx, IndexSpace parent, Color color) const;
2878
2879 IndexSpace get_index_subspace(
2880 MapperContext ctx, IndexPartition p, Color c) const;
2881 IndexSpace get_index_subspace(
2882 MapperContext ctx, IndexPartition p, const DomainPoint& color) const;
2883
2884 bool has_multiple_domains(MapperContext ctx, IndexSpace handle) const;
2885
2886 Domain get_index_space_domain(MapperContext ctx, IndexSpace handle) const;
2887
2888 void get_index_space_domains(
2889 MapperContext ctx, IndexSpace handle,
2890 std::vector<Domain>& domains) const;
2891
2892 Domain get_index_partition_color_space(
2893 MapperContext ctx, IndexPartition p) const;
2894
2895 IndexSpace get_index_partition_color_space_name(
2896 MapperContext ctx, IndexPartition p) const;
2897
2898 void get_index_space_partition_colors(
2899 MapperContext ctx, IndexSpace sp, std::set<Color>& colors) const;
2900
2901 bool is_index_partition_disjoint(
2902 MapperContext ctx, IndexPartition p) const;
2903
2904 bool is_index_partition_complete(
2905 MapperContext ctx, IndexPartition p) const;
2906
2907 Color get_index_space_color(MapperContext ctx, IndexSpace handle) const;
2908
2909 DomainPoint get_index_space_color_point(
2910 MapperContext ctx, IndexSpace handle) const;
2911
2912 Color get_index_partition_color(
2913 MapperContext ctx, IndexPartition handle) const;
2914
2915 IndexSpace get_parent_index_space(
2916 MapperContext ctx, IndexPartition handle) const;
2917
2918 bool has_parent_index_partition(
2919 MapperContext ctx, IndexSpace handle) const;
2920
2921 IndexPartition get_parent_index_partition(
2922 MapperContext ctx, IndexSpace handle) const;
2923
2924 unsigned get_index_space_depth(
2925 MapperContext ctx, IndexSpace handle) const;
2926
2927 unsigned get_index_partition_depth(
2928 MapperContext ctx, IndexPartition handle) const;
2929 public:
2930 //------------------------------------------------------------------------
2931 // Methods for introspecting field spaces
2932 // For documentation see methods of the same name in Runtime
2933 //------------------------------------------------------------------------
2934 size_t get_field_size(
2935 MapperContext ctx, FieldSpace handle, FieldID fid) const;
2936
2937 void get_field_space_fields(
2938 MapperContext ctx, FieldSpace handle,
2939 std::vector<FieldID>& fields) const;
2940 void get_field_space_fields(
2941 MapperContext ctx, FieldSpace handle,
2942 std::set<FieldID>& fields) const;
2943 public:
2944 //------------------------------------------------------------------------
2945 // Methods for introspecting logical region trees
2946 //------------------------------------------------------------------------
2947 LogicalPartition get_logical_partition(
2948 MapperContext ctx, LogicalRegion parent, IndexPartition handle) const;
2949
2950 LogicalPartition get_logical_partition_by_color(
2951 MapperContext ctx, LogicalRegion parent, Color color) const;
2952 LogicalPartition get_logical_partition_by_color(
2953 MapperContext ctx, LogicalRegion parent,
2954 const DomainPoint& color) const;
2955
2956 LogicalPartition get_logical_partition_by_tree(
2957 MapperContext ctx, IndexPartition handle, FieldSpace fspace,
2958 RegionTreeID tid) const;
2959
2960 LogicalRegion get_logical_subregion(
2961 MapperContext ctx, LogicalPartition parent, IndexSpace handle) const;
2962
2963 LogicalRegion get_logical_subregion_by_color(
2964 MapperContext ctx, LogicalPartition parent, Color color) const;
2965 LogicalRegion get_logical_subregion_by_color(
2966 MapperContext ctx, LogicalPartition parent,
2967 const DomainPoint& color) const;
2968
2969 LogicalRegion get_logical_subregion_by_tree(
2970 MapperContext ctx, IndexSpace handle, FieldSpace fspace,
2971 RegionTreeID tid) const;
2972
2973 Color get_logical_region_color(
2974 MapperContext ctx, LogicalRegion handle) const;
2975
2976 DomainPoint get_logical_region_color_point(
2977 MapperContext ctx, LogicalRegion handle) const;
2978
2979 Color get_logical_partition_color(
2980 MapperContext ctx, LogicalPartition handle) const;
2981
2982 LogicalRegion get_parent_logical_region(
2983 MapperContext ctx, LogicalPartition handle) const;
2984
2985 bool has_parent_logical_partition(
2986 MapperContext ctx, LogicalRegion handle) const;
2987
2988 LogicalPartition get_parent_logical_partition(
2989 MapperContext ctx, LogicalRegion handle) const;
2990 public:
2991 //------------------------------------------------------------------------
2992 // Methods for getting access to semantic info
2993 //------------------------------------------------------------------------
2994 bool retrieve_semantic_information(
2995 MapperContext ctx, TaskID task_id, SemanticTag tag,
2996 const void*& result, size_t& size, bool can_fail = false,
2997 bool wait_until_ready = false) const;
2998
2999 bool retrieve_semantic_information(
3000 MapperContext ctx, IndexSpace handle, SemanticTag tag,
3001 const void*& result, size_t& size, bool can_fail = false,
3002 bool wait_until_ready = false) const;
3003
3004 bool retrieve_semantic_information(
3005 MapperContext ctx, IndexPartition handle, SemanticTag tag,
3006 const void*& result, size_t& size, bool can_fail = false,
3007 bool wait_until_ready = false) const;
3008
3009 bool retrieve_semantic_information(
3010 MapperContext ctx, FieldSpace handle, SemanticTag tag,
3011 const void*& result, size_t& size, bool can_fail = false,
3012 bool wait_until_ready = false) const;
3013
3014 bool retrieve_semantic_information(
3015 MapperContext ctx, FieldSpace handle, FieldID fid, SemanticTag tag,
3016 const void*& result, size_t& size, bool can_fail = false,
3017 bool wait_until_ready = false) const;
3018
3019 bool retrieve_semantic_information(
3020 MapperContext ctx, LogicalRegion handle, SemanticTag tag,
3021 const void*& result, size_t& size, bool can_fail = false,
3022 bool wait_until_ready = false) const;
3023
3024 bool retrieve_semantic_information(
3025 MapperContext ctx, LogicalPartition handle, SemanticTag tag,
3026 const void*& result, size_t& size, bool can_fail = false,
3027 bool wait_until_ready = false) const;
3028
3029 void retrieve_name(
3030 MapperContext ctx, TaskID task_id, const char*& result) const;
3031
3032 void retrieve_name(
3033 MapperContext ctx, IndexSpace handle, const char*& result) const;
3034
3035 void retrieve_name(
3036 MapperContext ctx, IndexPartition handle, const char*& result) const;
3037
3038 void retrieve_name(
3039 MapperContext ctx, FieldSpace handle, const char*& result) const;
3040
3041 void retrieve_name(
3042 MapperContext ctx, FieldSpace handle, FieldID fid,
3043 const char*& result) const;
3044
3045 void retrieve_name(
3046 MapperContext ctx, LogicalRegion handle, const char*& result) const;
3047
3048 void retrieve_name(
3049 MapperContext ctx, LogicalPartition handle,
3050 const char*& result) const;
3051 public:
3052 //------------------------------------------------------------------------
3053 // Methods for MPI interoperability
3054 //------------------------------------------------------------------------
3055 bool is_MPI_interop_configured(MapperContext ctx) const;
3056 const std::map<int /*rank*/, AddressSpace>& find_forward_MPI_mapping(
3057 MapperContext ctx) const;
3058
3059 const std::map<AddressSpace, int /*rank*/>& find_reverse_MPI_mapping(
3060 MapperContext ctx) const;
3061 int find_local_MPI_rank(MapperContext ctx) const;
3062 public:
3063 //------------------------------------------------------------------------
3064 // Support for packing tunable values
3065 //------------------------------------------------------------------------
3066 template<typename T>
3067 void pack_tunable(
3068 const T& result, Mapper::SelectTunableOutput& output) const
3069 {
3070 static_assert(
3071 std::is_trivially_copyable<T>::value,
3072 "tunable type must be trivially copyable");
3073 void* output_result = malloc(sizeof(T));
3074 memcpy(output_result, &result, sizeof(T));
3075 output.value = output_result;
3076 output.size = sizeof(T);
3077 }
3078 };
3079
3088 public:
3089 AutoLock(MapperContext ctx, LocalLock& r, bool excl = true);
3090 [[deprecated("Use the version without a mode")]]
3091 AutoLock(MapperContext ctx, LocalLock& r, int mode, bool excl = true);
3092 AutoLock(AutoLock&& rhs) = delete;
3093 AutoLock(const AutoLock& rhs) = delete;
3094 ~AutoLock(void) { };
3095 public:
3096 AutoLock& operator=(AutoLock&& rhs) = delete;
3097 AutoLock& operator=(const AutoLock& rhs) = delete;
3098 public:
3099 void reacquire(void);
3100 protected:
3101 const MapperContext ctx;
3102 };
3103
3104 } // namespace Mapping
3105} // namespace Legion
3106
3107#include "legion/api/mapping.inl"
3108
3109#endif // __LEGION_MAPPING_H__
Definition mapping.h:235
Definition mapping.h:287
Definition mapping.h:180
Definition geometry.h:154
Definition geometry.h:29
Definition constraints.h:240
Definition data.h:147
static const FieldSpace NO_SPACE
Definition data.h:149
Definition mapping.h:307
Definition future.h:45
Definition data.h:87
Definition data.h:30
static const IndexSpace NO_SPACE
Definition data.h:32
Definition mapping.h:211
Definition types.h:1125
Definition types.h:1008
Definition types.h:947
Definition constraints.h:275
Definition constraints.h:881
Definition data.h:255
Definition data.h:184
Definition mapping.h:37
Definition mapping.h:3087
Definition mapping.h:481
Definition mapping.h:517
Definition mapping.h:633
virtual void select_sharding_functor(MapperContext ctx, const Partition &partition, const SelectShardingFunctorInput &input, SelectShardingFunctorOutput &output)=0
virtual void select_sharding_functor(MapperContext ctx, const Copy &copy, const SelectShardingFunctorInput &input, SelectShardingFunctorOutput &output)=0
virtual void select_sharding_functor(MapperContext ctx, const Acquire &acquire, const SelectShardingFunctorInput &input, SelectShardingFunctorOutput &output)=0
virtual void select_sharding_functor(MapperContext ctx, const Release &release, const SelectShardingFunctorInput &input, SelectShardingFunctorOutput &output)=0
MapperSyncModel
Definition mapping.h:669
virtual bool request_valid_instances(void) const
Definition mapping.h:691
virtual void select_sharding_functor(MapperContext ctx, const Close &close, const SelectShardingFunctorInput &input, SelectShardingFunctorOutput &output)=0
virtual void handle_instance_collection(const MapperContext ctx, const PhysicalInstance &inst)
Definition mapping.h:2436
virtual const char * get_mapper_name(void) const =0
virtual void select_sharding_functor(MapperContext ctx, const Fill &fill, const SelectShardingFunctorInput &input, SelectShardingFunctorOutput &output)=0
Definition mapping.h:2449
Definition mapping.h:405
Definition mapping.h:559
Definition mapping.h:580
Definition mapping.h:372
Definition mapping.h:337
Definition constraints.h:783
Definition mapping.h:259
Definition runtime.h:103
Definition mapping.h:107
Definition constraints.h:942
Definition mapping.h:1394
Definition mapping.h:2274
Definition mapping.h:1122
Definition mapping.h:1127
Definition mapping.h:774
Definition mapping.h:860
Definition registrars.h:71
Definition requirements.h:37
Definition registrars.h:106