Legion Runtime
Loading...
Searching...
No Matches
mapping.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_MAPPING_H__
17#define __LEGION_MAPPING_H__
18
24// Need these since we're handing these to the client
25#include <map>
26#include <set>
27#include <list>
28#include <deque>
29#include <vector>
30
32#include "legion/api/runtime.h"
33
34namespace Legion {
35
42 class Mappable {
43 public:
44 Mappable(void);
45 public:
46 // Return a globally unique ID for this operation
47 virtual UniqueID get_unique_id(void) const = 0;
48 // Return the number of operations that came before
49 // this operation in the same context (close operations
50 // return number of previous close operations)
51 virtual uint64_t get_context_index(void) const = 0;
52 // Return the depth of this operation in the task tree
53 virtual int get_depth(void) const = 0;
54 // Get the parent task associated with this mappable
55 virtual const Task* get_parent_task(void) const = 0;
56 // Get the provenance string for this mappable
57 // By default we return the human readable component but
58 // you can also get the machine component as well
59 virtual const std::string_view& get_provenance_string(
60 bool human = true) const = 0;
61 public:
62 virtual MappableType get_mappable_type(void) const = 0;
63 virtual const Task* as_task(void) const { return nullptr; }
64 virtual const Copy* as_copy(void) const { return nullptr; }
65 virtual const InlineMapping* as_inline(void) const { return nullptr; }
66 virtual const Acquire* as_acquire(void) const { return nullptr; }
67 virtual const Release* as_release(void) const { return nullptr; }
68 virtual const Close* as_close(void) const { return nullptr; }
69 virtual const Fill* as_fill(void) const { return nullptr; }
70 virtual const Partition* as_partition(void) const { return nullptr; }
71 virtual const MustEpoch* as_must_epoch(void) const { return nullptr; }
72 public:
73 MapperID map_id;
74 MappingTagID tag;
75 public:
76 // The 'parent_task' member is here for backwards compatibility
77 // It's better to use the 'get_parent_task' method
78 // as this may be nullptr until that method is called
79 mutable const Task* parent_task;
80 public:
81 // Mapper annotated data
82 void* mapper_data;
83 size_t mapper_data_size;
84 public:
85 // These are here for backwards compatibility from a time when
86 // the MappableType enum was inside of this class
87#ifndef __GNUC__
88 // GCC doesn't like this line even though it's just creating a
89 // type alias, who knows what their problem is
90 typedef Legion::MappableType MappableType;
91#endif
92 static const MappableType TASK_MAPPABLE = ::LEGION_TASK_MAPPABLE;
93 static const MappableType COPY_MAPPABLE = ::LEGION_COPY_MAPPABLE;
94 static const MappableType INLINE_MAPPABLE = ::LEGION_INLINE_MAPPABLE;
95 static const MappableType ACQUIRE_MAPPABLE = ::LEGION_ACQUIRE_MAPPABLE;
96 static const MappableType RELEASE_MAPPABLE = ::LEGION_RELEASE_MAPPABLE;
97 static const MappableType CLOSE_MAPPABLE = ::LEGION_CLOSE_MAPPABLE;
98 static const MappableType FILL_MAPPABLE = ::LEGION_FILL_MAPPABLE;
99 static const MappableType PARTITION_MAPPABLE = ::LEGION_PARTITION_MAPPABLE;
100 static const MappableType MUST_EPOCH_MAPPABLE =
101 ::LEGION_MUST_EPOCH_MAPPABLE;
102 };
103
112 class Task : public Mappable {
113 public:
114 Task(void);
115 public:
116 // Check whether this task has a parent task.
117 virtual bool has_parent_task(void) const = 0;
118 // Return the name of the task.
119 virtual const char* get_task_name(void) const = 0;
120 // Returns the current slice of the index domain that this
121 // task is operating over. This method will only return a
122 // valid domain if this is part of an index space task.
123 virtual Domain get_slice_domain(void) const = 0;
124 //------------------------------------------------------------------------
125 // Control Replication methods
126 // In general SPMD-style programming in Legion is wrong. If you find
127 // yourself writing SPMD-style code for large fractions of your program
128 // then you're probably doing something wrong. There are a few exceptions:
129 // 1. index attach/detach operations are collective and may need
130 // to do per-shard work
131 // 2. I/O in general often needs to do per-shard work
132 // 3. interaction with collective frameworks like MPI and NCCL
133 // 4. others?
134 // For these reasons we allow users to get access to sharding information
135 // Please, please, please be careful with how you use it
136 //------------------------------------------------------------------------
137 virtual ShardID get_shard_id(void) const = 0;
138 virtual size_t get_total_shards(void) const = 0;
139 virtual DomainPoint get_shard_point(void) const = 0;
140 virtual Domain get_shard_domain(void) const = 0;
141 public:
142 virtual MappableType get_mappable_type(void) const
143 {
144 return LEGION_TASK_MAPPABLE;
145 }
146 virtual const Task* as_task(void) const { return this; }
147 public:
148 // Task argument information
149 TaskID task_id;
150 std::vector<IndexSpaceRequirement> indexes;
151 std::vector<RegionRequirement> regions;
152 std::vector<OutputRequirement> output_regions;
153 std::vector<Future> futures;
154 std::vector<Grant> grants;
155 std::vector<PhaseBarrier> wait_barriers;
156 std::vector<PhaseBarrier> arrive_barriers;
157 const void* args;
158 size_t arglen;
159 public:
160 // Index task argument information
161 bool is_index_space;
162 bool concurrent_task;
163 bool must_epoch_task;
164 Domain index_domain;
165 DomainPoint index_point;
166 IndexSpace sharding_space;
167 const void* local_args;
168 size_t local_arglen;
169 public:
170 // Meta data information from the runtime
171 Processor orig_proc;
172 Processor current_proc;
173 Processor target_proc;
174 unsigned steal_count;
175 bool stealable;
176 bool speculated;
177 bool local_function;
178 };
179
185 class Copy : public Mappable {
186 public:
187 Copy(void);
188 public:
189 virtual MappableType get_mappable_type(void) const
190 {
191 return LEGION_COPY_MAPPABLE;
192 }
193 virtual const Copy* as_copy(void) const { return this; }
194 public:
195 // Copy Launcher arguments
196 std::vector<RegionRequirement> src_requirements;
197 std::vector<RegionRequirement> dst_requirements;
198 std::vector<RegionRequirement> src_indirect_requirements;
199 std::vector<RegionRequirement> dst_indirect_requirements;
200 std::vector<Grant> grants;
201 std::vector<PhaseBarrier> wait_barriers;
202 std::vector<PhaseBarrier> arrive_barriers;
203 public:
204 // Index copy argument information
205 bool is_index_space;
206 Domain index_domain;
207 DomainPoint index_point;
208 IndexSpace sharding_space;
209 };
210
216 class InlineMapping : public Mappable {
217 public:
218 InlineMapping(void);
219 public:
220 virtual MappableType get_mappable_type(void) const
221 {
222 return LEGION_INLINE_MAPPABLE;
223 }
224 virtual const InlineMapping* as_inline(void) const { return this; }
225 virtual ShardID get_parent_shard(void) const { return 0; }
226 public:
227 // Inline Launcher arguments
228 RegionRequirement requirement;
229 std::vector<Grant> grants;
230 std::vector<PhaseBarrier> wait_barriers;
231 std::vector<PhaseBarrier> arrive_barriers;
232 LayoutConstraintID layout_constraint_id;
233 };
234
240 class Acquire : public Mappable {
241 public:
242 Acquire(void);
243 public:
244 virtual MappableType get_mappable_type(void) const
245 {
246 return LEGION_ACQUIRE_MAPPABLE;
247 }
248 virtual const Acquire* as_acquire(void) const { return this; }
249 public:
250 // Acquire Launcher arguments
251 LogicalRegion logical_region;
252 LogicalRegion parent_region;
253 std::set<FieldID> fields;
254 std::vector<Grant> grants;
255 std::vector<PhaseBarrier> wait_barriers;
256 std::vector<PhaseBarrier> arrive_barriers;
257 };
258
264 class Release : public Mappable {
265 public:
266 Release(void);
267 public:
268 virtual MappableType get_mappable_type(void) const
269 {
270 return LEGION_RELEASE_MAPPABLE;
271 }
272 virtual const Release* as_release(void) const { return this; }
273 public:
274 // Release Launcher arguments
275 LogicalRegion logical_region;
276 LogicalRegion parent_region;
277 std::set<FieldID> fields;
278 std::vector<Grant> grants;
279 std::vector<PhaseBarrier> wait_barriers;
280 std::vector<PhaseBarrier> arrive_barriers;
281 };
282
292 class Close : public Mappable {
293 public:
294 Close(void);
295 public:
296 virtual MappableType get_mappable_type(void) const
297 {
298 return LEGION_CLOSE_MAPPABLE;
299 }
300 virtual const Close* as_close(void) const { return this; }
301 public:
302 // Synthesized region requirement
303 RegionRequirement requirement;
304 };
305
312 class Fill : public Mappable {
313 public:
314 Fill(void);
315 public:
316 virtual MappableType get_mappable_type(void) const
317 {
318 return LEGION_FILL_MAPPABLE;
319 }
320 virtual const Fill* as_fill(void) const { return this; }
321 public:
322 // Synthesized region requirement
323 RegionRequirement requirement;
324 std::vector<Grant> grants;
325 std::vector<PhaseBarrier> wait_barriers;
326 std::vector<PhaseBarrier> arrive_barriers;
327 public:
328 // Index fill argument information
329 bool is_index_space;
330 Domain index_domain;
331 DomainPoint index_point;
332 IndexSpace sharding_space;
333 };
334
342 class Partition : public Mappable {
343 public:
344 Partition(void);
345 public:
346 virtual MappableType get_mappable_type(void) const
347 {
348 return LEGION_PARTITION_MAPPABLE;
349 }
350 virtual const Partition* as_partition(void) const { return this; }
351 public:
352 enum PartitionKind {
353 BY_FIELD, // create partition by field
354 BY_IMAGE, // create partition by image
355 BY_IMAGE_RANGE, // create partition by image range
356 BY_PREIMAGE, // create partition by preimage
357 BY_PREIMAGE_RANGE, // create partition by preimage range
358 BY_ASSOCIATION, // create partition by association
359 };
360 virtual PartitionKind get_partition_kind(void) const = 0;
361 public:
362 // Synthesized region requirement
363 RegionRequirement requirement;
364 public:
365 // Index partition argument information
366 bool is_index_space;
367 Domain index_domain;
368 DomainPoint index_point;
369 };
370
377 class MustEpoch : public Mappable {
378 public:
379 MustEpoch(void);
380 public:
381 virtual MappableType get_mappable_type(void) const
382 {
383 return LEGION_MUST_EPOCH_MAPPABLE;
384 }
385 virtual const MustEpoch* as_must_epoch(void) const { return this; }
386 public:
387 std::vector<const Task*> individual_tasks;
388 std::vector<const Task*> index_space_tasks;
389 public:
390 // Index space of points for the must epoch operation
391 Domain launch_domain;
392 IndexSpace sharding_space;
393 };
394
399 namespace Mapping {
400
415 public:
416 PhysicalInstance(void);
417 PhysicalInstance(PhysicalInstance&& rhs) noexcept;
419 ~PhysicalInstance(void);
420 public:
421 PhysicalInstance& operator=(PhysicalInstance&& rhs) noexcept;
422 PhysicalInstance& operator=(const PhysicalInstance& rhs);
423 public:
424 bool operator<(const PhysicalInstance& rhs) const;
425 bool operator==(const PhysicalInstance& rhs) const;
426 bool operator!=(const PhysicalInstance& rhs) const;
427 std::size_t hash(void) const;
428 public:
429 // Get the location of this physical instance
430 Memory get_location(void) const;
431 unsigned long get_instance_id(void) const;
432 size_t get_instance_size(void) const;
433 Domain get_instance_domain(void) const;
434 // Adds all fields that exist in instance to 'fields', unless
435 // instance is virtual
436 void get_fields(std::set<FieldID>& fields) const;
437 public:
438 FieldSpace get_field_space(void) const;
439 RegionTreeID get_tree_id(void) const;
440 LayoutConstraintID get_layout_id(void) const;
441 PointerConstraint get_pointer_constraint(void) const;
442 public:
443 // See if our instance still exists or if it has been
444 // garbage collected, this is just a sample, using the
445 // acquire methods provided by the mapper_rt interface
446 // can prevent it from being collected during the
447 // lifetime of a mapper call.
448 bool exists(bool strong_test = false) const;
449 bool is_normal_instance(void) const;
450 bool is_virtual_instance(void) const;
451 bool is_reduction_instance(void) const;
452 bool is_external_instance(void) const;
453 public:
454 bool has_field(FieldID fid) const;
455 void has_fields(std::map<FieldID, bool>& fids) const;
456 void remove_space_fields(std::set<FieldID>& fids) const;
457 public:
458 // Use these to specify the fields for which this instance
459 // should be used. It is optional to specify this and is only
460 // necessary to disambiguate which fields should be used when
461 // multiple selected instances have the same field(s).
462 void add_use_field(FieldID fid);
463 void add_use_fields(const std::set<FieldID>& fids);
464 public:
465 // Check to see if a whole set of constraints are satisfied
466 bool entails(
467 const LayoutConstraintSet& constraint_set,
468 const LayoutConstraint** failed_constraint = nullptr) const;
469 public:
470 static PhysicalInstance get_virtual_instance(void);
471 private:
472 friend class CollectiveView;
473 FRIEND_ALL_RUNTIME_CLASSES
474 // Only the runtime can make an instance like this
475 PhysicalInstance(PhysicalInstanceImpl impl);
476 private:
477 PhysicalInstanceImpl impl;
478 friend std::ostream& operator<<(
479 std::ostream& os, const PhysicalInstance& p);
480 };
481
491 public:
492 CollectiveView(void);
493 CollectiveView(CollectiveView&& rhs) noexcept;
494 CollectiveView(const CollectiveView& rhs);
495 ~CollectiveView(void);
496 public:
497 CollectiveView& operator=(CollectiveView&& rhs) noexcept;
498 CollectiveView& operator=(const CollectiveView& rhs);
499 public:
500 bool operator<(const CollectiveView& rhs) const;
501 bool operator==(const CollectiveView& rhs) const;
502 bool operator!=(const CollectiveView& rhs) const;
503 std::size_t hash(void) const;
504 public:
505 void find_instances_in_memory(
506 Memory memory, std::vector<PhysicalInstance>& insts) const;
507 void find_instances_nearest_memory(
508 Memory memory, std::vector<PhysicalInstance>& insts,
509 bool bandwidth = true) const;
510 private:
511 FRIEND_ALL_RUNTIME_CLASSES
512 // Only the runtime can make an instance like this
513 CollectiveView(CollectiveViewImpl impl);
514 private:
515 CollectiveViewImpl impl;
516 friend std::ostream& operator<<(
517 std::ostream& os, const CollectiveView& p);
518 };
519
527 public:
528 MapperEvent(void) : impl(Internal::RtUserEvent()) { }
529 FRIEND_ALL_RUNTIME_CLASSES
530 public:
531 inline bool exists(void) const { return impl.exists(); }
532 inline bool operator==(const MapperEvent& rhs) const
533 {
534 return (impl.id == rhs.impl.id);
535 }
536 inline bool operator<(const MapperEvent& rhs) const
537 {
538 return (impl.id < rhs.impl.id);
539 }
540 inline std::size_t hash(void) const
541 {
542 return std::hash<unsigned long long>{}(impl.id);
543 }
544 private:
546 };
547
548 namespace ProfilingMeasurements {
549 // import all the Realm measurements into this namespace too
550 using namespace Realm::ProfilingMeasurements;
551
552 struct RuntimeOverhead {
553 static const ProfilingMeasurementID ID = PMID_RUNTIME_OVERHEAD;
554 RuntimeOverhead(void);
555 // application, runtime, wait times all reported in nanoseconds
556 long long application_time; // time spent in application code
557 long long runtime_time; // time spent in runtime code
558 long long wait_time; // time spent waiting
559 };
560 }; // namespace ProfilingMeasurements
561
569 public:
570 ProfilingRequest(void);
571 ~ProfilingRequest(void);
572
573 template<typename T>
574 inline ProfilingRequest& add_measurement(void);
575
576 inline bool empty(void) const;
577 protected:
578 FRIEND_ALL_RUNTIME_CLASSES
579 void populate_realm_profiling_request(Realm::ProfilingRequest& req);
580
581 std::set<ProfilingMeasurementID> requested_measurements;
582 };
583
590 public:
591 // default constructor used because this appears in the
592 // {...}ProfilingInfo structs below
593 ProfilingResponse(void);
594 ~ProfilingResponse(void);
595
596 // even if a measurement was requested, it may not have been performed -
597 // use this to check
598 template<typename T>
599 inline bool has_measurement(void) const;
600
601 // extracts a measurement (if available), returning a dynamically
602 // allocated result - caller should delete it when done
603 template<typename T>
604 inline T* get_measurement(void) const;
605
606 template<typename T>
607 inline bool get_measurement(T& result) const;
608 protected:
609 FRIEND_ALL_RUNTIME_CLASSES
610 void attach_realm_profiling_response(
611 const Realm::ProfilingResponse& resp);
612 void attach_overhead(ProfilingMeasurements::RuntimeOverhead* overhead);
613
614 const Realm::ProfilingResponse* realm_resp;
615 ProfilingMeasurements::RuntimeOverhead* overhead;
616 };
617
629 public:
630 TaskID task_id;
631 MapperID mapper_id;
632 ExecutionConstraintSet execution_constraints;
633 TaskLayoutConstraintSet layout_constraints;
634 };
635
642 class Mapper {
643 public:
645 virtual ~Mapper(void);
646 public:
647 MapperRuntime* const runtime;
648 public:
659 virtual const char* get_mapper_name(void) const = 0;
660 public:
679 CONCURRENT_MAPPER_MODEL,
680 SERIALIZED_REENTRANT_MAPPER_MODEL,
681 SERIALIZED_NON_REENTRANT_MAPPER_MODEL,
682 };
683 virtual MapperSyncModel get_mapper_sync_model(void) const = 0;
684 public:
700 virtual bool request_valid_instances(void) const { return true; }
701 public: // Task mapping calls
783 struct TaskOptions {
784 Processor initial_proc; // = current
785 bool inline_task = false;
786 bool stealable = false;
787 bool map_locally = false;
788 bool valid_instances = true;
789 bool memoize = false;
790 bool replicate = false;
791 TaskPriority parent_priority; // = current
792 std::set<unsigned> check_collective_regions;
793 };
794 //------------------------------------------------------------------------
795 virtual void select_task_options(
796 MapperContext ctx, const Task& task, TaskOptions& output) = 0;
797 //------------------------------------------------------------------------
798
820 LEGION_DEPRECATED("Premapping regions is no longer supported")
821 std::map<unsigned, std::vector<PhysicalInstance> > valid_instances;
822 PremapTaskInput(void);
823 ~PremapTaskInput(void);
824 };
826 Processor new_target_proc;
827 std::vector<Memory> reduction_futures;
828 LEGION_DEPRECATED("Premapping regions is no longer supported")
829 std::map<unsigned, std::vector<PhysicalInstance> > premapped_instances;
830 LEGION_DEPRECATED("Premapping regions is no longer supported")
831 std::map<unsigned, std::vector<PhysicalInstance> > premapped_sources;
832 LEGION_DEPRECATED("Premapping regions is no longer supported")
833 ProfilingRequest copy_prof_requests;
834 LEGION_DEPRECATED("Premapping regions is no longer supported")
835 TaskPriority profiling_priority;
836 PremapTaskOutput(void);
837 ~PremapTaskOutput(void);
838 };
839 //------------------------------------------------------------------------
840 virtual void premap_task(
841 MapperContext ctx, const Task& task, const PremapTaskInput& input,
842 PremapTaskOutput& output) = 0;
843 //------------------------------------------------------------------------
844
869 struct TaskSlice {
870 public:
871 TaskSlice(void)
872 : domain_is(IndexSpace::NO_SPACE), domain(Domain::NO_DOMAIN),
873 proc(Processor::NO_PROC), recurse(false), stealable(false),
874 take_ownership(false)
875 { }
876 TaskSlice(
877 const Domain& d, Processor p, bool r, bool s, bool own = false)
878 : domain_is(IndexSpace::NO_SPACE), domain(d), proc(p), recurse(r),
879 stealable(s), take_ownership(own)
880 { }
881 TaskSlice(IndexSpace is, Processor p, bool r, bool s)
882 : domain_is(is), domain(Domain::NO_DOMAIN), proc(p), recurse(r),
883 stealable(s), take_ownership(false)
884 { }
885 public:
886 IndexSpace domain_is;
887 Domain domain;
888 Processor proc;
889 bool recurse;
890 bool stealable;
891 bool take_ownership;
892 };
894 IndexSpace domain_is;
895 Domain domain;
896 IndexSpace sharding_is;
897 };
899 std::vector<TaskSlice> slices;
900 bool verify_correctness = false;
901 };
902 //------------------------------------------------------------------------
903 virtual void slice_task(
904 MapperContext ctx, const Task& task, const SliceTaskInput& input,
905 SliceTaskOutput& output) = 0;
906 //------------------------------------------------------------------------
907
995 std::vector<std::vector<PhysicalInstance> > valid_instances;
996 std::vector<std::vector<CollectiveView> > valid_collectives;
997 std::vector<unsigned> premapped_regions;
998 // These only apply when mapping a replicated task
999 DomainPoint shard;
1000 Domain shard_domain;
1001 Processor shard_processor;
1002 VariantID shard_variant;
1003 };
1005 std::vector<std::vector<PhysicalInstance> > chosen_instances;
1006 std::vector<std::vector<PhysicalInstance> > source_instances;
1007 std::vector<Memory> output_targets;
1008 std::vector<LayoutConstraintSet> output_constraints;
1009 std::set<unsigned> untracked_valid_regions;
1010 std::vector<Memory> future_locations;
1011 std::vector<Processor> target_procs;
1012 std::map<Memory, PoolBounds> leaf_pool_bounds,
1013 non_escaping_leaf_pool_bounds;
1014 VariantID chosen_variant = 0;
1015 TaskPriority task_priority = 0;
1016 RealmPriority copy_fill_priority = 0;
1017 RealmPriority profiling_priority = 0;
1018 ProfilingRequest task_prof_requests;
1019 ProfilingRequest copy_prof_requests;
1020 bool postmap_task = false;
1021 bool abort_mapping = false;
1022 };
1023 //------------------------------------------------------------------------
1024 virtual void map_task(
1025 MapperContext ctx, const Task& task, const MapTaskInput& input,
1026 MapTaskOutput& output) = 0;
1027 //------------------------------------------------------------------------
1028
1063 // Nothing here for now
1064 };
1066 VariantID chosen_variant = 0;
1067 std::vector<Processor> target_processors;
1068 // The following outputs are optional
1069 std::vector<VariantID> leaf_variants;
1070 std::vector<DomainPoint> shard_points;
1071 Domain shard_domain;
1072 };
1073 //------------------------------------------------------------------------
1074 virtual void replicate_task(
1075 MapperContext ctx, const Task& task, const ReplicateTaskInput& input,
1076 ReplicateTaskOutput& output) = 0;
1077 //------------------------------------------------------------------------
1078
1079 // This is here for backwards compatibility
1080 // The mapper call it was used by no longer exists
1081 // It was replaced by replicate_task
1083 std::vector<MapTaskOutput> task_mappings;
1084 std::vector<Processor> control_replication_map;
1085 std::vector<DomainPoint> shard_points;
1086 Domain shard_domain;
1087 };
1088
1100 Processor processor;
1101 std::vector<std::vector<PhysicalInstance> > chosen_instances;
1102 };
1104 VariantID chosen_variant = 0;
1105 };
1106 //------------------------------------------------------------------------
1107 virtual void select_task_variant(
1108 MapperContext ctx, const Task& task, const SelectVariantInput& input,
1109 SelectVariantOutput& output) = 0;
1110 //------------------------------------------------------------------------
1111
1132 std::vector<std::vector<PhysicalInstance> > mapped_regions;
1133 std::vector<std::vector<PhysicalInstance> > valid_instances;
1134 std::vector<std::vector<CollectiveView> > valid_collectives;
1135 };
1137 std::vector<std::vector<PhysicalInstance> > chosen_instances;
1138 std::vector<std::vector<PhysicalInstance> > source_instances;
1139 };
1140 //------------------------------------------------------------------------
1141 virtual void postmap_task(
1142 MapperContext ctx, const Task& task, const PostMapInput& input,
1143 PostMapOutput& output) = 0;
1144 //------------------------------------------------------------------------
1145
1161 PhysicalInstance target;
1162 std::vector<PhysicalInstance> source_instances;
1163 std::vector<CollectiveView> collective_views;
1164 unsigned region_req_index;
1165 };
1167 std::deque<PhysicalInstance> chosen_ranking;
1168 };
1169 //------------------------------------------------------------------------
1170 virtual void select_task_sources(
1171 MapperContext ctx, const Task& task, const SelectTaskSrcInput& input,
1172 SelectTaskSrcOutput& output) = 0;
1173 //------------------------------------------------------------------------
1174
1175 // These are here for backwards compatibility
1176 // The mapper call these were used by no longer exists
1178 unsigned region_requirement_index;
1179 PhysicalInstance destination_instance;
1180 };
1182 PhysicalInstance temporary_instance;
1183 };
1184
1185 // Keep this struct around for backwards compatibility
1187 bool speculate;
1188 bool speculative_value;
1189 bool speculate_mapping_only;
1190 };
1191
1209 ProfilingResponse profiling_responses;
1210 unsigned region_requirement_index;
1211 unsigned total_reports;
1212 bool task_response;
1213 bool fill_response;
1214 };
1215 //------------------------------------------------------------------------
1216 virtual void report_profiling(
1217 MapperContext ctx, const Task& task,
1218 const TaskProfilingInfo& input) = 0;
1219 //------------------------------------------------------------------------
1220
1236 std::vector<Processor> shard_mapping;
1237 };
1239 ShardingID chosen_functor = std::numeric_limits<ShardingID>::max();
1240 bool slice_recurse = true;
1241 };
1242 //------------------------------------------------------------------------
1243 virtual void select_sharding_functor(
1244 MapperContext ctx, const Task& task,
1245 const SelectShardingFunctorInput& input,
1246 SelectShardingFunctorOutput& output) = 0;
1247 //------------------------------------------------------------------------
1248 public: // Inline mapping
1272 std::vector<PhysicalInstance> valid_instances;
1273 std::vector<CollectiveView> valid_collectives;
1274 };
1276 std::vector<PhysicalInstance> chosen_instances;
1277 std::vector<PhysicalInstance> source_instances;
1278 RealmPriority copy_fill_priority = 0;
1279 ProfilingRequest profiling_requests;
1280 RealmPriority profiling_priority = 0;
1281 bool track_valid_region = true;
1282 };
1283 //------------------------------------------------------------------------
1284 virtual void map_inline(
1285 MapperContext ctx, const InlineMapping& inline_op,
1286 const MapInlineInput& input, MapInlineOutput& output) = 0;
1287 //------------------------------------------------------------------------
1288
1303 PhysicalInstance target;
1304 std::vector<PhysicalInstance> source_instances;
1305 std::vector<CollectiveView> collective_views;
1306 };
1308 std::deque<PhysicalInstance> chosen_ranking;
1309 };
1310 //------------------------------------------------------------------------
1311 virtual void select_inline_sources(
1312 MapperContext ctx, const InlineMapping& inline_op,
1313 const SelectInlineSrcInput& input, SelectInlineSrcOutput& output) = 0;
1314 //------------------------------------------------------------------------
1315
1316 // These are here for backwards compatibility
1317 // The mapper call these were used by no longer exists
1319 PhysicalInstance destination_instance;
1320 };
1322 PhysicalInstance temporary_instance;
1323 };
1324
1325 // No speculation for inline mappings
1326
1342 ProfilingResponse profiling_responses;
1343 unsigned total_reports;
1344 bool fill_response;
1345 };
1346 //------------------------------------------------------------------------
1347 virtual void report_profiling(
1348 MapperContext ctx, const InlineMapping& inline_op,
1349 const InlineProfilingInfo& input) = 0;
1350 //------------------------------------------------------------------------
1351 public: // Region-to-region copies
1404 std::vector<std::vector<PhysicalInstance> > src_instances;
1405 std::vector<std::vector<PhysicalInstance> > dst_instances;
1406 std::vector<std::vector<PhysicalInstance> > src_indirect_instances;
1407 std::vector<std::vector<PhysicalInstance> > dst_indirect_instances;
1408 std::vector<std::vector<CollectiveView> > src_collectives;
1409 std::vector<std::vector<CollectiveView> > dst_collectives;
1410 std::vector<std::vector<CollectiveView> > src_indirect_collectives;
1411 std::vector<std::vector<CollectiveView> > dst_indirect_collectives;
1412 };
1414 std::vector<std::vector<PhysicalInstance> > src_instances;
1415 std::vector<std::vector<PhysicalInstance> > dst_instances;
1416 std::vector<PhysicalInstance> src_indirect_instances;
1417 std::vector<PhysicalInstance> dst_indirect_instances;
1418 std::vector<std::vector<PhysicalInstance> > src_source_instances;
1419 std::vector<std::vector<PhysicalInstance> > dst_source_instances;
1420 std::vector<std::vector<PhysicalInstance> >
1421 src_indirect_source_instances;
1422 std::vector<std::vector<PhysicalInstance> >
1423 dst_indirect_source_instances;
1424
1425 std::set<unsigned> untracked_valid_srcs;
1426 std::set<unsigned> untracked_valid_ind_srcs;
1427 std::set<unsigned> untracked_valid_ind_dsts;
1428 ProfilingRequest profiling_requests;
1429 RealmPriority profiling_priority = 0;
1430 RealmPriority copy_fill_priority = 0;
1431 bool compute_preimages = false;
1432 bool shadow_indirections = false;
1433 };
1434 //------------------------------------------------------------------------
1435 virtual void map_copy(
1436 MapperContext ctx, const Copy& copy, const MapCopyInput& input,
1437 MapCopyOutput& output) = 0;
1438 //------------------------------------------------------------------------
1439
1457 PhysicalInstance target;
1458 std::vector<PhysicalInstance> source_instances;
1459 std::vector<CollectiveView> collective_views;
1460 bool is_src;
1461 bool is_dst;
1462 bool is_src_indirect;
1463 bool is_dst_indirect;
1464 unsigned region_req_index;
1465 };
1467 std::deque<PhysicalInstance> chosen_ranking;
1468 };
1469 //------------------------------------------------------------------------
1470 virtual void select_copy_sources(
1471 MapperContext ctx, const Copy& copy, const SelectCopySrcInput& input,
1472 SelectCopySrcOutput& output) = 0;
1473 //------------------------------------------------------------------------
1474
1475 // These are here for backwards compatibility
1476 // The mapper call these were used by no longer exists
1478 unsigned region_requirement_index;
1479 bool src_requirement;
1480 PhysicalInstance destination_instance;
1481 };
1483 PhysicalInstance temporary_instance;
1484 };
1485
1504 ProfilingResponse profiling_responses;
1505 unsigned src_index;
1506 unsigned dst_index;
1507 unsigned total_reports;
1508 bool fill_response;
1509 };
1510 //------------------------------------------------------------------------
1511 virtual void report_profiling(
1512 MapperContext ctx, const Copy& copy,
1513 const CopyProfilingInfo& input) = 0;
1514 //------------------------------------------------------------------------
1515
1528 //------------------------------------------------------------------------
1530 MapperContext ctx, const Copy& copy,
1531 const SelectShardingFunctorInput& input,
1532 SelectShardingFunctorOutput& output) = 0;
1533 //------------------------------------------------------------------------
1534 public: // Close operations
1535 // These are here for backwards compatibility
1536 // The mapper call these were used by no longer exists
1538 std::vector<PhysicalInstance> valid_instances;
1539 };
1541 std::vector<PhysicalInstance> chosen_instances;
1542 ProfilingRequest profiling_requests;
1543 RealmPriority profiling_priority;
1544 };
1545
1558 PhysicalInstance target;
1559 std::vector<PhysicalInstance> source_instances;
1560 std::vector<CollectiveView> collective_views;
1561 };
1563 std::deque<PhysicalInstance> chosen_ranking;
1564 };
1565 //------------------------------------------------------------------------
1566 virtual void select_close_sources(
1567 MapperContext ctx, const Close& close,
1568 const SelectCloseSrcInput& input, SelectCloseSrcOutput& output) = 0;
1569 //------------------------------------------------------------------------
1570
1571 // These are here for backwards compatibility
1572 // The mapper call these were used by no longer exists
1574 PhysicalInstance destination_instance;
1575 };
1577 PhysicalInstance temporary_instance;
1578 };
1579
1580 // No speculation for close operations
1581
1599 ProfilingResponse profiling_responses;
1600 unsigned total_reports;
1601 bool fill_response;
1602 };
1603 //------------------------------------------------------------------------
1604 virtual void report_profiling(
1605 MapperContext ctx, const Close& close,
1606 const CloseProfilingInfo& input) = 0;
1607 //------------------------------------------------------------------------
1608
1621 //------------------------------------------------------------------------
1623 MapperContext ctx, const Close& close,
1624 const SelectShardingFunctorInput& input,
1625 SelectShardingFunctorOutput& output) = 0;
1626 //------------------------------------------------------------------------
1627 public: // Acquire operations
1638 // Nothing
1639 };
1641 ProfilingRequest profiling_requests;
1642 RealmPriority profiling_priority = 0;
1643 RealmPriority copy_fill_priority = 0;
1644 };
1645 //------------------------------------------------------------------------
1646 virtual void map_acquire(
1647 MapperContext ctx, const Acquire& acquire,
1648 const MapAcquireInput& input, MapAcquireOutput& output) = 0;
1649 //------------------------------------------------------------------------
1650
1666 ProfilingResponse profiling_responses;
1667 unsigned total_reports;
1668 bool fill_response;
1669 };
1670 //------------------------------------------------------------------------
1671 virtual void report_profiling(
1672 MapperContext ctx, const Acquire& acquire,
1673 const AcquireProfilingInfo& input) = 0;
1674 //------------------------------------------------------------------------
1675
1688 //------------------------------------------------------------------------
1690 MapperContext ctx, const Acquire& acquire,
1691 const SelectShardingFunctorInput& input,
1692 SelectShardingFunctorOutput& output) = 0;
1693 //------------------------------------------------------------------------
1694 public: // Release operations
1708 // Nothing
1709 };
1711 std::vector<PhysicalInstance> source_instances;
1712 ProfilingRequest profiling_requests;
1713 RealmPriority profiling_priority = 0;
1714 RealmPriority copy_fill_priority = 0;
1715 };
1716 //------------------------------------------------------------------------
1717 virtual void map_release(
1718 MapperContext ctx, const Release& release,
1719 const MapReleaseInput& input, MapReleaseOutput& output) = 0;
1720 //------------------------------------------------------------------------
1721
1734 PhysicalInstance target;
1735 std::vector<PhysicalInstance> source_instances;
1736 std::vector<CollectiveView> collective_views;
1737 };
1739 std::deque<PhysicalInstance> chosen_ranking;
1740 };
1741 //------------------------------------------------------------------------
1742 virtual void select_release_sources(
1743 MapperContext ctx, const Release& release,
1744 const SelectReleaseSrcInput& input,
1745 SelectReleaseSrcOutput& output) = 0;
1746 //------------------------------------------------------------------------
1747
1748 // These are here for backwards compatibility
1749 // The mapper call these were used by no longer exists
1751 PhysicalInstance destination_instance;
1752 };
1754 PhysicalInstance temporary_instance;
1755 };
1756
1772 ProfilingResponse profiling_responses;
1773 unsigned total_reports;
1774 bool fill_response;
1775 };
1776 //------------------------------------------------------------------------
1777 virtual void report_profiling(
1778 MapperContext ctx, const Release& release,
1779 const ReleaseProfilingInfo& input) = 0;
1780 //------------------------------------------------------------------------
1781
1794 //------------------------------------------------------------------------
1796 MapperContext ctx, const Release& release,
1797 const SelectShardingFunctorInput& input,
1798 SelectShardingFunctorOutput& output) = 0;
1799 //------------------------------------------------------------------------
1800 public: // Partition Operations
1824 std::vector<LogicalPartition> open_complete_partitions;
1825 };
1827 LogicalPartition chosen_partition;
1828 };
1829 //------------------------------------------------------------------------
1830 virtual void select_partition_projection(
1831 MapperContext ctx, const Partition& partition,
1832 const SelectPartitionProjectionInput& input,
1834 //------------------------------------------------------------------------
1835
1861 std::vector<PhysicalInstance> valid_instances;
1862 std::vector<CollectiveView> valid_collectives;
1863 };
1865 std::vector<PhysicalInstance> chosen_instances;
1866 std::vector<PhysicalInstance> source_instances;
1867 ProfilingRequest profiling_requests;
1868 RealmPriority profiling_priority = 0;
1869 RealmPriority copy_fill_priority = 0;
1870 bool track_valid_region = true;
1871 };
1872 //------------------------------------------------------------------------
1873 virtual void map_partition(
1874 MapperContext ctx, const Partition& partition,
1875 const MapPartitionInput& input, MapPartitionOutput& output) = 0;
1876 //------------------------------------------------------------------------
1877
1892 PhysicalInstance target;
1893 std::vector<PhysicalInstance> source_instances;
1894 std::vector<CollectiveView> collective_views;
1895 };
1897 std::deque<PhysicalInstance> chosen_ranking;
1898 };
1899 //------------------------------------------------------------------------
1900 virtual void select_partition_sources(
1901 MapperContext ctx, const Partition& partition,
1902 const SelectPartitionSrcInput& input,
1903 SelectPartitionSrcOutput& output) = 0;
1904 //------------------------------------------------------------------------
1905
1906 // These are here for backwards compatibility
1907 // The mapper call these were used by no longer exists
1909 PhysicalInstance destination_instance;
1910 };
1912 PhysicalInstance temporary_instance;
1913 };
1914
1915 // No speculation for dependent partition operations
1916
1932 ProfilingResponse profiling_responses;
1933 unsigned total_reports;
1934 bool fill_response;
1935 };
1936 //------------------------------------------------------------------------
1937 virtual void report_profiling(
1938 MapperContext ctx, const Partition& partition,
1939 const PartitionProfilingInfo& input) = 0;
1940 //------------------------------------------------------------------------
1941
1954 //------------------------------------------------------------------------
1956 MapperContext ctx, const Partition& partition,
1957 const SelectShardingFunctorInput& input,
1958 SelectShardingFunctorOutput& output) = 0;
1959 //------------------------------------------------------------------------
1960 public: // Fill Operations
1973 //------------------------------------------------------------------------
1975 MapperContext ctx, const Fill& fill,
1976 const SelectShardingFunctorInput& input,
1977 SelectShardingFunctorOutput& output) = 0;
1978 //------------------------------------------------------------------------
1979 public: // Future Map Reductions
2002 MappingTagID tag;
2003 };
2005 std::vector<Memory> destination_memories;
2006 size_t serdez_upper_bound = std::numeric_limits<size_t>::max();
2007 };
2008 //------------------------------------------------------------------------
2009 virtual void map_future_map_reduction(
2010 MapperContext ctx, const FutureMapReductionInput& input,
2012 { }
2013 //------------------------------------------------------------------------
2014 public: // Single Task Context
2116 unsigned max_window_size = LEGION_DEFAULT_MAX_TASK_WINDOW;
2117 unsigned hysteresis_percentage = LEGION_DEFAULT_TASK_WINDOW_HYSTERESIS;
2118 unsigned max_outstanding_frames = 0;
2119 unsigned min_tasks_to_schedule = LEGION_DEFAULT_MIN_TASKS_TO_SCHEDULE;
2120 unsigned min_frames_to_schedule = 0;
2121 unsigned meta_task_vector_width = LEGION_DEFAULT_META_TASK_VECTOR_WIDTH;
2122 unsigned max_templates_per_trace =
2123 LEGION_DEFAULT_MAX_TEMPLATES_PER_TRACE;
2124 bool mutable_priority = false;
2125 bool auto_tracing_enabled = true;
2126 unsigned auto_tracing_window_size = 1000;
2127 unsigned auto_tracing_ruler_function = 100;
2128 unsigned auto_tracing_min_trace_length = 5;
2129 unsigned auto_tracing_max_trace_length =
2130 std::numeric_limits<unsigned>::max();
2131 unsigned auto_tracing_visit_threshold = 10;
2132 unsigned auto_tracing_turbo_lag = 16;
2133 };
2134 //------------------------------------------------------------------------
2135 virtual void configure_context(
2136 MapperContext ctx, const Task& task, ContextConfigOutput& output) = 0;
2137 //------------------------------------------------------------------------
2138
2156 TunableID tunable_id;
2157 MappingTagID mapping_tag;
2158 std::vector<Future> futures;
2159 const void* args;
2160 size_t size;
2161 };
2163 void* value = nullptr;
2164 size_t size = 0;
2165 bool take_ownership = true;
2166 };
2167 //------------------------------------------------------------------------
2168 virtual void select_tunable_value(
2169 MapperContext ctx, const Task& task, const SelectTunableInput& input,
2170 SelectTunableOutput& output) = 0;
2171 //------------------------------------------------------------------------
2172 public: // Mapping collections of operations
2193 bool collective_map_must_epoch_call;
2194 };
2195 //------------------------------------------------------------------------
2196 virtual void select_sharding_functor(
2197 MapperContext ctx, const MustEpoch& epoch,
2198 const SelectShardingFunctorInput& input,
2199 MustEpochShardingFunctorOutput& output) = 0;
2200 //------------------------------------------------------------------------
2201
2236 std::vector<const Task*> constrained_tasks;
2237 std::vector<unsigned> requirement_indexes;
2238 // tasks.size() == requirement_indexes.size()
2239 };
2241 std::vector<const Task*> tasks;
2242 std::vector<MappingConstraint> constraints;
2243 MappingTagID mapping_tag;
2244 // For collective map_must_epoch only
2245 std::vector<Processor> shard_mapping;
2246 ShardID local_shard;
2247 };
2249 std::vector<Processor> task_processors;
2250 std::vector<std::vector<PhysicalInstance> > constraint_mappings;
2251 // For collective map_must_epoch only
2252 std::vector<int> weights;
2253 };
2254 //------------------------------------------------------------------------
2255 virtual void map_must_epoch(
2256 MapperContext ctx, const MapMustEpochInput& input,
2257 MapMustEpochOutput& output) = 0;
2258 //------------------------------------------------------------------------
2259
2261#if 0
2262 std::vector<const Task*> nodes;
2263 std::vector<DataflowEdge> edges;
2264 std::vector<Callsite> callsites;
2265#endif
2266 };
2268 //------------------------------------------------------------------------
2269 virtual void map_dataflow_graph(
2270 MapperContext ctx, const MapDataflowGraphInput& input,
2271 MapDataflowGraphOutput& output) = 0;
2272 //------------------------------------------------------------------------
2273 public: // Memoizing physical analyses of operations
2284 TraceID trace_id;
2285 };
2287 bool memoize = true;
2288 };
2289 //------------------------------------------------------------------------
2290 virtual void memoize_operation(
2291 MapperContext ctx, const Mappable& mappable,
2292 const MemoizeInput& input, MemoizeOutput& output) = 0;
2293 //------------------------------------------------------------------------
2294 public: // Mapping control
2319 std::list<const Task*> ready_tasks;
2320 Processor processor;
2321 };
2323 std::set<const Task*> map_tasks;
2324 std::map<const Task*, Processor> relocate_tasks;
2325 MapperEvent deferral_event;
2326 };
2327 //------------------------------------------------------------------------
2328 virtual void select_tasks_to_map(
2329 MapperContext ctx, const SelectMappingInput& input,
2330 SelectMappingOutput& output) = 0;
2331 //------------------------------------------------------------------------
2332 public: // Stealing
2351 std::set<Processor> blacklist;
2352 };
2354 std::set<Processor> targets;
2355 };
2356 //------------------------------------------------------------------------
2357 virtual void select_steal_targets(
2358 MapperContext ctx, const SelectStealingInput& input,
2359 SelectStealingOutput& output) = 0;
2360 //------------------------------------------------------------------------
2361
2378 Processor thief_proc;
2379 std::vector<const Task*> stealable_tasks;
2380 };
2382 std::set<const Task*> stolen_tasks;
2383 };
2384 //------------------------------------------------------------------------
2385 virtual void permit_steal_request(
2386 MapperContext ctx, const StealRequestInput& input,
2387 StealRequestOutput& output) = 0;
2388 //------------------------------------------------------------------------
2389 public: // Handling
2404 Processor sender;
2405 unsigned kind;
2406 const void* message;
2407 size_t size;
2408 bool broadcast;
2409 };
2410 //------------------------------------------------------------------------
2411 virtual void handle_message(
2412 MapperContext ctx, const MapperMessage& message) = 0;
2413 //------------------------------------------------------------------------
2414
2427 MapperEvent mapper_event;
2428 const void* result;
2429 size_t result_size;
2430 };
2431 //------------------------------------------------------------------------
2432 virtual void handle_task_result(
2433 MapperContext ctx, const MapperTaskResult& result) = 0;
2434 //------------------------------------------------------------------------
2435
2444 //------------------------------------------------------------------------
2446 const MapperContext ctx, const PhysicalInstance& inst)
2447 { }
2448 //------------------------------------------------------------------------
2449 };
2450
2459 protected:
2460 // These runtime objects will be created by Legion
2461 friend class Internal::Runtime;
2462 MapperRuntime(Internal::Runtime* runtime);
2463 ~MapperRuntime(void);
2464 private:
2465 Internal::Runtime* const runtime;
2466 public:
2467 //------------------------------------------------------------------------
2468 // Methods for managing access to mapper state in the concurrent model
2469 // These calls are illegal in the serialized mapper model
2470 //------------------------------------------------------------------------
2471 bool is_locked(MapperContext ctx) const;
2472 void lock_mapper(MapperContext ctx, bool read_only = false) const;
2473 void unlock_mapper(MapperContext ctx) const;
2474 public:
2475 //------------------------------------------------------------------------
2476 // Methods for managing the re-entrant state in the serialized model
2477 // These calls are illegal in the concurrent mapper model
2478 //------------------------------------------------------------------------
2479 bool is_reentrant(MapperContext ctx) const;
2480 void enable_reentrant(MapperContext ctx) const;
2481 void disable_reentrant(MapperContext ctx) const;
2482 public:
2483 //------------------------------------------------------------------------
2484 // These two methods allow mappers to define their own profile ranges
2485 // inside of the profiler. Each start call must be matched with a
2486 // corresponding stop call inside of the same mapper context.
2487 void start_profiling_range(MapperContext ctx) const;
2488 void stop_profiling_range(
2489 MapperContext ctx, const char* provenance) const;
2490 public:
2491 //------------------------------------------------------------------------
2492 // Methods for updating mappable data
2493 // The mapper is responsible for atomicity of these calls
2494 // (usually through the choice of mapper synchronization model)
2495 //------------------------------------------------------------------------
2496 void update_mappable_tag(
2497 MapperContext ctx, const Mappable& mappable,
2498 MappingTagID new_tag) const;
2499 // Runtime will make a copy of the data passed into this method
2500 void update_mappable_data(
2501 MapperContext ctx, const Mappable& mappable, const void* mapper_data,
2502 size_t mapper_data_size) const;
2503 public:
2504 //------------------------------------------------------------------------
2505 // Methods for communicating with other mappers of the same kind
2506 //------------------------------------------------------------------------
2507 void send_message(
2508 MapperContext ctx, Processor target, const void* message,
2509 size_t message_size, unsigned message_kind = 0) const;
2510 void broadcast(
2511 MapperContext ctx, const void* message, size_t message_size,
2512 unsigned message_kind = 0, int radix = 4) const;
2513 public:
2514 //------------------------------------------------------------------------
2515 // Methods for packing and unpacking physical instances
2516 //------------------------------------------------------------------------
2517 void pack_physical_instance(
2518 MapperContext ctx, Serializer& rez, PhysicalInstance instance) const;
2519 void unpack_physical_instance(
2520 MapperContext ctx, Deserializer& derez,
2521 PhysicalInstance& instance) const;
2522 public:
2523 //------------------------------------------------------------------------
2524 // Methods for managing the execution of mapper tasks
2525 //------------------------------------------------------------------------
2526 // MapperEvent launch_mapper_task(MapperContext ctx,
2527 // Processor::TaskFuncID tid,
2528 // const UntypedBuffer &arg) const;
2529
2530 // void defer_mapper_call(MapperContext ctx,
2531 // MapperEvent event) const;
2532
2533 // MapperEvent merge_mapper_events(MapperContext ctx,
2534 // const std::set<MapperEvent>
2535 // &events)const;
2536 public:
2537 //------------------------------------------------------------------------
2538 // Methods for managing mapper events
2539 //------------------------------------------------------------------------
2540 MapperEvent create_mapper_event(MapperContext ctx) const;
2541 bool has_mapper_event_triggered(
2542 MapperContext ctx, MapperEvent event) const;
2543 void trigger_mapper_event(MapperContext ctx, MapperEvent event) const;
2544 void wait_on_mapper_event(MapperContext ctx, MapperEvent event) const;
2545 public:
2546 //------------------------------------------------------------------------
2547 // Methods for managing constraint information
2548 //------------------------------------------------------------------------
2549 const ExecutionConstraintSet& find_execution_constraints(
2550 MapperContext ctx, TaskID task_id, VariantID vid) const;
2551 const TaskLayoutConstraintSet& find_task_layout_constraints(
2552 MapperContext ctx, TaskID task_id, VariantID vid) const;
2553 const LayoutConstraintSet& find_layout_constraints(
2554 MapperContext ctx, LayoutConstraintID id) const;
2555 LayoutConstraintID register_layout(
2556 MapperContext ctx, const LayoutConstraintSet& layout_constraints,
2557 FieldSpace handle = FieldSpace::NO_SPACE) const;
2558 void release_layout(
2559 MapperContext ctx, LayoutConstraintID layout_id) const;
2560 bool do_constraints_conflict(
2561 MapperContext ctx, LayoutConstraintID set1, LayoutConstraintID set2,
2562 const LayoutConstraint** conflict_constraint = nullptr) const;
2563 bool do_constraints_entail(
2564 MapperContext ctx, LayoutConstraintID source,
2565 LayoutConstraintID target,
2566 const LayoutConstraint** failed_constraint = nullptr) const;
2567 public:
2568 //------------------------------------------------------------------------
2569 // Methods for manipulating variants
2570 //------------------------------------------------------------------------
2571 void find_valid_variants(
2572 MapperContext ctx, TaskID task_id,
2573 std::vector<VariantID>& valid_variants,
2574 Processor::Kind kind = Processor::NO_KIND) const;
2575 void find_generator_variants(
2576 MapperContext ctx, TaskID task_id,
2577 std::vector<std::pair<TaskID, VariantID> >& generator_variants,
2578 Processor::Kind kind = Processor::NO_KIND) const;
2579 VariantID find_or_create_variant(
2580 MapperContext ctx, TaskID task_id,
2581 const ExecutionConstraintSet& execution_constrains,
2582 const TaskLayoutConstraintSet& layout_constraints,
2583 TaskID generator_tid, VariantID generator_vid,
2584 Processor generator_processor, bool& created) const;
2585 const char* find_task_variant_name(
2586 MapperContext ctx, TaskID task_id, VariantID vid) const;
2587 bool is_leaf_variant(
2588 MapperContext ctx, TaskID task_id, VariantID variant_id) const;
2589 bool is_inner_variant(
2590 MapperContext ctx, TaskID task_id, VariantID variant_id) const;
2591 bool is_idempotent_variant(
2592 MapperContext ctx, TaskID task_id, VariantID variant_id) const;
2593 bool is_replicable_variant(
2594 MapperContext ctx, TaskID task_id, VariantID variant_id) const;
2595 public:
2596 //------------------------------------------------------------------------
2597 // Methods for registering variants
2598 //------------------------------------------------------------------------
2599 template<
2600 typename T, T (*TASK_PTR)(
2601 const Task*, const std::vector<PhysicalRegion>&,
2602 Context, Runtime*)>
2603 VariantID register_task_variant(
2604 MapperContext ctx, const TaskVariantRegistrar& registrar) const;
2605 template<
2606 typename T, typename UDT,
2607 T (*TASK_PTR)(
2608 const Task*, const std::vector<PhysicalRegion>&, Context,
2609 Runtime*, const UDT&)>
2610 VariantID register_task_variant(
2611 MapperContext ctx, const TaskVariantRegistrar& registrar,
2612 const UDT& user_data) const;
2613 template<void (*TASK_PTR)(
2614 const Task*, const std::vector<PhysicalRegion>&, Context, Runtime*)>
2615 VariantID register_task_variant(
2616 MapperContext ctx, const TaskVariantRegistrar& registrar) const;
2617 template<
2618 typename UDT, void (*TASK_PTR)(
2619 const Task*, const std::vector<PhysicalRegion>&,
2620 Context, Runtime*, const UDT&)>
2621 VariantID register_task_variant(
2622 MapperContext ctx, const TaskVariantRegistrar& registrar,
2623 const UDT& user_data) const;
2624 VariantID register_task_variant(
2625 MapperContext ctx, const TaskVariantRegistrar& registrar,
2626 const CodeDescriptor& codedesc, const void* user_data = nullptr,
2627 size_t user_len = 0, size_t return_type_size = LEGION_MAX_RETURN_SIZE,
2628 bool has_return_type = false) const;
2629 public:
2630 //------------------------------------------------------------------------
2631 // Methods for accelerating mapping decisions
2632 //------------------------------------------------------------------------
2633 // Filter variants based on the chosen instances
2634 void filter_variants(
2635 MapperContext ctx, const Task& task,
2636 const std::vector<std::vector<PhysicalInstance> >& chosen_intances,
2637 std::vector<VariantID>& variants) const;
2638 // Filter instances based on a chosen variant
2639 void filter_instances(
2640 MapperContext ctx, const Task& task, VariantID chosen_variant,
2641 std::vector<std::vector<PhysicalInstance> >& instances,
2642 std::vector<std::set<FieldID> >& missing_fields) const;
2643 // Filter a specific set of instances for one region requirement
2644 void filter_instances(
2645 MapperContext ctx, const Task& task, unsigned index,
2646 VariantID chosen_variant, std::vector<PhysicalInstance>& instances,
2647 std::set<FieldID>& missing_fields) const;
2648 public:
2649 //------------------------------------------------------------------------
2650 // Methods for managing physical instances
2651 //------------------------------------------------------------------------
2652 bool create_physical_instance(
2653 MapperContext ctx, Memory target_memory,
2654 const LayoutConstraintSet& constraints,
2655 const std::vector<LogicalRegion>& regions, PhysicalInstance& result,
2656 bool acquire = true, GCPriority priority = 0,
2657 bool tight_region_bounds = false, size_t* footprint = nullptr,
2658 const LayoutConstraint** unsat = nullptr) const;
2659 bool create_physical_instance(
2660 MapperContext ctx, Memory target_memory, LayoutConstraintID layout_id,
2661 const std::vector<LogicalRegion>& regions, PhysicalInstance& result,
2662 bool acquire = true, GCPriority priority = 0,
2663 bool tight_region_bounds = false, size_t* footprint = nullptr,
2664 const LayoutConstraint** unsat = nullptr) const;
2665 bool find_or_create_physical_instance(
2666 MapperContext ctx, Memory target_memory,
2667 const LayoutConstraintSet& constraints,
2668 const std::vector<LogicalRegion>& regions, PhysicalInstance& result,
2669 bool& created, bool acquire = true, GCPriority priority = 0,
2670 bool tight_region_bounds = false, size_t* footprint = nullptr,
2671 const LayoutConstraint** unsat = nullptr) const;
2672 bool find_or_create_physical_instance(
2673 MapperContext ctx, Memory target_memory, LayoutConstraintID layout_id,
2674 const std::vector<LogicalRegion>& regions, PhysicalInstance& result,
2675 bool& created, bool acquire = true, GCPriority priority = 0,
2676 bool tight_region_bounds = false, size_t* footprint = nullptr,
2677 const LayoutConstraint** unsat = nullptr) const;
2678 bool find_physical_instance(
2679 MapperContext ctx, Memory target_memory,
2680 const LayoutConstraintSet& constraints,
2681 const std::vector<LogicalRegion>& regions, PhysicalInstance& result,
2682 bool acquire = true, bool tight_region_bounds = false) const;
2683 bool find_physical_instance(
2684 MapperContext ctx, Memory target_memory, LayoutConstraintID layout_id,
2685 const std::vector<LogicalRegion>& regions, PhysicalInstance& result,
2686 bool acquire = true, bool tight_region_bounds = false) const;
2687 void find_physical_instances(
2688 MapperContext ctx, Memory target_memory,
2689 const LayoutConstraintSet& constraints,
2690 const std::vector<LogicalRegion>& regions,
2691 std::vector<PhysicalInstance>& results, bool acquire = false,
2692 bool tight_region_bounds = false) const;
2693 void find_physical_instances(
2694 MapperContext ctx, Memory target_memory, LayoutConstraintID layout_id,
2695 const std::vector<LogicalRegion>& regions,
2696 std::vector<PhysicalInstance>& results, bool acquire = false,
2697 bool tight_region_bounds = false) const;
2698 void set_garbage_collection_priority(
2699 MapperContext ctx, const PhysicalInstance& instance,
2700 GCPriority priority) const;
2701 // These methods will atomically check to make sure that these instances
2702 // are still valid and then add an implicit reference to them to ensure
2703 // that they aren't collected before this mapping call completes. They
2704 // don't need to be called as part of mapping an instance, but they are
2705 // highly recommended to ensure correctness. Acquiring instances and
2706 // then not using them is also acceptable as the runtime will implicitly
2707 // release the references after the call. Instances can also be released
2708 // as might be expected if a mapper opts to attempt to map a different
2709 // instance, but this is an optional performance improvement.
2710 bool acquire_instance(
2711 MapperContext ctx, const PhysicalInstance& instance) const;
2712 bool acquire_instances(
2713 MapperContext ctx, const std::vector<PhysicalInstance>& insts) const;
2714 bool acquire_and_filter_instances(
2715 MapperContext ctx, std::vector<PhysicalInstance>& instances,
2716 bool filter_acquired_instance = false) const;
2717 bool acquire_instances(
2718 MapperContext ctx,
2719 const std::vector<std::vector<PhysicalInstance> >& instances) const;
2720 bool acquire_and_filter_instances(
2721 MapperContext ctx,
2722 std::vector<std::vector<PhysicalInstance> >& instances,
2723 bool filter_acquired_instances = false) const;
2724 void release_instance(
2725 MapperContext ctx, const PhysicalInstance& instance) const;
2726 void release_instances(
2727 MapperContext ctx,
2728 const std::vector<PhysicalInstance>& instances) const;
2729 void release_instances(
2730 MapperContext ctx,
2731 const std::vector<std::vector<PhysicalInstance> >& instances) const;
2732 // Subscribing to an instance will ensure that a mapper receives a
2733 // mapper invocation when that instance has been deleted. Note that this
2734 // subscription will fail if the instance has already been deleted
2735 // Duplicate subscriptions from the same mapper will be deduplicated
2736 // and only a single callback will be performed
2737 bool subscribe(MapperContext ctx, const PhysicalInstance& instance) const;
2738 void unsubscribe(MapperContext ctx, const PhysicalInstance& inst) const;
2739 // This will try to eagerly collect the physical instance if it does not
2740 // contain any valid data, the runtime returns if the collection was
2741 // successful or not. The only reason it will not succeed is if the
2742 // instance contains valid data.
2743 bool collect_instance(
2744 MapperContext ctx, const PhysicalInstance& inst) const;
2745 // This method will try to collect several instances concurrently and
2746 // will return which instances were successfully collected in a
2747 // vector of booleans.
2748 void collect_instances(
2749 MapperContext ctx, const std::vector<PhysicalInstance>& instances,
2750 std::vector<bool>& collected) const;
2751 // This method will attempt to redistrict an instance from one layout
2752 // to another one, thereby reusing the memory associated with the first
2753 // instance to create the new instance (thereby deleting the original
2754 // instance in the process). This will only be permitted if the original
2755 // instance does not not contain any valid data and if the new layout
2756 // fits within the footprint of the original instance. The runtime will
2757 // return a boolean indicating whether the redistricting was successful.
2758 // If the invocation is successful, the 'instance' will be overwritten
2759 // with a handle to the new instance.
2760 bool redistrict_instance(
2761 MapperContext ctx, PhysicalInstance& instance,
2762 const LayoutConstraintSet& constraints,
2763 const std::vector<LogicalRegion>& regions, bool acquire = true,
2764 GCPriority priority = 0, bool tight_region_bounds = false);
2765 bool redistrict_instance(
2766 MapperContext ctx, PhysicalInstance& instance,
2767 LayoutConstraintID layout_id,
2768 const std::vector<LogicalRegion>& regions, bool acquire = true,
2769 GCPriority priority = 0, bool tight_region_bounds = false);
2770 public:
2771 // Futures can also be acquired to ensure that they are available in
2772 // particular memories prior to running a task.
2773 bool acquire_future(MapperContext ctx, const Future& f, Memory mem) const;
2774 // Users can also acquire memory for unbound memory pools when mapping
2775 // tasks. These pools will be implicitly used to satisfy any leaf_pool
2776 // bounds requested for mapping the task. This interface allows mappers
2777 // to discover if leaf pools can be allocated and potentially switch to
2778 // an alternative mapping strategy if they cannot. Mappers must say
2779 // whether the pool being acquired is escaping or non-escaping. If the
2780 // mapper already acquired a pool for this operation in the same memory
2781 // and with the same escaping property then the prior pool will be
2782 // released if the acquire for the new pool succeeds because Legion
2783 // does not permit operations to have more than one pool in the same
2784 // memory with the same escaping property. Users can decide if they
2785 // want the prior pool (if any) to be released before the acquire
2786 // attempt (optimistically) or only when the acquire succeeds to allocate
2787 // the new pool (pessimistically). The former allows the memory from
2788 // the previous pool to be used to satisfy the new pool being acquired
2789 // while the latter ensures that at least one memory pool is always live.
2790 bool acquire_pool(
2791 MapperContext ctx, Memory memory, const PoolBounds& bounds,
2792 bool escaping = true, bool optimistic = false) const;
2793 void release_pool(MapperContext ctx, Memory memory, bool escaping = true);
2794 public:
2795 //------------------------------------------------------------------------
2796 // Methods for creating index spaces which mappers need to do
2797 // in order to be able to properly slice index space operations
2798 //------------------------------------------------------------------------
2799 IndexSpace create_index_space(
2800 MapperContext ctx, const Domain& bounds, TypeTag type_tag = 0,
2801 const char* provenance = nullptr, bool take_ownership = false) const;
2802 // Template version
2803 template<int DIM, typename COORD_T>
2804 IndexSpaceT<DIM, COORD_T> create_index_space(
2805 MapperContext ctx, Rect<DIM, COORD_T> bounds,
2806 const char* provenance = nullptr) const;
2807
2808 IndexSpace create_index_space(
2809 MapperContext ctx, const std::vector<DomainPoint>& points,
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<Point<DIM, COORD_T> >& points,
2815 const char* provenance = nullptr) const;
2816
2817 IndexSpace create_index_space(
2818 MapperContext ctx, const std::vector<Domain>& rects,
2819 const char* provenance = nullptr) const;
2820 // Template version
2821 template<int DIM, typename COORD_T>
2822 IndexSpaceT<DIM, COORD_T> create_index_space(
2823 MapperContext ctx, const std::vector<Rect<DIM, COORD_T> >& rects,
2824 const char* provenance = nullptr) const;
2825
2826 IndexSpace union_index_spaces(
2827 MapperContext ctx, const std::vector<IndexSpace>& sources,
2828 const char* provenance = nullptr) const;
2829 // Template version
2830 template<int DIM, typename COORD_T>
2831 IndexSpaceT<DIM, COORD_T> union_index_spaces(
2832 MapperContext ctx,
2833 const std::vector<IndexSpaceT<DIM, COORD_T> >& sources,
2834 const char* provenance = nullptr) const;
2835
2836 IndexSpace intersect_index_spaces(
2837 MapperContext ctx, const std::vector<IndexSpace>& sources,
2838 const char* provenance = nullptr) const;
2839 // Template version
2840 template<int DIM, typename COORD_T>
2841 IndexSpaceT<DIM, COORD_T> intersect_index_spaces(
2842 MapperContext ctx,
2843 const std::vector<IndexSpaceT<DIM, COORD_T> >& sources,
2844 const char* provenance = nullptr) const;
2845
2846 IndexSpace subtract_index_spaces(
2847 MapperContext ctx, IndexSpace left, IndexSpace right,
2848 const char* provenance = nullptr) const;
2849 // Template version
2850 template<int DIM, typename COORD_T>
2851 IndexSpaceT<DIM, COORD_T> subtract_index_spaces(
2852 MapperContext ctx, IndexSpaceT<DIM, COORD_T> left,
2853 IndexSpaceT<DIM, COORD_T> right,
2854 const char* provenance = nullptr) const;
2855 public:
2856 //------------------------------------------------------------------------
2857 // Convenience methods for introspecting index spaces
2858 //------------------------------------------------------------------------
2859 bool is_index_space_empty(MapperContext ctx, IndexSpace handle) const;
2860 template<int DIM, typename COORD_T>
2861 bool is_index_space_empty(
2862 MapperContext ctx, IndexSpaceT<DIM, COORD_T> handle) const;
2863
2864 bool index_spaces_overlap(
2865 MapperContext ctx, IndexSpace one, IndexSpace two) const;
2866 template<int DIM, typename COORD_T>
2867 bool index_spaces_overlap(
2868 MapperContext ctx, IndexSpaceT<DIM, COORD_T> one,
2869 IndexSpaceT<DIM, COORD_T> two) const;
2870
2871 bool index_space_dominates(
2872 MapperContext ctx, IndexSpace test, IndexSpace dominator) const;
2873 template<int DIM, typename COORD_T>
2874 bool index_space_dominates(
2875 MapperContext ctx, IndexSpaceT<DIM, COORD_T> test,
2876 IndexSpaceT<DIM, COORD_T> dominator) const;
2877 public:
2878 //------------------------------------------------------------------------
2879 // Methods for introspecting index space trees
2880 // For documentation see methods of the same name in Runtime
2881 //------------------------------------------------------------------------
2882 bool has_index_partition(
2883 MapperContext ctx, IndexSpace parent, Color c) const;
2884
2885 IndexPartition get_index_partition(
2886 MapperContext ctx, IndexSpace parent, Color color) const;
2887
2888 IndexSpace get_index_subspace(
2889 MapperContext ctx, IndexPartition p, Color c) const;
2890 IndexSpace get_index_subspace(
2891 MapperContext ctx, IndexPartition p, const DomainPoint& color) const;
2892
2893 bool has_multiple_domains(MapperContext ctx, IndexSpace handle) const;
2894
2895 Domain get_index_space_domain(MapperContext ctx, IndexSpace handle) const;
2896
2897 void get_index_space_domains(
2898 MapperContext ctx, IndexSpace handle,
2899 std::vector<Domain>& domains) const;
2900
2901 Domain get_index_partition_color_space(
2902 MapperContext ctx, IndexPartition p) const;
2903
2904 IndexSpace get_index_partition_color_space_name(
2905 MapperContext ctx, IndexPartition p) const;
2906
2907 void get_index_space_partition_colors(
2908 MapperContext ctx, IndexSpace sp, std::set<Color>& colors) const;
2909
2910 bool is_index_partition_disjoint(
2911 MapperContext ctx, IndexPartition p) const;
2912
2913 bool is_index_partition_complete(
2914 MapperContext ctx, IndexPartition p) const;
2915
2916 Color get_index_space_color(MapperContext ctx, IndexSpace handle) const;
2917
2918 DomainPoint get_index_space_color_point(
2919 MapperContext ctx, IndexSpace handle) const;
2920
2921 Color get_index_partition_color(
2922 MapperContext ctx, IndexPartition handle) const;
2923
2924 IndexSpace get_parent_index_space(
2925 MapperContext ctx, IndexPartition handle) const;
2926
2927 bool has_parent_index_partition(
2928 MapperContext ctx, IndexSpace handle) const;
2929
2930 IndexPartition get_parent_index_partition(
2931 MapperContext ctx, IndexSpace handle) const;
2932
2933 unsigned get_index_space_depth(
2934 MapperContext ctx, IndexSpace handle) const;
2935
2936 unsigned get_index_partition_depth(
2937 MapperContext ctx, IndexPartition handle) const;
2938 public:
2939 //------------------------------------------------------------------------
2940 // Methods for introspecting field spaces
2941 // For documentation see methods of the same name in Runtime
2942 //------------------------------------------------------------------------
2943 size_t get_field_size(
2944 MapperContext ctx, FieldSpace handle, FieldID fid) const;
2945
2946 void get_field_space_fields(
2947 MapperContext ctx, FieldSpace handle,
2948 std::vector<FieldID>& fields) const;
2949 void get_field_space_fields(
2950 MapperContext ctx, FieldSpace handle,
2951 std::set<FieldID>& fields) const;
2952 public:
2953 //------------------------------------------------------------------------
2954 // Methods for introspecting logical region trees
2955 //------------------------------------------------------------------------
2956 LogicalPartition get_logical_partition(
2957 MapperContext ctx, LogicalRegion parent, IndexPartition handle) const;
2958
2959 LogicalPartition get_logical_partition_by_color(
2960 MapperContext ctx, LogicalRegion parent, Color color) const;
2961 LogicalPartition get_logical_partition_by_color(
2962 MapperContext ctx, LogicalRegion parent,
2963 const DomainPoint& color) const;
2964
2965 LogicalPartition get_logical_partition_by_tree(
2966 MapperContext ctx, IndexPartition handle, FieldSpace fspace,
2967 RegionTreeID tid) const;
2968
2969 LogicalRegion get_logical_subregion(
2970 MapperContext ctx, LogicalPartition parent, IndexSpace handle) const;
2971
2972 LogicalRegion get_logical_subregion_by_color(
2973 MapperContext ctx, LogicalPartition parent, Color color) const;
2974 LogicalRegion get_logical_subregion_by_color(
2975 MapperContext ctx, LogicalPartition parent,
2976 const DomainPoint& color) const;
2977
2978 LogicalRegion get_logical_subregion_by_tree(
2979 MapperContext ctx, IndexSpace handle, FieldSpace fspace,
2980 RegionTreeID tid) const;
2981
2982 Color get_logical_region_color(
2983 MapperContext ctx, LogicalRegion handle) const;
2984
2985 DomainPoint get_logical_region_color_point(
2986 MapperContext ctx, LogicalRegion handle) const;
2987
2988 Color get_logical_partition_color(
2989 MapperContext ctx, LogicalPartition handle) const;
2990
2991 LogicalRegion get_parent_logical_region(
2992 MapperContext ctx, LogicalPartition handle) const;
2993
2994 bool has_parent_logical_partition(
2995 MapperContext ctx, LogicalRegion handle) const;
2996
2997 LogicalPartition get_parent_logical_partition(
2998 MapperContext ctx, LogicalRegion handle) const;
2999 public:
3000 //------------------------------------------------------------------------
3001 // Methods for getting access to semantic info
3002 //------------------------------------------------------------------------
3003 bool retrieve_semantic_information(
3004 MapperContext ctx, TaskID task_id, SemanticTag tag,
3005 const void*& result, size_t& size, bool can_fail = false,
3006 bool wait_until_ready = false) const;
3007
3008 bool retrieve_semantic_information(
3009 MapperContext ctx, IndexSpace handle, SemanticTag tag,
3010 const void*& result, size_t& size, bool can_fail = false,
3011 bool wait_until_ready = false) const;
3012
3013 bool retrieve_semantic_information(
3014 MapperContext ctx, IndexPartition handle, SemanticTag tag,
3015 const void*& result, size_t& size, bool can_fail = false,
3016 bool wait_until_ready = false) const;
3017
3018 bool retrieve_semantic_information(
3019 MapperContext ctx, FieldSpace handle, SemanticTag tag,
3020 const void*& result, size_t& size, bool can_fail = false,
3021 bool wait_until_ready = false) const;
3022
3023 bool retrieve_semantic_information(
3024 MapperContext ctx, FieldSpace handle, FieldID fid, SemanticTag tag,
3025 const void*& result, size_t& size, bool can_fail = false,
3026 bool wait_until_ready = false) const;
3027
3028 bool retrieve_semantic_information(
3029 MapperContext ctx, LogicalRegion handle, SemanticTag tag,
3030 const void*& result, size_t& size, bool can_fail = false,
3031 bool wait_until_ready = false) const;
3032
3033 bool retrieve_semantic_information(
3034 MapperContext ctx, LogicalPartition handle, SemanticTag tag,
3035 const void*& result, size_t& size, bool can_fail = false,
3036 bool wait_until_ready = false) const;
3037
3038 void retrieve_name(
3039 MapperContext ctx, TaskID task_id, const char*& result) const;
3040
3041 void retrieve_name(
3042 MapperContext ctx, IndexSpace handle, const char*& result) const;
3043
3044 void retrieve_name(
3045 MapperContext ctx, IndexPartition handle, const char*& result) const;
3046
3047 void retrieve_name(
3048 MapperContext ctx, FieldSpace handle, const char*& result) const;
3049
3050 void retrieve_name(
3051 MapperContext ctx, FieldSpace handle, FieldID fid,
3052 const char*& result) const;
3053
3054 void retrieve_name(
3055 MapperContext ctx, LogicalRegion handle, const char*& result) const;
3056
3057 void retrieve_name(
3058 MapperContext ctx, LogicalPartition handle,
3059 const char*& result) const;
3060 public:
3061 //------------------------------------------------------------------------
3062 // Methods for MPI interoperability
3063 //------------------------------------------------------------------------
3064 bool is_MPI_interop_configured(MapperContext ctx) const;
3065 const std::map<int /*rank*/, AddressSpace>& find_forward_MPI_mapping(
3066 MapperContext ctx) const;
3067
3068 const std::map<AddressSpace, int /*rank*/>& find_reverse_MPI_mapping(
3069 MapperContext ctx) const;
3070 int find_local_MPI_rank(MapperContext ctx) const;
3071 public:
3072 //------------------------------------------------------------------------
3073 // Support for packing tunable values
3074 //------------------------------------------------------------------------
3075 template<typename T>
3076 void pack_tunable(
3077 const T& result, Mapper::SelectTunableOutput& output) const
3078 {
3079 static_assert(
3080 std::is_trivially_copyable<T>::value,
3081 "tunable type must be trivially copyable");
3082 void* output_result = malloc(sizeof(T));
3083 memcpy(output_result, &result, sizeof(T));
3084 output.value = output_result;
3085 output.size = sizeof(T);
3086 }
3087 };
3088
3097 public:
3098 AutoLock(MapperContext ctx, LocalLock& r, bool excl = true);
3099 [[deprecated("Use the version without a mode")]]
3100 AutoLock(MapperContext ctx, LocalLock& r, int mode, bool excl = true);
3101 AutoLock(AutoLock&& rhs) = delete;
3102 AutoLock(const AutoLock& rhs) = delete;
3103 ~AutoLock(void) { };
3104 public:
3105 AutoLock& operator=(AutoLock&& rhs) = delete;
3106 AutoLock& operator=(const AutoLock& rhs) = delete;
3107 public:
3108 void reacquire(void);
3109 protected:
3110 const MapperContext ctx;
3111 };
3112
3113 } // namespace Mapping
3114} // namespace Legion
3115
3116#include "legion/api/mapping.inl"
3117
3118#endif // __LEGION_MAPPING_H__
Definition mapping.h:240
Definition mapping.h:292
Definition mapping.h:185
Definition geometry.h:159
Definition geometry.h:34
Definition constraints.h:240
Definition data.h:152
static const FieldSpace NO_SPACE
Definition data.h:154
Definition mapping.h:312
Definition future.h:50
Definition data.h:92
Definition data.h:35
static const IndexSpace NO_SPACE
Definition data.h:37
Definition mapping.h:216
Definition types.h:1134
Definition types.h:1017
Definition types.h:956
Definition constraints.h:275
Definition constraints.h:881
Definition data.h:260
Definition data.h:189
Definition mapping.h:42
Definition mapping.h:3096
Definition mapping.h:490
Definition mapping.h:526
Definition mapping.h:642
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:678
virtual bool request_valid_instances(void) const
Definition mapping.h:700
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:2445
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:2458
Definition mapping.h:414
Definition mapping.h:568
Definition mapping.h:589
Definition mapping.h:377
Definition mapping.h:342
Definition constraints.h:783
Definition mapping.h:264
Definition runtime.h:108
Definition mapping.h:112
Definition constraints.h:942
Definition accessors.h:29
Definition mapping.h:1403
Definition mapping.h:2283
Definition mapping.h:1131
Definition mapping.h:1136
Definition mapping.h:783
Definition mapping.h:869
Definition registrars.h:76
Definition requirements.h:42
Definition registrars.h:111