Legion Runtime
Loading...
Searching...
No Matches
wrapper_mapper.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/*
17 This wrapper mapper takes a Legion mapper as a parameter and wraps it,
18 so that the user can print information or stop program execution when
19 important properties of a task are set (properties set by
20 select_task_options())
21 One can wrap individual mappers using the constructor
22 Legion::Mapping::WrapperMapper
23 (Mapper* mapper, MapperRuntime *rt, Machine machine, Processor local);
24
25 At the start of the program execution, the user can enter the task names or
26 the processor indexes (index for a processor can be seen using the
27 "processors" command) to be monitored in a command-line interface.
28 The commands to do so are as follows:
29
30 stop task +<task_name> --> To stop when properties for task
31 "task_name" are set
32 print task +<task_name> --> To print the properties of task "task_name"
33 task -<task_name> --> To remove task "task_name" from the lists of tasks
34 which are being monitored
35 processors --> To see the list of processors with their corresponding indexes
36 stop processor +<processor_index> --> To stop when any task is mapped to a
37 particular processor
38 print processor +<processor_index> --> To print properties when any task is
39 mapped to a particular processor
40 processor -<processor_index> --> To remove a processor from the lists of
41 processors which are being monitored
42 exit --> To exit from the command-line interface
43 help --> To show the list of commands
44
45 On stopping at a task/processor, one can change properties.
46 One can also enter the above command line interface to add or remove tasks
47 or processors by typing "change".
48 */
49
50#ifndef __WRAPPER_MAPPER_h__
51#define __WRAPPER_MAPPER_h__
52
58#include "legion.h"
59
60#include <stdlib.h>
61#include <assert.h>
62#include <algorithm>
63
64namespace Legion {
65 namespace Mapping {
66
67 //Struct to send properties set by select_task_options
69 int tag;
70 int task_name;
72 int action;
73 };
74 /*
75 struct get_input_message{
76 int tag;
77 Processor processor;
78 std::map<Processor, int> procs_map;
79 std::map<std::string, int> tasks_map;
80 std::map<Memory, int> mems_map;
81 };
82 */
83
84 class WrapperMapper: public Mapper{
85
86 public:
87 Mapper* dmapper;
88 //static std::map<std::string, int> tasks_map;
89 static std::vector<std::string> print_tasks;
90 static std::vector<std::string> stop_tasks;
91 static std::map<int, int> methods_map;
92 static std::set<Memory> all_mems;
93 static std::set<Processor> all_procs;
94 static std::map<Processor, int> procs_map;
95 static std::map<int, int> procs_map_int;
96 static bool inputtaken;
97 static bool databroadcasted;
98 static Processor ownerprocessor;
99 static Processor localowner;
100 static MapperEvent mapevent;
101 static int broadcastcount;
102 WrapperMapper(Mapper* dmapper, MapperRuntime *rt,
103 Machine machine, Processor local);
104 ~WrapperMapper(void);
105 void get_input();
106 void get_input(const MapperContext ctx);
107 void get_select_task_options_input
108 (const MapperContext ctx, std::string task_name, TaskOptions& output);
109 bool InputNumberCheck(std::string strUserInput);
110 Mapper::TaskOptions wait_task_options;
111
112 public:
113 void Deserialize(std::string rec_string);
114 std::string Serialize(const std::map<std::string, int> &tasks_map,
115 const std::map<int, int> &procs_map );
116 std::string Serialize(const std::vector<std::string> &print_tasks,
117 const std::vector<std::string> &stop_tasks,
118 const std::map<int, int> &procs_map);
119 const char* get_mapper_name(void) const override;
120 MapperSyncModel get_mapper_sync_model(void) const override;
121
122 using Mapper::report_profiling;
123 public: // Task mapping calls
124 void select_task_options(const MapperContext ctx,
125 const Task& task,
126 TaskOptions& output) override;
127 void premap_task(const MapperContext ctx,
128 const Task& task,
129 const PremapTaskInput& input,
130 PremapTaskOutput& output) override;
131 void slice_task(const MapperContext ctx,
132 const Task& task,
133 const SliceTaskInput& input,
134 SliceTaskOutput& output) override;
135 void map_task(const MapperContext ctx,
136 const Task& task,
137 const MapTaskInput& input,
138 MapTaskOutput& output) override;
139 void select_task_variant(const MapperContext ctx,
140 const Task& task,
141 const SelectVariantInput& input,
142 SelectVariantOutput& output) override;
143 void postmap_task(const MapperContext ctx,
144 const Task& task,
145 const PostMapInput& input,
146 PostMapOutput& output) override;
147 void select_task_sources(const MapperContext ctx,
148 const Task& task,
149 const SelectTaskSrcInput& input,
150 SelectTaskSrcOutput& output) override;
151 void report_profiling(const MapperContext ctx,
152 const Task& task,
153 const TaskProfilingInfo& input) override;
154 public: // Inline mapping calls
155 void map_inline(const MapperContext ctx,
156 const InlineMapping& inline_op,
157 const MapInlineInput& input,
158 MapInlineOutput& output) override;
159 void select_inline_sources(const MapperContext ctx,
160 const InlineMapping& inline_op,
161 const SelectInlineSrcInput& input,
162 SelectInlineSrcOutput& output) override;
163 void report_profiling(const MapperContext ctx,
164 const InlineMapping& inline_op,
165 const InlineProfilingInfo& input) override;
166 public: // Copy mapping calls
167 void map_copy(const MapperContext ctx,
168 const Copy& copy,
169 const MapCopyInput& input,
170 MapCopyOutput& output) override;
171 void select_copy_sources(const MapperContext ctx,
172 const Copy& copy,
173 const SelectCopySrcInput& input,
174 SelectCopySrcOutput& output) override;
175 void report_profiling(const MapperContext ctx,
176 const Copy& copy,
177 const CopyProfilingInfo& input) override;
178 public: // Close mapping calls
179 void select_close_sources(const MapperContext ctx,
180 const Close& close,
181 const SelectCloseSrcInput& input,
182 SelectCloseSrcOutput& output) override;
183 void report_profiling(const MapperContext ctx,
184 const Close& close,
185 const CloseProfilingInfo& input) override;
186 public: // Acquire mapping calls
187 void map_acquire(const MapperContext ctx,
188 const Acquire& acquire,
189 const MapAcquireInput& input,
190 MapAcquireOutput& output) override;
191 void report_profiling(const MapperContext ctx,
192 const Acquire& acquire,
193 const AcquireProfilingInfo& input) override;
194 public: // Release mapping calls
195 void map_release(const MapperContext ctx,
196 const Release& release,
197 const MapReleaseInput& input,
198 MapReleaseOutput& output) override;
199 void select_release_sources(const MapperContext ctx,
200 const Release& release,
201 const SelectReleaseSrcInput& input,
202 SelectReleaseSrcOutput& output) override;
203 void report_profiling(const MapperContext ctx,
204 const Release& release,
205 const ReleaseProfilingInfo& input) override;
206 public: // Task execution mapping calls
207 void configure_context(const MapperContext ctx,
208 const Task& task,
209 ContextConfigOutput& output) override;
210 void select_tunable_value(const MapperContext ctx,
211 const Task& task,
212 const SelectTunableInput& input,
213 SelectTunableOutput& output) override;
214 public: // Must epoch mapping
215 void map_must_epoch(const MapperContext ctx,
216 const MapMustEpochInput& input,
217 MapMustEpochOutput& output) override;
218 public: // Dataflow graph mapping
219 void map_dataflow_graph(const MapperContext ctx,
220 const MapDataflowGraphInput& input,
221 MapDataflowGraphOutput& output) override;
222 public: // Mapping control and stealing
223 void select_tasks_to_map(const MapperContext ctx,
224 const SelectMappingInput& input,
225 SelectMappingOutput& output) override;
226 void select_steal_targets(const MapperContext ctx,
227 const SelectStealingInput& input,
228 SelectStealingOutput& output) override;
229 void permit_steal_request(const MapperContext ctx,
230 const StealRequestInput& input,
231 StealRequestOutput& output) override;
232 public: // handling
233 void handle_message(const MapperContext ctx,
234 const MapperMessage& message) override;
235 void handle_task_result(const MapperContext ctx,
236 const MapperTaskResult& result) override;
237
238 protected:
239 MapperRuntime *const mrt;
240 const Processor local_proc;
241 const Processor::Kind local_kind;
242 const AddressSpace node_id;
243 const Machine machine;
244 //const char *const mapper_name;
245
246 protected:
247 // The maximum number of tasks a mapper will allow to be stolen at a time
248 // Controlled by -dm:thefts
249 unsigned max_steals_per_theft;
250 // The maximum number of times that a single task is allowed to be stolen
251 // Controlled by -dm:count
252 unsigned max_steal_count;
253 // Do a breadth-first traversal of the task tree, by default we do
254 // a depth-first traversal to improve locality
255 bool breadth_first_traversal;
256 // Track whether stealing is enabled
257 bool stealing_enabled;
258 // The maximum number of tasks scheduled per step
259 unsigned max_schedule_count;
260 };
261
262
263 }; // namespace Mapping
264}; // namespace Legion
265
266#endif
267
Definition mapping.h:240
Definition mapping.h:292
Definition mapping.h:185
Definition mapping.h:216
Definition mapping.h:526
Definition mapping.h:642
MapperSyncModel
Definition mapping.h:678
Definition mapping.h:2458
Definition wrapper_mapper.h:84
const char * get_mapper_name(void) const override
Definition mapping.h:264
Definition mapping.h:112
Definition accessors.h:29
Definition mapping.h:1403
Definition mapping.h:1131
Definition mapping.h:1136
Definition mapping.h:783
Definition wrapper_mapper.h:68