forked from StanfordLegion/task-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapper.cc
82 lines (72 loc) · 2.63 KB
/
mapper.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* Copyright 2020 Stanford University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mapper.h"
#include "mappers/default_mapper.h"
#define SPMD_SHARD_USE_IO_PROC 1
using namespace Legion;
using namespace Legion::Mapping;
static LegionRuntime::Logger::Category log_stencil("stencil");
class TaskBenchMapper : public DefaultMapper
{
public:
TaskBenchMapper(MapperRuntime *rt, Machine machine, Processor local,
const char *mapper_name);
virtual void default_policy_rank_processor_kinds(
MapperContext ctx, const Task &task,
std::vector<Processor::Kind> &ranking);
};
TaskBenchMapper::TaskBenchMapper(MapperRuntime *rt, Machine machine, Processor local,
const char *mapper_name)
: DefaultMapper(rt, machine, local, mapper_name)
{
}
void TaskBenchMapper::default_policy_rank_processor_kinds(MapperContext ctx,
const Task &task, std::vector<Processor::Kind> &ranking)
{
#if SPMD_SHARD_USE_IO_PROC
const char* task_name = task.get_task_name();
const char* prefix = "shard_";
if (strncmp(task_name, prefix, strlen(prefix)) == 0) {
// Put shard tasks on IO processors.
ranking.resize(4);
ranking[0] = Processor::TOC_PROC;
ranking[1] = Processor::PROC_SET;
ranking[2] = Processor::IO_PROC;
ranking[3] = Processor::LOC_PROC;
} else {
#endif
ranking.resize(4);
ranking[0] = Processor::TOC_PROC;
ranking[1] = Processor::PROC_SET;
ranking[2] = Processor::LOC_PROC;
ranking[3] = Processor::IO_PROC;
#if SPMD_SHARD_USE_IO_PROC
}
#endif
}
static void create_mappers(Machine machine, HighLevelRuntime *runtime, const std::set<Processor> &local_procs)
{
for (std::set<Processor>::const_iterator it = local_procs.begin();
it != local_procs.end(); it++)
{
TaskBenchMapper* mapper = new TaskBenchMapper(runtime->get_mapper_runtime(),
machine, *it, "task_bench_mapper");
runtime->replace_default_mapper(mapper, *it);
}
}
void register_mappers()
{
HighLevelRuntime::add_registration_callback(create_mappers);
}