From ee6f7dcdf443ae5688e27dc59a12531657240447 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 4 Oct 2022 17:05:03 -0700 Subject: [PATCH 1/9] 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 2/9] 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 7edc7dab764652b899a3871d175fb8683ae217c4 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 5 Oct 2022 12:08:41 -0700 Subject: [PATCH 3/9] 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 4949ae1280321bc430f1ebcdde40c25baeb41be6 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 5 Oct 2022 12:51:31 -0700 Subject: [PATCH 4/9] 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 5/9] 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 f70165082565867733b23f2e12c281bf0d239a99 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Wed, 5 Oct 2022 13:52:23 -0700 Subject: [PATCH 6/9] 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 7/9] 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 8/9] 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 9/9] 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)