diff --git a/experiment/sapling/run_all_tests.sh b/experiment/sapling/run_all_tests.sh index d1c7e63..d45dc38 100755 --- a/experiment/sapling/run_all_tests.sh +++ b/experiment/sapling/run_all_tests.sh @@ -11,13 +11,14 @@ root_dir="$(dirname "$(dirname "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" cd "$root_dir" export FUZZER_OP_COUNT=1000 -export FUZZER_EXTRA_FLAGS="-ll:util 2 -ll:cpu 3" function run_fuzzer_config { config_name="$1" mode="$2" + extra_flags="$3" fuzzer_exe="$PWD/build_${config_name}/src/fuzzer" + fuzzer_flags="-ll:util 2 -ll:cpu 3 $extra_flags" if [[ $mode = single ]]; then test_count=100000 @@ -35,10 +36,12 @@ function run_fuzzer_config { # Generate a random seed so we explore a novel part of the state space. seed="$(( 16#$(openssl rand -hex 4) * test_count ))" - FUZZER_EXE="$fuzzer_exe" FUZZER_MODE=$mode FUZZER_TEST_COUNT=$test_count FUZZER_SEED=$seed FUZZER_LAUNCHER="$launcher" sbatch --nodes 1 "experiment/$FUZZER_MACHINE/sbatch_fuzzer.sh" + FUZZER_EXE="$fuzzer_exe" FUZZER_MODE=$mode FUZZER_TEST_COUNT=$test_count FUZZER_SEED=$seed FUZZER_LAUNCHER="$launcher" FUZZER_EXTRA_FLAGS="$fuzzer_flags" sbatch --nodes 1 "experiment/$FUZZER_MACHINE/sbatch_fuzzer.sh" } run_fuzzer_config debug_single single run_fuzzer_config release_single single run_fuzzer_config debug_multi multi run_fuzzer_config release_multi multi +run_fuzzer_config debug_multi multi "-fuzz:replicate 1" +run_fuzzer_config release_multi multi "-fuzz:replicate 1" diff --git a/src/fuzzer.cc b/src/fuzzer.cc index 3f4cb58..67725d1 100644 --- a/src/fuzzer.cc +++ b/src/fuzzer.cc @@ -20,6 +20,7 @@ #include "deterministic_random.h" #include "legion.h" +#include "logging_wrapper.h" #include "mapper.h" using namespace Legion; @@ -51,6 +52,8 @@ enum ProjectionIDs { static Logger log_fuzz("fuzz"); static RngSeed root_seed; +static uint64_t replicate_levels = 0; +static bool mapper_logging = false; static long long parse_long_long(const std::string &flag, const std::string &arg) { long long result; @@ -80,8 +83,10 @@ struct FuzzerConfig { uint64_t region_tree_branch_factor = 4; uint64_t region_tree_size_factor = 4; uint64_t region_tree_num_fields = 4; + uint64_t replicate_levels = 0; uint64_t num_ops = 1; uint64_t skip_ops = 0; + bool mapper_logging = false; static FuzzerConfig parse_args(int argc, char **argv) { FuzzerConfig config; @@ -105,12 +110,17 @@ struct FuzzerConfig { } else if (flag == "-fuzz:fields") { std::string arg(argv[++i]); config.region_tree_num_fields = parse_uint64_t(flag, arg); + } else if (flag == "-fuzz:replicate") { + std::string arg(argv[++i]); + config.replicate_levels = parse_uint64_t(flag, arg); } else if (flag == "-fuzz:ops") { std::string arg(argv[++i]); config.num_ops = parse_uint64_t(flag, arg); } else if (flag == "-fuzz:skip") { std::string arg(argv[++i]); config.skip_ops = parse_uint64_t(flag, arg); + } else if (flag == "-fuzz:mapper_logging") { + config.mapper_logging = true; } } return config; @@ -127,8 +137,10 @@ struct FuzzerConfig { << region_tree_size_factor); LOG_ONCE(log_fuzz.print() << " config.region_tree_num_fields = " << region_tree_num_fields); + LOG_ONCE(log_fuzz.print() << " config.replicate_levels = " << replicate_levels); LOG_ONCE(log_fuzz.print() << " config.num_ops = " << num_ops); LOG_ONCE(log_fuzz.print() << " config.skip_ops = " << skip_ops); + LOG_ONCE(log_fuzz.print() << " config.mapper_logging = " << mapper_logging); } }; @@ -1205,8 +1217,12 @@ void top_level(const Task *task, const std::vector ®ions, Con static void create_mappers(Machine machine, Runtime *runtime, const std::set &local_procs) { for (Processor proc : local_procs) { - FuzzMapper::FuzzMapper *mapper = new FuzzMapper::FuzzMapper( - runtime->get_mapper_runtime(), machine, proc, root_seed.make_stream()); + Mapping::Mapper *mapper = + new FuzzMapper::FuzzMapper(runtime->get_mapper_runtime(), machine, proc, + root_seed.make_stream(), replicate_levels); + if (mapper_logging) { + mapper = new Mapping::LoggingWrapper(mapper); + } runtime->replace_default_mapper(mapper, proc); } } @@ -1219,6 +1235,8 @@ int main(int argc, char **argv) { Runtime::initialize(&argc, &argv, true /* filter */); FuzzerConfig config = FuzzerConfig::parse_args(argc, argv); root_seed = RngSeed(config.initial_seed); + replicate_levels = config.replicate_levels; + mapper_logging = config.mapper_logging; Runtime::preregister_projection_functor(PROJECTION_OFFSET_1_ID, new OffsetProjection(1)); diff --git a/src/mapper.cc b/src/mapper.cc index 55feabc..45c85b8 100644 --- a/src/mapper.cc +++ b/src/mapper.cc @@ -31,13 +31,15 @@ enum MapperCallIDs { static Logger log_map("fuzz_mapper"); -FuzzMapper::FuzzMapper(MapperRuntime *rt, Machine machine, Processor local, RngStream st) +FuzzMapper::FuzzMapper(MapperRuntime *rt, Machine machine, Processor local, RngStream st, + uint64_t replicate) : NullMapper(rt, machine), stream(st), select_tasks_to_map_channel(st.make_channel(int32_t(SELECT_TASKS_TO_MAP))), map_inline_channel(st.make_channel(int32_t(MAP_INLINE))), select_inline_sources_channel(st.make_channel(int32_t(SELECT_INLINE_SOURCES))), - local_proc(local) { + local_proc(local), + replicate_levels(replicate) { // TODO: something other than CPU processor { Machine::ProcessorQuery query(machine); @@ -85,7 +87,7 @@ void FuzzMapper::select_task_options(const MapperContext ctx, const Task &task, output.map_locally = false; // TODO output.valid_instances = false; output.memoize = true; - output.replicate = task.get_depth() == 0; // TODO: replicate other tasks + output.replicate = task.get_depth() < static_cast(replicate_levels); // output.parent_priority = ...; // Leave parent at current priority. // output.check_collective_regions.insert(...); // TODO } @@ -124,7 +126,11 @@ void FuzzMapper::map_task(const MapperContext ctx, const Task &task, log_map.debug() << "map_task: Selected variant " << output.chosen_variant; // TODO: assign to variant's correct processor kind - if (rng.uniform_range(0, 1) == 0) { + output.target_procs.clear(); + if (input.shard_processor.exists()) { + log_map.debug() << "map_task: Mapping to shard proc"; + output.target_procs.push_back(input.shard_processor); + } else if (rng.uniform_range(0, 1) == 0) { log_map.debug() << "map_task: Mapping to all local procs"; output.target_procs.insert(output.target_procs.end(), local_procs.begin(), local_procs.end()); @@ -149,6 +155,8 @@ void FuzzMapper::map_task(const MapperContext ctx, const Task &task, void FuzzMapper::replicate_task(MapperContext ctx, const Task &task, const ReplicateTaskInput &input, ReplicateTaskOutput &output) { + if (task.get_depth() >= static_cast(replicate_levels)) return; + // TODO: cache this? std::vector variants; runtime->find_valid_variants(ctx, task.task_id, variants); @@ -158,7 +166,28 @@ void FuzzMapper::replicate_task(MapperContext ctx, const Task &task, abort(); } output.chosen_variant = variants.at(0); - // TODO: actually replicate + + bool is_replicable = + runtime->is_replicable_variant(ctx, task.task_id, output.chosen_variant); + // For now assume we always have replicable variants at this level. + if (!is_replicable) { + log_map.fatal() << "Bad variants in replicate_task: variant is not replicable"; + abort(); + } + + std::map targets; + for (Processor proc : global_procs) { + AddressSpace space = proc.address_space(); + if (!targets.count(space)) { + targets[space] = proc; + } + } + + if (targets.size() > 1) { + for (auto &target : targets) { + output.target_processors.push_back(target.second); + } + } } void FuzzMapper::select_task_sources(const MapperContext ctx, const Task &task, @@ -168,6 +197,13 @@ void FuzzMapper::select_task_sources(const MapperContext ctx, const Task &task, random_sources(rng, input.source_instances, output.chosen_ranking); } +void FuzzMapper::select_sharding_functor(const MapperContext ctx, const Task &task, + const SelectShardingFunctorInput &input, + SelectShardingFunctorOutput &output) { + // TODO: customize the sharding functor + output.chosen_functor = 0; +} + void FuzzMapper::map_inline(const MapperContext ctx, const InlineMapping &inline_op, const MapInlineInput &input, MapInlineOutput &output) { RngChannel &rng = map_inline_channel; diff --git a/src/mapper.h b/src/mapper.h index cfe2009..727627d 100644 --- a/src/mapper.h +++ b/src/mapper.h @@ -28,7 +28,8 @@ using namespace Legion::Mapping; class FuzzMapper : public NullMapper { public: - FuzzMapper(MapperRuntime *runtime, Machine machine, Processor local, RngStream stream); + FuzzMapper(MapperRuntime *runtime, Machine machine, Processor local, RngStream stream, + uint64_t replicate); public: const char *get_mapper_name(void) const override; @@ -49,6 +50,9 @@ class FuzzMapper : public NullMapper { void select_task_sources(const MapperContext ctx, const Task &task, const SelectTaskSrcInput &input, SelectTaskSrcOutput &output) override; + void select_sharding_functor(const MapperContext ctx, const Task &task, + const SelectShardingFunctorInput &input, + SelectShardingFunctorOutput &output) override; public: // Inline mapping calls void map_inline(const MapperContext ctx, const InlineMapping &inline_op, @@ -97,6 +101,8 @@ class FuzzMapper : public NullMapper { Processor local_proc; std::vector local_procs; std::vector global_procs; + + uint64_t replicate_levels; }; } // namespace FuzzMapper