From ee6f7dcdf443ae5688e27dc59a12531657240447 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 4 Oct 2022 17:05:03 -0700 Subject: [PATCH 01/15] Autoscheduler test reorg, part 1 The end goal here is to move the tests for all autoschedulers into `test/autoschedulers/`. This part handles the tests for the Mullapudi2016 autoscheduler: - Moves from test/auto_schedule - Silences a lot of the irrelevant noise that the tests emit to stdout (see also #7063) - Ensure that the tests that run manual-and-auto tests actually check the times for plausibility (where "plausible" means "no worse than the current status quo") - Changes the test group label from `auto_schedule` to `autoschedulers` --- Makefile | 15 ++--- test/CMakeLists.txt | 4 +- test/autoschedulers/CMakeLists.txt | 3 + .../mullapudi2016}/CMakeLists.txt | 4 +- .../mullapudi2016}/cost_function.cpp | 15 ++--- .../mullapudi2016}/data_dependent.cpp | 4 +- .../mullapudi2016}/extern.cpp | 12 ++-- .../mullapudi2016}/fibonacci.cpp | 17 ++++-- .../mullapudi2016}/histogram.cpp | 18 +++--- .../mullapudi2016}/large_window.cpp | 4 +- .../mullapudi2016}/mat_mul.cpp | 23 +++---- .../mullapudi2016}/max_filter.cpp | 19 +++--- .../mullapudi2016}/multi_output.cpp | 6 +- .../mullapudi2016}/overlap.cpp | 4 +- .../mullapudi2016}/param.cpp | 16 ++--- .../mullapudi2016}/reorder.cpp | 60 +++++++++---------- .../mullapudi2016}/small_pure_update.cpp | 0 .../mullapudi2016}/tile_vs_inline.cpp | 4 +- .../mullapudi2016}/unused_func.cpp | 4 +- .../vectorize_var_in_update.cpp | 4 +- 20 files changed, 125 insertions(+), 111 deletions(-) create mode 100644 test/autoschedulers/CMakeLists.txt rename test/{auto_schedule => autoschedulers/mullapudi2016}/CMakeLists.txt (86%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/cost_function.cpp (80%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/data_dependent.cpp (94%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/extern.cpp (94%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/fibonacci.cpp (70%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/histogram.cpp (88%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/large_window.cpp (94%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/mat_mul.cpp (88%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/max_filter.cpp (89%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/multi_output.cpp (93%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/overlap.cpp (94%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/param.cpp (91%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/reorder.cpp (74%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/small_pure_update.cpp (100%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/tile_vs_inline.cpp (95%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/unused_func.cpp (91%) rename test/{auto_schedule => autoschedulers/mullapudi2016}/vectorize_var_in_update.cpp (95%) diff --git a/Makefile b/Makefile index abae57d670c4..3ff23d010bcd 100644 --- a/Makefile +++ b/Makefile @@ -1175,7 +1175,7 @@ RUNTIME_TESTS = $(shell ls $(ROOT_DIR)/test/runtime/*.cpp) GENERATOR_EXTERNAL_TESTS := $(shell ls $(ROOT_DIR)/test/generator/*test.cpp) GENERATOR_EXTERNAL_TEST_GENERATOR := $(shell ls $(ROOT_DIR)/test/generator/*_generator.cpp) TUTORIALS = $(filter-out %_generate.cpp, $(shell ls $(ROOT_DIR)/tutorial/*.cpp)) -AUTO_SCHEDULE_TESTS = $(shell ls $(ROOT_DIR)/test/auto_schedule/*.cpp) +MULLAPUDI2016_TESTS = $(shell ls $(ROOT_DIR)/test/autoschedulers/mullapudi2016/*.cpp) test_correctness: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=quiet_correctness_%) $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.c=quiet_correctness_%) test_performance: $(PERFORMANCE_TESTS:$(ROOT_DIR)/test/performance/%.cpp=performance_%) @@ -1185,7 +1185,8 @@ test_runtime: $(RUNTIME_TESTS:$(ROOT_DIR)/test/runtime/%.cpp=runtime_%) test_tutorial: $(TUTORIALS:$(ROOT_DIR)/tutorial/%.cpp=tutorial_%) test_valgrind: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=valgrind_%) test_avx512: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=avx512_%) -test_auto_schedule: test_mullapudi2016 test_li2018 test_adams2019 +test_autoschedulers: test_mullapudi2016 test_li2018 test_adams2019 +test_auto_schedule: test_autoschedulers .PHONY: test_correctness_multi_gpu test_correctness_multi_gpu: correctness_gpu_multi_device @@ -1282,7 +1283,7 @@ init_time_compilation_%: TIME_COMPILATION ?= /usr/bin/time -a -f "$@,%U,%S,%E" -o run_tests: $(ALL_TESTS) - make -f $(THIS_MAKEFILE) test_performance test_auto_schedule + make -f $(THIS_MAKEFILE) test_performance test_autoschedulers .PHONY: build_tests build_tests: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=$(BIN_DIR)/correctness_%) \ @@ -1292,7 +1293,7 @@ build_tests: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=$(BIN_DIR)/c $(RUNTIME_TESTS:$(ROOT_DIR)/test/runtime/%.cpp=$(BIN_DIR)/runtime_%) \ $(GENERATOR_EXTERNAL_TESTS:$(ROOT_DIR)/test/generator/%_aottest.cpp=$(BIN_DIR)/$(TARGET)/generator_aot_%) \ $(GENERATOR_EXTERNAL_TESTS:$(ROOT_DIR)/test/generator/%_jittest.cpp=$(BIN_DIR)/generator_jit_%) \ - $(AUTO_SCHEDULE_TESTS:$(ROOT_DIR)/test/auto_schedule/%.cpp=$(BIN_DIR)/auto_schedule_%) + $(MULLAPUDI2016_TESTS:$(ROOT_DIR)/test/autoschedulers/mullapudi2016/%.cpp=$(BIN_DIR)/mullapudi2016_%) clean_generator: rm -rf $(BIN_DIR)/*.generator @@ -1368,7 +1369,7 @@ $(BIN_DIR)/runtime_%: $(ROOT_DIR)/test/runtime/%.cpp $(ROOT_DIR)/test/runtime/co $(CXX) $(TEST_CXX_FLAGS) $(RUNTIME_TESTS_CXXFLAGS) -I$(ROOT_DIR)/test/runtime -I$(ROOT_DIR)/src/runtime $(OPTIMIZE_FOR_BUILD_TIME) $< $(COMMON_LD_FLAGS) -o $@ # Auto schedule tests that link against libHalide -$(BIN_DIR)/auto_schedule_%: $(ROOT_DIR)/test/auto_schedule/%.cpp $(BIN_DIR)/libHalide.$(SHARED_EXT) $(INCLUDE_DIR)/Halide.h +$(BIN_DIR)/mullapudi2016_%: $(ROOT_DIR)/test/autoschedulers/mullapudi2016/%.cpp $(BIN_DIR)/libHalide.$(SHARED_EXT) $(INCLUDE_DIR)/Halide.h $(CXX) $(TEST_CXX_FLAGS) $(OPTIMIZE_FOR_BUILD_TIME) $< -I$(INCLUDE_DIR) $(TEST_LD_FLAGS) -o $@ # TODO(srj): this doesn't auto-delete, why not? @@ -1998,11 +1999,11 @@ tutorial_%: $(BIN_DIR)/tutorial_% $(TMP_DIR)/images/rgb.png $(TMP_DIR)/images/gr cd $(TMP_DIR) ; $(CURDIR)/$< @-echo -test_mullapudi2016: $(AUTO_SCHEDULE_TESTS:$(ROOT_DIR)/test/auto_schedule/%.cpp=auto_schedule_%) +test_mullapudi2016: $(MULLAPUDI2016_TESTS:$(ROOT_DIR)/test/autoschedulers/mullapudi2016/%.cpp=mullapudi2016_%) # These tests were written for the Mullapudi2016 autoscheduler. # TODO: either make them work with all autoschedulers or move them under src/autoschedulers/mullapudi2016 -auto_schedule_%: $(BIN_DIR)/auto_schedule_% $(BIN_MULLAPUDI2016) +mullapudi2016_%: $(BIN_DIR)/mullapudi2016_% $(BIN_MULLAPUDI2016) @-mkdir -p $(TMP_DIR) cd $(TMP_DIR) ; $(CURDIR)/$< $(realpath $(BIN_MULLAPUDI2016)) @-echo diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ca1e3f46acf8..cdc45a5eb1d7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -9,9 +9,9 @@ target_precompile_headers(_test_internal PRIVATE ) add_halide_test(_test_internal GROUPS internal) -option(WITH_TEST_AUTO_SCHEDULE "Build auto_schedule tests" ON) +option(WITH_TEST_AUTO_SCHEDULE "Build autoscheduler tests" ON) if (WITH_TEST_AUTO_SCHEDULE) - add_subdirectory(auto_schedule) + add_subdirectory(autoschedulers) endif () option(WITH_TEST_CORRECTNESS "Build correctness tests" ON) diff --git a/test/autoschedulers/CMakeLists.txt b/test/autoschedulers/CMakeLists.txt new file mode 100644 index 000000000000..cc7944010019 --- /dev/null +++ b/test/autoschedulers/CMakeLists.txt @@ -0,0 +1,3 @@ +include(HalideTestHelpers) + +add_subdirectory(mullapudi2016) diff --git a/test/auto_schedule/CMakeLists.txt b/test/autoschedulers/mullapudi2016/CMakeLists.txt similarity index 86% rename from test/auto_schedule/CMakeLists.txt rename to test/autoschedulers/mullapudi2016/CMakeLists.txt index e4dc2b8e671b..4a0de457608e 100644 --- a/test/auto_schedule/CMakeLists.txt +++ b/test/autoschedulers/mullapudi2016/CMakeLists.txt @@ -1,11 +1,11 @@ if (TARGET Halide::Mullapudi2016) - tests(GROUPS auto_schedule + tests(GROUPS mullapudi2016 autoschedulers SOURCES extern.cpp param.cpp ARGS $) - tests(GROUPS auto_schedule multithreaded + tests(GROUPS mullapudi2016 autoschedulers multithreaded SOURCES cost_function.cpp data_dependent.cpp diff --git a/test/auto_schedule/cost_function.cpp b/test/autoschedulers/mullapudi2016/cost_function.cpp similarity index 80% rename from test/auto_schedule/cost_function.cpp rename to test/autoschedulers/mullapudi2016/cost_function.cpp index 7200c9348f5d..b9dce4a5cc5b 100644 --- a/test/auto_schedule/cost_function.cpp +++ b/test/autoschedulers/mullapudi2016/cost_function.cpp @@ -54,13 +54,14 @@ int main(int argc, char **argv) { AutoSchedulerResults results = p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - std::cout << "\n\n******************************************\nSCHEDULE:\n" - << "******************************************\n" - << results.schedule_source - << "\n******************************************\n\n"; - - // Inspect the schedule - stencils[num_stencils - 1].print_loop_nest(); + // Don't dump to stdout (this is only for debugging) + // std::cout << "\n\n******************************************\nSCHEDULE:\n" + // << "******************************************\n" + // << results.schedule_source + // << "\n******************************************\n\n"; + + // Inspect the schedule (only for debugging)) + // stencils[num_stencils - 1].print_loop_nest(); // Run the schedule p.realize({6204, 4604}); diff --git a/test/auto_schedule/data_dependent.cpp b/test/autoschedulers/mullapudi2016/data_dependent.cpp similarity index 94% rename from test/auto_schedule/data_dependent.cpp rename to test/autoschedulers/mullapudi2016/data_dependent.cpp index 828a1061cd3e..e8cb980d243c 100644 --- a/test/auto_schedule/data_dependent.cpp +++ b/test/autoschedulers/mullapudi2016/data_dependent.cpp @@ -46,8 +46,8 @@ int main(int argc, char **argv) { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - g.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // g.print_loop_nest(); // Run the schedule Buffer out = p.realize({input.width() - 1, input.height()}); diff --git a/test/auto_schedule/extern.cpp b/test/autoschedulers/mullapudi2016/extern.cpp similarity index 94% rename from test/auto_schedule/extern.cpp rename to test/autoschedulers/mullapudi2016/extern.cpp index 8cd4b5181c2c..31b2a80d1ce1 100644 --- a/test/auto_schedule/extern.cpp +++ b/test/autoschedulers/mullapudi2016/extern.cpp @@ -58,8 +58,8 @@ void test_case_1() { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - g.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // g.print_loop_nest(); } // Test with an extern Func which consumes a trivial Func; autoscheduler @@ -92,8 +92,8 @@ void test_case_2() { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - g.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // g.print_loop_nest(); } // Test with an extern Func that consumes a non-pure Func. @@ -128,8 +128,8 @@ void test_case_3() { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - g.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // g.print_loop_nest(); } int main(int argc, char **argv) { diff --git a/test/auto_schedule/fibonacci.cpp b/test/autoschedulers/mullapudi2016/fibonacci.cpp similarity index 70% rename from test/auto_schedule/fibonacci.cpp rename to test/autoschedulers/mullapudi2016/fibonacci.cpp index 0d2a05a3001b..87e531d6897f 100644 --- a/test/auto_schedule/fibonacci.cpp +++ b/test/autoschedulers/mullapudi2016/fibonacci.cpp @@ -29,8 +29,8 @@ double run_test(bool auto_schedule) { #endif } - // Inspect the schedule - g.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // g.print_loop_nest(); // Benchmark the schedule Buffer out(100); @@ -57,10 +57,15 @@ int main(int argc, char **argv) { double manual_time = run_test(false); double auto_time = run_test(true); - std::cout << "======================\n" - << "Manual time: " << manual_time << "ms\n" - << "Auto time: " << auto_time << "ms\n" - << "======================\n"; + const double slowdown_factor = 3.0; + if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { + std::cerr << "Autoscheduler time is slower than expected:\n" + << "======================\n" + << "Manual time: " << manual_time << "ms\n" + << "Auto time: " << auto_time << "ms\n" + << "======================\n"; + exit(1); + } printf("Success!\n"); return 0; diff --git a/test/auto_schedule/histogram.cpp b/test/autoschedulers/mullapudi2016/histogram.cpp similarity index 88% rename from test/auto_schedule/histogram.cpp rename to test/autoschedulers/mullapudi2016/histogram.cpp index 0cc4f151030b..53863f5e9c19 100644 --- a/test/auto_schedule/histogram.cpp +++ b/test/autoschedulers/mullapudi2016/histogram.cpp @@ -112,7 +112,8 @@ double run_test(bool auto_schedule) { } p.compile_to_lowered_stmt("histogram.html", {in}, HTML, target); - color.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // color.print_loop_nest(); Buffer out(in.width(), in.height(), in.channels()); double t = benchmark(3, 10, [&]() { @@ -138,13 +139,14 @@ int main(int argc, char **argv) { double manual_time = run_test(false); double auto_time = run_test(true); - std::cout << "======================" << std::endl; - std::cout << "Manual time: " << manual_time << "ms" << std::endl; - std::cout << "Auto time: " << auto_time << "ms" << std::endl; - std::cout << "======================" << std::endl; - - if (auto_time > manual_time * 3) { - fprintf(stderr, "Warning: Auto-scheduler is much much slower than it should be.\n"); + const double slowdown_factor = 5.0; + if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { + std::cerr << "Autoscheduler time is slower than expected:\n" + << "======================\n" + << "Manual time: " << manual_time << "ms\n" + << "Auto time: " << auto_time << "ms\n" + << "======================\n"; + exit(1); } printf("Success!\n"); diff --git a/test/auto_schedule/large_window.cpp b/test/autoschedulers/mullapudi2016/large_window.cpp similarity index 94% rename from test/auto_schedule/large_window.cpp rename to test/autoschedulers/mullapudi2016/large_window.cpp index c449d7136873..0055f3442c90 100644 --- a/test/auto_schedule/large_window.cpp +++ b/test/autoschedulers/mullapudi2016/large_window.cpp @@ -52,8 +52,8 @@ int main(int argc, char **argv) { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - g.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // g.print_loop_nest(); // Run the schedule Buffer out = p.realize({input.width(), input.height()}); diff --git a/test/auto_schedule/mat_mul.cpp b/test/autoschedulers/mullapudi2016/mat_mul.cpp similarity index 88% rename from test/auto_schedule/mat_mul.cpp rename to test/autoschedulers/mullapudi2016/mat_mul.cpp index 73bac853d393..0c03b0b3d268 100644 --- a/test/auto_schedule/mat_mul.cpp +++ b/test/autoschedulers/mullapudi2016/mat_mul.cpp @@ -110,11 +110,12 @@ double run_test(bool auto_schedule) { prod.compute_at(out, x).vectorize(x); prod.update().reorder(x, y, r).vectorize(x).unroll(y); out.tile(x, y, xi, yi, 16, 4).vectorize(xi).unroll(yi).parallel(y); - out.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // out.print_loop_nest(); } - // Inspect the schedule - out.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // out.print_loop_nest(); // Benchmark the schedule Buffer result(size, size); @@ -141,14 +142,14 @@ int main(int argc, char **argv) { double manual_time = run_test(false); double auto_time = run_test(true); - std::cout << "======================\n" - << "Manual time: " << manual_time << "ms\n" - << "Auto time: " << auto_time << "ms\n" - << "======================\n"; - - if (!get_jit_target_from_environment().has_gpu_feature() && - (auto_time > manual_time * 5.0)) { - fprintf(stderr, "Warning: Auto-scheduler is much much slower than it should be.\n"); + const double slowdown_factor = 4.0; + if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { + std::cerr << "Autoscheduler time is slower than expected:\n" + << "======================\n" + << "Manual time: " << manual_time << "ms\n" + << "Auto time: " << auto_time << "ms\n" + << "======================\n"; + exit(1); } printf("Success!\n"); diff --git a/test/auto_schedule/max_filter.cpp b/test/autoschedulers/mullapudi2016/max_filter.cpp similarity index 89% rename from test/auto_schedule/max_filter.cpp rename to test/autoschedulers/mullapudi2016/max_filter.cpp index f9d7e0854012..7499ae747f93 100644 --- a/test/auto_schedule/max_filter.cpp +++ b/test/autoschedulers/mullapudi2016/max_filter.cpp @@ -113,8 +113,8 @@ double run_test(bool auto_schedule) { } p.compile_to_lowered_stmt("max_filter.html", {in}, HTML, target); - // Inspect the schedule - final.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // final.print_loop_nest(); // Run the schedule Buffer out(in.width(), in.height(), in.channels()); @@ -141,13 +141,14 @@ int main(int argc, char **argv) { double manual_time = run_test(false); double auto_time = run_test(true); - std::cout << "======================\n" - << "Manual time: " << manual_time << "ms\n" - << "Auto time: " << auto_time << "ms\n" - << "======================\n"; - - if (auto_time > manual_time * 2) { - fprintf(stderr, "Warning: Auto-scheduler is much much slower than it should be.\n"); + const double slowdown_factor = 2.0; + if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { + std::cerr << "Autoscheduler time is slower than expected:\n" + << "======================\n" + << "Manual time: " << manual_time << "ms\n" + << "Auto time: " << auto_time << "ms\n" + << "======================\n"; + exit(1); } printf("Success!\n"); diff --git a/test/auto_schedule/multi_output.cpp b/test/autoschedulers/mullapudi2016/multi_output.cpp similarity index 93% rename from test/auto_schedule/multi_output.cpp rename to test/autoschedulers/mullapudi2016/multi_output.cpp index 3ad372568e13..d3e63d8f984a 100644 --- a/test/auto_schedule/multi_output.cpp +++ b/test/autoschedulers/mullapudi2016/multi_output.cpp @@ -53,9 +53,9 @@ int main(int argc, char **argv) { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - h.print_loop_nest(); - g.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // h.print_loop_nest(); + // g.print_loop_nest(); Buffer out_1(999, 999), out_2(999, 999); diff --git a/test/auto_schedule/overlap.cpp b/test/autoschedulers/mullapudi2016/overlap.cpp similarity index 94% rename from test/auto_schedule/overlap.cpp rename to test/autoschedulers/mullapudi2016/overlap.cpp index 2f747879244f..eabb9ed56f13 100644 --- a/test/auto_schedule/overlap.cpp +++ b/test/autoschedulers/mullapudi2016/overlap.cpp @@ -56,8 +56,8 @@ int main(int argc, char **argv) { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - up[num_levels - 1].print_loop_nest(); + // Inspect the schedule (only for debugging)) + // up[num_levels - 1].print_loop_nest(); // Run the schedule Buffer out = p.realize({1500, 1500}); diff --git a/test/auto_schedule/param.cpp b/test/autoschedulers/mullapudi2016/param.cpp similarity index 91% rename from test/auto_schedule/param.cpp rename to test/autoschedulers/mullapudi2016/param.cpp index 7102e1d61217..48f05619da2b 100644 --- a/test/auto_schedule/param.cpp +++ b/test/autoschedulers/mullapudi2016/param.cpp @@ -29,8 +29,8 @@ void run_test_1() { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - g.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // g.print_loop_nest(); } void run_test_2() { @@ -60,8 +60,8 @@ void run_test_2() { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - g.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // g.print_loop_nest(); } void run_test_3() { @@ -91,8 +91,8 @@ void run_test_3() { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - output.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // output.print_loop_nest(); } // Same as run_test_3, but with an output producing Tuples, @@ -125,8 +125,8 @@ void run_test_4() { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - output.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // output.print_loop_nest(); } int main(int argc, char **argv) { diff --git a/test/auto_schedule/reorder.cpp b/test/autoschedulers/mullapudi2016/reorder.cpp similarity index 74% rename from test/auto_schedule/reorder.cpp rename to test/autoschedulers/mullapudi2016/reorder.cpp index ba15be2544aa..4ac11bf1271f 100644 --- a/test/auto_schedule/reorder.cpp +++ b/test/autoschedulers/mullapudi2016/reorder.cpp @@ -41,7 +41,8 @@ double run_test_1(bool auto_schedule) { // odd have to investigate this further. } - r.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // r.print_loop_nest(); // Run the schedule Buffer out(1024, 1024, 3); @@ -93,7 +94,8 @@ double run_test_2(bool auto_schedule) { diff.reorder(c, z).fuse(c, z, t).parallel(t).vectorize(x, 16); } - diff.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // diff.print_loop_nest(); // Run the schedule Buffer out(left_im.width(), left_im.height(), 32, 3); @@ -137,7 +139,8 @@ double run_test_3(bool auto_schedule) { r.fuse(c, y, par).parallel(par).vectorize(x, 4); } - r.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // r.print_loop_nest(); // Run the schedule Buffer out(1024, 1024, 3); @@ -161,51 +164,48 @@ int main(int argc, char **argv) { load_plugin(argv[1]); - const double slowdown_factor = 6.0; - { - std::cout << "Test 1:\n"; double manual_time = run_test_1(false); double auto_time = run_test_1(true); - std::cout << "======================\n" - << "Manual time: " << manual_time << "ms\n" - << "Auto time: " << auto_time << "ms\n" - << "======================\n"; - - if (auto_time > manual_time * slowdown_factor) { - fprintf(stderr, "Warning: Auto-scheduler is much much slower than it should be.\n"); + const double slowdown_factor = 3.0; + if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { + std::cerr << "Autoscheduler time is slower than expected:\n" + << "======================\n" + << "Manual time: " << manual_time << "ms\n" + << "Auto time: " << auto_time << "ms\n" + << "======================\n"; + exit(1); } } { - std::cout << "Test 2:" - << "\n"; double manual_time = run_test_2(false); double auto_time = run_test_2(true); - std::cout << "======================\n" - << "Manual time: " << manual_time << "ms\n" - << "Auto time: " << auto_time << "ms\n" - << "======================\n"; - - if (auto_time > manual_time * slowdown_factor) { - fprintf(stderr, "Warning: Auto-scheduler is much much slower than it should be.\n"); + const double slowdown_factor = 1.0; + if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { + std::cerr << "Autoscheduler time is slower than expected:\n" + << "======================\n" + << "Manual time: " << manual_time << "ms\n" + << "Auto time: " << auto_time << "ms\n" + << "======================\n"; + exit(1); } } { - std::cout << "Test 3:\n"; double manual_time = run_test_3(false); double auto_time = run_test_3(true); - std::cout << "======================\n" - << "Manual time: " << manual_time << "ms\n" - << "Auto time: " << auto_time << "ms\n" - << "======================\n"; - - if (auto_time > manual_time * slowdown_factor) { - fprintf(stderr, "Warning: Auto-scheduler is much much slower than it should be.\n"); + const double slowdown_factor = 2.0; + if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { + std::cerr << "Autoscheduler time is slower than expected:\n" + << "======================\n" + << "Manual time: " << manual_time << "ms\n" + << "Auto time: " << auto_time << "ms\n" + << "======================\n"; + exit(1); } } diff --git a/test/auto_schedule/small_pure_update.cpp b/test/autoschedulers/mullapudi2016/small_pure_update.cpp similarity index 100% rename from test/auto_schedule/small_pure_update.cpp rename to test/autoschedulers/mullapudi2016/small_pure_update.cpp diff --git a/test/auto_schedule/tile_vs_inline.cpp b/test/autoschedulers/mullapudi2016/tile_vs_inline.cpp similarity index 95% rename from test/auto_schedule/tile_vs_inline.cpp rename to test/autoschedulers/mullapudi2016/tile_vs_inline.cpp index 01ebaa15baca..142e3eec658d 100644 --- a/test/auto_schedule/tile_vs_inline.cpp +++ b/test/autoschedulers/mullapudi2016/tile_vs_inline.cpp @@ -50,8 +50,8 @@ int main(int argc, char **argv) { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - g.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // g.print_loop_nest(); // Run the schedule Buffer out = p.realize({input.width() - 2, input.height() - 2, 3}); diff --git a/test/auto_schedule/unused_func.cpp b/test/autoschedulers/mullapudi2016/unused_func.cpp similarity index 91% rename from test/auto_schedule/unused_func.cpp rename to test/autoschedulers/mullapudi2016/unused_func.cpp index 406ba438f0c9..860c5bce1ee6 100644 --- a/test/auto_schedule/unused_func.cpp +++ b/test/autoschedulers/mullapudi2016/unused_func.cpp @@ -34,8 +34,8 @@ int main(int argc, char **argv) { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - f.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // f.print_loop_nest(); // Run the schedule p.realize({256}); diff --git a/test/auto_schedule/vectorize_var_in_update.cpp b/test/autoschedulers/mullapudi2016/vectorize_var_in_update.cpp similarity index 95% rename from test/auto_schedule/vectorize_var_in_update.cpp rename to test/autoschedulers/mullapudi2016/vectorize_var_in_update.cpp index 13f9bf155bb9..72b7a2c53cd4 100644 --- a/test/auto_schedule/vectorize_var_in_update.cpp +++ b/test/autoschedulers/mullapudi2016/vectorize_var_in_update.cpp @@ -56,8 +56,8 @@ int main(int argc, char **argv) { p.apply_autoscheduler(target, {"Mullapudi2016"}); #endif - // Inspect the schedule - h.print_loop_nest(); + // Inspect the schedule (only for debugging)) + // h.print_loop_nest(); // Run the schedule Buffer out = p.realize({50, 50}); From 6fff600f6fe50fcd21d5d0c376cade9da62bf16d Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 4 Oct 2022 17:30:43 -0700 Subject: [PATCH 02/15] Fixes --- .github/workflows/presubmit.yml | 14 ++--- .../mullapudi2016/CMakeLists.txt | 53 ++++++++++--------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index c37440f2ace5..42743439da1a 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -50,10 +50,10 @@ jobs: - name: Run test sources check run: | shopt -s nullglob - (cd test/auto_schedule && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) - (cd test/correctness && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) - (cd test/error && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) - (cd test/generator && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) - (cd test/failing_with_issue && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) - (cd test/performance && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) - (cd test/warning && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) + (cd test/autoschedulers/mullapudi2016 && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) + (cd test/correctness && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) + (cd test/error && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) + (cd test/generator && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) + (cd test/failing_with_issue && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) + (cd test/performance && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) + (cd test/warning && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) diff --git a/test/autoschedulers/mullapudi2016/CMakeLists.txt b/test/autoschedulers/mullapudi2016/CMakeLists.txt index 4a0de457608e..ce97765bc1e6 100644 --- a/test/autoschedulers/mullapudi2016/CMakeLists.txt +++ b/test/autoschedulers/mullapudi2016/CMakeLists.txt @@ -1,27 +1,28 @@ -if (TARGET Halide::Mullapudi2016) - tests(GROUPS mullapudi2016 autoschedulers - SOURCES - extern.cpp - param.cpp - ARGS $) +if (NOT TARGET Halide::Mullapudi2016) + message(STATUS "Disabling mullapudi2016 tests for static Halide") + return() +endif() - tests(GROUPS mullapudi2016 autoschedulers multithreaded - SOURCES - cost_function.cpp - data_dependent.cpp - fibonacci.cpp - histogram.cpp - large_window.cpp - mat_mul.cpp - max_filter.cpp - multi_output.cpp - overlap.cpp - reorder.cpp - small_pure_update.cpp - tile_vs_inline.cpp - unused_func.cpp - vectorize_var_in_update.cpp - ARGS $) -else () - message(STATUS "Disabling autoscheduler tests for static Halide") -endif () +tests(GROUPS mullapudi2016 autoschedulers + SOURCES + extern.cpp + param.cpp + ARGS $) + +tests(GROUPS mullapudi2016 autoschedulers multithreaded + SOURCES + cost_function.cpp + data_dependent.cpp + fibonacci.cpp + histogram.cpp + large_window.cpp + mat_mul.cpp + max_filter.cpp + multi_output.cpp + overlap.cpp + reorder.cpp + small_pure_update.cpp + tile_vs_inline.cpp + unused_func.cpp + vectorize_var_in_update.cpp + ARGS $) From 2fce574c88b504c94b0a65d698b5b64f42f61326 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 4 Oct 2022 18:18:02 -0700 Subject: [PATCH 03/15] Autoscheduler test reorg, part 2 Move the Li2018 tests to tests/autoschedulers. Drive-by fix to the Python test. --- .github/workflows/presubmit.yml | 1 + Makefile | 18 ++++-- src/autoschedulers/li2018/CMakeLists.txt | 62 ------------------- src/autoschedulers/li2018/Makefile | 35 ----------- src/autoschedulers/li2018/README.md | 9 +-- test/autoschedulers/CMakeLists.txt | 1 + test/autoschedulers/li2018/CMakeLists.txt | 40 ++++++++++++ .../autoschedulers/li2018/demo_generator.cpp | 0 {src => test}/autoschedulers/li2018/test.cpp | 42 ++++++++----- {src => test}/autoschedulers/li2018/test.py | 9 ++- tools/RunGenMain.cpp | 17 +++++ 11 files changed, 105 insertions(+), 129 deletions(-) create mode 100644 test/autoschedulers/li2018/CMakeLists.txt rename {src => test}/autoschedulers/li2018/demo_generator.cpp (100%) rename {src => test}/autoschedulers/li2018/test.cpp (76%) rename {src => test}/autoschedulers/li2018/test.py (80%) diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index 42743439da1a..255a88bf1618 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -50,6 +50,7 @@ jobs: - name: Run test sources check run: | shopt -s nullglob + (cd test/autoschedulers/li2018 && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) (cd test/autoschedulers/mullapudi2016 && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) (cd test/correctness && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) (cd test/error && comm -23 <(ls *.{c,cpp} | sort) <(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) | tee missing_files && [ ! -s missing_files ]) diff --git a/Makefile b/Makefile index 3ff23d010bcd..9a28daea1540 100644 --- a/Makefile +++ b/Makefile @@ -1176,6 +1176,7 @@ GENERATOR_EXTERNAL_TESTS := $(shell ls $(ROOT_DIR)/test/generator/*test.cpp) GENERATOR_EXTERNAL_TEST_GENERATOR := $(shell ls $(ROOT_DIR)/test/generator/*_generator.cpp) TUTORIALS = $(filter-out %_generate.cpp, $(shell ls $(ROOT_DIR)/tutorial/*.cpp)) MULLAPUDI2016_TESTS = $(shell ls $(ROOT_DIR)/test/autoschedulers/mullapudi2016/*.cpp) +LI2018_TESTS = $(shell ls $(ROOT_DIR)/test/autoschedulers/li2018/test.cpp) test_correctness: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=quiet_correctness_%) $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.c=quiet_correctness_%) test_performance: $(PERFORMANCE_TESTS:$(ROOT_DIR)/test/performance/%.cpp=performance_%) @@ -1294,6 +1295,7 @@ build_tests: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=$(BIN_DIR)/c $(GENERATOR_EXTERNAL_TESTS:$(ROOT_DIR)/test/generator/%_aottest.cpp=$(BIN_DIR)/$(TARGET)/generator_aot_%) \ $(GENERATOR_EXTERNAL_TESTS:$(ROOT_DIR)/test/generator/%_jittest.cpp=$(BIN_DIR)/generator_jit_%) \ $(MULLAPUDI2016_TESTS:$(ROOT_DIR)/test/autoschedulers/mullapudi2016/%.cpp=$(BIN_DIR)/mullapudi2016_%) + $(LI2018_TESTS:$(ROOT_DIR)/test/autoschedulers/li2018/%.cpp=$(BIN_DIR)/li2018_%) clean_generator: rm -rf $(BIN_DIR)/*.generator @@ -1372,6 +1374,9 @@ $(BIN_DIR)/runtime_%: $(ROOT_DIR)/test/runtime/%.cpp $(ROOT_DIR)/test/runtime/co $(BIN_DIR)/mullapudi2016_%: $(ROOT_DIR)/test/autoschedulers/mullapudi2016/%.cpp $(BIN_DIR)/libHalide.$(SHARED_EXT) $(INCLUDE_DIR)/Halide.h $(CXX) $(TEST_CXX_FLAGS) $(OPTIMIZE_FOR_BUILD_TIME) $< -I$(INCLUDE_DIR) $(TEST_LD_FLAGS) -o $@ +$(BIN_DIR)/li2018_%: $(ROOT_DIR)/test/autoschedulers/li2018/%.cpp $(BIN_DIR)/libHalide.$(SHARED_EXT) $(INCLUDE_DIR)/Halide.h + $(CXX) $(TEST_CXX_FLAGS) $(OPTIMIZE_FOR_BUILD_TIME) $< -I$(INCLUDE_DIR) $(TEST_LD_FLAGS) -o $@ + # TODO(srj): this doesn't auto-delete, why not? .INTERMEDIATE: $(BIN_DIR)/%.generator @@ -2001,22 +2006,23 @@ tutorial_%: $(BIN_DIR)/tutorial_% $(TMP_DIR)/images/rgb.png $(TMP_DIR)/images/gr test_mullapudi2016: $(MULLAPUDI2016_TESTS:$(ROOT_DIR)/test/autoschedulers/mullapudi2016/%.cpp=mullapudi2016_%) -# These tests were written for the Mullapudi2016 autoscheduler. -# TODO: either make them work with all autoschedulers or move them under src/autoschedulers/mullapudi2016 mullapudi2016_%: $(BIN_DIR)/mullapudi2016_% $(BIN_MULLAPUDI2016) @-mkdir -p $(TMP_DIR) cd $(TMP_DIR) ; $(CURDIR)/$< $(realpath $(BIN_MULLAPUDI2016)) @-echo +test_li2018: $(LI2018_TESTS:$(ROOT_DIR)/test/autoschedulers/li2018/%.cpp=li2018_%) + +li2018_%: $(BIN_DIR)/li2018_% $(BIN_LI2018) + @-mkdir -p $(TMP_DIR) + cd $(TMP_DIR) ; $(CURDIR)/$< $(realpath $(BIN_LI2018)) + @-echo + # The other autoschedulers contain their own tests test_adams2019: distrib $(MAKE) -f $(SRC_DIR)/autoschedulers/adams2019/Makefile test \ HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) -test_li2018: distrib - $(MAKE) -f $(SRC_DIR)/autoschedulers/li2018/Makefile test \ - HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) - time_compilation_test_%: $(BIN_DIR)/test_% $(TIME_COMPILATION) compile_times_correctness.csv make -f $(THIS_MAKEFILE) $(@:time_compilation_test_%=test_%) diff --git a/src/autoschedulers/li2018/CMakeLists.txt b/src/autoschedulers/li2018/CMakeLists.txt index bb726162bdf6..4872fa709971 100644 --- a/src/autoschedulers/li2018/CMakeLists.txt +++ b/src/autoschedulers/li2018/CMakeLists.txt @@ -1,65 +1,3 @@ add_autoscheduler(NAME Li2018 SOURCES GradientAutoscheduler.cpp) target_link_libraries(Halide_Li2018 PRIVATE ParamParser) -# ========================================================== -# TODO(#4053): move these to a separate folder since they're tests. - -add_executable(demo_gradient.generator demo_generator.cpp) -target_link_libraries(demo_gradient.generator PRIVATE Halide::Generator) - -add_halide_library(demo_gradient FROM demo_gradient.generator - TARGETS cmake - GENERATOR demo - FUNCTION_NAME demo - AUTOSCHEDULER Halide::Li2018 - REGISTRATION DEMO_REGISTRATION_FILE) - -add_executable(demo_gradient_autoscheduler ${DEMO_REGISTRATION_FILE}) -target_link_libraries(demo_gradient_autoscheduler PRIVATE demo_gradient Halide::RunGenMain) - -add_test(NAME demo_gradient_autoscheduler - COMMAND demo_gradient_autoscheduler --benchmarks=all --benchmark_min_time=1 --estimate_all) - -set_tests_properties(demo_gradient_autoscheduler PROPERTIES LABELS "Li2018;multithreaded;auto_schedule") - -## - -if (BUILD_SHARED_LIBS) - add_executable(gradient_autoscheduler_test_cpp test.cpp) - target_link_libraries(gradient_autoscheduler_test_cpp PRIVATE Halide::Halide) - - add_test(NAME gradient_autoscheduler_test_cpp - COMMAND gradient_autoscheduler_test_cpp $) - - set_tests_properties(gradient_autoscheduler_test_cpp PROPERTIES LABELS "Li2018;auto_schedule") -endif () - -## - -if (WITH_PYTHON_BINDINGS) - # TODO(#4053): rework this as an app under python_bindings. - # TODO(#4876): Disabled due to issue #4876 - if (FALSE) - find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) - - add_test(NAME gradient_autoscheduler_test_py - COMMAND Python3::Interpreter "${CMAKE_CURRENT_SOURCE_DIR}/test.py") - - set( - PYTHONPATH - "$/.." - ) - list(TRANSFORM PYTHONPATH PREPEND "PYTHONPATH=path_list_prepend:") - - set( - PATH - "$" - "$" - ) - list(TRANSFORM PATH PREPEND "PATH=path_list_prepend:") - - set_tests_properties(gradient_autoscheduler_test_py PROPERTIES - LABELS "Li2018;auto_schedule" - ENVIRONMENT_MODIFICATION "${PYTHONPATH};${PATH}") - endif () -endif () diff --git a/src/autoschedulers/li2018/Makefile b/src/autoschedulers/li2018/Makefile index 715477190dbf..07afdb8b1403 100644 --- a/src/autoschedulers/li2018/Makefile +++ b/src/autoschedulers/li2018/Makefile @@ -7,7 +7,6 @@ COMMON_DIR = $(realpath $(SRC)/../common/) # Makefile should probably set this variable explicitly. HALIDE_DISTRIB_PATH ?= $(HALIDE_SRC_ROOT)/distrib -# The example uses a generator, though the autoscheduler itself does not require one include $(HALIDE_SRC_ROOT)/apps/support/Makefile.inc CXXFLAGS += -I$(COMMON_DIR) @@ -25,37 +24,3 @@ $(BIN)/libautoschedule_li2018.$(PLUGIN_EXT): $(SRC)/GradientAutoscheduler.cpp | @mkdir -p $(@D) $(CXX) -shared $(USE_EXPORT_DYNAMIC) -fPIC -fvisibility=hidden -fvisibility-inlines-hidden $(CXXFLAGS) $(OPTIMIZE) $^ -o $@ $(HALIDE_SYSTEM_LIBS) $(HALIDE_RPATH_FOR_LIB) -# Demonstrate a JIT-based use of gradient autoscheuler -$(BIN)/test: $(SRC)/test.cpp $(BIN)/libautoschedule_li2018.$(PLUGIN_EXT) - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $(USE_EXPORT_DYNAMIC) $(SRC)/test.cpp -o $@ $(LIBHALIDE_LDFLAGS) $(HALIDE_SYSTEM_LIBS) - -# Demonstrate a generator-based use of gradient autoscheuler -$(GENERATOR_BIN)/demo.generator: $(SRC)/demo_generator.cpp $(GENERATOR_DEPS) - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $(USE_EXPORT_DYNAMIC) -g $(filter-out %.h,$^) -o $@ $(LIBHALIDE_LDFLAGS) $(HALIDE_SYSTEM_LIBS) - -# Use the -p flag to the generator to load the autoscheduler as a plugin -$(BIN)/%/demo.a: $(GENERATOR_BIN)/demo.generator $(BIN)/libautoschedule_li2018.$(PLUGIN_EXT) - @mkdir -p $(@D) - $(GENERATOR_BIN)/demo.generator -g demo -o $(@D) -f demo target=$* autoscheduler=Li2018 -p $(BIN)/libautoschedule_li2018.$(PLUGIN_EXT) - -$(BIN)/%/demo.rungen: $(BIN)/%/RunGenMain.o $(BIN)/%/demo.registration.cpp $(BIN)/%/demo.a - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -I$(BIN)/$* $^ -o $@ $(HALIDE_SYSTEM_LIBS) $(IMAGE_IO_FLAGS) - -.PHONY: build test clean run_test_cpp test_generator - -# demonstrates single-shot use of the autoscheduler -test_generator: $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.$(PLUGIN_EXT) - $< --benchmarks=all --benchmark_min_time=1 --estimate_all - -run_test_cpp: $(BIN)/test - LD_LIBRARY_PATH=$(BIN) $< $(BIN)/libautoschedule_li2018.$(PLUGIN_EXT) - -build: $(BIN)/test $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.$(PLUGIN_EXT) - -test: run_test_cpp test_generator - -clean: - rm -rf $(BIN) diff --git a/src/autoschedulers/li2018/README.md b/src/autoschedulers/li2018/README.md index 9ead81ad79ee..1e548da06cd2 100644 --- a/src/autoschedulers/li2018/README.md +++ b/src/autoschedulers/li2018/README.md @@ -21,11 +21,4 @@ use `halide_reuse_device_allocations(nullptr, true)` for GPU) Tested on a 8 core Intel CPU (16 with HT) and TITAN Xp. -See `test.cpp` and `demo_generator.cpp` for how to use this autoscheduler. It -can also be used with Python bindings. Compile with - -``` -WITH_PYTHON=1 make -``` - -and see `test.py` for usage. +See `test/autoschedulers/li2018` for examples of using this autoscheduler. diff --git a/test/autoschedulers/CMakeLists.txt b/test/autoschedulers/CMakeLists.txt index cc7944010019..0b7b5d347751 100644 --- a/test/autoschedulers/CMakeLists.txt +++ b/test/autoschedulers/CMakeLists.txt @@ -1,3 +1,4 @@ include(HalideTestHelpers) +add_subdirectory(li2018) add_subdirectory(mullapudi2016) diff --git a/test/autoschedulers/li2018/CMakeLists.txt b/test/autoschedulers/li2018/CMakeLists.txt new file mode 100644 index 000000000000..843c9fca4339 --- /dev/null +++ b/test/autoschedulers/li2018/CMakeLists.txt @@ -0,0 +1,40 @@ +if (NOT TARGET Halide::Li2018) + message(STATUS "Disabling li2018 tests for static Halide") + return() +endif () + +add_halide_generator(li2018_demo_gradient.generator + SOURCES demo_generator.cpp) + +add_halide_library(li2018_demo_gradient FROM li2018_demo_gradient.generator + TARGETS cmake + GENERATOR demo + FUNCTION_NAME demo + AUTOSCHEDULER Halide::Li2018 + REGISTRATION DEMO_REGISTRATION_FILE) + +add_executable(li2018_demo_gradient_autoscheduler ${DEMO_REGISTRATION_FILE}) +target_link_libraries(li2018_demo_gradient_autoscheduler PRIVATE li2018_demo_gradient Halide::RunGenMain) + +add_halide_test(li2018_demo_gradient_autoscheduler + COMMAND li2018_demo_gradient_autoscheduler --benchmarks=all --benchmark_min_time=1 --estimate_all --success + GROUPS li2018 autoschedulers multithreaded) + +tests(GROUPS li2018 autoschedulers + SOURCES + test.cpp + ARGS $) + +if (WITH_PYTHON_BINDINGS) + find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) + + add_test(NAME li2018_gradient_autoscheduler_test_py + COMMAND Python3::Interpreter "${CMAKE_CURRENT_SOURCE_DIR}/test.py" $) + + set(PYTHONPATH "$/..") + list(TRANSFORM PYTHONPATH PREPEND "PYTHONPATH=path_list_prepend:") + + set_tests_properties(li2018_gradient_autoscheduler_test_py PROPERTIES + LABELS "li2018;autoschedulers" + ENVIRONMENT_MODIFICATION "${PYTHONPATH}") +endif () diff --git a/src/autoschedulers/li2018/demo_generator.cpp b/test/autoschedulers/li2018/demo_generator.cpp similarity index 100% rename from src/autoschedulers/li2018/demo_generator.cpp rename to test/autoschedulers/li2018/demo_generator.cpp diff --git a/src/autoschedulers/li2018/test.cpp b/test/autoschedulers/li2018/test.cpp similarity index 76% rename from src/autoschedulers/li2018/test.cpp rename to test/autoschedulers/li2018/test.cpp index f3fb11f7cca7..a4a00074d965 100644 --- a/src/autoschedulers/li2018/test.cpp +++ b/test/autoschedulers/li2018/test.cpp @@ -38,8 +38,9 @@ int main(int argc, char **argv) { #else AutoSchedulerResults result = Pipeline(f2).apply_autoscheduler(target, params); #endif - std::cout << "Schedule for 1D pointwise operations:\n" - << result.schedule_source << "\n\n"; + // Don't dump to stdout (this is only for debugging) + // std::cout << "Schedule for 1D pointwise operations:\n" + // << result.schedule_source << "\n\n"; } { // Simple 2D pointwise operations. Should inline. @@ -60,8 +61,9 @@ int main(int argc, char **argv) { #else AutoSchedulerResults result = Pipeline(f2).apply_autoscheduler(target, params); #endif - std::cout << "Schedule for 2D pointwise operations:\n" - << result.schedule_source << "\n\n"; + // Don't dump to stdout (this is only for debugging) + // std::cout << "Schedule for 2D pointwise operations:\n" + // << result.schedule_source << "\n\n"; } { // 1D Convolution. @@ -78,8 +80,9 @@ int main(int argc, char **argv) { #else AutoSchedulerResults result = Pipeline(f0).apply_autoscheduler(target, params); #endif - std::cout << "Schedule for 1D convolution:\n" - << result.schedule_source << "\n\n"; + // Don't dump to stdout (this is only for debugging) + // std::cout << "Schedule for 1D convolution:\n" + // << result.schedule_source << "\n\n"; } { // 2D Convolution. @@ -97,8 +100,9 @@ int main(int argc, char **argv) { #else AutoSchedulerResults result = Pipeline(f0).apply_autoscheduler(target, params); #endif - std::cout << "Schedule for 2D convolution:\n" - << result.schedule_source << "\n\n"; + // Don't dump to stdout (this is only for debugging) + // std::cout << "Schedule for 2D convolution:\n" + // << result.schedule_source << "\n\n"; } { // 1D Histogram. @@ -116,8 +120,9 @@ int main(int argc, char **argv) { #else AutoSchedulerResults result = Pipeline(hist).apply_autoscheduler(target, params); #endif - std::cout << "Schedule for 1D histogram:\n" - << result.schedule_source << "\n\n"; + // Don't dump to stdout (this is only for debugging) + // std::cout << "Schedule for 1D histogram:\n" + // << result.schedule_source << "\n\n"; } { // 2D Histogram. @@ -135,8 +140,9 @@ int main(int argc, char **argv) { #else AutoSchedulerResults result = Pipeline(hist).apply_autoscheduler(target, params); #endif - std::cout << "Schedule for 2D histogram:\n" - << result.schedule_source << "\n\n"; + // Don't dump to stdout (this is only for debugging) + // std::cout << "Schedule for 2D histogram:\n" + // << result.schedule_source << "\n\n"; } { // 2D Histogram, but the domain is much larger. @@ -154,8 +160,9 @@ int main(int argc, char **argv) { #else AutoSchedulerResults result = Pipeline(hist).apply_autoscheduler(target, params); #endif - std::cout << "Schedule for 2D histogram with larger domain:\n" - << result.schedule_source << "\n\n"; + // Don't dump to stdout (this is only for debugging) + // std::cout << "Schedule for 2D histogram with larger domain:\n" + // << result.schedule_source << "\n\n"; } { // Test for conjunction use of bound and estimates. @@ -178,8 +185,11 @@ int main(int argc, char **argv) { #else AutoSchedulerResults result = Pipeline(f2).apply_autoscheduler(target, params); #endif - std::cout << "Schedule for 2D pointwise operations with small x dimension:\n" - << result.schedule_source << "\n\n"; + // Don't dump to stdout (this is only for debugging) + // std::cout << "Schedule for 2D pointwise operations with small x dimension:\n" + // << result.schedule_source << "\n\n"; } + + printf("Success!\n"); return 0; } diff --git a/src/autoschedulers/li2018/test.py b/test/autoschedulers/li2018/test.py similarity index 80% rename from src/autoschedulers/li2018/test.py rename to test/autoschedulers/li2018/test.py index 72afc9334540..b2a59335de59 100644 --- a/src/autoschedulers/li2018/test.py +++ b/test/autoschedulers/li2018/test.py @@ -1,8 +1,7 @@ import halide as hl +import sys def main(): - hl.load_plugin("autoschedule_li2018") - x = hl.Var('x') f_in = hl.Func('in') f_in[x] = hl.f32(x) # Cast to float 32 @@ -26,4 +25,10 @@ def main(): buf = p.realize([1000]) # compute and get the buffer if __name__ == '__main__': + if len(sys.argv) != 2: + print("Usage: test path/to/Li2018-autoscheduler-plugin",sys.argv) + sys.exit(1) + + hl.load_plugin(sys.argv[1]) + main() diff --git a/tools/RunGenMain.cpp b/tools/RunGenMain.cpp index 0f33d102b512..0c7874d52fc4 100644 --- a/tools/RunGenMain.cpp +++ b/tools/RunGenMain.cpp @@ -171,6 +171,11 @@ Usage: $NAME$ argument=value [argument=value... ] [flags] and is a convenience for automated benchmarking. + --success: + Print "Success!" to stdout if we exit with a result code of zero. + (This is mainly useful for use with Halide's testing infrastructure, + which relies on this for successful tests.) + Known Issues: * Filters running on GPU (vs CPU) have not been tested. @@ -391,6 +396,7 @@ int main(int argc, char **argv) { std::string default_input_buffers; std::string default_input_scalars; std::string benchmarks_flag_value; + bool emit_success = false; for (int i = 1; i < argc; ++i) { if (argv[i][0] == '-') { const char *p = argv[i] + 1; // skip - @@ -471,6 +477,13 @@ int main(int argc, char **argv) { default_input_buffers = "random:0:estimate_then_auto"; default_input_scalars = "estimate"; user_specified_output_shape = "estimate"; + } else if (flag_name == "success") { + if (flag_value.empty()) { + flag_value = "true"; + } + if (!parse_scalar(flag_value, &emit_success)) { + fail() << "Invalid value for flag: " << flag_name; + } } else { usage(argv[0]); fail() << "Unknown flag: " << flag_name; @@ -548,5 +561,9 @@ int main(int argc, char **argv) { // Save the output(s), if necessary. r.save_outputs(); + if (emit_success) { + std::cout << "Success!\n"; + } + return 0; } From 4c461105a8e9777706f2517200ab8f788cab952a Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 4 Oct 2022 18:21:09 -0700 Subject: [PATCH 04/15] Update CMakeLists.txt --- test/autoschedulers/li2018/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/autoschedulers/li2018/CMakeLists.txt b/test/autoschedulers/li2018/CMakeLists.txt index 843c9fca4339..efa0fa27eca1 100644 --- a/test/autoschedulers/li2018/CMakeLists.txt +++ b/test/autoschedulers/li2018/CMakeLists.txt @@ -16,6 +16,7 @@ add_halide_library(li2018_demo_gradient FROM li2018_demo_gradient.generator add_executable(li2018_demo_gradient_autoscheduler ${DEMO_REGISTRATION_FILE}) target_link_libraries(li2018_demo_gradient_autoscheduler PRIVATE li2018_demo_gradient Halide::RunGenMain) +# demo_generator.cpp add_halide_test(li2018_demo_gradient_autoscheduler COMMAND li2018_demo_gradient_autoscheduler --benchmarks=all --benchmark_min_time=1 --estimate_all --success GROUPS li2018 autoschedulers multithreaded) From 2a8d0eb3dd771bd42ea5a83ff5984e740b9dd6af Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 4 Oct 2022 18:39:04 -0700 Subject: [PATCH 05/15] trigger buildbots From 7edc7dab764652b899a3871d175fb8683ae217c4 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 5 Oct 2022 12:08:41 -0700 Subject: [PATCH 06/15] Update CMakeLists.txt --- test/autoschedulers/mullapudi2016/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/autoschedulers/mullapudi2016/CMakeLists.txt b/test/autoschedulers/mullapudi2016/CMakeLists.txt index ce97765bc1e6..518e9b69d159 100644 --- a/test/autoschedulers/mullapudi2016/CMakeLists.txt +++ b/test/autoschedulers/mullapudi2016/CMakeLists.txt @@ -3,13 +3,13 @@ if (NOT TARGET Halide::Mullapudi2016) return() endif() -tests(GROUPS mullapudi2016 autoschedulers +tests(GROUPS mullapudi2016 autoschedulers auto_schedule SOURCES extern.cpp param.cpp ARGS $) -tests(GROUPS mullapudi2016 autoschedulers multithreaded +tests(GROUPS mullapudi2016 autoschedulers auto_schedule multithreaded SOURCES cost_function.cpp data_dependent.cpp From cf4003363ad9b6fd2dff4276206031d165dac960 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 5 Oct 2022 12:48:56 -0700 Subject: [PATCH 07/15] fixes --- Makefile | 3 +-- test/autoschedulers/li2018/CMakeLists.txt | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 9a28daea1540..b1aef1fc1dea 100644 --- a/Makefile +++ b/Makefile @@ -1294,7 +1294,7 @@ build_tests: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=$(BIN_DIR)/c $(RUNTIME_TESTS:$(ROOT_DIR)/test/runtime/%.cpp=$(BIN_DIR)/runtime_%) \ $(GENERATOR_EXTERNAL_TESTS:$(ROOT_DIR)/test/generator/%_aottest.cpp=$(BIN_DIR)/$(TARGET)/generator_aot_%) \ $(GENERATOR_EXTERNAL_TESTS:$(ROOT_DIR)/test/generator/%_jittest.cpp=$(BIN_DIR)/generator_jit_%) \ - $(MULLAPUDI2016_TESTS:$(ROOT_DIR)/test/autoschedulers/mullapudi2016/%.cpp=$(BIN_DIR)/mullapudi2016_%) + $(MULLAPUDI2016_TESTS:$(ROOT_DIR)/test/autoschedulers/mullapudi2016/%.cpp=$(BIN_DIR)/mullapudi2016_%) \ $(LI2018_TESTS:$(ROOT_DIR)/test/autoschedulers/li2018/%.cpp=$(BIN_DIR)/li2018_%) clean_generator: @@ -2384,7 +2384,6 @@ ifeq ($(UNAME), Darwin) install_name_tool -id @rpath/$(@F) $(CURDIR)/$@ endif -.PHONY: autoschedulers autoschedulers: \ $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(PLUGIN_EXT) \ $(DISTRIB_DIR)/lib/libautoschedule_li2018.$(PLUGIN_EXT) \ diff --git a/test/autoschedulers/li2018/CMakeLists.txt b/test/autoschedulers/li2018/CMakeLists.txt index efa0fa27eca1..f35083e22be8 100644 --- a/test/autoschedulers/li2018/CMakeLists.txt +++ b/test/autoschedulers/li2018/CMakeLists.txt @@ -19,9 +19,9 @@ target_link_libraries(li2018_demo_gradient_autoscheduler PRIVATE li2018_demo_gra # demo_generator.cpp add_halide_test(li2018_demo_gradient_autoscheduler COMMAND li2018_demo_gradient_autoscheduler --benchmarks=all --benchmark_min_time=1 --estimate_all --success - GROUPS li2018 autoschedulers multithreaded) + GROUPS li2018 autoschedulers auto_schedule multithreaded) -tests(GROUPS li2018 autoschedulers +tests(GROUPS li2018 autoschedulers auto_schedule SOURCES test.cpp ARGS $) @@ -36,6 +36,6 @@ if (WITH_PYTHON_BINDINGS) list(TRANSFORM PYTHONPATH PREPEND "PYTHONPATH=path_list_prepend:") set_tests_properties(li2018_gradient_autoscheduler_test_py PROPERTIES - LABELS "li2018;autoschedulers" + LABELS "li2018;autoschedulers;auto_schedule" ENVIRONMENT_MODIFICATION "${PYTHONPATH}") endif () From 4949ae1280321bc430f1ebcdde40c25baeb41be6 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 5 Oct 2022 12:51:31 -0700 Subject: [PATCH 08/15] Update mat_mul.cpp --- test/autoschedulers/mullapudi2016/mat_mul.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/autoschedulers/mullapudi2016/mat_mul.cpp b/test/autoschedulers/mullapudi2016/mat_mul.cpp index 0c03b0b3d268..1acaf82cdbe5 100644 --- a/test/autoschedulers/mullapudi2016/mat_mul.cpp +++ b/test/autoschedulers/mullapudi2016/mat_mul.cpp @@ -142,7 +142,7 @@ int main(int argc, char **argv) { double manual_time = run_test(false); double auto_time = run_test(true); - const double slowdown_factor = 4.0; + const double slowdown_factor = 8.0; if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { std::cerr << "Autoscheduler time is slower than expected:\n" << "======================\n" From 4544733cd7493e1f727469c57e127f82a44c120b Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 5 Oct 2022 13:26:46 -0700 Subject: [PATCH 09/15] fixes --- test/autoschedulers/mullapudi2016/fibonacci.cpp | 2 +- test/autoschedulers/mullapudi2016/reorder.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/autoschedulers/mullapudi2016/fibonacci.cpp b/test/autoschedulers/mullapudi2016/fibonacci.cpp index 87e531d6897f..f5d70597f315 100644 --- a/test/autoschedulers/mullapudi2016/fibonacci.cpp +++ b/test/autoschedulers/mullapudi2016/fibonacci.cpp @@ -57,7 +57,7 @@ int main(int argc, char **argv) { double manual_time = run_test(false); double auto_time = run_test(true); - const double slowdown_factor = 3.0; + const double slowdown_factor = 10.0; if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { std::cerr << "Autoscheduler time is slower than expected:\n" << "======================\n" diff --git a/test/autoschedulers/mullapudi2016/reorder.cpp b/test/autoschedulers/mullapudi2016/reorder.cpp index 4ac11bf1271f..89d511f54443 100644 --- a/test/autoschedulers/mullapudi2016/reorder.cpp +++ b/test/autoschedulers/mullapudi2016/reorder.cpp @@ -168,9 +168,9 @@ int main(int argc, char **argv) { double manual_time = run_test_1(false); double auto_time = run_test_1(true); - const double slowdown_factor = 3.0; + const double slowdown_factor = 7.0; if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { - std::cerr << "Autoscheduler time is slower than expected:\n" + std::cerr << "Autoscheduler time (1) is slower than expected:\n" << "======================\n" << "Manual time: " << manual_time << "ms\n" << "Auto time: " << auto_time << "ms\n" @@ -185,7 +185,7 @@ int main(int argc, char **argv) { const double slowdown_factor = 1.0; if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { - std::cerr << "Autoscheduler time is slower than expected:\n" + std::cerr << "Autoscheduler time (2) is slower than expected:\n" << "======================\n" << "Manual time: " << manual_time << "ms\n" << "Auto time: " << auto_time << "ms\n" @@ -200,7 +200,7 @@ int main(int argc, char **argv) { const double slowdown_factor = 2.0; if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { - std::cerr << "Autoscheduler time is slower than expected:\n" + std::cerr << "Autoscheduler time (3) is slower than expected:\n" << "======================\n" << "Manual time: " << manual_time << "ms\n" << "Auto time: " << auto_time << "ms\n" From 09e72646e4f66ee73229255104e1d7e0e7a883ea Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 5 Oct 2022 13:31:04 -0700 Subject: [PATCH 10/15] Autoscheduler test reorg, part 3 --- Makefile | 17 ++- src/autoschedulers/adams2019/CMakeLists.txt | 90 ++----------- src/autoschedulers/adams2019/Makefile | 123 +----------------- test/autoschedulers/CMakeLists.txt | 1 + test/autoschedulers/adams2019/CMakeLists.txt | 84 ++++++++++++ .../adams2019/demo_generator.cpp | 0 .../included_schedule_file.schedule.h | 0 .../included_schedule_file_generator.cpp | 0 .../autoschedulers/adams2019/test.cpp | 0 9 files changed, 106 insertions(+), 209 deletions(-) create mode 100644 test/autoschedulers/adams2019/CMakeLists.txt rename {src => test}/autoschedulers/adams2019/demo_generator.cpp (100%) rename {src => test}/autoschedulers/adams2019/included_schedule_file.schedule.h (100%) rename {src => test}/autoschedulers/adams2019/included_schedule_file_generator.cpp (100%) rename {src => test}/autoschedulers/adams2019/test.cpp (100%) diff --git a/Makefile b/Makefile index b1aef1fc1dea..9bfbcd26435f 100644 --- a/Makefile +++ b/Makefile @@ -1177,6 +1177,7 @@ GENERATOR_EXTERNAL_TEST_GENERATOR := $(shell ls $(ROOT_DIR)/test/generator/*_gen TUTORIALS = $(filter-out %_generate.cpp, $(shell ls $(ROOT_DIR)/tutorial/*.cpp)) MULLAPUDI2016_TESTS = $(shell ls $(ROOT_DIR)/test/autoschedulers/mullapudi2016/*.cpp) LI2018_TESTS = $(shell ls $(ROOT_DIR)/test/autoschedulers/li2018/test.cpp) +ADAMS2019_TESTS = $(shell ls $(ROOT_DIR)/test/autoschedulers/adams2019/test.cpp) test_correctness: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=quiet_correctness_%) $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.c=quiet_correctness_%) test_performance: $(PERFORMANCE_TESTS:$(ROOT_DIR)/test/performance/%.cpp=performance_%) @@ -1295,7 +1296,8 @@ build_tests: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=$(BIN_DIR)/c $(GENERATOR_EXTERNAL_TESTS:$(ROOT_DIR)/test/generator/%_aottest.cpp=$(BIN_DIR)/$(TARGET)/generator_aot_%) \ $(GENERATOR_EXTERNAL_TESTS:$(ROOT_DIR)/test/generator/%_jittest.cpp=$(BIN_DIR)/generator_jit_%) \ $(MULLAPUDI2016_TESTS:$(ROOT_DIR)/test/autoschedulers/mullapudi2016/%.cpp=$(BIN_DIR)/mullapudi2016_%) \ - $(LI2018_TESTS:$(ROOT_DIR)/test/autoschedulers/li2018/%.cpp=$(BIN_DIR)/li2018_%) + $(LI2018_TESTS:$(ROOT_DIR)/test/autoschedulers/li2018/%.cpp=$(BIN_DIR)/li2018_%) \ + $(ADAMS2019_TESTS:$(ROOT_DIR)/test/autoschedulers/adams2019/%.cpp=$(BIN_DIR)/adams2019_%) clean_generator: rm -rf $(BIN_DIR)/*.generator @@ -1377,6 +1379,9 @@ $(BIN_DIR)/mullapudi2016_%: $(ROOT_DIR)/test/autoschedulers/mullapudi2016/%.cpp $(BIN_DIR)/li2018_%: $(ROOT_DIR)/test/autoschedulers/li2018/%.cpp $(BIN_DIR)/libHalide.$(SHARED_EXT) $(INCLUDE_DIR)/Halide.h $(CXX) $(TEST_CXX_FLAGS) $(OPTIMIZE_FOR_BUILD_TIME) $< -I$(INCLUDE_DIR) $(TEST_LD_FLAGS) -o $@ +$(BIN_DIR)/adams2019_%: $(ROOT_DIR)/test/autoschedulers/adams2019/%.cpp $(BIN_DIR)/libHalide.$(SHARED_EXT) $(INCLUDE_DIR)/Halide.h + $(CXX) $(TEST_CXX_FLAGS) $(OPTIMIZE_FOR_BUILD_TIME) $< -I$(INCLUDE_DIR) $(TEST_LD_FLAGS) -o $@ + # TODO(srj): this doesn't auto-delete, why not? .INTERMEDIATE: $(BIN_DIR)/%.generator @@ -2018,10 +2023,12 @@ li2018_%: $(BIN_DIR)/li2018_% $(BIN_LI2018) cd $(TMP_DIR) ; $(CURDIR)/$< $(realpath $(BIN_LI2018)) @-echo -# The other autoschedulers contain their own tests -test_adams2019: distrib - $(MAKE) -f $(SRC_DIR)/autoschedulers/adams2019/Makefile test \ - HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) +test_adams2019: $(ADAMS2019_TESTS:$(ROOT_DIR)/test/autoschedulers/adams2019/%.cpp=adams2019_%) + +adams2019_test: $(BIN_DIR)/adams2019_test $(BIN_ADAMS2019) $(SRC_DIR)/autoschedulers/adams2019/baseline.weights + @-mkdir -p $(TMP_DIR) + cd $(TMP_DIR) ; $(CURDIR)/$< $(realpath $(BIN_ADAMS2019)) $(realpath $(SRC_DIR)/autoschedulers/adams2019/baseline.weights) + @-echo time_compilation_test_%: $(BIN_DIR)/test_% $(TIME_COMPILATION) compile_times_correctness.csv make -f $(THIS_MAKEFILE) $(@:time_compilation_test_%=test_%) diff --git a/src/autoschedulers/adams2019/CMakeLists.txt b/src/autoschedulers/adams2019/CMakeLists.txt index 2d9da255bb54..aa90271977f3 100644 --- a/src/autoschedulers/adams2019/CMakeLists.txt +++ b/src/autoschedulers/adams2019/CMakeLists.txt @@ -2,31 +2,7 @@ # Build rules for the Adams2019 autoscheduler library ## -function(add_adams2019_test NAME) - set(options "") - set(oneValueArgs ENVIRONMENT) - set(multiValueArgs COMMAND LABELS) - cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if (NOT ARGS_COMMAND) - set(ARGS_COMMAND ${NAME}) - endif() - - if (NOT ARGS_LABELS) - set(ARGS_LABELS "") - endif() - list(APPEND ARGS_LABELS Adams2019) - list(APPEND ARGS_LABELS auto_schedule) - - add_test(NAME ${NAME} - COMMAND ${ARGS_COMMAND}) - set_tests_properties(${NAME} - PROPERTIES - LABELS "${ARGS_LABELS}" - ENVIRONMENT "${ENVIRONMENT}") -endfunction() - - +# ================================================================= # weights set(WF_CPP baseline.cpp) configure_file(baseline.weights baseline.weights COPYONLY) @@ -59,6 +35,7 @@ add_executable(adams2019_retrain_cost_model $) target_link_libraries(adams2019_retrain_cost_model PRIVATE ASLog adams2019_cost_model adams2019_train_cost_model Halide::Halide Halide::Plugin) +# ================================================================= ## # Main autoscheduler library ## @@ -76,45 +53,6 @@ add_autoscheduler(NAME Adams2019 target_link_libraries(Halide_Adams2019 PRIVATE ASLog ParamParser adams2019_cost_model adams2019_train_cost_model) -## -# Tests and demos -# TODO(#4053): move these to a separate folder since they're tests. -## - -# ================================================================= - -add_executable(adams2019_demo.generator demo_generator.cpp) -target_link_libraries(adams2019_demo.generator PRIVATE Halide::Generator) - -add_halide_library(adams2019_demo FROM adams2019_demo.generator - GENERATOR demo - TARGETS cmake - AUTOSCHEDULER Halide::Adams2019 - REGISTRATION DEMO_REGISTRATION_FILE) - -add_executable(adams2019_demo_apps_autoscheduler ${DEMO_REGISTRATION_FILE}) -target_link_libraries(adams2019_demo_apps_autoscheduler PRIVATE adams2019_demo Halide::RunGenMain) - -add_adams2019_test(adams2019_demo_apps_autoscheduler - COMMAND adams2019_demo_apps_autoscheduler --benchmarks=all --benchmark_min_time=1 --estimate_all) - -# ================================================================= - -add_executable(adams2019_included_schedule_file.generator included_schedule_file_generator.cpp) -target_link_libraries(adams2019_included_schedule_file.generator PRIVATE Halide::Generator) - -add_halide_library(adams2019_included_schedule_file FROM adams2019_included_schedule_file.generator - GENERATOR included_schedule_file - TARGETS cmake - AUTOSCHEDULER Halide::Adams2019 - REGISTRATION adams2019_included_schedule_reg) - -add_executable(adams2019_demo_included_schedule_file ${adams2019_included_schedule_reg}) -target_link_libraries(adams2019_demo_included_schedule_file PRIVATE adams2019_included_schedule_file Halide::RunGenMain) - -add_adams2019_test(adams2019_demo_included_schedule_file - COMMAND adams2019_demo_included_schedule_file --benchmarks=all --benchmark_min_time=1 --estimate_all) - # ==================================================== # Auto-tuning support utilities. # TODO(#4053): implement auto-tuning support in CMake? @@ -128,27 +66,15 @@ add_executable(adams2019_weightsdir_to_weightsfile weightsdir_to_weightsfile.cpp target_link_libraries(adams2019_weightsdir_to_weightsfile PRIVATE Halide::Runtime) # ================================================================= -# Smaller tests - -if (BUILD_SHARED_LIBS) - add_executable(adams2019_test_apps_autoscheduler test.cpp) - target_link_libraries(adams2019_test_apps_autoscheduler PRIVATE Halide::Halide Halide::Tools ${CMAKE_DL_LIBS}) - - add_adams2019_test(adams2019_test_apps_autoscheduler - COMMAND adams2019_test_apps_autoscheduler $ ${CMAKE_CURRENT_SOURCE_DIR}/baseline.weights - LABELS multithreaded - ENVIRONMENT "LD_LIBRARY_PATH=$:$ENV{LD_LIBRARY_PATH}") -endif () - -## +# Tests for private/internal functionality of Adams2019 (vs for public functionality, +# which is handled in tests/autoschedulers/Adams2019) add_executable(adams2019_test_perfect_hash_map test_perfect_hash_map.cpp) - -add_adams2019_test(adams2019_test_perfect_hash_map) - -## +add_test(NAME adams2019_test_perfect_hash_map COMMAND adams2019_test_perfect_hash_map) +set_tests_properties(adams2019_test_perfect_hash_map PROPERTIES LABELS "adams2019;autoschedulers;auto_schedule") add_executable(adams2019_test_function_dag test_function_dag.cpp FunctionDAG.cpp) target_link_libraries(adams2019_test_function_dag PRIVATE ASLog Halide::Halide Halide::Tools Halide::Plugin) +add_test(NAME adams2019_test_function_dag COMMAND adams2019_test_function_dag) +set_tests_properties(adams2019_test_function_dag PROPERTIES LABELS "adams2019;autoschedulers;auto_schedule") -add_adams2019_test(adams2019_test_function_dag) diff --git a/src/autoschedulers/adams2019/Makefile b/src/autoschedulers/adams2019/Makefile index cbabe9b94b42..fb0ac8461af1 100644 --- a/src/autoschedulers/adams2019/Makefile +++ b/src/autoschedulers/adams2019/Makefile @@ -112,129 +112,8 @@ $(BIN)/weightsdir_to_weightsfile: $(SRC)/weightsdir_to_weightsfile.cpp $(SRC)/We @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $^ $(OPTIMIZE) -o $@ -# A sample generator to autoschedule. Note that if it statically links -# to libHalide, then it must be build with $(USE_EXPORT_DYNAMIC), or the -# autoscheduler can't find the libHalide symbols that it needs. -$(GENERATOR_BIN)/demo.generator: $(SRC)/demo_generator.cpp $(GENERATOR_DEPS) - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $(USE_EXPORT_DYNAMIC) -g $(filter %.cpp,$^) -o $@ $(LIBHALIDE_LDFLAGS) - -# To use the autoscheduler, set a few environment variables and use the -p flag to the generator to load the autoscheduler as a plugin -$(BIN)/%/demo.a: $(GENERATOR_BIN)/demo.generator $(BIN)/libautoschedule_adams2019.$(PLUGIN_EXT) - @mkdir -p $(@D) - $(GENERATOR_BIN)/demo.generator -g demo -o $(@D) -f demo target=$* \ - autoscheduler=Adams2019 \ - autoscheduler.parallelism=32 \ - autoscheduler.weights_path=$(SRC)/baseline.weights \ - -p $(BIN)/libautoschedule_adams2019.$(PLUGIN_EXT) - -$(BIN)/%/demo.rungen: $(BIN)/%/RunGenMain.o $(BIN)/%/demo.registration.cpp $(BIN)/%/demo.a - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -I$(BIN)/$* $^ -o $@ $(HALIDE_SYSTEM_LIBS) $(IMAGE_IO_FLAGS) - -# demonstrates single-shot use of the autoscheduler -demo: $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_adams2019.$(PLUGIN_EXT) - $< --benchmarks=all --benchmark_min_time=1 --estimate_all - -# demonstrates an autotuning loop -# (using $(BIN) and $(SRC) here seems overkill, but makes copy-n-paste elsewhere easier) -autotune: $(GENERATOR_BIN)/demo.generator $(BIN)/featurization_to_sample $(BIN)/get_host_target $(BIN)/retrain_cost_model $(BIN)/libautoschedule_adams2019.$(PLUGIN_EXT) $(SRC)/autotune_loop.sh - @mkdir -p $(@D) - bash $(SRC)/autotune_loop.sh \ - $(GENERATOR_BIN)/demo.generator \ - demo \ - "" \ - $(SRC)/baseline.weights \ - $(BIN) \ - $(HALIDE_DISTRIB_PATH) \ - $(BIN)/samples - -$(BIN)/test_perfect_hash_map: $(SRC)/test_perfect_hash_map.cpp $(SRC)/PerfectHashMap.h - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $< -o $@ - -$(BIN)/test_function_dag: $(SRC)/test_function_dag.cpp $(SRC)/FunctionDAG.h $(SRC)/FunctionDAG.cpp $(COMMON_DIR)/ASLog.h $(COMMON_DIR)/ASLog.cpp - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $(USE_EXPORT_DYNAMIC) $(filter-out %.h,$^) -o $@ $(LIBHALIDE_LDFLAGS) $(HALIDE_SYSTEM_LIBS) - -# Simple jit-based test -$(BIN)/%/test: $(SRC)/test.cpp $(BIN)/libautoschedule_adams2019.$(PLUGIN_EXT) - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $(USE_EXPORT_DYNAMIC) $< -o $@ $(LIBHALIDE_LDFLAGS) $(HALIDE_SYSTEM_LIBS) - -test_perfect_hash_map: $(BIN)/test_perfect_hash_map - $^ - -test_function_dag: $(BIN)/test_function_dag - $^ - -run_test: $(BIN)/$(HL_TARGET)/test - LD_LIBRARY_PATH=$(BIN):$(LD_LIBRARY_PATH) $< $(BIN)/libautoschedule_adams2019.$(PLUGIN_EXT) $(SRC)/baseline.weights - -.PHONY: test clean - -# Note that 'make build' and 'make test' is used by Halide buildbots -# to spot-check changes, so it's important to try a little of each of -# the important paths here, including single-shot and autotune-loop -build: $(BIN)/$(HL_TARGET)/test \ - $(BIN)/test_perfect_hash_map \ - $(BIN)/test_function_dag \ - $(BIN)/$(HL_TARGET)/included_schedule_file.rungen \ - $(GENERATOR_BIN)/demo.generator \ - $(BIN)/featurization_to_sample \ - $(BIN)/get_host_target \ - $(BIN)/retrain_cost_model \ - $(BIN)/libautoschedule_adams2019.$(PLUGIN_EXT) - -test: run_test test_perfect_hash_map test_function_dag demo test_included_schedule_file autotune +.PHONY: clean clean: rm -rf $(BIN) -# A sample generator to demonstrate including autogenerated .sample.h -# files for scheduling purposes; the catch here is that we'll need -# to be able to compile the Generator two different ways: -# -# - one that will be used to generate the .schedule.h -# - one that will consume the .schedule.h generated above -# -# We'll use the preprocessor (GENERATING_SCHEDULE) to distinguish between these two. - -$(GENERATOR_BIN)/included_schedule_file_none.generator: $(SRC)/included_schedule_file_generator.cpp $(GENERATOR_DEPS) - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $(USE_EXPORT_DYNAMIC) -DGENERATING_SCHEDULE -g $(filter-out %.h,$^) -o $@ $(LIBHALIDE_LDFLAGS) $(HALIDE_SYSTEM_LIBS) - -# This is the target you build to (re)generate the schedule file. -# (Note that we only need the schedule output, so we pass `-e schedule` to -# the Generator so that it can skip producing other outputs.) -$(BIN)/%/included_schedule_file.schedule.h: $(GENERATOR_BIN)/included_schedule_file_none.generator $(BIN)/libautoschedule_adams2019.$(PLUGIN_EXT) - @mkdir -p $(@D) - $< -g included_schedule_file -o $(@D) -f included_schedule_file target=$* \ - autoscheduler=Adams2019 \ - autoscheduler.parallelism=32 \ - autoscheduler.weights_path=$(SRC)/baseline.weights \ - -p $(BIN)/libautoschedule_adams2019.$(PLUGIN_EXT) -e schedule - -# Note that this depends on included_schedule_file.schedule.h rather than $(BIN)/%/included_schedule_file.schedule.h -- -# the former should be generated by something like -# -# make bin/host/included_schedule_file.schedule.h -# cp bin/host/included_schedule_file.schedule.h included_schedule_file.schedule.h -# -$(GENERATOR_BIN)/included_schedule_file.generator: $(SRC)/included_schedule_file_generator.cpp $(SRC)/included_schedule_file.schedule.h $(GENERATOR_DEPS) - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $(USE_EXPORT_DYNAMIC) -g $(filter-out %.h,$^) -o $@ $(LIBHALIDE_LDFLAGS) $(HALIDE_SYSTEM_LIBS) - -# Note that this does not depend on libauto_schedule nor does it call -# the autoscheduler at build time; it includes the generated schedule (included_schedule_file.schedule.h), -# which has been added to our local source control. -$(BIN)/%/included_schedule_file.a: $(GENERATOR_BIN)/included_schedule_file.generator - @mkdir -p $(@D) - $< -g included_schedule_file -o $(@D) -f included_schedule_file target=$* - -$(BIN)/%/included_schedule_file.rungen: $(BIN)/%/RunGenMain.o $(BIN)/%/included_schedule_file.registration.cpp $(BIN)/%/included_schedule_file.a - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -I$(BIN)/$* $^ -o $@ $(HALIDE_SYSTEM_LIBS) $(IMAGE_IO_FLAGS) - -test_included_schedule_file: $(BIN)/$(HL_TARGET)/included_schedule_file.rungen - $^ --benchmarks=all --benchmark_min_time=1 --estimate_all diff --git a/test/autoschedulers/CMakeLists.txt b/test/autoschedulers/CMakeLists.txt index 0b7b5d347751..b34ae32a7526 100644 --- a/test/autoschedulers/CMakeLists.txt +++ b/test/autoschedulers/CMakeLists.txt @@ -1,4 +1,5 @@ include(HalideTestHelpers) +add_subdirectory(adams2019) add_subdirectory(li2018) add_subdirectory(mullapudi2016) diff --git a/test/autoschedulers/adams2019/CMakeLists.txt b/test/autoschedulers/adams2019/CMakeLists.txt new file mode 100644 index 000000000000..8cec08754651 --- /dev/null +++ b/test/autoschedulers/adams2019/CMakeLists.txt @@ -0,0 +1,84 @@ +if (NOT TARGET Halide::Adams2019) + message(STATUS "Disabling adams2019 tests for static Halide") + return() +endif () + +## +# Build rules for the Adams2019 autoscheduler library +## + +function(add_adams2019_test NAME) + set(options "") + set(oneValueArgs ENVIRONMENT) + set(multiValueArgs COMMAND LABELS) + cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (NOT ARGS_COMMAND) + set(ARGS_COMMAND ${NAME}) + endif() + + if (NOT ARGS_LABELS) + set(ARGS_LABELS "") + endif() + list(APPEND ARGS_LABELS adams2019) + list(APPEND ARGS_LABELS autoschedulers) + + add_test(NAME ${NAME} + COMMAND ${ARGS_COMMAND}) + set_tests_properties(${NAME} + PROPERTIES + LABELS "${ARGS_LABELS}" + ENVIRONMENT "${ENVIRONMENT}") +endfunction() + + +## +# Tests and demos +# TODO(#4053): move these to a separate folder since they're tests. +## + +# ================================================================= + +add_halide_generator(adams2019_demo.generator + SOURCES demo_generator.cpp) + +add_halide_library(adams2019_demo FROM adams2019_demo.generator + GENERATOR demo + TARGETS cmake + AUTOSCHEDULER Halide::Adams2019 + REGISTRATION DEMO_REGISTRATION_FILE) + +add_executable(adams2019_demo_apps_autoscheduler ${DEMO_REGISTRATION_FILE}) +target_link_libraries(adams2019_demo_apps_autoscheduler PRIVATE adams2019_demo Halide::RunGenMain) + +add_adams2019_test(adams2019_demo_apps_autoscheduler + COMMAND adams2019_demo_apps_autoscheduler --benchmarks=all --benchmark_min_time=1 --estimate_all) + +# ================================================================= + +add_halide_generator(adams2019_included_schedule_file.generator + SOURCES included_schedule_file_generator.cpp) + +add_halide_library(adams2019_included_schedule_file FROM adams2019_included_schedule_file.generator + GENERATOR included_schedule_file + TARGETS cmake + AUTOSCHEDULER Halide::Adams2019 + REGISTRATION adams2019_included_schedule_reg) + +add_executable(adams2019_demo_included_schedule_file ${adams2019_included_schedule_reg}) +target_link_libraries(adams2019_demo_included_schedule_file PRIVATE adams2019_included_schedule_file Halide::RunGenMain) + +add_adams2019_test(adams2019_demo_included_schedule_file + COMMAND adams2019_demo_included_schedule_file --benchmarks=all --benchmark_min_time=1 --estimate_all) + +# ================================================================= +# Smaller tests + +add_executable(adams2019_test_apps_autoscheduler test.cpp) +target_link_libraries(adams2019_test_apps_autoscheduler PRIVATE Halide::Halide Halide::Tools ${CMAKE_DL_LIBS}) + +add_adams2019_test(adams2019_test_apps_autoscheduler + COMMAND adams2019_test_apps_autoscheduler $ $/baseline.weights + LABELS multithreaded + ENVIRONMENT "LD_LIBRARY_PATH=$:$ENV{LD_LIBRARY_PATH}") + diff --git a/src/autoschedulers/adams2019/demo_generator.cpp b/test/autoschedulers/adams2019/demo_generator.cpp similarity index 100% rename from src/autoschedulers/adams2019/demo_generator.cpp rename to test/autoschedulers/adams2019/demo_generator.cpp diff --git a/src/autoschedulers/adams2019/included_schedule_file.schedule.h b/test/autoschedulers/adams2019/included_schedule_file.schedule.h similarity index 100% rename from src/autoschedulers/adams2019/included_schedule_file.schedule.h rename to test/autoschedulers/adams2019/included_schedule_file.schedule.h diff --git a/src/autoschedulers/adams2019/included_schedule_file_generator.cpp b/test/autoschedulers/adams2019/included_schedule_file_generator.cpp similarity index 100% rename from src/autoschedulers/adams2019/included_schedule_file_generator.cpp rename to test/autoschedulers/adams2019/included_schedule_file_generator.cpp diff --git a/src/autoschedulers/adams2019/test.cpp b/test/autoschedulers/adams2019/test.cpp similarity index 100% rename from src/autoschedulers/adams2019/test.cpp rename to test/autoschedulers/adams2019/test.cpp From f70165082565867733b23f2e12c281bf0d239a99 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 5 Oct 2022 13:52:23 -0700 Subject: [PATCH 11/15] Update reorder.cpp --- test/autoschedulers/mullapudi2016/reorder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/autoschedulers/mullapudi2016/reorder.cpp b/test/autoschedulers/mullapudi2016/reorder.cpp index 89d511f54443..baabe2a307ce 100644 --- a/test/autoschedulers/mullapudi2016/reorder.cpp +++ b/test/autoschedulers/mullapudi2016/reorder.cpp @@ -183,7 +183,7 @@ int main(int argc, char **argv) { double manual_time = run_test_2(false); double auto_time = run_test_2(true); - const double slowdown_factor = 1.0; + const double slowdown_factor = 2.0; if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { std::cerr << "Autoscheduler time (2) is slower than expected:\n" << "======================\n" From ceebfebcae16219bcff055c50e17d2f5c591db91 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 5 Oct 2022 15:11:03 -0700 Subject: [PATCH 12/15] fixes --- test/autoschedulers/mullapudi2016/max_filter.cpp | 2 +- test/autoschedulers/mullapudi2016/reorder.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/autoschedulers/mullapudi2016/max_filter.cpp b/test/autoschedulers/mullapudi2016/max_filter.cpp index 7499ae747f93..83bb269b9417 100644 --- a/test/autoschedulers/mullapudi2016/max_filter.cpp +++ b/test/autoschedulers/mullapudi2016/max_filter.cpp @@ -141,7 +141,7 @@ int main(int argc, char **argv) { double manual_time = run_test(false); double auto_time = run_test(true); - const double slowdown_factor = 2.0; + const double slowdown_factor = 3.0; if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { std::cerr << "Autoscheduler time is slower than expected:\n" << "======================\n" diff --git a/test/autoschedulers/mullapudi2016/reorder.cpp b/test/autoschedulers/mullapudi2016/reorder.cpp index baabe2a307ce..39527c1523be 100644 --- a/test/autoschedulers/mullapudi2016/reorder.cpp +++ b/test/autoschedulers/mullapudi2016/reorder.cpp @@ -168,7 +168,7 @@ int main(int argc, char **argv) { double manual_time = run_test_1(false); double auto_time = run_test_1(true); - const double slowdown_factor = 7.0; + const double slowdown_factor = 15.0; // TODO: whoa if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { std::cerr << "Autoscheduler time (1) is slower than expected:\n" << "======================\n" From 7d44b801c16c05490d4f28f2344d18a31f29c850 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 5 Oct 2022 16:22:11 -0700 Subject: [PATCH 13/15] Update max_filter.cpp --- test/autoschedulers/mullapudi2016/max_filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/autoschedulers/mullapudi2016/max_filter.cpp b/test/autoschedulers/mullapudi2016/max_filter.cpp index 83bb269b9417..4fd852c3cbb9 100644 --- a/test/autoschedulers/mullapudi2016/max_filter.cpp +++ b/test/autoschedulers/mullapudi2016/max_filter.cpp @@ -141,7 +141,7 @@ int main(int argc, char **argv) { double manual_time = run_test(false); double auto_time = run_test(true); - const double slowdown_factor = 3.0; + const double slowdown_factor = 4.0; if (!get_jit_target_from_environment().has_gpu_feature() && auto_time > manual_time * slowdown_factor) { std::cerr << "Autoscheduler time is slower than expected:\n" << "======================\n" From e81df5ac9d583eaca0e5a6b0996f21526c4df2ef Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Thu, 6 Oct 2022 10:55:16 -0700 Subject: [PATCH 14/15] Update CMakeLists.txt --- test/autoschedulers/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/autoschedulers/CMakeLists.txt b/test/autoschedulers/CMakeLists.txt index cc7944010019..12aecdc55a26 100644 --- a/test/autoschedulers/CMakeLists.txt +++ b/test/autoschedulers/CMakeLists.txt @@ -1,3 +1 @@ -include(HalideTestHelpers) - add_subdirectory(mullapudi2016) From fac8ea7305c896e7244df75a6e05dd44492c314e Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Thu, 6 Oct 2022 11:02:02 -0700 Subject: [PATCH 15/15] Update CMakeLists.txt --- src/autoschedulers/adams2019/CMakeLists.txt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/autoschedulers/adams2019/CMakeLists.txt b/src/autoschedulers/adams2019/CMakeLists.txt index aa90271977f3..c6a56d3f38c4 100644 --- a/src/autoschedulers/adams2019/CMakeLists.txt +++ b/src/autoschedulers/adams2019/CMakeLists.txt @@ -69,12 +69,15 @@ target_link_libraries(adams2019_weightsdir_to_weightsfile PRIVATE Halide::Runtim # Tests for private/internal functionality of Adams2019 (vs for public functionality, # which is handled in tests/autoschedulers/Adams2019) -add_executable(adams2019_test_perfect_hash_map test_perfect_hash_map.cpp) -add_test(NAME adams2019_test_perfect_hash_map COMMAND adams2019_test_perfect_hash_map) -set_tests_properties(adams2019_test_perfect_hash_map PROPERTIES LABELS "adams2019;autoschedulers;auto_schedule") +if (WITH_TESTS) -add_executable(adams2019_test_function_dag test_function_dag.cpp FunctionDAG.cpp) -target_link_libraries(adams2019_test_function_dag PRIVATE ASLog Halide::Halide Halide::Tools Halide::Plugin) -add_test(NAME adams2019_test_function_dag COMMAND adams2019_test_function_dag) -set_tests_properties(adams2019_test_function_dag PROPERTIES LABELS "adams2019;autoschedulers;auto_schedule") + add_executable(adams2019_test_perfect_hash_map test_perfect_hash_map.cpp) + add_test(NAME adams2019_test_perfect_hash_map COMMAND adams2019_test_perfect_hash_map) + set_tests_properties(adams2019_test_perfect_hash_map PROPERTIES LABELS "adams2019;autoschedulers;auto_schedule") + add_executable(adams2019_test_function_dag test_function_dag.cpp FunctionDAG.cpp) + target_link_libraries(adams2019_test_function_dag PRIVATE ASLog Halide::Halide Halide::Tools Halide::Plugin) + add_test(NAME adams2019_test_function_dag COMMAND adams2019_test_function_dag) + set_tests_properties(adams2019_test_function_dag PROPERTIES LABELS "adams2019;autoschedulers;auto_schedule") + +endif() \ No newline at end of file