From a8f7acfe47eaaa8ad06168ac5b984e71fb3e01ff Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Sun, 30 Aug 2020 14:14:16 -0700 Subject: [PATCH 01/31] Move autoscheduler sources into dedicated folders --- apps/CMakeLists.txt | 9 --------- src/CMakeLists.txt | 2 ++ src/plugins/CMakeLists.txt | 5 +++++ src/plugins/autoschedulers/CMakeLists.txt | 3 +++ .../plugins/autoschedulers/adams2019}/ASLog.cpp | 0 .../plugins/autoschedulers/adams2019}/ASLog.h | 0 .../autoschedulers/adams2019}/AutoSchedule.cpp | 0 .../autoschedulers/adams2019}/AutoSchedule.h | 0 .../autoschedulers/adams2019}/CMakeLists.txt | 0 .../plugins/autoschedulers/adams2019}/CostModel.h | 0 .../autoschedulers/adams2019}/DefaultCostModel.cpp | 0 .../autoschedulers/adams2019}/DefaultCostModel.h | 0 .../plugins/autoschedulers/adams2019}/Errors.h | 0 .../autoschedulers/adams2019}/Featurization.h | 0 .../autoschedulers/adams2019}/FunctionDAG.cpp | 0 .../plugins/autoschedulers/adams2019}/FunctionDAG.h | 0 .../plugins/autoschedulers/adams2019}/LoopNest.cpp | 0 .../plugins/autoschedulers/adams2019}/LoopNest.h | 0 .../plugins/autoschedulers/adams2019}/Makefile | 0 .../plugins/autoschedulers/adams2019}/NetworkSize.h | 0 .../autoschedulers/adams2019}/PerfectHashMap.h | 0 .../plugins/autoschedulers/adams2019}/Weights.cpp | 0 .../plugins/autoschedulers/adams2019}/Weights.h | 0 .../autoschedulers/adams2019}/autotune_loop.sh | 0 .../autoschedulers/adams2019}/baseline.weights | Bin .../adams2019}/cost_model_generator.cpp | 0 .../autoschedulers/adams2019}/cost_model_schedule.h | 0 .../autoschedulers/adams2019}/demo_generator.cpp | 0 .../adams2019}/featurization_to_sample.cpp | 0 .../autoschedulers/adams2019}/get_host_target.cpp | 0 .../adams2019}/included_schedule_file.schedule.h | 0 .../adams2019}/included_schedule_file_generator.cpp | 0 .../adams2019}/retrain_cost_model.cpp | 0 .../plugins/autoschedulers/adams2019}/test.cpp | 0 .../autoschedulers/adams2019}/test_function_dag.cpp | 0 .../adams2019}/test_perfect_hash_map.cpp | 0 .../adams2019}/weightsdir_to_weightsfile.cpp | 0 .../plugins/autoschedulers/li2018}/ASLog.cpp | 0 .../plugins/autoschedulers/li2018}/ASLog.h | 0 .../plugins/autoschedulers/li2018}/CMakeLists.txt | 0 .../plugins/autoschedulers/li2018}/Errors.h | 0 .../li2018}/GradientAutoscheduler.cpp | 0 .../plugins/autoschedulers/li2018}/Makefile | 0 .../plugins/autoschedulers/li2018}/README.md | 0 .../autoschedulers/li2018}/demo_generator.cpp | 0 .../plugins/autoschedulers/li2018}/test.cpp | 0 .../plugins/autoschedulers/li2018}/test.py | 0 .../autoschedulers/mullapudi2016/CMakeLists.txt | 0 48 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 src/plugins/CMakeLists.txt create mode 100644 src/plugins/autoschedulers/CMakeLists.txt rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/ASLog.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/ASLog.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/AutoSchedule.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/AutoSchedule.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/CMakeLists.txt (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/CostModel.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/DefaultCostModel.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/DefaultCostModel.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/Errors.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/Featurization.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/FunctionDAG.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/FunctionDAG.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/LoopNest.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/LoopNest.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/Makefile (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/NetworkSize.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/PerfectHashMap.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/Weights.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/Weights.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/autotune_loop.sh (100%) mode change 100755 => 100644 rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/baseline.weights (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/cost_model_generator.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/cost_model_schedule.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/demo_generator.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/featurization_to_sample.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/get_host_target.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/included_schedule_file.schedule.h (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/included_schedule_file_generator.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/retrain_cost_model.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/test.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/test_function_dag.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/test_perfect_hash_map.cpp (100%) rename {apps/autoscheduler => src/plugins/autoschedulers/adams2019}/weightsdir_to_weightsfile.cpp (100%) rename {apps/gradient_autoscheduler => src/plugins/autoschedulers/li2018}/ASLog.cpp (100%) rename {apps/gradient_autoscheduler => src/plugins/autoschedulers/li2018}/ASLog.h (100%) rename {apps/gradient_autoscheduler => src/plugins/autoschedulers/li2018}/CMakeLists.txt (100%) rename {apps/gradient_autoscheduler => src/plugins/autoschedulers/li2018}/Errors.h (100%) rename {apps/gradient_autoscheduler => src/plugins/autoschedulers/li2018}/GradientAutoscheduler.cpp (100%) rename {apps/gradient_autoscheduler => src/plugins/autoschedulers/li2018}/Makefile (100%) rename {apps/gradient_autoscheduler => src/plugins/autoschedulers/li2018}/README.md (100%) rename {apps/gradient_autoscheduler => src/plugins/autoschedulers/li2018}/demo_generator.cpp (100%) rename {apps/gradient_autoscheduler => src/plugins/autoschedulers/li2018}/test.cpp (100%) rename {apps/gradient_autoscheduler => src/plugins/autoschedulers/li2018}/test.py (100%) create mode 100644 src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 53ea697cda23..e17e8e4dec0e 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -89,12 +89,3 @@ add_app_test(resize) add_app_test(stencil_chain) add_app_test(unsharp) add_app_test(wavelet) - -# Add the autoschedulers. -# TODO(#4053): refactor into separate modules -if (TARGET_WEBASSEMBLY AND Halide_TARGET MATCHES "wasm") - # Don't attempt to build these for wasm yet. -else () - add_subdirectory(autoscheduler) - add_subdirectory(gradient_autoscheduler) -endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ffa4bcae27ee..022da15618e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -420,6 +420,8 @@ endif () add_library(Halide::Plugin ALIAS Halide_Plugin) +add_subdirectory(plugins) + ## # Set compiler options for libHalide ## diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt new file mode 100644 index 000000000000..f8ba4a82e468 --- /dev/null +++ b/src/plugins/CMakeLists.txt @@ -0,0 +1,5 @@ +if (TARGET_WEBASSEMBLY AND Halide_TARGET MATCHES "wasm") + # Don't attempt to build these for wasm yet. +else () + add_subdirectory(autoschedulers) +endif () diff --git a/src/plugins/autoschedulers/CMakeLists.txt b/src/plugins/autoschedulers/CMakeLists.txt new file mode 100644 index 000000000000..302ea6489378 --- /dev/null +++ b/src/plugins/autoschedulers/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(adams2019) +add_subdirectory(li2018) +add_subdirectory(mullapudi2016) diff --git a/apps/autoscheduler/ASLog.cpp b/src/plugins/autoschedulers/adams2019/ASLog.cpp similarity index 100% rename from apps/autoscheduler/ASLog.cpp rename to src/plugins/autoschedulers/adams2019/ASLog.cpp diff --git a/apps/autoscheduler/ASLog.h b/src/plugins/autoschedulers/adams2019/ASLog.h similarity index 100% rename from apps/autoscheduler/ASLog.h rename to src/plugins/autoschedulers/adams2019/ASLog.h diff --git a/apps/autoscheduler/AutoSchedule.cpp b/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp similarity index 100% rename from apps/autoscheduler/AutoSchedule.cpp rename to src/plugins/autoschedulers/adams2019/AutoSchedule.cpp diff --git a/apps/autoscheduler/AutoSchedule.h b/src/plugins/autoschedulers/adams2019/AutoSchedule.h similarity index 100% rename from apps/autoscheduler/AutoSchedule.h rename to src/plugins/autoschedulers/adams2019/AutoSchedule.h diff --git a/apps/autoscheduler/CMakeLists.txt b/src/plugins/autoschedulers/adams2019/CMakeLists.txt similarity index 100% rename from apps/autoscheduler/CMakeLists.txt rename to src/plugins/autoschedulers/adams2019/CMakeLists.txt diff --git a/apps/autoscheduler/CostModel.h b/src/plugins/autoschedulers/adams2019/CostModel.h similarity index 100% rename from apps/autoscheduler/CostModel.h rename to src/plugins/autoschedulers/adams2019/CostModel.h diff --git a/apps/autoscheduler/DefaultCostModel.cpp b/src/plugins/autoschedulers/adams2019/DefaultCostModel.cpp similarity index 100% rename from apps/autoscheduler/DefaultCostModel.cpp rename to src/plugins/autoschedulers/adams2019/DefaultCostModel.cpp diff --git a/apps/autoscheduler/DefaultCostModel.h b/src/plugins/autoschedulers/adams2019/DefaultCostModel.h similarity index 100% rename from apps/autoscheduler/DefaultCostModel.h rename to src/plugins/autoschedulers/adams2019/DefaultCostModel.h diff --git a/apps/autoscheduler/Errors.h b/src/plugins/autoschedulers/adams2019/Errors.h similarity index 100% rename from apps/autoscheduler/Errors.h rename to src/plugins/autoschedulers/adams2019/Errors.h diff --git a/apps/autoscheduler/Featurization.h b/src/plugins/autoschedulers/adams2019/Featurization.h similarity index 100% rename from apps/autoscheduler/Featurization.h rename to src/plugins/autoschedulers/adams2019/Featurization.h diff --git a/apps/autoscheduler/FunctionDAG.cpp b/src/plugins/autoschedulers/adams2019/FunctionDAG.cpp similarity index 100% rename from apps/autoscheduler/FunctionDAG.cpp rename to src/plugins/autoschedulers/adams2019/FunctionDAG.cpp diff --git a/apps/autoscheduler/FunctionDAG.h b/src/plugins/autoschedulers/adams2019/FunctionDAG.h similarity index 100% rename from apps/autoscheduler/FunctionDAG.h rename to src/plugins/autoschedulers/adams2019/FunctionDAG.h diff --git a/apps/autoscheduler/LoopNest.cpp b/src/plugins/autoschedulers/adams2019/LoopNest.cpp similarity index 100% rename from apps/autoscheduler/LoopNest.cpp rename to src/plugins/autoschedulers/adams2019/LoopNest.cpp diff --git a/apps/autoscheduler/LoopNest.h b/src/plugins/autoschedulers/adams2019/LoopNest.h similarity index 100% rename from apps/autoscheduler/LoopNest.h rename to src/plugins/autoschedulers/adams2019/LoopNest.h diff --git a/apps/autoscheduler/Makefile b/src/plugins/autoschedulers/adams2019/Makefile similarity index 100% rename from apps/autoscheduler/Makefile rename to src/plugins/autoschedulers/adams2019/Makefile diff --git a/apps/autoscheduler/NetworkSize.h b/src/plugins/autoschedulers/adams2019/NetworkSize.h similarity index 100% rename from apps/autoscheduler/NetworkSize.h rename to src/plugins/autoschedulers/adams2019/NetworkSize.h diff --git a/apps/autoscheduler/PerfectHashMap.h b/src/plugins/autoschedulers/adams2019/PerfectHashMap.h similarity index 100% rename from apps/autoscheduler/PerfectHashMap.h rename to src/plugins/autoschedulers/adams2019/PerfectHashMap.h diff --git a/apps/autoscheduler/Weights.cpp b/src/plugins/autoschedulers/adams2019/Weights.cpp similarity index 100% rename from apps/autoscheduler/Weights.cpp rename to src/plugins/autoschedulers/adams2019/Weights.cpp diff --git a/apps/autoscheduler/Weights.h b/src/plugins/autoschedulers/adams2019/Weights.h similarity index 100% rename from apps/autoscheduler/Weights.h rename to src/plugins/autoschedulers/adams2019/Weights.h diff --git a/apps/autoscheduler/autotune_loop.sh b/src/plugins/autoschedulers/adams2019/autotune_loop.sh old mode 100755 new mode 100644 similarity index 100% rename from apps/autoscheduler/autotune_loop.sh rename to src/plugins/autoschedulers/adams2019/autotune_loop.sh diff --git a/apps/autoscheduler/baseline.weights b/src/plugins/autoschedulers/adams2019/baseline.weights similarity index 100% rename from apps/autoscheduler/baseline.weights rename to src/plugins/autoschedulers/adams2019/baseline.weights diff --git a/apps/autoscheduler/cost_model_generator.cpp b/src/plugins/autoschedulers/adams2019/cost_model_generator.cpp similarity index 100% rename from apps/autoscheduler/cost_model_generator.cpp rename to src/plugins/autoschedulers/adams2019/cost_model_generator.cpp diff --git a/apps/autoscheduler/cost_model_schedule.h b/src/plugins/autoschedulers/adams2019/cost_model_schedule.h similarity index 100% rename from apps/autoscheduler/cost_model_schedule.h rename to src/plugins/autoschedulers/adams2019/cost_model_schedule.h diff --git a/apps/autoscheduler/demo_generator.cpp b/src/plugins/autoschedulers/adams2019/demo_generator.cpp similarity index 100% rename from apps/autoscheduler/demo_generator.cpp rename to src/plugins/autoschedulers/adams2019/demo_generator.cpp diff --git a/apps/autoscheduler/featurization_to_sample.cpp b/src/plugins/autoschedulers/adams2019/featurization_to_sample.cpp similarity index 100% rename from apps/autoscheduler/featurization_to_sample.cpp rename to src/plugins/autoschedulers/adams2019/featurization_to_sample.cpp diff --git a/apps/autoscheduler/get_host_target.cpp b/src/plugins/autoschedulers/adams2019/get_host_target.cpp similarity index 100% rename from apps/autoscheduler/get_host_target.cpp rename to src/plugins/autoschedulers/adams2019/get_host_target.cpp diff --git a/apps/autoscheduler/included_schedule_file.schedule.h b/src/plugins/autoschedulers/adams2019/included_schedule_file.schedule.h similarity index 100% rename from apps/autoscheduler/included_schedule_file.schedule.h rename to src/plugins/autoschedulers/adams2019/included_schedule_file.schedule.h diff --git a/apps/autoscheduler/included_schedule_file_generator.cpp b/src/plugins/autoschedulers/adams2019/included_schedule_file_generator.cpp similarity index 100% rename from apps/autoscheduler/included_schedule_file_generator.cpp rename to src/plugins/autoschedulers/adams2019/included_schedule_file_generator.cpp diff --git a/apps/autoscheduler/retrain_cost_model.cpp b/src/plugins/autoschedulers/adams2019/retrain_cost_model.cpp similarity index 100% rename from apps/autoscheduler/retrain_cost_model.cpp rename to src/plugins/autoschedulers/adams2019/retrain_cost_model.cpp diff --git a/apps/autoscheduler/test.cpp b/src/plugins/autoschedulers/adams2019/test.cpp similarity index 100% rename from apps/autoscheduler/test.cpp rename to src/plugins/autoschedulers/adams2019/test.cpp diff --git a/apps/autoscheduler/test_function_dag.cpp b/src/plugins/autoschedulers/adams2019/test_function_dag.cpp similarity index 100% rename from apps/autoscheduler/test_function_dag.cpp rename to src/plugins/autoschedulers/adams2019/test_function_dag.cpp diff --git a/apps/autoscheduler/test_perfect_hash_map.cpp b/src/plugins/autoschedulers/adams2019/test_perfect_hash_map.cpp similarity index 100% rename from apps/autoscheduler/test_perfect_hash_map.cpp rename to src/plugins/autoschedulers/adams2019/test_perfect_hash_map.cpp diff --git a/apps/autoscheduler/weightsdir_to_weightsfile.cpp b/src/plugins/autoschedulers/adams2019/weightsdir_to_weightsfile.cpp similarity index 100% rename from apps/autoscheduler/weightsdir_to_weightsfile.cpp rename to src/plugins/autoschedulers/adams2019/weightsdir_to_weightsfile.cpp diff --git a/apps/gradient_autoscheduler/ASLog.cpp b/src/plugins/autoschedulers/li2018/ASLog.cpp similarity index 100% rename from apps/gradient_autoscheduler/ASLog.cpp rename to src/plugins/autoschedulers/li2018/ASLog.cpp diff --git a/apps/gradient_autoscheduler/ASLog.h b/src/plugins/autoschedulers/li2018/ASLog.h similarity index 100% rename from apps/gradient_autoscheduler/ASLog.h rename to src/plugins/autoschedulers/li2018/ASLog.h diff --git a/apps/gradient_autoscheduler/CMakeLists.txt b/src/plugins/autoschedulers/li2018/CMakeLists.txt similarity index 100% rename from apps/gradient_autoscheduler/CMakeLists.txt rename to src/plugins/autoschedulers/li2018/CMakeLists.txt diff --git a/apps/gradient_autoscheduler/Errors.h b/src/plugins/autoschedulers/li2018/Errors.h similarity index 100% rename from apps/gradient_autoscheduler/Errors.h rename to src/plugins/autoschedulers/li2018/Errors.h diff --git a/apps/gradient_autoscheduler/GradientAutoscheduler.cpp b/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp similarity index 100% rename from apps/gradient_autoscheduler/GradientAutoscheduler.cpp rename to src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp diff --git a/apps/gradient_autoscheduler/Makefile b/src/plugins/autoschedulers/li2018/Makefile similarity index 100% rename from apps/gradient_autoscheduler/Makefile rename to src/plugins/autoschedulers/li2018/Makefile diff --git a/apps/gradient_autoscheduler/README.md b/src/plugins/autoschedulers/li2018/README.md similarity index 100% rename from apps/gradient_autoscheduler/README.md rename to src/plugins/autoschedulers/li2018/README.md diff --git a/apps/gradient_autoscheduler/demo_generator.cpp b/src/plugins/autoschedulers/li2018/demo_generator.cpp similarity index 100% rename from apps/gradient_autoscheduler/demo_generator.cpp rename to src/plugins/autoschedulers/li2018/demo_generator.cpp diff --git a/apps/gradient_autoscheduler/test.cpp b/src/plugins/autoschedulers/li2018/test.cpp similarity index 100% rename from apps/gradient_autoscheduler/test.cpp rename to src/plugins/autoschedulers/li2018/test.cpp diff --git a/apps/gradient_autoscheduler/test.py b/src/plugins/autoschedulers/li2018/test.py similarity index 100% rename from apps/gradient_autoscheduler/test.py rename to src/plugins/autoschedulers/li2018/test.py diff --git a/src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt b/src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt new file mode 100644 index 000000000000..e69de29bb2d1 From 5101b9d23679470cf9f02dba8375b40799c47ca5 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Mon, 31 Aug 2020 03:37:55 -0700 Subject: [PATCH 02/31] Convert plugins to named-entry-point --- apps/bgu/CMakeLists.txt | 1 + apps/bilateral_grid/CMakeLists.txt | 1 + apps/camera_pipe/CMakeLists.txt | 1 + apps/conv_layer/CMakeLists.txt | 1 + apps/depthwise_separable_conv/CMakeLists.txt | 1 + apps/harris/CMakeLists.txt | 1 + apps/hist/CMakeLists.txt | 1 + apps/iir_blur/CMakeLists.txt | 1 + apps/interpolate/CMakeLists.txt | 1 + apps/lens_blur/CMakeLists.txt | 1 + apps/local_laplacian/CMakeLists.txt | 1 + apps/max_filter/CMakeLists.txt | 1 + apps/nl_means/CMakeLists.txt | 1 + apps/stencil_chain/CMakeLists.txt | 1 + apps/unsharp/CMakeLists.txt | 1 + src/AutoSchedule.h | 29 ---------- src/CMakeLists.txt | 34 ++--------- src/Pipeline.cpp | 27 ++------- src/Pipeline.h | 3 - src/plugins/CMakeLists.txt | 6 ++ .../autoschedulers/adams2019/AutoSchedule.cpp | 51 +++++++--------- .../autoschedulers/adams2019/CMakeLists.txt | 56 ++++++++---------- .../adams2019/DefaultCostModel.h | 2 +- .../autoschedulers/li2018/CMakeLists.txt | 42 +++----------- src/plugins/autoschedulers/li2018/Errors.h | 26 --------- .../li2018/GradientAutoscheduler.cpp | 54 +++++++---------- .../mullapudi2016}/AutoSchedule.cpp | 58 ++++++++++++------- .../mullapudi2016/CMakeLists.txt | 13 +++++ test/generator/CMakeLists.txt | 3 +- tools/build_halide_h.cpp | 4 +- tutorial/CMakeLists.txt | 1 + 31 files changed, 166 insertions(+), 258 deletions(-) delete mode 100644 src/AutoSchedule.h delete mode 100644 src/plugins/autoschedulers/li2018/Errors.h rename src/{ => plugins/autoschedulers/mullapudi2016}/AutoSchedule.cpp (98%) diff --git a/apps/bgu/CMakeLists.txt b/apps/bgu/CMakeLists.txt index e22e15299ef1..acaf01653844 100644 --- a/apps/bgu/CMakeLists.txt +++ b/apps/bgu/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(bgu.generator PRIVATE Halide::Generator Halide::Tools) add_halide_library(bgu FROM bgu.generator) add_halide_library(bgu_auto_schedule FROM bgu.generator GENERATOR bgu + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/bilateral_grid/CMakeLists.txt b/apps/bilateral_grid/CMakeLists.txt index 6244696b581d..0c3bf26cb311 100644 --- a/apps/bilateral_grid/CMakeLists.txt +++ b/apps/bilateral_grid/CMakeLists.txt @@ -24,6 +24,7 @@ add_halide_library(bilateral_grid_auto_schedule FROM bilateral_grid.generator GENERATOR bilateral_grid STMT bilateral_grid_auto_schedule_STMT SCHEDULE bilateral_grid_auto_schedule_SCHEDULE + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/camera_pipe/CMakeLists.txt b/apps/camera_pipe/CMakeLists.txt index c06422745581..77e994a5f5a9 100644 --- a/apps/camera_pipe/CMakeLists.txt +++ b/apps/camera_pipe/CMakeLists.txt @@ -22,6 +22,7 @@ target_link_libraries(camera_pipe.generator add_halide_library(camera_pipe FROM camera_pipe.generator) add_halide_library(camera_pipe_auto_schedule FROM camera_pipe.generator GENERATOR camera_pipe + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/conv_layer/CMakeLists.txt b/apps/conv_layer/CMakeLists.txt index 5b074701b1bc..ed1a8a667a44 100644 --- a/apps/conv_layer/CMakeLists.txt +++ b/apps/conv_layer/CMakeLists.txt @@ -21,6 +21,7 @@ target_link_libraries(conv_layer.generator add_halide_library(conv_layer FROM conv_layer.generator) add_halide_library(conv_layer_auto_schedule FROM conv_layer.generator GENERATOR conv_layer + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/depthwise_separable_conv/CMakeLists.txt b/apps/depthwise_separable_conv/CMakeLists.txt index 2eae5db79820..947b7a485638 100644 --- a/apps/depthwise_separable_conv/CMakeLists.txt +++ b/apps/depthwise_separable_conv/CMakeLists.txt @@ -21,6 +21,7 @@ target_link_libraries(depthwise_separable_conv.generator add_halide_library(depthwise_separable_conv FROM depthwise_separable_conv.generator) add_halide_library(depthwise_separable_conv_auto_schedule FROM depthwise_separable_conv.generator GENERATOR depthwise_separable_conv + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/harris/CMakeLists.txt b/apps/harris/CMakeLists.txt index f409834dc17c..3d029d82c774 100644 --- a/apps/harris/CMakeLists.txt +++ b/apps/harris/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(harris.generator PRIVATE Halide::Generator Halide::Tools) add_halide_library(harris FROM harris.generator) add_halide_library(harris_auto_schedule FROM harris.generator GENERATOR harris + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/hist/CMakeLists.txt b/apps/hist/CMakeLists.txt index bbef5aef6d84..141222b76d3d 100644 --- a/apps/hist/CMakeLists.txt +++ b/apps/hist/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(hist.generator PRIVATE Halide::Generator Halide::Tools) add_halide_library(hist FROM hist.generator) add_halide_library(hist_auto_schedule FROM hist.generator GENERATOR hist + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/iir_blur/CMakeLists.txt b/apps/iir_blur/CMakeLists.txt index 196f4410e16d..d6df9fc0b537 100644 --- a/apps/iir_blur/CMakeLists.txt +++ b/apps/iir_blur/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(iir_blur.generator PRIVATE Halide::Generator) add_halide_library(iir_blur FROM iir_blur.generator) add_halide_library(iir_blur_auto_schedule FROM iir_blur.generator GENERATOR iir_blur + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/interpolate/CMakeLists.txt b/apps/interpolate/CMakeLists.txt index c1464867da50..4696001e7dd4 100644 --- a/apps/interpolate/CMakeLists.txt +++ b/apps/interpolate/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(interpolate.generator PRIVATE Halide::Generator Halide::To add_halide_library(interpolate FROM interpolate.generator) add_halide_library(interpolate_auto_schedule FROM interpolate.generator GENERATOR interpolate + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/lens_blur/CMakeLists.txt b/apps/lens_blur/CMakeLists.txt index 5d5add734655..fae47f93a2b1 100644 --- a/apps/lens_blur/CMakeLists.txt +++ b/apps/lens_blur/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(lens_blur.generator PRIVATE Halide::Generator Halide::Tool add_halide_library(lens_blur FROM lens_blur.generator) add_halide_library(lens_blur_auto_schedule FROM lens_blur.generator GENERATOR lens_blur + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/local_laplacian/CMakeLists.txt b/apps/local_laplacian/CMakeLists.txt index a816551342b5..d23166916a31 100644 --- a/apps/local_laplacian/CMakeLists.txt +++ b/apps/local_laplacian/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(local_laplacian.generator PRIVATE Halide::Generator Halide add_halide_library(local_laplacian FROM local_laplacian.generator) add_halide_library(local_laplacian_auto_schedule FROM local_laplacian.generator GENERATOR local_laplacian + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/max_filter/CMakeLists.txt b/apps/max_filter/CMakeLists.txt index ff2486b5ef59..e776f644a8b6 100644 --- a/apps/max_filter/CMakeLists.txt +++ b/apps/max_filter/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(max_filter.generator PRIVATE Halide::Generator Halide::Too add_halide_library(max_filter FROM max_filter.generator) add_halide_library(max_filter_auto_schedule FROM max_filter.generator GENERATOR max_filter + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/nl_means/CMakeLists.txt b/apps/nl_means/CMakeLists.txt index d09f0d0d31d8..a3db4da64743 100644 --- a/apps/nl_means/CMakeLists.txt +++ b/apps/nl_means/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(nl_means.generator PRIVATE Halide::Generator Halide::Tools add_halide_library(nl_means FROM nl_means.generator) add_halide_library(nl_means_auto_schedule FROM nl_means.generator GENERATOR nl_means + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/stencil_chain/CMakeLists.txt b/apps/stencil_chain/CMakeLists.txt index 0efebaf63c98..0c1ec2ed64ad 100644 --- a/apps/stencil_chain/CMakeLists.txt +++ b/apps/stencil_chain/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(stencil_chain.generator PRIVATE Halide::Generator Halide:: add_halide_library(stencil_chain FROM stencil_chain.generator) add_halide_library(stencil_chain_auto_schedule FROM stencil_chain.generator GENERATOR stencil_chain + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/apps/unsharp/CMakeLists.txt b/apps/unsharp/CMakeLists.txt index 222c15d36142..37c5e3532396 100644 --- a/apps/unsharp/CMakeLists.txt +++ b/apps/unsharp/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(unsharp.generator PRIVATE Halide::Generator Halide::Tools) add_halide_library(unsharp FROM unsharp.generator) add_halide_library(unsharp_auto_schedule FROM unsharp.generator GENERATOR unsharp + AUTOSCHEDULER Halide::Mullapudi2016 PARAMS auto_schedule=true) # Main executable diff --git a/src/AutoSchedule.h b/src/AutoSchedule.h deleted file mode 100644 index bf962eb560d1..000000000000 --- a/src/AutoSchedule.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef HALIDE_INTERNAL_AUTO_SCHEDULE_H -#define HALIDE_INTERNAL_AUTO_SCHEDULE_H - -/** \file - * - * Defines the method that does automatic scheduling of Funcs within a pipeline. - */ - -#include "Pipeline.h" -#include "Target.h" - -namespace Halide { -namespace Internal { - -class Function; - -/** Generate schedules for Funcs within a pipeline. The Funcs should not already - * have specializations or schedules as the current auto-scheduler does not take - * into account user-defined schedules or specializations. This applies the - * schedules and returns a string representation of the schedules. The target - * architecture is specified by 'target'. */ -std::string generate_schedules(const std::vector &outputs, - const Target &target, - const MachineParams &arch_params); - -} // namespace Internal -} // namespace Halide - -#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 022da15618e9..bb168b8ee7d6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,7 +15,6 @@ set(HEADER_FILES AssociativeOpsTable.h Associativity.h AsyncProducers.h - AutoSchedule.h AutoScheduleUtils.h BoundaryConditions.h Bounds.h @@ -180,7 +179,6 @@ set(SOURCE_FILES AssociativeOpsTable.cpp Associativity.cpp AsyncProducers.cpp - AutoSchedule.cpp AutoScheduleUtils.cpp BoundaryConditions.cpp Bounds.cpp @@ -396,32 +394,6 @@ endif () set(Halide_INCLUDE_PATH "$") target_include_directories(Halide INTERFACE ${Halide_INCLUDE_PATH}) -## -# Plugin interface for Halide on weak systems -## - -add_library(Halide_Plugin INTERFACE) -set_target_properties(Halide_Plugin PROPERTIES EXPORT_NAME Plugin) - -if (NOT BUILD_SHARED_LIBS) - if (MSVC) - message(STATUS "Notice: Halide plugins are not available when building statically with MSVC") - else () - target_link_libraries(Halide_Plugin INTERFACE Halide::LanguageOptions) - target_link_options(Halide_Plugin INTERFACE - $<$:-rdynamic> - $<$:-undefined dynamic_lookup>) - target_include_directories(Halide_Plugin INTERFACE ${Halide_INCLUDE_PATH}) - add_dependencies(Halide_Plugin Halide) - endif () -else () - target_link_libraries(Halide_Plugin INTERFACE Halide::Halide) -endif () - -add_library(Halide::Plugin ALIAS Halide_Plugin) - -add_subdirectory(plugins) - ## # Set compiler options for libHalide ## @@ -496,3 +468,9 @@ option(Halide_USE_CODEMODEL_LARGE "Use the Large LLVM codemodel" OFF) if (Halide_USE_CODEMODEL_LARGE) target_compile_definitions(Halide PRIVATE HALIDE_USE_CODEMODEL_LARGE) endif () + +## +# Add compiler plugins (ie. autoschedulers) to the build. +## + +add_subdirectory(plugins) diff --git a/src/Pipeline.cpp b/src/Pipeline.cpp index 9cd14aacdeea..bf97a4b31438 100644 --- a/src/Pipeline.cpp +++ b/src/Pipeline.cpp @@ -3,7 +3,6 @@ #include #include "Argument.h" -#include "AutoSchedule.h" #include "CodeGen_Internal.h" #include "FindCalls.h" #include "Func.h" @@ -179,33 +178,15 @@ vector Pipeline::outputs() const { return funcs; } -/* static */ -void Pipeline::auto_schedule_Mullapudi2016(const Pipeline &pipeline, const Target &target, - const MachineParams &arch_params, AutoSchedulerResults *outputs) { - AutoSchedulerResults results; - results.target = target; - results.machine_params_string = arch_params.to_string(); - - user_assert(target.arch == Target::X86 || target.arch == Target::ARM || - target.arch == Target::POWERPC || target.arch == Target::MIPS) - << "The Mullapudi2016 autoscheduler is not supported for the target: " << target; - results.scheduler_name = "Mullapudi2016"; - results.schedule_source = generate_schedules(pipeline.contents->outputs, target, arch_params); - // this autoscheduler has no featurization - - *outputs = results; -} - /* static */ std::map &Pipeline::get_autoscheduler_map() { - static std::map autoschedulers = { - {"Mullapudi2016", auto_schedule_Mullapudi2016}}; + static std::map autoschedulers = {}; return autoschedulers; } /* static */ std::string &Pipeline::get_default_autoscheduler_name() { - static std::string autoscheduler_name = "Mullapudi2016"; + static std::string autoscheduler_name = ""; return autoscheduler_name; } @@ -226,7 +207,9 @@ AutoSchedulerFn Pipeline::find_autoscheduler(const std::string &autoscheduler_na AutoSchedulerResults Pipeline::auto_schedule(const std::string &autoscheduler_name, const Target &target, const MachineParams &arch_params) { auto autoscheduler_fn = find_autoscheduler(autoscheduler_name); - internal_assert(autoscheduler_fn != nullptr); + internal_assert(autoscheduler_fn) + << "Could not find autoscheduler named '" << autoscheduler_name << "'.\n" + << "Did you remember to load the plugin?"; AutoSchedulerResults results; results.target = target; diff --git a/src/Pipeline.h b/src/Pipeline.h index 3f8baecf50ae..40b32b33247d 100644 --- a/src/Pipeline.h +++ b/src/Pipeline.h @@ -148,9 +148,6 @@ class Pipeline { static std::vector make_externs_jit_module(const Target &target, std::map &externs_in_out); - static void auto_schedule_Mullapudi2016(const Pipeline &pipeline, const Target &target, - const MachineParams &arch_params, AutoSchedulerResults *outputs); - static std::map &get_autoscheduler_map(); static std::string &get_default_autoscheduler_name(); diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index f8ba4a82e468..ce18f04c9d39 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,3 +1,9 @@ +# Ensure that plugins export only what is needed to load them. +# Everything else should be omitted to keep binary size low. +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN YES) + if (TARGET_WEBASSEMBLY AND Halide_TARGET MATCHES "wasm") # Don't attempt to build these for wasm yet. else () diff --git a/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp b/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp index 8d1da73f7aa5..60a1dc5e1d38 100644 --- a/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp +++ b/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp @@ -64,32 +64,26 @@ TODO: expose these settings by adding some means to pass args to generator plugins instead of environment vars. */ +#include "halide_adams2019_export.h" + #include #include #include #include #include #include -#include -#include #include #include #include "ASLog.h" #include "AutoSchedule.h" -#include "CostModel.h" #include "DefaultCostModel.h" -#include "Errors.h" -#include "Featurization.h" -#include "FunctionDAG.h" -#include "Halide.h" #include "LoopNest.h" -#include "NetworkSize.h" -#include "PerfectHashMap.h" + +#include #ifdef _WIN32 #include -#define _isatty isatty; #endif namespace Halide { @@ -138,7 +132,7 @@ struct ProgressBar { private: uint32_t counter = 0; - const bool draw_progress_bar = isatty(2); + const bool draw_progress_bar = _isatty(2); }; // Get the HL_RANDOM_DROPOUT environment variable. Purpose of this is described above. @@ -1319,24 +1313,6 @@ void generate_schedule(const std::vector &outputs, } } -// Halide uses a plugin architecture for registering custom -// autoschedulers. We register our autoscheduler using a static -// constructor. -struct RegisterAutoscheduler { - RegisterAutoscheduler() { - aslog(1) << "Registering autoscheduler 'Adams2019'...\n"; - Pipeline::add_autoscheduler("Adams2019", *this); - } - - void operator()(const Pipeline &p, const Target &target, const MachineParams ¶ms, AutoSchedulerResults *results) { - std::vector outputs; - for (Func f : p.outputs()) { - outputs.push_back(f.function()); - } - Autoscheduler::generate_schedule(outputs, target, params, results); - } -} register_auto_scheduler; - // An alternative entrypoint for other uses void find_and_apply_schedule(FunctionDAG &dag, const std::vector &outputs, @@ -1382,3 +1358,20 @@ void destroy(const Autoscheduler::State *t) { } // namespace Internal } // namespace Halide + +extern "C" { +HALIDE_ADAMS2019_EXPORT +const char *AutoschedulerName() { + Halide::Internal::aslog(1) << "Registering autoscheduler 'Adams2019'...\n"; + return "Adams2019"; +} + +HALIDE_ADAMS2019_EXPORT +void AutoschedulerRun(const Halide::Pipeline &p, const Halide::Target &target, const Halide::MachineParams ¶ms, Halide::AutoSchedulerResults *results) { + std::vector outputs; + for (Halide::Func f : p.outputs()) { + outputs.push_back(f.function()); + } + Halide::Internal::Autoscheduler::generate_schedule(outputs, target, params, results); +} +} diff --git a/src/plugins/autoschedulers/adams2019/CMakeLists.txt b/src/plugins/autoschedulers/adams2019/CMakeLists.txt index 8e46956db40b..ca5617acd358 100644 --- a/src/plugins/autoschedulers/adams2019/CMakeLists.txt +++ b/src/plugins/autoschedulers/adams2019/CMakeLists.txt @@ -1,18 +1,6 @@ -# ================================================================================ -# Halide autoscheduler plugins rely on weak linking to work with static libraries. -# This is not standard C++ and only works on Linux / macOS. Nothing special needs -# to be done when linking to a shared version of Halide, however. - -if (NOT BUILD_SHARED_LIBS) - if (MSVC) - message(WARNING "Autoscheduler plugins cannot be built against static Halide on Windows") - return() - endif () - - # Need to enable exports for the plugins to find Halide's symbols. - set(CMAKE_ENABLE_EXPORTS ON) -endif () - +## +# Resources for the autoscheduler library +## # weights set(WF_CPP baseline.cpp) @@ -37,12 +25,16 @@ add_executable(retrain_cost_model Weights.cpp retrain_cost_model.cpp ${WF_CPP}) -target_include_directories(retrain_cost_model PRIVATE ${PROJECT_SOURCE_DIR}/apps/support) # TODO(#4053): relocate. just for cmdline.h +target_include_directories(retrain_cost_model + PRIVATE + # TODO(#4053): relocate. just for cmdline.h + ${PROJECT_SOURCE_DIR}/apps/support) target_link_libraries(retrain_cost_model PRIVATE cost_model train_cost_model Halide::Halide) -# libauto_schedule -# Note: must use MODULE here (not SHARED) to get .so (instead of .dylib) on OSX. -# This means that this can only be opened dynamically (not linked directly), but that's ok. +## +# Main autoscheduler library +## + add_library(Halide_Adams2019 MODULE ASLog.cpp @@ -53,20 +45,23 @@ add_library(Halide_Adams2019 Weights.cpp ${WF_CPP}) add_library(Halide::Adams2019 ALIAS Halide_Adams2019) + +include(GenerateExportHeader) +generate_export_header(Halide_Adams2019) +target_include_directories(Halide_Adams2019 PRIVATE $) + +target_link_libraries(Halide_Adams2019 PRIVATE cost_model train_cost_model Halide::Halide) + set_target_properties(Halide_Adams2019 PROPERTIES EXPORT_NAME Adams2019 OUTPUT_NAME auto_schedule) -target_link_libraries(Halide_Adams2019 PRIVATE cost_model train_cost_model Halide::Plugin) - -if (NOT Halide_ENABLE_RTTI) - target_compile_options(Halide_Adams2019 PRIVATE - $<$:/GR-> - $<$,$>>:-fno-rtti>) -endif () +## +# Tests and demos +# TODO(#4053): move these to a separate folder since they're tests. +## # ================================================================= -# TODO(#4053): move this to a separate folder since it's a demo/app add_executable(demo.generator demo_generator.cpp) target_link_libraries(demo.generator PRIVATE Halide::Generator) @@ -88,7 +83,6 @@ set_tests_properties(demo_apps_autoscheduler ENVIRONMENT "HL_TARGET=${Halide_TARGET}") # ================================================================= -# TODO(#4053): move this to a separate folder since it's a demo/app add_executable(included_schedule_file.generator included_schedule_file_generator.cpp) target_link_libraries(included_schedule_file.generator PRIVATE Halide::Generator) @@ -96,9 +90,9 @@ target_link_libraries(included_schedule_file.generator PRIVATE Halide::Generator add_halide_library(included_schedule_file FROM included_schedule_file.generator PARAMS auto_schedule=true AUTOSCHEDULER Halide::Adams2019 - REGISTRATION INCLUDED_SCHEDULE_FILE_REGISTRATION_FILE) + REGISTRATION included_schedule_reg) -add_executable(demo_included_schedule_file ${INCLUDED_SCHEDULE_FILE_REGISTRATION_FILE}) +add_executable(demo_included_schedule_file ${included_schedule_reg}) target_link_libraries(demo_included_schedule_file PRIVATE included_schedule_file Halide::RunGenMain) add_test(NAME demo_included_schedule_file @@ -122,7 +116,7 @@ add_executable(weightsdir_to_weightsfile weightsdir_to_weightsfile.cpp Weights.c target_link_libraries(weightsdir_to_weightsfile PRIVATE Halide::Runtime) # ================================================================= -# TODO(#4053): move these to a separate folder since they're tests. +# Smaller tests add_executable(test_apps_autoscheduler test.cpp) target_link_libraries(test_apps_autoscheduler PRIVATE Halide::Halide Halide::Tools ${CMAKE_DL_LIBS}) diff --git a/src/plugins/autoschedulers/adams2019/DefaultCostModel.h b/src/plugins/autoschedulers/adams2019/DefaultCostModel.h index 288b470091da..11dff14ef0dc 100644 --- a/src/plugins/autoschedulers/adams2019/DefaultCostModel.h +++ b/src/plugins/autoschedulers/adams2019/DefaultCostModel.h @@ -33,7 +33,7 @@ class DefaultCostModel : public CostModel { load_weights(); } - virtual ~DefaultCostModel() = default; + ~DefaultCostModel() override = default; // Configure the cost model for the algorithm to be scheduled. void set_pipeline_features(const Internal::Autoscheduler::FunctionDAG &dag, diff --git a/src/plugins/autoschedulers/li2018/CMakeLists.txt b/src/plugins/autoschedulers/li2018/CMakeLists.txt index 909d25fd99ac..a2c449b5dbe2 100644 --- a/src/plugins/autoschedulers/li2018/CMakeLists.txt +++ b/src/plugins/autoschedulers/li2018/CMakeLists.txt @@ -1,34 +1,17 @@ -# ================================================================================ -# Halide autoscheduler plugins rely on weak linking to work with static libraries. -# This is not standard C++ and only works on Linux / macOS. Nothing special needs -# to be done when linking to a shared version of Halide, however. - -if (NOT BUILD_SHARED_LIBS) - if (MSVC) - message(WARNING "Autoscheduler plugins cannot be built against static Halide on Windows") - return() - endif () +add_library(Halide_Li2018 MODULE GradientAutoscheduler.cpp) +add_library(Halide::Li2018 ALIAS Halide_Li2018) - # Need to enable exports for the plugins to find Halide's symbols. - set(CMAKE_ENABLE_EXPORTS ON) -endif () +include(GenerateExportHeader) +generate_export_header(Halide_Li2018) +target_include_directories(Halide_Li2018 PRIVATE $) -# ================================= -# Define the autoscheduler library. +target_link_libraries(Halide_Li2018 PRIVATE Halide::Halide) +target_compile_definitions(Halide_Li2018 PRIVATE Halide_ERROR_MACROS) -add_library(Halide_Li2018 MODULE GradientAutoscheduler.cpp ASLog.cpp) -add_library(Halide::Li2018 ALIAS Halide_Li2018) set_target_properties(Halide_Li2018 PROPERTIES EXPORT_NAME Li2018 OUTPUT_NAME gradient_autoscheduler) -target_link_libraries(Halide_Li2018 PRIVATE Halide::Plugin) - -if (NOT Halide_ENABLE_RTTI) - target_compile_options(Halide_Li2018 PRIVATE - $<$:/GR-> - $<$,$>>:-fno-rtti>) -endif () # ========================================================== # TODO(#4053): move these to a separate folder since they're tests. @@ -53,17 +36,8 @@ set_tests_properties(demo_gradient_autoscheduler PROPERTIES LABELS Li2018) ## -# Hack to include all symbols in the gradient autoscheduler test. -# DerivativeUtils.h/inference_bounds is not used elsewhere and so doesn't get linked to the test. -unset(WHOLE_ARCHIVE) -unset(NO_WHOLE_ARCHIVE) -if (NOT BUILD_SHARED_LIBS) - set(WHOLE_ARCHIVE $<$:-Wl,-whole-archive> $<$:-Wl,-all_load>) - set(NO_WHOLE_ARCHIVE $<$:-Wl,-no-whole-archive> $<$:-Wl,-noall_load>) -endif () - add_executable(gradient_autoscheduler_test_cpp test.cpp) -target_link_libraries(gradient_autoscheduler_test_cpp PRIVATE ${WHOLE_ARCHIVE} Halide::Halide ${NO_WHOLE_ARCHIVE}) +target_link_libraries(gradient_autoscheduler_test_cpp PRIVATE Halide::Halide) add_test(NAME gradient_autoscheduler_test_cpp COMMAND gradient_autoscheduler_test_cpp diff --git a/src/plugins/autoschedulers/li2018/Errors.h b/src/plugins/autoschedulers/li2018/Errors.h deleted file mode 100644 index 0057b2fbc3a9..000000000000 --- a/src/plugins/autoschedulers/li2018/Errors.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef ERRORS_H -#define ERRORS_H - -#include "Halide.h" - -#ifndef user_error -#define user_error Halide::Internal::ErrorReport(__FILE__, __LINE__, nullptr, Halide::Internal::ErrorReport::User) -#endif - -#ifndef user_warning -#define user_warning Halide::Internal::ErrorReport(__FILE__, __LINE__, nullptr, Halide::Internal::ErrorReport::User | Halide::Internal::ErrorReport::Warning) -#endif - -#ifndef user_assert -#define user_assert(c) _halide_internal_assertion(c, Halide::Internal::ErrorReport::User) -#endif - -#ifndef internal_assert -#define internal_assert(c) _halide_internal_assertion(c, 0) -#endif - -#ifndef internal_error -#define internal_error Halide::Internal::ErrorReport(__FILE__, __LINE__, nullptr, 0) -#endif - -#endif diff --git a/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp b/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp index 486789bd32ab..c67ace630eb9 100644 --- a/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp +++ b/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp @@ -1,19 +1,16 @@ -#include "ASLog.h" -#include "Errors.h" -#include "Halide.h" - -namespace Halide { -namespace Internal { -namespace Autoscheduler { +#include "halide_li2018_export.h" -namespace { +#include "Halide.h" +#include +using namespace Halide; +using namespace Halide::Internal; std::map inference_bounds(const std::vector &functions, const std::vector &output_bounds) { std::vector funcs; funcs.reserve(functions.size()); for (const auto &f : functions) { - funcs.push_back(Func(f)); + funcs.emplace_back(f); } return inference_bounds(funcs, output_bounds); } @@ -817,8 +814,6 @@ void apply_schedule(const MachineParams ¶ms, schedule_source << ";\n"; } -} // namespace - void generate_schedule(const std::vector &outputs, const Target &target, const MachineParams ¶ms, @@ -910,7 +905,7 @@ void generate_schedule(const std::vector &outputs, // Traverse from the consumers to the producers for (auto it = order.rbegin(); it != order.rend(); it++) { Func func(env[*it]); - aslog(1) << "[gradient_autoscheduler] Processing function:" << *it << "\n"; + debug(1) << "[gradient_autoscheduler] Processing function:" << *it << "\n"; // Get the bounds in integer constant by substitute all the parameters' estimates. Box bounds = func_bounds[*it]; std::vector int_bounds = get_int_bounds(bounds); @@ -925,27 +920,22 @@ void generate_schedule(const std::vector &outputs, auto_scheduler_results->scheduler_name = "Li2018"; auto_scheduler_results->schedule_source = schedule_source.str(); - aslog(1) << schedule_source.str() << "\n"; + debug(1) << schedule_source.str() << "\n"; } -// Halide uses a plugin architecture for registering custom -// autoschedulers. We register our autoscheduler using a static -// constructor. -struct RegisterGradientAutoscheduler { - RegisterGradientAutoscheduler() { - aslog(1) << "Registering autoscheduler 'Li2018'...\n"; - Pipeline::add_autoscheduler("Li2018", *this); - } +extern "C" { +HALIDE_LI2018_EXPORT +const char *AutoschedulerName() { + debug(1) << "Registering autoscheduler 'Li2018'...\n"; + return "Li2018"; +} - void operator()(const Pipeline &p, const Target &target, const MachineParams ¶ms, AutoSchedulerResults *results) { - std::vector outputs; - for (Func f : p.outputs()) { - outputs.push_back(f.function()); - } - generate_schedule(outputs, target, params, results); +HALIDE_LI2018_EXPORT +void AutoschedulerRun(const Pipeline &p, const Target &target, const MachineParams ¶ms, AutoSchedulerResults *results) { + std::vector outputs; + for (Func f : p.outputs()) { + outputs.push_back(f.function()); } -} register_auto_scheduler; - -} // namespace Autoscheduler -} // namespace Internal -} // namespace Halide + generate_schedule(outputs, target, params, results); +} +} diff --git a/src/AutoSchedule.cpp b/src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp similarity index 98% rename from src/AutoSchedule.cpp rename to src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp index 04d2a0967f5d..24bfe5140503 100644 --- a/src/AutoSchedule.cpp +++ b/src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp @@ -1,23 +1,14 @@ +#include "halide_mullapudi2016_export.h" + #include +#include #include +#include #include -#include "AutoSchedule.h" -#include "AutoScheduleUtils.h" -#include "ExprUsesVar.h" -#include "FindCalls.h" -#include "Func.h" -#include "IREquality.h" -#include "Inline.h" -#include "ParallelRVar.h" -#include "RealizationOrder.h" -#include "RegionCosts.h" -#include "Scope.h" -#include "Simplify.h" -#include "Util.h" - -namespace Halide { -namespace Internal { +#include +using namespace Halide; +using namespace Halide::Internal; using std::make_pair; using std::map; @@ -3168,9 +3159,11 @@ bool inline_unbounded(const vector &outputs, } // anonymous namespace -// Generate schedules for all functions in the pipeline required to compute the -// outputs. This applies the schedules and returns a string representation of -// the schedules. The target architecture is specified by 'target'. +/** Generate schedules for Funcs within a pipeline. The Funcs should not already + * have specializations or schedules as the current auto-scheduler does not take + * into account user-defined schedules or specializations. This applies the + * schedules and returns a string representation of the schedules. The target + * architecture is specified by 'target'. */ string generate_schedules(const vector &outputs, const Target &target, const MachineParams &arch_params) { // Make an environment map which is used throughout the auto scheduling process. @@ -3377,6 +3370,29 @@ string generate_schedules(const vector &outputs, const Target &target, return sched_string; } -} // namespace Internal +extern "C" { +HALIDE_MULLAPUDI2016_EXPORT +const char *AutoschedulerName() { + return "Mullapudi2016"; +} + +HALIDE_MULLAPUDI2016_EXPORT +void AutoschedulerRun(const Pipeline &pipeline, const Target &target, const MachineParams &arch_params, AutoSchedulerResults *outputs) { + AutoSchedulerResults results; + results.target = target; + results.machine_params_string = arch_params.to_string(); -} // namespace Halide + user_assert(target.arch == Target::X86 || target.arch == Target::ARM || + target.arch == Target::POWERPC || target.arch == Target::MIPS) + << "The Mullapudi2016 autoscheduler is not supported for the target: " << target.to_string(); + results.scheduler_name = AutoschedulerName(); + std::vector pipeline_outputs; + for (Func f : pipeline.outputs()) { + pipeline_outputs.push_back(f.function()); + } + results.schedule_source = generate_schedules(pipeline_outputs, target, arch_params); + // this autoscheduler has no featurization + + *outputs = results; +} +} diff --git a/src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt b/src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt index e69de29bb2d1..3556e5be4a0c 100644 --- a/src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt +++ b/src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt @@ -0,0 +1,13 @@ +add_library(Halide_Mullapudi2016 MODULE AutoSchedule.cpp) +add_library(Halide::Mullapudi2016 ALIAS Halide_Mullapudi2016) + +include(GenerateExportHeader) +generate_export_header(Halide_Mullapudi2016) +target_include_directories(Halide_Mullapudi2016 PRIVATE $) + +target_link_libraries(Halide_Mullapudi2016 PRIVATE Halide::Halide) +target_compile_definitions(Halide_Mullapudi2016 PRIVATE Halide_ERROR_MACROS) + +set_target_properties(Halide_Mullapudi2016 PROPERTIES + EXPORT_NAME Mullapudi2016 + OUTPUT_NAME mullapudi2016) diff --git a/test/generator/CMakeLists.txt b/test/generator/CMakeLists.txt index 342659232b3e..eeb463cc115f 100644 --- a/test/generator/CMakeLists.txt +++ b/test/generator/CMakeLists.txt @@ -161,7 +161,8 @@ if (TARGET generator_aot_autograd) GRADIENT_DESCENT FROM autograd.generator GENERATOR autograd - PARAMS "auto_schedule=true") + AUTOSCHEDULER Halide::Mullapudi2016 + PARAMS auto_schedule=true) target_link_libraries(generator_aot_autograd PRIVATE autograd_grad) endif () diff --git a/tools/build_halide_h.cpp b/tools/build_halide_h.cpp index ac2eba7ce98c..d0073cec5146 100644 --- a/tools/build_halide_h.cpp +++ b/tools/build_halide_h.cpp @@ -82,13 +82,15 @@ int main(int argc, char **files) { fprintf(stdout, "\n"); fprintf(stdout, "// Clean up macros used inside Halide headers\n" + "#ifndef Halide_ERROR_MACROS\n" "#undef user_assert\n" "#undef user_error\n" "#undef user_warning\n" "#undef internal_error\n" "#undef internal_assert\n" "#undef halide_runtime_error\n" - "#undef HALIDE_EXPORT\n\n" + "#undef HALIDE_EXPORT\n" + "#endif // Halide_ERROR_MACROS\n\n" "#endif // HALIDE_H\n"); return 0; diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt index 1ee71b060a58..ca405d43ea8d 100644 --- a/tutorial/CMakeLists.txt +++ b/tutorial/CMakeLists.txt @@ -198,6 +198,7 @@ else () add_halide_library(auto_schedule_false FROM lesson_21_auto_scheduler_generate GENERATOR auto_schedule_gen PARAMS auto_schedule=false) add_halide_library(auto_schedule_true FROM lesson_21_auto_scheduler_generate + AUTOSCHEDULER Halide::Mullapudi2016 GENERATOR auto_schedule_gen PARAMS auto_schedule=true machine_params=32,16777216,40) add_executable(lesson_21_auto_scheduler_run lesson_21_auto_scheduler_run.cpp) From de65a60ad6080e728bb0de1153c46ec3a64ca38d Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Mon, 31 Aug 2020 03:42:00 -0700 Subject: [PATCH 03/31] Setting an autoscheduler now implies you want to use it. --- apps/bgu/CMakeLists.txt | 3 +-- apps/bilateral_grid/CMakeLists.txt | 3 +-- apps/camera_pipe/CMakeLists.txt | 3 +-- apps/conv_layer/CMakeLists.txt | 3 +-- apps/depthwise_separable_conv/CMakeLists.txt | 3 +-- apps/harris/CMakeLists.txt | 3 +-- apps/hist/CMakeLists.txt | 3 +-- apps/iir_blur/CMakeLists.txt | 3 +-- apps/interpolate/CMakeLists.txt | 3 +-- apps/lens_blur/CMakeLists.txt | 3 +-- apps/local_laplacian/CMakeLists.txt | 3 +-- apps/max_filter/CMakeLists.txt | 3 +-- apps/nl_means/CMakeLists.txt | 3 +-- apps/stencil_chain/CMakeLists.txt | 3 +-- apps/unsharp/CMakeLists.txt | 3 +-- cmake/HalideGeneratorHelpers.cmake | 2 +- src/plugins/autoschedulers/adams2019/CMakeLists.txt | 2 -- src/plugins/autoschedulers/li2018/CMakeLists.txt | 1 - test/generator/CMakeLists.txt | 3 +-- tutorial/CMakeLists.txt | 2 +- 20 files changed, 18 insertions(+), 37 deletions(-) diff --git a/apps/bgu/CMakeLists.txt b/apps/bgu/CMakeLists.txt index acaf01653844..ffba5714d889 100644 --- a/apps/bgu/CMakeLists.txt +++ b/apps/bgu/CMakeLists.txt @@ -19,8 +19,7 @@ target_link_libraries(bgu.generator PRIVATE Halide::Generator Halide::Tools) add_halide_library(bgu FROM bgu.generator) add_halide_library(bgu_auto_schedule FROM bgu.generator GENERATOR bgu - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(bgu_filter filter.cpp) diff --git a/apps/bilateral_grid/CMakeLists.txt b/apps/bilateral_grid/CMakeLists.txt index 0c3bf26cb311..ffab600382da 100644 --- a/apps/bilateral_grid/CMakeLists.txt +++ b/apps/bilateral_grid/CMakeLists.txt @@ -24,8 +24,7 @@ add_halide_library(bilateral_grid_auto_schedule FROM bilateral_grid.generator GENERATOR bilateral_grid STMT bilateral_grid_auto_schedule_STMT SCHEDULE bilateral_grid_auto_schedule_SCHEDULE - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(bilateral_grid_process filter.cpp) diff --git a/apps/camera_pipe/CMakeLists.txt b/apps/camera_pipe/CMakeLists.txt index 77e994a5f5a9..35f6de32dfbe 100644 --- a/apps/camera_pipe/CMakeLists.txt +++ b/apps/camera_pipe/CMakeLists.txt @@ -22,8 +22,7 @@ target_link_libraries(camera_pipe.generator add_halide_library(camera_pipe FROM camera_pipe.generator) add_halide_library(camera_pipe_auto_schedule FROM camera_pipe.generator GENERATOR camera_pipe - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(camera_pipe_process process.cpp) diff --git a/apps/conv_layer/CMakeLists.txt b/apps/conv_layer/CMakeLists.txt index ed1a8a667a44..fbc70d5494b1 100644 --- a/apps/conv_layer/CMakeLists.txt +++ b/apps/conv_layer/CMakeLists.txt @@ -21,8 +21,7 @@ target_link_libraries(conv_layer.generator add_halide_library(conv_layer FROM conv_layer.generator) add_halide_library(conv_layer_auto_schedule FROM conv_layer.generator GENERATOR conv_layer - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(conv_layer_process process.cpp) diff --git a/apps/depthwise_separable_conv/CMakeLists.txt b/apps/depthwise_separable_conv/CMakeLists.txt index 947b7a485638..8907777cb0fa 100644 --- a/apps/depthwise_separable_conv/CMakeLists.txt +++ b/apps/depthwise_separable_conv/CMakeLists.txt @@ -21,8 +21,7 @@ target_link_libraries(depthwise_separable_conv.generator add_halide_library(depthwise_separable_conv FROM depthwise_separable_conv.generator) add_halide_library(depthwise_separable_conv_auto_schedule FROM depthwise_separable_conv.generator GENERATOR depthwise_separable_conv - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(depthwise_separable_conv_process process.cpp) diff --git a/apps/harris/CMakeLists.txt b/apps/harris/CMakeLists.txt index 3d029d82c774..a61a0c0fcd67 100644 --- a/apps/harris/CMakeLists.txt +++ b/apps/harris/CMakeLists.txt @@ -19,8 +19,7 @@ target_link_libraries(harris.generator PRIVATE Halide::Generator Halide::Tools) add_halide_library(harris FROM harris.generator) add_halide_library(harris_auto_schedule FROM harris.generator GENERATOR harris - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(harris_filter filter.cpp) diff --git a/apps/hist/CMakeLists.txt b/apps/hist/CMakeLists.txt index 141222b76d3d..94db41663980 100644 --- a/apps/hist/CMakeLists.txt +++ b/apps/hist/CMakeLists.txt @@ -19,8 +19,7 @@ target_link_libraries(hist.generator PRIVATE Halide::Generator Halide::Tools) add_halide_library(hist FROM hist.generator) add_halide_library(hist_auto_schedule FROM hist.generator GENERATOR hist - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(hist_filter filter.cpp) diff --git a/apps/iir_blur/CMakeLists.txt b/apps/iir_blur/CMakeLists.txt index d6df9fc0b537..a2c39634c058 100644 --- a/apps/iir_blur/CMakeLists.txt +++ b/apps/iir_blur/CMakeLists.txt @@ -19,8 +19,7 @@ target_link_libraries(iir_blur.generator PRIVATE Halide::Generator) add_halide_library(iir_blur FROM iir_blur.generator) add_halide_library(iir_blur_auto_schedule FROM iir_blur.generator GENERATOR iir_blur - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(iir_blur_filter filter.cpp) diff --git a/apps/interpolate/CMakeLists.txt b/apps/interpolate/CMakeLists.txt index 4696001e7dd4..207597384e5b 100644 --- a/apps/interpolate/CMakeLists.txt +++ b/apps/interpolate/CMakeLists.txt @@ -19,8 +19,7 @@ target_link_libraries(interpolate.generator PRIVATE Halide::Generator Halide::To add_halide_library(interpolate FROM interpolate.generator) add_halide_library(interpolate_auto_schedule FROM interpolate.generator GENERATOR interpolate - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(interpolate_filter filter.cpp) diff --git a/apps/lens_blur/CMakeLists.txt b/apps/lens_blur/CMakeLists.txt index fae47f93a2b1..8515d77f40b7 100644 --- a/apps/lens_blur/CMakeLists.txt +++ b/apps/lens_blur/CMakeLists.txt @@ -19,8 +19,7 @@ target_link_libraries(lens_blur.generator PRIVATE Halide::Generator Halide::Tool add_halide_library(lens_blur FROM lens_blur.generator) add_halide_library(lens_blur_auto_schedule FROM lens_blur.generator GENERATOR lens_blur - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(lens_blur_filter process.cpp) diff --git a/apps/local_laplacian/CMakeLists.txt b/apps/local_laplacian/CMakeLists.txt index d23166916a31..4b6ab9384e6b 100644 --- a/apps/local_laplacian/CMakeLists.txt +++ b/apps/local_laplacian/CMakeLists.txt @@ -19,8 +19,7 @@ target_link_libraries(local_laplacian.generator PRIVATE Halide::Generator Halide add_halide_library(local_laplacian FROM local_laplacian.generator) add_halide_library(local_laplacian_auto_schedule FROM local_laplacian.generator GENERATOR local_laplacian - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(local_laplacian_process process.cpp) diff --git a/apps/max_filter/CMakeLists.txt b/apps/max_filter/CMakeLists.txt index e776f644a8b6..35aabf94e9a3 100644 --- a/apps/max_filter/CMakeLists.txt +++ b/apps/max_filter/CMakeLists.txt @@ -19,8 +19,7 @@ target_link_libraries(max_filter.generator PRIVATE Halide::Generator Halide::Too add_halide_library(max_filter FROM max_filter.generator) add_halide_library(max_filter_auto_schedule FROM max_filter.generator GENERATOR max_filter - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(max_filter_filter filter.cpp) diff --git a/apps/nl_means/CMakeLists.txt b/apps/nl_means/CMakeLists.txt index a3db4da64743..274bb1d2abd7 100644 --- a/apps/nl_means/CMakeLists.txt +++ b/apps/nl_means/CMakeLists.txt @@ -19,8 +19,7 @@ target_link_libraries(nl_means.generator PRIVATE Halide::Generator Halide::Tools add_halide_library(nl_means FROM nl_means.generator) add_halide_library(nl_means_auto_schedule FROM nl_means.generator GENERATOR nl_means - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(nl_means_process process.cpp) diff --git a/apps/stencil_chain/CMakeLists.txt b/apps/stencil_chain/CMakeLists.txt index 0c1ec2ed64ad..4dbcd508d89a 100644 --- a/apps/stencil_chain/CMakeLists.txt +++ b/apps/stencil_chain/CMakeLists.txt @@ -19,8 +19,7 @@ target_link_libraries(stencil_chain.generator PRIVATE Halide::Generator Halide:: add_halide_library(stencil_chain FROM stencil_chain.generator) add_halide_library(stencil_chain_auto_schedule FROM stencil_chain.generator GENERATOR stencil_chain - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(stencil_chain_process process.cpp) diff --git a/apps/unsharp/CMakeLists.txt b/apps/unsharp/CMakeLists.txt index 37c5e3532396..4221f1fa24eb 100644 --- a/apps/unsharp/CMakeLists.txt +++ b/apps/unsharp/CMakeLists.txt @@ -19,8 +19,7 @@ target_link_libraries(unsharp.generator PRIVATE Halide::Generator Halide::Tools) add_halide_library(unsharp FROM unsharp.generator) add_halide_library(unsharp_auto_schedule FROM unsharp.generator GENERATOR unsharp - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) # Main executable add_executable(unsharp_filter filter.cpp) diff --git a/cmake/HalideGeneratorHelpers.cmake b/cmake/HalideGeneratorHelpers.cmake index a6cc2e41d0b3..c09621348a2d 100644 --- a/cmake/HalideGeneratorHelpers.cmake +++ b/cmake/HalideGeneratorHelpers.cmake @@ -185,10 +185,10 @@ function(add_halide_library TARGET) list(APPEND ARG_PLUGINS "${ARG_AUTOSCHEDULER}") string(REGEX REPLACE ".*::(.*)" "\\1" ARG_AUTOSCHEDULER "${ARG_AUTOSCHEDULER}") elseif (NOT ARG_PLUGINS) - # TODO(#4053): this is spurious when the default autoscheduler is requested message(AUTHOR_WARNING "AUTOSCHEDULER set to a scheduler name but no plugins were loaded") endif () set(GEN_AUTOSCHEDULER -s "${ARG_AUTOSCHEDULER}") + list(PREPEND ARG_PARAMS auto_schedule=true) endif () ## diff --git a/src/plugins/autoschedulers/adams2019/CMakeLists.txt b/src/plugins/autoschedulers/adams2019/CMakeLists.txt index ca5617acd358..4c97bc29947f 100644 --- a/src/plugins/autoschedulers/adams2019/CMakeLists.txt +++ b/src/plugins/autoschedulers/adams2019/CMakeLists.txt @@ -67,7 +67,6 @@ add_executable(demo.generator demo_generator.cpp) target_link_libraries(demo.generator PRIVATE Halide::Generator) add_halide_library(demo FROM demo.generator - PARAMS auto_schedule=true AUTOSCHEDULER Halide::Adams2019 REGISTRATION DEMO_REGISTRATION_FILE) @@ -88,7 +87,6 @@ add_executable(included_schedule_file.generator included_schedule_file_generator target_link_libraries(included_schedule_file.generator PRIVATE Halide::Generator) add_halide_library(included_schedule_file FROM included_schedule_file.generator - PARAMS auto_schedule=true AUTOSCHEDULER Halide::Adams2019 REGISTRATION included_schedule_reg) diff --git a/src/plugins/autoschedulers/li2018/CMakeLists.txt b/src/plugins/autoschedulers/li2018/CMakeLists.txt index a2c449b5dbe2..5fce7f989731 100644 --- a/src/plugins/autoschedulers/li2018/CMakeLists.txt +++ b/src/plugins/autoschedulers/li2018/CMakeLists.txt @@ -22,7 +22,6 @@ target_link_libraries(demo_gradient.generator PRIVATE Halide::Generator) add_halide_library(demo_gradient FROM demo_gradient.generator GENERATOR demo FUNCTION_NAME demo - PARAMS auto_schedule=true AUTOSCHEDULER Halide::Li2018 REGISTRATION DEMO_REGISTRATION_FILE) diff --git a/test/generator/CMakeLists.txt b/test/generator/CMakeLists.txt index eeb463cc115f..f1b85b4dd696 100644 --- a/test/generator/CMakeLists.txt +++ b/test/generator/CMakeLists.txt @@ -161,8 +161,7 @@ if (TARGET generator_aot_autograd) GRADIENT_DESCENT FROM autograd.generator GENERATOR autograd - AUTOSCHEDULER Halide::Mullapudi2016 - PARAMS auto_schedule=true) + AUTOSCHEDULER Halide::Mullapudi2016) target_link_libraries(generator_aot_autograd PRIVATE autograd_grad) endif () diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt index ca405d43ea8d..e362459be357 100644 --- a/tutorial/CMakeLists.txt +++ b/tutorial/CMakeLists.txt @@ -199,7 +199,7 @@ else () GENERATOR auto_schedule_gen PARAMS auto_schedule=false) add_halide_library(auto_schedule_true FROM lesson_21_auto_scheduler_generate AUTOSCHEDULER Halide::Mullapudi2016 - GENERATOR auto_schedule_gen PARAMS auto_schedule=true machine_params=32,16777216,40) + GENERATOR auto_schedule_gen PARAMS machine_params=32,16777216,40) add_executable(lesson_21_auto_scheduler_run lesson_21_auto_scheduler_run.cpp) target_link_libraries(lesson_21_auto_scheduler_run PRIVATE From 3c1f62a4d2047bdea9ac8a9bbf62e1e48eaf1ed3 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Tue, 8 Sep 2020 23:40:53 -0700 Subject: [PATCH 04/31] Replace unset(v) with set(v "") --- apps/CMakeLists.txt | 4 ++-- apps/linear_algebra/CMakeLists.txt | 4 ++-- cmake/BundleStatic.cmake | 2 +- cmake/HalideGeneratorHelpers.cmake | 6 +++--- packaging/HalideConfig.cmake | 2 +- tutorial/CMakeLists.txt | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index e17e8e4dec0e..db7c90f1335a 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -26,7 +26,7 @@ function(add_app_test NAME) return() endif () - unset(cmakeToolchainOpts) + set(cmakeToolchainOpts "") if (NOT "${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") list(APPEND cmakeToolchainOpts "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") if (NOT "${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}" STREQUAL "") @@ -34,7 +34,7 @@ function(add_app_test NAME) endif () endif () - unset(cmakeGenOpts) + set(cmakeGenOpts "") if (NOT "${CMAKE_GENERATOR_TOOLSET}" STREQUAL "") list(APPEND cmakeGenOpts --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}") endif () diff --git a/apps/linear_algebra/CMakeLists.txt b/apps/linear_algebra/CMakeLists.txt index 60af2f407c48..2d649e0ec684 100644 --- a/apps/linear_algebra/CMakeLists.txt +++ b/apps/linear_algebra/CMakeLists.txt @@ -12,8 +12,8 @@ set(CMAKE_CXX_EXTENSIONS NO) find_package(Halide REQUIRED COMPONENTS Halide) # Find BLAS-es -unset(DEFAULT_BLAS) -unset(BLAS_TARGETS) +set(DEFAULT_BLAS "") +set(BLAS_TARGETS "") set(BLAS_VENDORS OpenBLAS ATLAS Apple Generic) # ATLAS is weird and has extra requirements diff --git a/cmake/BundleStatic.cmake b/cmake/BundleStatic.cmake index da250c56a3e5..1a834c528552 100644 --- a/cmake/BundleStatic.cmake +++ b/cmake/BundleStatic.cmake @@ -183,7 +183,7 @@ function(transfer_locations) message(VERBOSE "Transferring ${languages}[${cfg}] objects from ${lib} to ${ARG_TO}") - unset(globs) + set(globs "") foreach (lang IN LISTS languages) list(APPEND globs "${stage}/*${CMAKE_${lang}_OUTPUT_EXTENSION}") endforeach () diff --git a/cmake/HalideGeneratorHelpers.cmake b/cmake/HalideGeneratorHelpers.cmake index c09621348a2d..14159b704e3a 100644 --- a/cmake/HalideGeneratorHelpers.cmake +++ b/cmake/HalideGeneratorHelpers.cmake @@ -177,7 +177,7 @@ function(add_halide_library TARGET) # Attach an autoscheduler if the user requested it ## - unset(GEN_AUTOSCHEDULER) + set(GEN_AUTOSCHEDULER "") if (ARG_AUTOSCHEDULER) if ("${ARG_AUTOSCHEDULER}" MATCHES "::" AND TARGET "${ARG_AUTOSCHEDULER}") # Convention: if the argument names a target like "Namespace::Scheduler" then @@ -207,7 +207,7 @@ function(add_halide_library TARGET) endif () # Load the plugins and setup dependencies - unset(GEN_PLUGINS) + set(GEN_PLUGINS "") if (ARG_PLUGINS) foreach (p IN LISTS ARG_PLUGINS) list(APPEND GEN_PLUGINS "$") @@ -254,7 +254,7 @@ function(_Halide_add_halide_runtime RT) if (crosscompiling) set(GEN_OUTS "${RT}${static_library_suffix}") - unset(GEN_ARGS) + set(GEN_ARGS "") else () set(GEN_OUTS "${RT}${object_suffix}") set(GEN_ARGS -e object) diff --git a/packaging/HalideConfig.cmake b/packaging/HalideConfig.cmake index 9ee50f1d2fb5..e54aff545d0b 100644 --- a/packaging/HalideConfig.cmake +++ b/packaging/HalideConfig.cmake @@ -127,7 +127,7 @@ foreach (comp IN LISTS ${CMAKE_FIND_PACKAGE_NAME}_comps) # ${comp} is either PNG or JPEG, and this works for both packages if (NOT TARGET ${comp}::${comp}) - unset(extraArgs) + set(extraArgs "") if (${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) list(APPEND extraArgs QUIET) endif () diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt index e362459be357..9ae3c7fd8a8e 100644 --- a/tutorial/CMakeLists.txt +++ b/tutorial/CMakeLists.txt @@ -101,7 +101,7 @@ target_link_libraries(lesson_15_generate PRIVATE Halide::Generator) ## Hack to build the libraries add_custom_target(lesson_15_targets) -unset(LESSON_15_EXPECTED_FILES) +set(LESSON_15_EXPECTED_FILES "") ## add_halide_library(my_first_generator_win32 FROM lesson_15_generate From 8142c795d9ce3c8f226b4d1796d0ad0ac8ae4dc2 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Tue, 1 Sep 2020 23:03:56 -0700 Subject: [PATCH 05/31] Use static initializers again; drop static plugin support --- cmake/HalideGeneratorHelpers.cmake | 6 +- src/CMakeLists.txt | 7 ++- src/Pipeline.cpp | 2 +- src/plugins/autoschedulers/CMakeLists.txt | 24 +++++++ .../autoschedulers/adams2019/AutoSchedule.cpp | 46 +++++++------- .../autoschedulers/adams2019/CMakeLists.txt | 55 +++++++--------- .../autoschedulers/common/CMakeLists.txt | 4 ++ .../{adams2019 => common}/Errors.h | 0 .../autoschedulers/common/HalidePlugin.h | 14 +++++ .../plugins/autoschedulers/common}/cmdline.h | 0 src/plugins/autoschedulers/li2018/ASLog.cpp | 52 ---------------- src/plugins/autoschedulers/li2018/ASLog.h | 37 ----------- .../autoschedulers/li2018/CMakeLists.txt | 33 ++++------ .../li2018/GradientAutoscheduler.cpp | 47 +++++++------- .../mullapudi2016/AutoSchedule.cpp | 62 +++++++++---------- .../mullapudi2016/CMakeLists.txt | 14 +---- test/generator/CMakeLists.txt | 4 +- tools/build_halide_h.cpp | 4 +- tutorial/CMakeLists.txt | 5 +- 19 files changed, 173 insertions(+), 243 deletions(-) create mode 100644 src/plugins/autoschedulers/common/CMakeLists.txt rename src/plugins/autoschedulers/{adams2019 => common}/Errors.h (100%) create mode 100644 src/plugins/autoschedulers/common/HalidePlugin.h rename {apps/support => src/plugins/autoschedulers/common}/cmdline.h (100%) delete mode 100644 src/plugins/autoschedulers/li2018/ASLog.cpp delete mode 100644 src/plugins/autoschedulers/li2018/ASLog.h diff --git a/cmake/HalideGeneratorHelpers.cmake b/cmake/HalideGeneratorHelpers.cmake index 14159b704e3a..7b431d19f395 100644 --- a/cmake/HalideGeneratorHelpers.cmake +++ b/cmake/HalideGeneratorHelpers.cmake @@ -179,7 +179,11 @@ function(add_halide_library TARGET) set(GEN_AUTOSCHEDULER "") if (ARG_AUTOSCHEDULER) - if ("${ARG_AUTOSCHEDULER}" MATCHES "::" AND TARGET "${ARG_AUTOSCHEDULER}") + if ("${ARG_AUTOSCHEDULER}" MATCHES "::") + if (NOT TARGET "${ARG_AUTOSCHEDULER}") + message(FATAL_ERROR "Autoscheduler ${ARG_AUTOSCHEDULER} does not exist.") + endif () + # Convention: if the argument names a target like "Namespace::Scheduler" then # it is assumed to be a MODULE target providing a scheduler named "Scheduler". list(APPEND ARG_PLUGINS "${ARG_AUTOSCHEDULER}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bb168b8ee7d6..e15708e83182 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -473,4 +473,9 @@ endif () # Add compiler plugins (ie. autoschedulers) to the build. ## -add_subdirectory(plugins) +if (BUILD_SHARED_LIBS) + message(STATUS "Building autoschedulers") + add_subdirectory(plugins) +else () + message(STATUS "Not building autoschedulers (static Halide)") +endif () diff --git a/src/Pipeline.cpp b/src/Pipeline.cpp index bf97a4b31438..8a9363182488 100644 --- a/src/Pipeline.cpp +++ b/src/Pipeline.cpp @@ -207,7 +207,7 @@ AutoSchedulerFn Pipeline::find_autoscheduler(const std::string &autoscheduler_na AutoSchedulerResults Pipeline::auto_schedule(const std::string &autoscheduler_name, const Target &target, const MachineParams &arch_params) { auto autoscheduler_fn = find_autoscheduler(autoscheduler_name); - internal_assert(autoscheduler_fn) + user_assert(autoscheduler_fn) << "Could not find autoscheduler named '" << autoscheduler_name << "'.\n" << "Did you remember to load the plugin?"; diff --git a/src/plugins/autoschedulers/CMakeLists.txt b/src/plugins/autoschedulers/CMakeLists.txt index 302ea6489378..35e6af3fbce2 100644 --- a/src/plugins/autoschedulers/CMakeLists.txt +++ b/src/plugins/autoschedulers/CMakeLists.txt @@ -1,3 +1,27 @@ +function(add_autoscheduler) + set(options) + set(oneValueArgs NAME) + set(multiValueArgs SOURCES) + cmake_parse_arguments("arg" "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + add_library(Halide_${arg_NAME} MODULE ${arg_SOURCES}) + add_library(Halide::${arg_NAME} ALIAS Halide_${arg_NAME}) + + include(GenerateExportHeader) + generate_export_header(Halide_${arg_NAME} BASE_NAME autoscheduler) + target_include_directories(Halide_${arg_NAME} PRIVATE $) + + target_link_libraries(Halide_${arg_NAME} PRIVATE Halide::Plugin) + + string(TOLOWER "${arg_NAME}" name_lower) + set_target_properties(Halide_${arg_NAME} PROPERTIES + EXPORT_NAME ${arg_NAME} + OUTPUT_NAME autoschedule_${name_lower}) + +endfunction() + +add_subdirectory(common) + add_subdirectory(adams2019) add_subdirectory(li2018) add_subdirectory(mullapudi2016) diff --git a/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp b/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp index 60a1dc5e1d38..d2dc7136f4dc 100644 --- a/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp +++ b/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp @@ -64,7 +64,8 @@ TODO: expose these settings by adding some means to pass args to generator plugins instead of environment vars. */ -#include "halide_adams2019_export.h" +#include "HalidePlugin.h" +#include "autoscheduler_export.h" #include #include @@ -72,18 +73,26 @@ #include #include #include +#include +#include #include #include #include "ASLog.h" #include "AutoSchedule.h" +#include "CostModel.h" #include "DefaultCostModel.h" +#include "Errors.h" +#include "Featurization.h" +#include "FunctionDAG.h" +#include "Halide.h" #include "LoopNest.h" - -#include +#include "NetworkSize.h" +#include "PerfectHashMap.h" #ifdef _WIN32 #include +#define _isatty isatty; #endif namespace Halide { @@ -132,7 +141,7 @@ struct ProgressBar { private: uint32_t counter = 0; - const bool draw_progress_bar = _isatty(2); + const bool draw_progress_bar = isatty(2); }; // Get the HL_RANDOM_DROPOUT environment variable. Purpose of this is described above. @@ -1313,6 +1322,18 @@ void generate_schedule(const std::vector &outputs, } } +struct Adams2019 { + void operator()(const Pipeline &p, const Target &target, const MachineParams ¶ms, AutoSchedulerResults *results) { + std::vector outputs; + for (Func f : p.outputs()) { + outputs.push_back(f.function()); + } + Autoscheduler::generate_schedule(outputs, target, params, results); + } +}; + +REGISTER_AUTOSCHEDULER(Adams2019) + // An alternative entrypoint for other uses void find_and_apply_schedule(FunctionDAG &dag, const std::vector &outputs, @@ -1358,20 +1379,3 @@ void destroy(const Autoscheduler::State *t) { } // namespace Internal } // namespace Halide - -extern "C" { -HALIDE_ADAMS2019_EXPORT -const char *AutoschedulerName() { - Halide::Internal::aslog(1) << "Registering autoscheduler 'Adams2019'...\n"; - return "Adams2019"; -} - -HALIDE_ADAMS2019_EXPORT -void AutoschedulerRun(const Halide::Pipeline &p, const Halide::Target &target, const Halide::MachineParams ¶ms, Halide::AutoSchedulerResults *results) { - std::vector outputs; - for (Halide::Func f : p.outputs()) { - outputs.push_back(f.function()); - } - Halide::Internal::Autoscheduler::generate_schedule(outputs, target, params, results); -} -} diff --git a/src/plugins/autoschedulers/adams2019/CMakeLists.txt b/src/plugins/autoschedulers/adams2019/CMakeLists.txt index 4c97bc29947f..398e521c8488 100644 --- a/src/plugins/autoschedulers/adams2019/CMakeLists.txt +++ b/src/plugins/autoschedulers/adams2019/CMakeLists.txt @@ -25,36 +25,23 @@ add_executable(retrain_cost_model Weights.cpp retrain_cost_model.cpp ${WF_CPP}) -target_include_directories(retrain_cost_model - PRIVATE - # TODO(#4053): relocate. just for cmdline.h - ${PROJECT_SOURCE_DIR}/apps/support) -target_link_libraries(retrain_cost_model PRIVATE cost_model train_cost_model Halide::Halide) +target_link_libraries(retrain_cost_model PRIVATE cost_model train_cost_model Halide::Halide Halide::Plugin) ## # Main autoscheduler library ## -add_library(Halide_Adams2019 - MODULE - ASLog.cpp - AutoSchedule.cpp - DefaultCostModel.cpp - FunctionDAG.cpp - LoopNest.cpp - Weights.cpp - ${WF_CPP}) -add_library(Halide::Adams2019 ALIAS Halide_Adams2019) +add_autoscheduler(NAME Adams2019 + SOURCES + ASLog.cpp + AutoSchedule.cpp + DefaultCostModel.cpp + FunctionDAG.cpp + LoopNest.cpp + Weights.cpp + ${WF_CPP}) -include(GenerateExportHeader) -generate_export_header(Halide_Adams2019) -target_include_directories(Halide_Adams2019 PRIVATE $) - -target_link_libraries(Halide_Adams2019 PRIVATE cost_model train_cost_model Halide::Halide) - -set_target_properties(Halide_Adams2019 PROPERTIES - EXPORT_NAME Adams2019 - OUTPUT_NAME auto_schedule) +target_link_libraries(Halide_Adams2019 PRIVATE cost_model train_cost_model) ## # Tests and demos @@ -116,16 +103,18 @@ target_link_libraries(weightsdir_to_weightsfile PRIVATE Halide::Runtime) # ================================================================= # Smaller tests -add_executable(test_apps_autoscheduler test.cpp) -target_link_libraries(test_apps_autoscheduler PRIVATE Halide::Halide Halide::Tools ${CMAKE_DL_LIBS}) +if (BUILD_SHARED_LIBS) + add_executable(test_apps_autoscheduler test.cpp) + target_link_libraries(test_apps_autoscheduler PRIVATE Halide::Halide Halide::Tools ${CMAKE_DL_LIBS}) -add_test(NAME test_apps_autoscheduler - COMMAND test_apps_autoscheduler - WORKING_DIRECTORY $) + add_test(NAME test_apps_autoscheduler + COMMAND test_apps_autoscheduler + WORKING_DIRECTORY $) -set_tests_properties(test_apps_autoscheduler PROPERTIES - LABELS Adams2019 - ENVIRONMENT "LD_LIBRARY_PATH=$;HL_TARGET=${Halide_TARGET}") + set_tests_properties(test_apps_autoscheduler PROPERTIES + LABELS Adams2019 + ENVIRONMENT "LD_LIBRARY_PATH=$;HL_TARGET=${Halide_TARGET}") +endif () ## @@ -140,7 +129,7 @@ set_tests_properties(test_perfect_hash_map ## add_executable(test_function_dag test_function_dag.cpp FunctionDAG.cpp ASLog.cpp) -target_link_libraries(test_function_dag PRIVATE Halide::Halide Halide::Tools) +target_link_libraries(test_function_dag PRIVATE Halide::Halide Halide::Tools Halide::Plugin) add_test(NAME test_function_dag COMMAND test_function_dag) set_tests_properties(test_function_dag diff --git a/src/plugins/autoschedulers/common/CMakeLists.txt b/src/plugins/autoschedulers/common/CMakeLists.txt new file mode 100644 index 000000000000..90693889928b --- /dev/null +++ b/src/plugins/autoschedulers/common/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(Halide_Plugin INTERFACE) +add_library(Halide::Plugin ALIAS Halide_Plugin) +target_include_directories(Halide_Plugin INTERFACE $) +target_link_libraries(Halide_Plugin INTERFACE Halide::Halide) diff --git a/src/plugins/autoschedulers/adams2019/Errors.h b/src/plugins/autoschedulers/common/Errors.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/Errors.h rename to src/plugins/autoschedulers/common/Errors.h diff --git a/src/plugins/autoschedulers/common/HalidePlugin.h b/src/plugins/autoschedulers/common/HalidePlugin.h new file mode 100644 index 000000000000..2287cb6a309f --- /dev/null +++ b/src/plugins/autoschedulers/common/HalidePlugin.h @@ -0,0 +1,14 @@ +#ifndef HALIDE_HALIDEPLUGIN_H +#define HALIDE_HALIDEPLUGIN_H + +#include "Errors.h" + +#define REGISTER_AUTOSCHEDULER(NAME) \ + struct AUTOSCHEDULER_EXPORT Register##NAME { \ + Register##NAME() { \ + debug(1) << "Registering autoscheduler '" #NAME "'...\n"; \ + Pipeline::add_autoscheduler(#NAME, NAME()); \ + } \ + } register_##NAME; + +#endif //HALIDE_HALIDEPLUGIN_H diff --git a/apps/support/cmdline.h b/src/plugins/autoschedulers/common/cmdline.h similarity index 100% rename from apps/support/cmdline.h rename to src/plugins/autoschedulers/common/cmdline.h diff --git a/src/plugins/autoschedulers/li2018/ASLog.cpp b/src/plugins/autoschedulers/li2018/ASLog.cpp deleted file mode 100644 index 601ceabd3c71..000000000000 --- a/src/plugins/autoschedulers/li2018/ASLog.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "ASLog.h" - -namespace Halide { -namespace Internal { - -namespace { - -std::string get_env_variable(char const *env_var_name) { - if (!env_var_name) { - return ""; - } - -#ifdef _MSC_VER - // call getenv_s without a buffer to determine the correct string length: - size_t length = 0; - if ((getenv_s(&length, NULL, 0, env_var_name) != 0) || (length == 0)) { - return ""; - } - // call it again to retrieve the value of the environment variable; - // note that 'length' already accounts for the null-terminator - std::string lvl(length - 1, '@'); - size_t read = 0; - if ((getenv_s(&read, &lvl[0], length, env_var_name) != 0) || (read != length)) { - return ""; - } - return lvl; -#else - char *lvl = getenv(env_var_name); - if (lvl) return std::string(lvl); -#endif - - return ""; -} - -} // namespace - -int aslog::aslog_level() { - static int cached_aslog_level = ([]() -> int { - // If HL_DEBUG_AUTOSCHEDULE is defined, use that value. - std::string lvl = get_env_variable("HL_DEBUG_AUTOSCHEDULE"); - if (!lvl.empty()) { - return atoi(lvl.c_str()); - } - // Otherwise, use HL_DEBUG_CODEGEN. - lvl = get_env_variable("HL_DEBUG_CODEGEN"); - return !lvl.empty() ? atoi(lvl.c_str()) : 0; - })(); - return cached_aslog_level; -} - -} // namespace Internal -} // namespace Halide diff --git a/src/plugins/autoschedulers/li2018/ASLog.h b/src/plugins/autoschedulers/li2018/ASLog.h deleted file mode 100644 index 9ba9844ce342..000000000000 --- a/src/plugins/autoschedulers/li2018/ASLog.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef ASLOG_H -#define ASLOG_H - -// This class is used by train_cost_model, which doesn't link to -// libHalide, so (despite the namespace) we are better off not -// including Halide.h, lest we reference something we won't have available - -#include -#include -#include - -namespace Halide { -namespace Internal { - -class aslog { - const bool logging; - -public: - aslog(int verbosity) - : logging(verbosity <= aslog_level()) { - } - - template - aslog &operator<<(T &&x) { - if (logging) { - std::cerr << std::forward(x); - } - return *this; - } - - static int aslog_level(); -}; - -} // namespace Internal -} // namespace Halide - -#endif diff --git a/src/plugins/autoschedulers/li2018/CMakeLists.txt b/src/plugins/autoschedulers/li2018/CMakeLists.txt index 5fce7f989731..086c8029e872 100644 --- a/src/plugins/autoschedulers/li2018/CMakeLists.txt +++ b/src/plugins/autoschedulers/li2018/CMakeLists.txt @@ -1,17 +1,4 @@ -add_library(Halide_Li2018 MODULE GradientAutoscheduler.cpp) -add_library(Halide::Li2018 ALIAS Halide_Li2018) - -include(GenerateExportHeader) -generate_export_header(Halide_Li2018) -target_include_directories(Halide_Li2018 PRIVATE $) - -target_link_libraries(Halide_Li2018 PRIVATE Halide::Halide) -target_compile_definitions(Halide_Li2018 PRIVATE Halide_ERROR_MACROS) - -set_target_properties(Halide_Li2018 PROPERTIES - EXPORT_NAME Li2018 - OUTPUT_NAME gradient_autoscheduler) - +add_autoscheduler(NAME Li2018 SOURCES GradientAutoscheduler.cpp) # ========================================================== # TODO(#4053): move these to a separate folder since they're tests. @@ -35,16 +22,18 @@ set_tests_properties(demo_gradient_autoscheduler PROPERTIES LABELS Li2018) ## -add_executable(gradient_autoscheduler_test_cpp test.cpp) -target_link_libraries(gradient_autoscheduler_test_cpp PRIVATE Halide::Halide) +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 - WORKING_DIRECTORY $) + add_test(NAME gradient_autoscheduler_test_cpp + COMMAND gradient_autoscheduler_test_cpp + WORKING_DIRECTORY $) -set_tests_properties(gradient_autoscheduler_test_cpp PROPERTIES - LABELS Li2018 - ENVIRONMENT "LD_LIBRARY_PATH=$") + set_tests_properties(gradient_autoscheduler_test_cpp PROPERTIES + LABELS Li2018 + ENVIRONMENT "LD_LIBRARY_PATH=$") +endif () ## diff --git a/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp b/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp index c67ace630eb9..2c09cc27c2f1 100644 --- a/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp +++ b/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp @@ -1,16 +1,20 @@ -#include "halide_li2018_export.h" - +#include "Errors.h" #include "Halide.h" -#include -using namespace Halide; -using namespace Halide::Internal; +#include "HalidePlugin.h" +#include "autoscheduler_export.h" + +namespace Halide { +namespace Internal { +namespace Autoscheduler { + +namespace { std::map inference_bounds(const std::vector &functions, const std::vector &output_bounds) { std::vector funcs; funcs.reserve(functions.size()); for (const auto &f : functions) { - funcs.emplace_back(f); + funcs.push_back(Func(f)); } return inference_bounds(funcs, output_bounds); } @@ -814,6 +818,8 @@ void apply_schedule(const MachineParams ¶ms, schedule_source << ";\n"; } +} // namespace + void generate_schedule(const std::vector &outputs, const Target &target, const MachineParams ¶ms, @@ -923,19 +929,18 @@ void generate_schedule(const std::vector &outputs, debug(1) << schedule_source.str() << "\n"; } -extern "C" { -HALIDE_LI2018_EXPORT -const char *AutoschedulerName() { - debug(1) << "Registering autoscheduler 'Li2018'...\n"; - return "Li2018"; -} - -HALIDE_LI2018_EXPORT -void AutoschedulerRun(const Pipeline &p, const Target &target, const MachineParams ¶ms, AutoSchedulerResults *results) { - std::vector outputs; - for (Func f : p.outputs()) { - outputs.push_back(f.function()); +struct Li2018 { + void operator()(const Pipeline &p, const Target &target, const MachineParams ¶ms, AutoSchedulerResults *results) { + std::vector outputs; + for (Func f : p.outputs()) { + outputs.push_back(f.function()); + } + generate_schedule(outputs, target, params, results); } - generate_schedule(outputs, target, params, results); -} -} +}; + +REGISTER_AUTOSCHEDULER(Li2018) + +} // namespace Autoscheduler +} // namespace Internal +} // namespace Halide diff --git a/src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp b/src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp index 24bfe5140503..e9ceb7d980a0 100644 --- a/src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp +++ b/src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp @@ -1,4 +1,5 @@ -#include "halide_mullapudi2016_export.h" +#include "HalidePlugin.h" +#include "autoscheduler_export.h" #include #include @@ -6,9 +7,10 @@ #include #include -#include -using namespace Halide; -using namespace Halide::Internal; +#include "Halide.h" + +namespace Halide { +namespace Internal { using std::make_pair; using std::map; @@ -3159,11 +3161,9 @@ bool inline_unbounded(const vector &outputs, } // anonymous namespace -/** Generate schedules for Funcs within a pipeline. The Funcs should not already - * have specializations or schedules as the current auto-scheduler does not take - * into account user-defined schedules or specializations. This applies the - * schedules and returns a string representation of the schedules. The target - * architecture is specified by 'target'. */ +// Generate schedules for all functions in the pipeline required to compute the +// outputs. This applies the schedules and returns a string representation of +// the schedules. The target architecture is specified by 'target'. string generate_schedules(const vector &outputs, const Target &target, const MachineParams &arch_params) { // Make an environment map which is used throughout the auto scheduling process. @@ -3370,29 +3370,29 @@ string generate_schedules(const vector &outputs, const Target &target, return sched_string; } -extern "C" { -HALIDE_MULLAPUDI2016_EXPORT -const char *AutoschedulerName() { - return "Mullapudi2016"; -} +struct Mullapudi2016 { + void operator()(const Pipeline &pipeline, const Target &target, const MachineParams &arch_params, AutoSchedulerResults *outputs) { + AutoSchedulerResults results; + results.target = target; + results.machine_params_string = arch_params.to_string(); -HALIDE_MULLAPUDI2016_EXPORT -void AutoschedulerRun(const Pipeline &pipeline, const Target &target, const MachineParams &arch_params, AutoSchedulerResults *outputs) { - AutoSchedulerResults results; - results.target = target; - results.machine_params_string = arch_params.to_string(); + user_assert(target.arch == Target::X86 || target.arch == Target::ARM || + target.arch == Target::POWERPC || target.arch == Target::MIPS) + << "The Mullapudi2016 autoscheduler is not supported for the target: " << target.to_string(); + results.scheduler_name = "Mullapudi2016"; + std::vector pipeline_outputs; + for (Func f : pipeline.outputs()) { + pipeline_outputs.push_back(f.function()); + } + results.schedule_source = generate_schedules(pipeline_outputs, target, arch_params); + // this autoscheduler has no featurization - user_assert(target.arch == Target::X86 || target.arch == Target::ARM || - target.arch == Target::POWERPC || target.arch == Target::MIPS) - << "The Mullapudi2016 autoscheduler is not supported for the target: " << target.to_string(); - results.scheduler_name = AutoschedulerName(); - std::vector pipeline_outputs; - for (Func f : pipeline.outputs()) { - pipeline_outputs.push_back(f.function()); + *outputs = results; } - results.schedule_source = generate_schedules(pipeline_outputs, target, arch_params); - // this autoscheduler has no featurization +}; - *outputs = results; -} -} +REGISTER_AUTOSCHEDULER(Mullapudi2016) + +} // namespace Internal + +} // namespace Halide diff --git a/src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt b/src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt index 3556e5be4a0c..41a21ab1b086 100644 --- a/src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt +++ b/src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt @@ -1,13 +1 @@ -add_library(Halide_Mullapudi2016 MODULE AutoSchedule.cpp) -add_library(Halide::Mullapudi2016 ALIAS Halide_Mullapudi2016) - -include(GenerateExportHeader) -generate_export_header(Halide_Mullapudi2016) -target_include_directories(Halide_Mullapudi2016 PRIVATE $) - -target_link_libraries(Halide_Mullapudi2016 PRIVATE Halide::Halide) -target_compile_definitions(Halide_Mullapudi2016 PRIVATE Halide_ERROR_MACROS) - -set_target_properties(Halide_Mullapudi2016 PROPERTIES - EXPORT_NAME Mullapudi2016 - OUTPUT_NAME mullapudi2016) +add_autoscheduler(NAME Mullapudi2016 SOURCES AutoSchedule.cpp) diff --git a/test/generator/CMakeLists.txt b/test/generator/CMakeLists.txt index f1b85b4dd696..d5eeeb29f619 100644 --- a/test/generator/CMakeLists.txt +++ b/test/generator/CMakeLists.txt @@ -153,9 +153,7 @@ halide_define_aot_test(async_parallel # autograd_aottest.cpp # autograd_generator.cpp -halide_define_aot_test(autograd - # Requires Mullapudi2016 autoscheduler, which doesn't support wasm - ENABLE_IF NOT ${USING_WASM}) +halide_define_aot_test(autograd ENABLE_IF TARGET Halide::Mullapudi2016) if (TARGET generator_aot_autograd) add_halide_library(autograd_grad GRADIENT_DESCENT diff --git a/tools/build_halide_h.cpp b/tools/build_halide_h.cpp index d0073cec5146..ac2eba7ce98c 100644 --- a/tools/build_halide_h.cpp +++ b/tools/build_halide_h.cpp @@ -82,15 +82,13 @@ int main(int argc, char **files) { fprintf(stdout, "\n"); fprintf(stdout, "// Clean up macros used inside Halide headers\n" - "#ifndef Halide_ERROR_MACROS\n" "#undef user_assert\n" "#undef user_error\n" "#undef user_warning\n" "#undef internal_error\n" "#undef internal_assert\n" "#undef halide_runtime_error\n" - "#undef HALIDE_EXPORT\n" - "#endif // Halide_ERROR_MACROS\n\n" + "#undef HALIDE_EXPORT\n\n" "#endif // HALIDE_H\n"); return 0; diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt index 9ae3c7fd8a8e..1f5dfc439d07 100644 --- a/tutorial/CMakeLists.txt +++ b/tutorial/CMakeLists.txt @@ -188,10 +188,7 @@ add_tutorial(lesson_19_wrapper_funcs.cpp) add_tutorial(lesson_20_cloning_funcs.cpp) # Lesson 21 -if (TARGET_WEBASSEMBLY AND Halide_TARGET MATCHES "wasm") - # TODO: Requires custom build rules to work under wasm - message(WARNING "Not all tutorials build under WASM.") -else () +if (TARGET Halide::Mullapudi2016) add_executable(lesson_21_auto_scheduler_generate lesson_21_auto_scheduler_generate.cpp) target_link_libraries(lesson_21_auto_scheduler_generate PRIVATE Halide::Generator) From 163d95458ddc75869d804c52319ae7670bec88a3 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Mon, 7 Sep 2020 00:48:42 -0700 Subject: [PATCH 06/31] Fix autoscheduler packaging. --- CMakeLists.txt | 2 +- packaging/CMakeLists.txt | 9 +++++++-- packaging/HalideConfig.cmake | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a51d352c4aa1..02814e065873 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) message(STATUS "Building Python bindings disabled") endif () - option(WITH_APPS "Build apps" ON) + cmake_dependent_option(WITH_APPS "Build apps" ON "BUILD_SHARED_LIBS" OFF) if (WITH_APPS) message(STATUS "Building apps enabled") add_subdirectory(apps) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index 34d8d3504a45..842fe81a94e1 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -24,9 +24,14 @@ endforeach () # Main library exports ## -# TODO(#4053): add autoschedulers when refactored +set(optional_targets "") +foreach (target IN ITEMS Halide_Adams2019 Halide_Li2018 Halide_Mullapudi2016) + if (TARGET ${target}) + list(APPEND optional_targets ${target}) + endif () +endforeach () -install(TARGETS Halide Halide_Generator Halide_RunGenMain +install(TARGETS Halide Halide_Generator Halide_RunGenMain ${optional_targets} EXPORT Halide_Targets RUNTIME diff --git a/packaging/HalideConfig.cmake b/packaging/HalideConfig.cmake index e54aff545d0b..b364086960ce 100644 --- a/packaging/HalideConfig.cmake +++ b/packaging/HalideConfig.cmake @@ -62,7 +62,7 @@ macro(_Halide_include TYPE CAUSE) include("${CMAKE_CURRENT_LIST_DIR}/Halide-Targets-${TYPE}.cmake") if (NOT ${CMAKE_FIND_PACKAGE_NAME}_both) - foreach (target IN ITEMS Halide Generator RunGenMain) + foreach (target IN ITEMS Halide Generator RunGenMain Adams2019 Li2018 Mullapudi2016) if (NOT TARGET Halide::${TYPE}::${target}) continue() endif () From 8ec729ebb1bd1ff1047a711309c18d335110f091 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Mon, 7 Sep 2020 04:02:02 -0700 Subject: [PATCH 07/31] Fix auto schedule tests. --- cmake/HalideTestHelpers.cmake | 16 ++++---- src/Pipeline.cpp | 3 ++ .../autoschedulers/adams2019/CMakeLists.txt | 3 +- src/plugins/autoschedulers/adams2019/test.cpp | 5 +-- .../autoschedulers/li2018/CMakeLists.txt | 7 +--- src/plugins/autoschedulers/li2018/test.cpp | 5 +-- test/auto_schedule/CMakeLists.txt | 41 +++++++++++-------- test/auto_schedule/cost_function.cpp | 4 +- test/auto_schedule/data_dependent.cpp | 4 +- test/auto_schedule/extern.cpp | 4 +- test/auto_schedule/fibonacci.cpp | 4 +- test/auto_schedule/histogram.cpp | 4 +- test/auto_schedule/large_window.cpp | 4 +- test/auto_schedule/mat_mul.cpp | 4 +- test/auto_schedule/max_filter.cpp | 4 +- test/auto_schedule/multi_output.cpp | 4 +- test/auto_schedule/overlap.cpp | 4 +- test/auto_schedule/param.cpp | 4 +- test/auto_schedule/reorder.cpp | 4 +- .../small_pure_update.cpp} | 8 +++- test/auto_schedule/tile_vs_inline.cpp | 4 +- test/auto_schedule/unused_func.cpp | 4 +- .../auto_schedule/vectorize_var_in_update.cpp | 4 +- test/correctness/CMakeLists.txt | 1 - 24 files changed, 90 insertions(+), 59 deletions(-) rename test/{correctness/autoschedule_small_pure_update.cpp => auto_schedule/small_pure_update.cpp} (75%) diff --git a/cmake/HalideTestHelpers.cmake b/cmake/HalideTestHelpers.cmake index d049d5cf004b..7fe18e35630e 100644 --- a/cmake/HalideTestHelpers.cmake +++ b/cmake/HalideTestHelpers.cmake @@ -38,7 +38,7 @@ endif () function(add_halide_test TARGET) set(options EXPECT_FAILURE) set(oneValueArgs WORKING_DIRECTORY) - set(multiValueArgs GROUPS COMMAND) + set(multiValueArgs GROUPS COMMAND ARGS) cmake_parse_arguments(args "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if (NOT args_COMMAND) @@ -46,17 +46,15 @@ function(add_halide_test TARGET) endif () add_test(NAME ${TARGET} - COMMAND ${args_COMMAND} + COMMAND ${args_COMMAND} ${args_ARGS} WORKING_DIRECTORY "${args_WORKING_DIRECTORY}") set_tests_properties(${TARGET} PROPERTIES LABELS "${args_GROUPS}" ENVIRONMENT "HL_TARGET=${Halide_TARGET};HL_JIT_TARGET=${Halide_TARGET}" PASS_REGULAR_EXPRESSION "Success!" - SKIP_REGULAR_EXPRESSION "\\[SKIP\\]") - if (${args_EXPECT_FAILURE}) - set_tests_properties(${TARGET} PROPERTIES WILL_FAIL true) - endif () + SKIP_REGULAR_EXPRESSION "\\[SKIP\\]" + WILL_FAIL ${args_EXPECT_FAILURE}) # Add a meta-target for each group, to allow us to build by group easily foreach (GROUP IN LISTS args_GROUPS) @@ -72,7 +70,7 @@ endfunction() function(tests) set(options EXPECT_FAILURE) set(oneValueArgs) - set(multiValueArgs SOURCES GROUPS) + set(multiValueArgs SOURCES GROUPS ARGS) cmake_parse_arguments(args "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) list(GET args_GROUPS 0 PRIMARY_GROUP) @@ -91,10 +89,10 @@ function(tests) endif () if (args_EXPECT_FAILURE) - add_halide_test("${TARGET}" GROUPS ${args_GROUPS} EXPECT_FAILURE) + add_halide_test("${TARGET}" ARGS ${args_ARGS} GROUPS ${args_GROUPS} EXPECT_FAILURE) target_link_libraries("${TARGET}" PRIVATE Halide::ExpectAbort) else () - add_halide_test("${TARGET}" GROUPS ${args_GROUPS}) + add_halide_test("${TARGET}" ARGS ${args_ARGS} GROUPS ${args_GROUPS}) endif () endforeach () diff --git a/src/Pipeline.cpp b/src/Pipeline.cpp index 8a9363182488..e4d24cf679a9 100644 --- a/src/Pipeline.cpp +++ b/src/Pipeline.cpp @@ -187,6 +187,9 @@ std::map &Pipeline::get_autoscheduler_map() { /* static */ std::string &Pipeline::get_default_autoscheduler_name() { static std::string autoscheduler_name = ""; + if (autoscheduler_name.empty() && !get_autoscheduler_map().empty()) { + autoscheduler_name = get_autoscheduler_map().begin()->first; + } return autoscheduler_name; } diff --git a/src/plugins/autoschedulers/adams2019/CMakeLists.txt b/src/plugins/autoschedulers/adams2019/CMakeLists.txt index 398e521c8488..55c1800057f3 100644 --- a/src/plugins/autoschedulers/adams2019/CMakeLists.txt +++ b/src/plugins/autoschedulers/adams2019/CMakeLists.txt @@ -108,8 +108,7 @@ if (BUILD_SHARED_LIBS) target_link_libraries(test_apps_autoscheduler PRIVATE Halide::Halide Halide::Tools ${CMAKE_DL_LIBS}) add_test(NAME test_apps_autoscheduler - COMMAND test_apps_autoscheduler - WORKING_DIRECTORY $) + COMMAND test_apps_autoscheduler $) set_tests_properties(test_apps_autoscheduler PROPERTIES LABELS Adams2019 diff --git a/src/plugins/autoschedulers/adams2019/test.cpp b/src/plugins/autoschedulers/adams2019/test.cpp index 7e62e479ba36..2878e2d5f8ff 100644 --- a/src/plugins/autoschedulers/adams2019/test.cpp +++ b/src/plugins/autoschedulers/adams2019/test.cpp @@ -3,10 +3,7 @@ using namespace Halide; int main(int argc, char **argv) { - // Loads lib auto_schedule.so (or auto_schedule.dll), - // which is presumed to be in current library search path - load_plugin("auto_schedule"); - Pipeline::set_default_autoscheduler_name("Adams2019"); + load_plugin(argv[1]); MachineParams params(32, 16000000, 40); // Use a fixed target for the analysis to get consistent results from this test. diff --git a/src/plugins/autoschedulers/li2018/CMakeLists.txt b/src/plugins/autoschedulers/li2018/CMakeLists.txt index 086c8029e872..1a6aaad5dc72 100644 --- a/src/plugins/autoschedulers/li2018/CMakeLists.txt +++ b/src/plugins/autoschedulers/li2018/CMakeLists.txt @@ -27,12 +27,9 @@ if (BUILD_SHARED_LIBS) target_link_libraries(gradient_autoscheduler_test_cpp PRIVATE Halide::Halide) add_test(NAME gradient_autoscheduler_test_cpp - COMMAND gradient_autoscheduler_test_cpp - WORKING_DIRECTORY $) + COMMAND gradient_autoscheduler_test_cpp $) - set_tests_properties(gradient_autoscheduler_test_cpp PROPERTIES - LABELS Li2018 - ENVIRONMENT "LD_LIBRARY_PATH=$") + set_tests_properties(gradient_autoscheduler_test_cpp PROPERTIES LABELS Li2018) endif () ## diff --git a/src/plugins/autoschedulers/li2018/test.cpp b/src/plugins/autoschedulers/li2018/test.cpp index d07d3866c13b..342759441fe8 100644 --- a/src/plugins/autoschedulers/li2018/test.cpp +++ b/src/plugins/autoschedulers/li2018/test.cpp @@ -3,10 +3,7 @@ using namespace Halide; int main(int argc, char **argv) { - // Loads libgradient_autoscheduler.so (or gradient_autoscheduler.dll), - // which is presumed to be in current library search path - load_plugin("gradient_autoscheduler"); - Pipeline::set_default_autoscheduler_name("Li2018"); + load_plugin(argv[1]); MachineParams params(32, 16000000, 40); Target target; diff --git a/test/auto_schedule/CMakeLists.txt b/test/auto_schedule/CMakeLists.txt index 0222c5d6e737..668175d51ab5 100644 --- a/test/auto_schedule/CMakeLists.txt +++ b/test/auto_schedule/CMakeLists.txt @@ -1,18 +1,23 @@ -tests(GROUPS auto_schedule - SOURCES - cost_function.cpp - data_dependent.cpp - extern.cpp - fibonacci.cpp - histogram.cpp - large_window.cpp - mat_mul.cpp - max_filter.cpp - multi_output.cpp - overlap.cpp - param.cpp - reorder.cpp - tile_vs_inline.cpp - unused_func.cpp - vectorize_var_in_update.cpp - ) +if (TARGET Halide::Mullapudi2016) + tests(GROUPS auto_schedule + SOURCES + cost_function.cpp + data_dependent.cpp + extern.cpp + fibonacci.cpp + histogram.cpp + large_window.cpp + mat_mul.cpp + max_filter.cpp + multi_output.cpp + overlap.cpp + param.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 () diff --git a/test/auto_schedule/cost_function.cpp b/test/auto_schedule/cost_function.cpp index d1d4a07a9a18..8efa4c56e768 100644 --- a/test/auto_schedule/cost_function.cpp +++ b/test/auto_schedule/cost_function.cpp @@ -4,10 +4,12 @@ using namespace Halide; int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + int W = 6400; int H = 4800; Buffer input(W, H); diff --git a/test/auto_schedule/data_dependent.cpp b/test/auto_schedule/data_dependent.cpp index 8cda0e0758c4..d473c72e49af 100644 --- a/test/auto_schedule/data_dependent.cpp +++ b/test/auto_schedule/data_dependent.cpp @@ -4,10 +4,12 @@ using namespace Halide; int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + int W = 800; int H = 800; Buffer input(W, H); diff --git a/test/auto_schedule/extern.cpp b/test/auto_schedule/extern.cpp index 581f7d4b9c92..6acf3568e169 100644 --- a/test/auto_schedule/extern.cpp +++ b/test/auto_schedule/extern.cpp @@ -128,10 +128,12 @@ void test_case_3() { int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + test_case_1(); test_case_2(); test_case_3(); diff --git a/test/auto_schedule/fibonacci.cpp b/test/auto_schedule/fibonacci.cpp index 19cec9c1cbef..86ae68db7eaa 100644 --- a/test/auto_schedule/fibonacci.cpp +++ b/test/auto_schedule/fibonacci.cpp @@ -39,10 +39,12 @@ double run_test(bool auto_schedule) { int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + double manual_time = run_test(false); double auto_time = run_test(true); diff --git a/test/auto_schedule/histogram.cpp b/test/auto_schedule/histogram.cpp index f74d3b4d6713..ee95309d6022 100644 --- a/test/auto_schedule/histogram.cpp +++ b/test/auto_schedule/histogram.cpp @@ -120,10 +120,12 @@ double run_test(bool auto_schedule) { int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + double manual_time = run_test(false); double auto_time = run_test(true); diff --git a/test/auto_schedule/large_window.cpp b/test/auto_schedule/large_window.cpp index 7d7431a2f24a..53a611a5df5d 100644 --- a/test/auto_schedule/large_window.cpp +++ b/test/auto_schedule/large_window.cpp @@ -4,10 +4,12 @@ using namespace Halide; int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + int W = 800; int H = 1200; diff --git a/test/auto_schedule/mat_mul.cpp b/test/auto_schedule/mat_mul.cpp index a35ee0a53f29..0370cd150a64 100644 --- a/test/auto_schedule/mat_mul.cpp +++ b/test/auto_schedule/mat_mul.cpp @@ -123,10 +123,12 @@ double run_test(bool auto_schedule) { int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + double manual_time = run_test(false); double auto_time = run_test(true); diff --git a/test/auto_schedule/max_filter.cpp b/test/auto_schedule/max_filter.cpp index 08740d3f92ea..5c47b63db4de 100644 --- a/test/auto_schedule/max_filter.cpp +++ b/test/auto_schedule/max_filter.cpp @@ -123,10 +123,12 @@ double run_test(bool auto_schedule) { int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + double manual_time = run_test(false); double auto_time = run_test(true); diff --git a/test/auto_schedule/multi_output.cpp b/test/auto_schedule/multi_output.cpp index 30042bb801fb..2c795181d3f1 100644 --- a/test/auto_schedule/multi_output.cpp +++ b/test/auto_schedule/multi_output.cpp @@ -4,10 +4,12 @@ using namespace Halide; int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + int W = 1000; int H = 1000; Buffer input(W, H); diff --git a/test/auto_schedule/overlap.cpp b/test/auto_schedule/overlap.cpp index b37a3a7c6337..8df1bea9925d 100644 --- a/test/auto_schedule/overlap.cpp +++ b/test/auto_schedule/overlap.cpp @@ -5,10 +5,12 @@ using namespace Halide; int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + Var x("x"), y("y"), xi("xi"), yi("yi"); Buffer input = lambda(x, y, sin(x) + cos(y) + 1.0f).realize(2200, 2200); diff --git a/test/auto_schedule/param.cpp b/test/auto_schedule/param.cpp index ca50d9032a9a..c04b7475d4e9 100644 --- a/test/auto_schedule/param.cpp +++ b/test/auto_schedule/param.cpp @@ -115,10 +115,12 @@ void run_test_4() { int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + std::cout << "Test 1:\n"; run_test_1(); std::cout << "Test 2:\n"; diff --git a/test/auto_schedule/reorder.cpp b/test/auto_schedule/reorder.cpp index 5149fdfe18fe..6e5b6485913b 100644 --- a/test/auto_schedule/reorder.cpp +++ b/test/auto_schedule/reorder.cpp @@ -138,10 +138,12 @@ double run_test_3(bool auto_schedule) { int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + const double slowdown_factor = 6.0; { diff --git a/test/correctness/autoschedule_small_pure_update.cpp b/test/auto_schedule/small_pure_update.cpp similarity index 75% rename from test/correctness/autoschedule_small_pure_update.cpp rename to test/auto_schedule/small_pure_update.cpp index a59564b0597e..d8e990550afd 100644 --- a/test/correctness/autoschedule_small_pure_update.cpp +++ b/test/auto_schedule/small_pure_update.cpp @@ -1,8 +1,14 @@ #include "Halide.h" - using namespace Halide; int main(int argc, char **argv) { + if (get_jit_target_from_environment().arch == Target::WebAssembly) { + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); + return 0; + } + + load_plugin(argv[1]); + Buffer in(13, 17); ImageParam in_param(Float(32), 2); diff --git a/test/auto_schedule/tile_vs_inline.cpp b/test/auto_schedule/tile_vs_inline.cpp index 5dce5a306ab3..80e96fca1e4c 100644 --- a/test/auto_schedule/tile_vs_inline.cpp +++ b/test/auto_schedule/tile_vs_inline.cpp @@ -4,10 +4,12 @@ using namespace Halide; int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + int W = 1024; int H = 1024; diff --git a/test/auto_schedule/unused_func.cpp b/test/auto_schedule/unused_func.cpp index 8d084c12d975..5fa248a7a4a9 100644 --- a/test/auto_schedule/unused_func.cpp +++ b/test/auto_schedule/unused_func.cpp @@ -4,10 +4,12 @@ using namespace Halide; int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + Var x("x"), y("y"); Func f("f"), g("g"), h("h"); diff --git a/test/auto_schedule/vectorize_var_in_update.cpp b/test/auto_schedule/vectorize_var_in_update.cpp index a8db91e90b0d..49bb191fee0b 100644 --- a/test/auto_schedule/vectorize_var_in_update.cpp +++ b/test/auto_schedule/vectorize_var_in_update.cpp @@ -5,10 +5,12 @@ using namespace Halide; int main(int argc, char **argv) { if (get_jit_target_from_environment().arch == Target::WebAssembly) { - printf("[SKIP] Mullapudi2016 autoscheduler does not support WebAssembly.\n"); + printf("[SKIP] Autoschedulers do not support WebAssembly.\n"); return 0; } + load_plugin(argv[1]); + // This test is making sure that the auto-scheduler picks the appropriate // tail strategy when splitting the var of an update definition. // The default tail strategy for this case (i.e. RoundUp) will cause diff --git a/test/correctness/CMakeLists.txt b/test/correctness/CMakeLists.txt index f82c777170fa..8c3c5d4638bf 100644 --- a/test/correctness/CMakeLists.txt +++ b/test/correctness/CMakeLists.txt @@ -14,7 +14,6 @@ tests(GROUPS correctness atomic_tuples.cpp atomics.cpp autodiff.cpp - autoschedule_small_pure_update.cpp autotune_bug.cpp autotune_bug_2.cpp autotune_bug_3.cpp From 9ab81068a60b17fcd0cfc30f62f250c68b4b8d07 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Fri, 11 Sep 2020 14:34:20 -0700 Subject: [PATCH 08/31] Use (and fix) export macros in Util.h --- src/CMakeLists.txt | 2 +- src/Util.h | 8 +++++--- src/plugins/autoschedulers/CMakeLists.txt | 6 +----- src/plugins/autoschedulers/adams2019/AutoSchedule.cpp | 1 - src/plugins/autoschedulers/common/HalidePlugin.h | 2 +- .../autoschedulers/li2018/GradientAutoscheduler.cpp | 1 - src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp | 1 - 7 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e15708e83182..baa6a1fcf9cd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -373,7 +373,7 @@ add_library(Halide::Halide ALIAS Halide) target_link_libraries(Halide PRIVATE Halide::LLVM) target_link_libraries(Halide PUBLIC Halide::LanguageOptions) -target_compile_definitions(Halide PRIVATE $<$>:Halide_STATIC_DEFINE>) +target_compile_definitions(Halide PRIVATE $<$,STATIC_LIBRARY>:Halide_STATIC_DEFINE>) set_target_properties(Halide PROPERTIES POSITION_INDEPENDENT_CODE ON diff --git a/src/Util.h b/src/Util.h index dff866529333..fb8791df4687 100644 --- a/src/Util.h +++ b/src/Util.h @@ -22,8 +22,10 @@ #include "runtime/HalideRuntime.h" -#ifndef HALIDE_EXPORT -#if defined(_MSC_VER) && !defined(Halide_STATIC_DEFINE) +#ifdef Halide_STATIC_DEFINE +#define HALIDE_EXPORT +#else +#if defined(_MSC_VER) // Halide_EXPORTS is quietly defined by CMake when building a shared library #ifdef Halide_EXPORTS #define HALIDE_EXPORT __declspec(dllexport) @@ -31,7 +33,7 @@ #define HALIDE_EXPORT __declspec(dllimport) #endif #else -#define HALIDE_EXPORT +#define HALIDE_EXPORT __attribute__((visibility("default"))) #endif #endif diff --git a/src/plugins/autoschedulers/CMakeLists.txt b/src/plugins/autoschedulers/CMakeLists.txt index 35e6af3fbce2..04eb90e417ed 100644 --- a/src/plugins/autoschedulers/CMakeLists.txt +++ b/src/plugins/autoschedulers/CMakeLists.txt @@ -7,17 +7,13 @@ function(add_autoscheduler) add_library(Halide_${arg_NAME} MODULE ${arg_SOURCES}) add_library(Halide::${arg_NAME} ALIAS Halide_${arg_NAME}) - include(GenerateExportHeader) - generate_export_header(Halide_${arg_NAME} BASE_NAME autoscheduler) - target_include_directories(Halide_${arg_NAME} PRIVATE $) - + target_compile_definitions(Halide_${arg_NAME} PRIVATE Halide_EXPORTS) target_link_libraries(Halide_${arg_NAME} PRIVATE Halide::Plugin) string(TOLOWER "${arg_NAME}" name_lower) set_target_properties(Halide_${arg_NAME} PROPERTIES EXPORT_NAME ${arg_NAME} OUTPUT_NAME autoschedule_${name_lower}) - endfunction() add_subdirectory(common) diff --git a/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp b/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp index d2dc7136f4dc..12fd5ee9abeb 100644 --- a/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp +++ b/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp @@ -65,7 +65,6 @@ generator plugins instead of environment vars. */ #include "HalidePlugin.h" -#include "autoscheduler_export.h" #include #include diff --git a/src/plugins/autoschedulers/common/HalidePlugin.h b/src/plugins/autoschedulers/common/HalidePlugin.h index 2287cb6a309f..7e6636bb09c0 100644 --- a/src/plugins/autoschedulers/common/HalidePlugin.h +++ b/src/plugins/autoschedulers/common/HalidePlugin.h @@ -4,7 +4,7 @@ #include "Errors.h" #define REGISTER_AUTOSCHEDULER(NAME) \ - struct AUTOSCHEDULER_EXPORT Register##NAME { \ + struct HALIDE_EXPORT Register##NAME { \ Register##NAME() { \ debug(1) << "Registering autoscheduler '" #NAME "'...\n"; \ Pipeline::add_autoscheduler(#NAME, NAME()); \ diff --git a/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp b/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp index 2c09cc27c2f1..538534b90d10 100644 --- a/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp +++ b/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp @@ -1,7 +1,6 @@ #include "Errors.h" #include "Halide.h" #include "HalidePlugin.h" -#include "autoscheduler_export.h" namespace Halide { namespace Internal { diff --git a/src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp b/src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp index e9ceb7d980a0..497a31f97f09 100644 --- a/src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp +++ b/src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp @@ -1,5 +1,4 @@ #include "HalidePlugin.h" -#include "autoscheduler_export.h" #include #include From 646b049577414db685c05b98ea849903686895bb Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Fri, 11 Sep 2020 14:45:58 -0700 Subject: [PATCH 09/31] Keep HALIDE_EXPORT defined. --- tools/build_halide_h.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/build_halide_h.cpp b/tools/build_halide_h.cpp index ac2eba7ce98c..a170547e870f 100644 --- a/tools/build_halide_h.cpp +++ b/tools/build_halide_h.cpp @@ -88,7 +88,6 @@ int main(int argc, char **files) { "#undef internal_error\n" "#undef internal_assert\n" "#undef halide_runtime_error\n" - "#undef HALIDE_EXPORT\n\n" "#endif // HALIDE_H\n"); return 0; From a0972ab6f45f09d8578ebfcccc93f884043b0ac6 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Fri, 11 Sep 2020 15:19:36 -0700 Subject: [PATCH 10/31] Add argc error messages to autoscheduler loads. --- src/plugins/autoschedulers/adams2019/test.cpp | 5 +++++ src/plugins/autoschedulers/li2018/test.cpp | 5 +++++ test/auto_schedule/cost_function.cpp | 5 +++++ test/auto_schedule/data_dependent.cpp | 5 +++++ test/auto_schedule/extern.cpp | 5 +++++ test/auto_schedule/fibonacci.cpp | 5 +++++ test/auto_schedule/histogram.cpp | 5 +++++ test/auto_schedule/large_window.cpp | 5 +++++ test/auto_schedule/mat_mul.cpp | 5 +++++ test/auto_schedule/max_filter.cpp | 5 +++++ test/auto_schedule/multi_output.cpp | 5 +++++ test/auto_schedule/overlap.cpp | 5 +++++ test/auto_schedule/param.cpp | 5 +++++ test/auto_schedule/reorder.cpp | 5 +++++ test/auto_schedule/small_pure_update.cpp | 5 +++++ test/auto_schedule/tile_vs_inline.cpp | 5 +++++ test/auto_schedule/unused_func.cpp | 5 +++++ test/auto_schedule/vectorize_var_in_update.cpp | 5 +++++ 18 files changed, 90 insertions(+) diff --git a/src/plugins/autoschedulers/adams2019/test.cpp b/src/plugins/autoschedulers/adams2019/test.cpp index 2878e2d5f8ff..c710871c6185 100644 --- a/src/plugins/autoschedulers/adams2019/test.cpp +++ b/src/plugins/autoschedulers/adams2019/test.cpp @@ -3,6 +3,11 @@ using namespace Halide; int main(int argc, char **argv) { + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); MachineParams params(32, 16000000, 40); diff --git a/src/plugins/autoschedulers/li2018/test.cpp b/src/plugins/autoschedulers/li2018/test.cpp index 342759441fe8..6518cda38960 100644 --- a/src/plugins/autoschedulers/li2018/test.cpp +++ b/src/plugins/autoschedulers/li2018/test.cpp @@ -3,6 +3,11 @@ using namespace Halide; int main(int argc, char **argv) { + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); MachineParams params(32, 16000000, 40); diff --git a/test/auto_schedule/cost_function.cpp b/test/auto_schedule/cost_function.cpp index 8efa4c56e768..4cdf4ea10377 100644 --- a/test/auto_schedule/cost_function.cpp +++ b/test/auto_schedule/cost_function.cpp @@ -8,6 +8,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); int W = 6400; diff --git a/test/auto_schedule/data_dependent.cpp b/test/auto_schedule/data_dependent.cpp index d473c72e49af..d42a8f75eafe 100644 --- a/test/auto_schedule/data_dependent.cpp +++ b/test/auto_schedule/data_dependent.cpp @@ -8,6 +8,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); int W = 800; diff --git a/test/auto_schedule/extern.cpp b/test/auto_schedule/extern.cpp index 6acf3568e169..e442d8aca902 100644 --- a/test/auto_schedule/extern.cpp +++ b/test/auto_schedule/extern.cpp @@ -132,6 +132,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); test_case_1(); diff --git a/test/auto_schedule/fibonacci.cpp b/test/auto_schedule/fibonacci.cpp index 86ae68db7eaa..a394af50a921 100644 --- a/test/auto_schedule/fibonacci.cpp +++ b/test/auto_schedule/fibonacci.cpp @@ -43,6 +43,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); double manual_time = run_test(false); diff --git a/test/auto_schedule/histogram.cpp b/test/auto_schedule/histogram.cpp index ee95309d6022..c51cac7436b4 100644 --- a/test/auto_schedule/histogram.cpp +++ b/test/auto_schedule/histogram.cpp @@ -124,6 +124,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); double manual_time = run_test(false); diff --git a/test/auto_schedule/large_window.cpp b/test/auto_schedule/large_window.cpp index 53a611a5df5d..923a8470c1ab 100644 --- a/test/auto_schedule/large_window.cpp +++ b/test/auto_schedule/large_window.cpp @@ -8,6 +8,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); int W = 800; diff --git a/test/auto_schedule/mat_mul.cpp b/test/auto_schedule/mat_mul.cpp index 0370cd150a64..07e5fefce2ca 100644 --- a/test/auto_schedule/mat_mul.cpp +++ b/test/auto_schedule/mat_mul.cpp @@ -127,6 +127,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); double manual_time = run_test(false); diff --git a/test/auto_schedule/max_filter.cpp b/test/auto_schedule/max_filter.cpp index 5c47b63db4de..fa9b72706d5d 100644 --- a/test/auto_schedule/max_filter.cpp +++ b/test/auto_schedule/max_filter.cpp @@ -127,6 +127,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); double manual_time = run_test(false); diff --git a/test/auto_schedule/multi_output.cpp b/test/auto_schedule/multi_output.cpp index 2c795181d3f1..f00f4ee09fa3 100644 --- a/test/auto_schedule/multi_output.cpp +++ b/test/auto_schedule/multi_output.cpp @@ -8,6 +8,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); int W = 1000; diff --git a/test/auto_schedule/overlap.cpp b/test/auto_schedule/overlap.cpp index 8df1bea9925d..d9e7fdf14232 100644 --- a/test/auto_schedule/overlap.cpp +++ b/test/auto_schedule/overlap.cpp @@ -9,6 +9,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); Var x("x"), y("y"), xi("xi"), yi("yi"); diff --git a/test/auto_schedule/param.cpp b/test/auto_schedule/param.cpp index c04b7475d4e9..1db0458d0e2f 100644 --- a/test/auto_schedule/param.cpp +++ b/test/auto_schedule/param.cpp @@ -119,6 +119,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); std::cout << "Test 1:\n"; diff --git a/test/auto_schedule/reorder.cpp b/test/auto_schedule/reorder.cpp index 6e5b6485913b..24c4893051f7 100644 --- a/test/auto_schedule/reorder.cpp +++ b/test/auto_schedule/reorder.cpp @@ -142,6 +142,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); const double slowdown_factor = 6.0; diff --git a/test/auto_schedule/small_pure_update.cpp b/test/auto_schedule/small_pure_update.cpp index d8e990550afd..6d3fe2d2219b 100644 --- a/test/auto_schedule/small_pure_update.cpp +++ b/test/auto_schedule/small_pure_update.cpp @@ -7,6 +7,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); Buffer in(13, 17); diff --git a/test/auto_schedule/tile_vs_inline.cpp b/test/auto_schedule/tile_vs_inline.cpp index 80e96fca1e4c..1df108ac4a67 100644 --- a/test/auto_schedule/tile_vs_inline.cpp +++ b/test/auto_schedule/tile_vs_inline.cpp @@ -8,6 +8,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); int W = 1024; diff --git a/test/auto_schedule/unused_func.cpp b/test/auto_schedule/unused_func.cpp index 5fa248a7a4a9..24f1d33feb2c 100644 --- a/test/auto_schedule/unused_func.cpp +++ b/test/auto_schedule/unused_func.cpp @@ -8,6 +8,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); Var x("x"), y("y"); diff --git a/test/auto_schedule/vectorize_var_in_update.cpp b/test/auto_schedule/vectorize_var_in_update.cpp index 49bb191fee0b..a00f24e88c78 100644 --- a/test/auto_schedule/vectorize_var_in_update.cpp +++ b/test/auto_schedule/vectorize_var_in_update.cpp @@ -9,6 +9,11 @@ int main(int argc, char **argv) { return 0; } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + load_plugin(argv[1]); // This test is making sure that the auto-scheduler picks the appropriate From cb7e36c2f49b738c2746df80dee39caac7309afc Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Sat, 12 Sep 2020 15:11:38 -0700 Subject: [PATCH 11/31] Flatten src/plugins/autoschedulers -> src/autoschedulers --- src/CMakeLists.txt | 4 ++-- src/{plugins => }/autoschedulers/CMakeLists.txt | 6 ++++++ .../autoschedulers/adams2019/ASLog.cpp | 0 src/{plugins => }/autoschedulers/adams2019/ASLog.h | 0 .../autoschedulers/adams2019/AutoSchedule.cpp | 0 .../autoschedulers/adams2019/AutoSchedule.h | 0 .../autoschedulers/adams2019/CMakeLists.txt | 0 .../autoschedulers/adams2019/CostModel.h | 0 .../autoschedulers/adams2019/DefaultCostModel.cpp | 0 .../autoschedulers/adams2019/DefaultCostModel.h | 0 .../autoschedulers/adams2019/Featurization.h | 0 .../autoschedulers/adams2019/FunctionDAG.cpp | 0 .../autoschedulers/adams2019/FunctionDAG.h | 0 .../autoschedulers/adams2019/LoopNest.cpp | 0 .../autoschedulers/adams2019/LoopNest.h | 0 src/{plugins => }/autoschedulers/adams2019/Makefile | 0 .../autoschedulers/adams2019/NetworkSize.h | 0 .../autoschedulers/adams2019/PerfectHashMap.h | 0 .../autoschedulers/adams2019/Weights.cpp | 0 .../autoschedulers/adams2019/Weights.h | 0 .../autoschedulers/adams2019/autotune_loop.sh | 0 .../autoschedulers/adams2019/baseline.weights | Bin .../adams2019/cost_model_generator.cpp | 0 .../autoschedulers/adams2019/cost_model_schedule.h | 0 .../autoschedulers/adams2019/demo_generator.cpp | 0 .../adams2019/featurization_to_sample.cpp | 0 .../autoschedulers/adams2019/get_host_target.cpp | 0 .../adams2019/included_schedule_file.schedule.h | 0 .../adams2019/included_schedule_file_generator.cpp | 0 .../autoschedulers/adams2019/retrain_cost_model.cpp | 0 src/{plugins => }/autoschedulers/adams2019/test.cpp | 0 .../autoschedulers/adams2019/test_function_dag.cpp | 0 .../adams2019/test_perfect_hash_map.cpp | 0 .../adams2019/weightsdir_to_weightsfile.cpp | 0 .../autoschedulers/common/CMakeLists.txt | 0 src/{plugins => }/autoschedulers/common/Errors.h | 0 .../autoschedulers/common/HalidePlugin.h | 0 src/{plugins => }/autoschedulers/common/cmdline.h | 0 .../autoschedulers/li2018/CMakeLists.txt | 0 .../autoschedulers/li2018/GradientAutoscheduler.cpp | 0 src/{plugins => }/autoschedulers/li2018/Makefile | 0 src/{plugins => }/autoschedulers/li2018/README.md | 0 .../autoschedulers/li2018/demo_generator.cpp | 0 src/{plugins => }/autoschedulers/li2018/test.cpp | 0 src/{plugins => }/autoschedulers/li2018/test.py | 0 .../autoschedulers/mullapudi2016/AutoSchedule.cpp | 0 .../autoschedulers/mullapudi2016/CMakeLists.txt | 0 src/plugins/CMakeLists.txt | 11 ----------- 48 files changed, 8 insertions(+), 13 deletions(-) rename src/{plugins => }/autoschedulers/CMakeLists.txt (76%) rename src/{plugins => }/autoschedulers/adams2019/ASLog.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/ASLog.h (100%) rename src/{plugins => }/autoschedulers/adams2019/AutoSchedule.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/AutoSchedule.h (100%) rename src/{plugins => }/autoschedulers/adams2019/CMakeLists.txt (100%) rename src/{plugins => }/autoschedulers/adams2019/CostModel.h (100%) rename src/{plugins => }/autoschedulers/adams2019/DefaultCostModel.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/DefaultCostModel.h (100%) rename src/{plugins => }/autoschedulers/adams2019/Featurization.h (100%) rename src/{plugins => }/autoschedulers/adams2019/FunctionDAG.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/FunctionDAG.h (100%) rename src/{plugins => }/autoschedulers/adams2019/LoopNest.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/LoopNest.h (100%) rename src/{plugins => }/autoschedulers/adams2019/Makefile (100%) rename src/{plugins => }/autoschedulers/adams2019/NetworkSize.h (100%) rename src/{plugins => }/autoschedulers/adams2019/PerfectHashMap.h (100%) rename src/{plugins => }/autoschedulers/adams2019/Weights.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/Weights.h (100%) rename src/{plugins => }/autoschedulers/adams2019/autotune_loop.sh (100%) rename src/{plugins => }/autoschedulers/adams2019/baseline.weights (100%) rename src/{plugins => }/autoschedulers/adams2019/cost_model_generator.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/cost_model_schedule.h (100%) rename src/{plugins => }/autoschedulers/adams2019/demo_generator.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/featurization_to_sample.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/get_host_target.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/included_schedule_file.schedule.h (100%) rename src/{plugins => }/autoschedulers/adams2019/included_schedule_file_generator.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/retrain_cost_model.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/test.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/test_function_dag.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/test_perfect_hash_map.cpp (100%) rename src/{plugins => }/autoschedulers/adams2019/weightsdir_to_weightsfile.cpp (100%) rename src/{plugins => }/autoschedulers/common/CMakeLists.txt (100%) rename src/{plugins => }/autoschedulers/common/Errors.h (100%) rename src/{plugins => }/autoschedulers/common/HalidePlugin.h (100%) rename src/{plugins => }/autoschedulers/common/cmdline.h (100%) rename src/{plugins => }/autoschedulers/li2018/CMakeLists.txt (100%) rename src/{plugins => }/autoschedulers/li2018/GradientAutoscheduler.cpp (100%) rename src/{plugins => }/autoschedulers/li2018/Makefile (100%) rename src/{plugins => }/autoschedulers/li2018/README.md (100%) rename src/{plugins => }/autoschedulers/li2018/demo_generator.cpp (100%) rename src/{plugins => }/autoschedulers/li2018/test.cpp (100%) rename src/{plugins => }/autoschedulers/li2018/test.py (100%) rename src/{plugins => }/autoschedulers/mullapudi2016/AutoSchedule.cpp (100%) rename src/{plugins => }/autoschedulers/mullapudi2016/CMakeLists.txt (100%) delete mode 100644 src/plugins/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index baa6a1fcf9cd..0f75b50e5137 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -470,12 +470,12 @@ if (Halide_USE_CODEMODEL_LARGE) endif () ## -# Add compiler plugins (ie. autoschedulers) to the build. +# Add autoschedulers to the build. ## if (BUILD_SHARED_LIBS) message(STATUS "Building autoschedulers") - add_subdirectory(plugins) + add_subdirectory(autoschedulers) else () message(STATUS "Not building autoschedulers (static Halide)") endif () diff --git a/src/plugins/autoschedulers/CMakeLists.txt b/src/autoschedulers/CMakeLists.txt similarity index 76% rename from src/plugins/autoschedulers/CMakeLists.txt rename to src/autoschedulers/CMakeLists.txt index 04eb90e417ed..9b88f0a664a1 100644 --- a/src/plugins/autoschedulers/CMakeLists.txt +++ b/src/autoschedulers/CMakeLists.txt @@ -1,3 +1,9 @@ +# Ensure that plugins export only what is needed to load them. +# Everything else should be omitted to keep binary size low. +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN YES) + function(add_autoscheduler) set(options) set(oneValueArgs NAME) diff --git a/src/plugins/autoschedulers/adams2019/ASLog.cpp b/src/autoschedulers/adams2019/ASLog.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/ASLog.cpp rename to src/autoschedulers/adams2019/ASLog.cpp diff --git a/src/plugins/autoschedulers/adams2019/ASLog.h b/src/autoschedulers/adams2019/ASLog.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/ASLog.h rename to src/autoschedulers/adams2019/ASLog.h diff --git a/src/plugins/autoschedulers/adams2019/AutoSchedule.cpp b/src/autoschedulers/adams2019/AutoSchedule.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/AutoSchedule.cpp rename to src/autoschedulers/adams2019/AutoSchedule.cpp diff --git a/src/plugins/autoschedulers/adams2019/AutoSchedule.h b/src/autoschedulers/adams2019/AutoSchedule.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/AutoSchedule.h rename to src/autoschedulers/adams2019/AutoSchedule.h diff --git a/src/plugins/autoschedulers/adams2019/CMakeLists.txt b/src/autoschedulers/adams2019/CMakeLists.txt similarity index 100% rename from src/plugins/autoschedulers/adams2019/CMakeLists.txt rename to src/autoschedulers/adams2019/CMakeLists.txt diff --git a/src/plugins/autoschedulers/adams2019/CostModel.h b/src/autoschedulers/adams2019/CostModel.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/CostModel.h rename to src/autoschedulers/adams2019/CostModel.h diff --git a/src/plugins/autoschedulers/adams2019/DefaultCostModel.cpp b/src/autoschedulers/adams2019/DefaultCostModel.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/DefaultCostModel.cpp rename to src/autoschedulers/adams2019/DefaultCostModel.cpp diff --git a/src/plugins/autoschedulers/adams2019/DefaultCostModel.h b/src/autoschedulers/adams2019/DefaultCostModel.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/DefaultCostModel.h rename to src/autoschedulers/adams2019/DefaultCostModel.h diff --git a/src/plugins/autoschedulers/adams2019/Featurization.h b/src/autoschedulers/adams2019/Featurization.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/Featurization.h rename to src/autoschedulers/adams2019/Featurization.h diff --git a/src/plugins/autoschedulers/adams2019/FunctionDAG.cpp b/src/autoschedulers/adams2019/FunctionDAG.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/FunctionDAG.cpp rename to src/autoschedulers/adams2019/FunctionDAG.cpp diff --git a/src/plugins/autoschedulers/adams2019/FunctionDAG.h b/src/autoschedulers/adams2019/FunctionDAG.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/FunctionDAG.h rename to src/autoschedulers/adams2019/FunctionDAG.h diff --git a/src/plugins/autoschedulers/adams2019/LoopNest.cpp b/src/autoschedulers/adams2019/LoopNest.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/LoopNest.cpp rename to src/autoschedulers/adams2019/LoopNest.cpp diff --git a/src/plugins/autoschedulers/adams2019/LoopNest.h b/src/autoschedulers/adams2019/LoopNest.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/LoopNest.h rename to src/autoschedulers/adams2019/LoopNest.h diff --git a/src/plugins/autoschedulers/adams2019/Makefile b/src/autoschedulers/adams2019/Makefile similarity index 100% rename from src/plugins/autoschedulers/adams2019/Makefile rename to src/autoschedulers/adams2019/Makefile diff --git a/src/plugins/autoschedulers/adams2019/NetworkSize.h b/src/autoschedulers/adams2019/NetworkSize.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/NetworkSize.h rename to src/autoschedulers/adams2019/NetworkSize.h diff --git a/src/plugins/autoschedulers/adams2019/PerfectHashMap.h b/src/autoschedulers/adams2019/PerfectHashMap.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/PerfectHashMap.h rename to src/autoschedulers/adams2019/PerfectHashMap.h diff --git a/src/plugins/autoschedulers/adams2019/Weights.cpp b/src/autoschedulers/adams2019/Weights.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/Weights.cpp rename to src/autoschedulers/adams2019/Weights.cpp diff --git a/src/plugins/autoschedulers/adams2019/Weights.h b/src/autoschedulers/adams2019/Weights.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/Weights.h rename to src/autoschedulers/adams2019/Weights.h diff --git a/src/plugins/autoschedulers/adams2019/autotune_loop.sh b/src/autoschedulers/adams2019/autotune_loop.sh similarity index 100% rename from src/plugins/autoschedulers/adams2019/autotune_loop.sh rename to src/autoschedulers/adams2019/autotune_loop.sh diff --git a/src/plugins/autoschedulers/adams2019/baseline.weights b/src/autoschedulers/adams2019/baseline.weights similarity index 100% rename from src/plugins/autoschedulers/adams2019/baseline.weights rename to src/autoschedulers/adams2019/baseline.weights diff --git a/src/plugins/autoschedulers/adams2019/cost_model_generator.cpp b/src/autoschedulers/adams2019/cost_model_generator.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/cost_model_generator.cpp rename to src/autoschedulers/adams2019/cost_model_generator.cpp diff --git a/src/plugins/autoschedulers/adams2019/cost_model_schedule.h b/src/autoschedulers/adams2019/cost_model_schedule.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/cost_model_schedule.h rename to src/autoschedulers/adams2019/cost_model_schedule.h diff --git a/src/plugins/autoschedulers/adams2019/demo_generator.cpp b/src/autoschedulers/adams2019/demo_generator.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/demo_generator.cpp rename to src/autoschedulers/adams2019/demo_generator.cpp diff --git a/src/plugins/autoschedulers/adams2019/featurization_to_sample.cpp b/src/autoschedulers/adams2019/featurization_to_sample.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/featurization_to_sample.cpp rename to src/autoschedulers/adams2019/featurization_to_sample.cpp diff --git a/src/plugins/autoschedulers/adams2019/get_host_target.cpp b/src/autoschedulers/adams2019/get_host_target.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/get_host_target.cpp rename to src/autoschedulers/adams2019/get_host_target.cpp diff --git a/src/plugins/autoschedulers/adams2019/included_schedule_file.schedule.h b/src/autoschedulers/adams2019/included_schedule_file.schedule.h similarity index 100% rename from src/plugins/autoschedulers/adams2019/included_schedule_file.schedule.h rename to src/autoschedulers/adams2019/included_schedule_file.schedule.h diff --git a/src/plugins/autoschedulers/adams2019/included_schedule_file_generator.cpp b/src/autoschedulers/adams2019/included_schedule_file_generator.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/included_schedule_file_generator.cpp rename to src/autoschedulers/adams2019/included_schedule_file_generator.cpp diff --git a/src/plugins/autoschedulers/adams2019/retrain_cost_model.cpp b/src/autoschedulers/adams2019/retrain_cost_model.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/retrain_cost_model.cpp rename to src/autoschedulers/adams2019/retrain_cost_model.cpp diff --git a/src/plugins/autoschedulers/adams2019/test.cpp b/src/autoschedulers/adams2019/test.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/test.cpp rename to src/autoschedulers/adams2019/test.cpp diff --git a/src/plugins/autoschedulers/adams2019/test_function_dag.cpp b/src/autoschedulers/adams2019/test_function_dag.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/test_function_dag.cpp rename to src/autoschedulers/adams2019/test_function_dag.cpp diff --git a/src/plugins/autoschedulers/adams2019/test_perfect_hash_map.cpp b/src/autoschedulers/adams2019/test_perfect_hash_map.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/test_perfect_hash_map.cpp rename to src/autoschedulers/adams2019/test_perfect_hash_map.cpp diff --git a/src/plugins/autoschedulers/adams2019/weightsdir_to_weightsfile.cpp b/src/autoschedulers/adams2019/weightsdir_to_weightsfile.cpp similarity index 100% rename from src/plugins/autoschedulers/adams2019/weightsdir_to_weightsfile.cpp rename to src/autoschedulers/adams2019/weightsdir_to_weightsfile.cpp diff --git a/src/plugins/autoschedulers/common/CMakeLists.txt b/src/autoschedulers/common/CMakeLists.txt similarity index 100% rename from src/plugins/autoschedulers/common/CMakeLists.txt rename to src/autoschedulers/common/CMakeLists.txt diff --git a/src/plugins/autoschedulers/common/Errors.h b/src/autoschedulers/common/Errors.h similarity index 100% rename from src/plugins/autoschedulers/common/Errors.h rename to src/autoschedulers/common/Errors.h diff --git a/src/plugins/autoschedulers/common/HalidePlugin.h b/src/autoschedulers/common/HalidePlugin.h similarity index 100% rename from src/plugins/autoschedulers/common/HalidePlugin.h rename to src/autoschedulers/common/HalidePlugin.h diff --git a/src/plugins/autoschedulers/common/cmdline.h b/src/autoschedulers/common/cmdline.h similarity index 100% rename from src/plugins/autoschedulers/common/cmdline.h rename to src/autoschedulers/common/cmdline.h diff --git a/src/plugins/autoschedulers/li2018/CMakeLists.txt b/src/autoschedulers/li2018/CMakeLists.txt similarity index 100% rename from src/plugins/autoschedulers/li2018/CMakeLists.txt rename to src/autoschedulers/li2018/CMakeLists.txt diff --git a/src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp b/src/autoschedulers/li2018/GradientAutoscheduler.cpp similarity index 100% rename from src/plugins/autoschedulers/li2018/GradientAutoscheduler.cpp rename to src/autoschedulers/li2018/GradientAutoscheduler.cpp diff --git a/src/plugins/autoschedulers/li2018/Makefile b/src/autoschedulers/li2018/Makefile similarity index 100% rename from src/plugins/autoschedulers/li2018/Makefile rename to src/autoschedulers/li2018/Makefile diff --git a/src/plugins/autoschedulers/li2018/README.md b/src/autoschedulers/li2018/README.md similarity index 100% rename from src/plugins/autoschedulers/li2018/README.md rename to src/autoschedulers/li2018/README.md diff --git a/src/plugins/autoschedulers/li2018/demo_generator.cpp b/src/autoschedulers/li2018/demo_generator.cpp similarity index 100% rename from src/plugins/autoschedulers/li2018/demo_generator.cpp rename to src/autoschedulers/li2018/demo_generator.cpp diff --git a/src/plugins/autoschedulers/li2018/test.cpp b/src/autoschedulers/li2018/test.cpp similarity index 100% rename from src/plugins/autoschedulers/li2018/test.cpp rename to src/autoschedulers/li2018/test.cpp diff --git a/src/plugins/autoschedulers/li2018/test.py b/src/autoschedulers/li2018/test.py similarity index 100% rename from src/plugins/autoschedulers/li2018/test.py rename to src/autoschedulers/li2018/test.py diff --git a/src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp b/src/autoschedulers/mullapudi2016/AutoSchedule.cpp similarity index 100% rename from src/plugins/autoschedulers/mullapudi2016/AutoSchedule.cpp rename to src/autoschedulers/mullapudi2016/AutoSchedule.cpp diff --git a/src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt b/src/autoschedulers/mullapudi2016/CMakeLists.txt similarity index 100% rename from src/plugins/autoschedulers/mullapudi2016/CMakeLists.txt rename to src/autoschedulers/mullapudi2016/CMakeLists.txt diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt deleted file mode 100644 index ce18f04c9d39..000000000000 --- a/src/plugins/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Ensure that plugins export only what is needed to load them. -# Everything else should be omitted to keep binary size low. -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF) -set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(CMAKE_VISIBILITY_INLINES_HIDDEN YES) - -if (TARGET_WEBASSEMBLY AND Halide_TARGET MATCHES "wasm") - # Don't attempt to build these for wasm yet. -else () - add_subdirectory(autoschedulers) -endif () From 39c2082dac2231c1c8e130ca24b2af5d50f2e843 Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Sat, 12 Sep 2020 15:48:00 -0700 Subject: [PATCH 12/31] Autoscheduler Makefile improvements --- Makefile | 35 +++- apps/support/Makefile.inc | 9 +- src/plugins/autoschedulers/adams2019/Makefile | 160 ++++++++++++++---- .../autoschedulers/adams2019/autotune_loop.sh | 2 +- src/plugins/autoschedulers/li2018/Makefile | 32 ++-- .../autoschedulers/mullapudi2016/Makefile | 13 ++ 6 files changed, 195 insertions(+), 56 deletions(-) create mode 100644 src/plugins/autoschedulers/mullapudi2016/Makefile diff --git a/Makefile b/Makefile index a9867a02d292..afe2fbe0f076 100644 --- a/Makefile +++ b/Makefile @@ -399,7 +399,6 @@ SOURCE_FILES = \ AssociativeOpsTable.cpp \ Associativity.cpp \ AsyncProducers.cpp \ - AutoSchedule.cpp \ AutoScheduleUtils.cpp \ BoundaryConditions.cpp \ Bounds.cpp \ @@ -573,7 +572,6 @@ HEADER_FILES = \ AssociativeOpsTable.h \ Associativity.h \ AsyncProducers.h \ - AutoSchedule.h \ AutoScheduleUtils.h \ BoundaryConditions.h \ Bounds.h \ @@ -2128,8 +2126,9 @@ $(BUILD_DIR)/halide_config.%: $(ROOT_DIR)/tools/halide_config.%.tpl | sed -e 's;@HALIDE_LLVM_CXX_FLAGS_RAW@;${LLVM_CXX_FLAGS};g' > $@ -$(DISTRIB_DIR)/halide.tgz: $(LIB_DIR)/libHalide.a \ - $(BIN_DIR)/libHalide.$(SHARED_EXT) \ +$(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT): \ + $(LIB_DIR)/libHalide.a \ + $(BIN_DIR)/libHalide.$(SHARED_EXT) \ $(INCLUDE_DIR)/Halide.h \ $(RUNTIME_EXPORTED_INCLUDES) \ $(ROOT_DIR)/README*.md \ @@ -2168,6 +2167,30 @@ $(DISTRIB_DIR)/halide.tgz: $(LIB_DIR)/libHalide.a \ cp $(ROOT_DIR)/tools/halide_trace_config.h $(DISTRIB_DIR)/tools cp $(ROOT_DIR)/README*.md $(DISTRIB_DIR) cp $(BUILD_DIR)/halide_config.* $(DISTRIB_DIR) + +$(DISTRIB_DIR)/bin/libautoschedule_%.$(SHARED_EXT): $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT) + $(MAKE) -f $(SRC_DIR)/plugins/autoschedulers/$*/Makefile bin/libautoschedule_$*.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(DISTRIB_DIR) + cp $(BIN_DIR)/libautoschedule_$*.so $(DISTRIB_DIR)/bin; + +# Adams2019 also includes autotuning tools +$(DISTRIB_DIR)/bin/libautoschedule_adams2019.$(SHARED_EXT): $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT) + $(MAKE) -f $(SRC_DIR)/plugins/autoschedulers/adams2019/Makefile bin/libautoschedule_adams2019.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(DISTRIB_DIR) bin/retrain_cost_model bin/featurization_to_sample bin/get_host_target + cp $(BIN_DIR)/libautoschedule_adams2019.so $(DISTRIB_DIR)/bin/ + cp $(BIN_DIR)/retrain_cost_model $(DISTRIB_DIR)/bin/ + cp $(BIN_DIR)/featurization_to_sample $(DISTRIB_DIR)/bin/ + cp $(BIN_DIR)/get_host_target $(DISTRIB_DIR)/bin/ + cp $(SRC_DIR)/plugins/autoschedulers/adams2019/autotune_loop.sh $(DISTRIB_DIR)/tools/ + +.PHONY: autoschedulers +autoschedulers: \ +$(DISTRIB_DIR)/bin/libautoschedule_mullapudi2016.$(SHARED_EXT) \ +$(DISTRIB_DIR)/bin/libautoschedule_li2018.$(SHARED_EXT) \ +$(DISTRIB_DIR)/bin/libautoschedule_adams2019.$(SHARED_EXT) + +.PHONY: distrib +distrib: $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT) autoschedulers + +$(DISTRIB_DIR)/halide.tgz: distrib ln -sf $(DISTRIB_DIR) halide tar -czf $(BUILD_DIR)/halide.tgz \ halide/bin \ @@ -2180,10 +2203,6 @@ $(DISTRIB_DIR)/halide.tgz: $(LIB_DIR)/libHalide.a \ rm -rf halide mv $(BUILD_DIR)/halide.tgz $(DISTRIB_DIR)/halide.tgz - -.PHONY: distrib -distrib: $(DISTRIB_DIR)/halide.tgz - $(BIN_DIR)/HalideTraceViz: $(ROOT_DIR)/util/HalideTraceViz.cpp $(INCLUDE_DIR)/HalideRuntime.h $(ROOT_DIR)/tools/halide_image_io.h $(ROOT_DIR)/tools/halide_trace_config.h $(CXX) $(OPTIMIZE) -std=c++11 $(filter %.cpp,$^) -I$(INCLUDE_DIR) -I$(ROOT_DIR)/tools -L$(BIN_DIR) -o $@ diff --git a/apps/support/Makefile.inc b/apps/support/Makefile.inc index a0865f86aaae..bbfacd2da136 100644 --- a/apps/support/Makefile.inc +++ b/apps/support/Makefile.inc @@ -126,11 +126,16 @@ LIB_HALIDE_STATIC = $(HALIDE_DISTRIB_PATH)/lib/libHalide.a LIB_HALIDE = $(HALIDE_DISTRIB_PATH)/bin/libHalide.$(SHARED_EXT) -GENERATOR_DEPS ?= $(LIB_HALIDE) $(HALIDE_DISTRIB_PATH)/include/Halide.h $(HALIDE_DISTRIB_PATH)/tools/GenGen.cpp +# Autoschedulers. Mullapudi2016 is currently the default, because it's fast. +AUTOSCHEDULER ?= mullapudi2016 + +LIB_AUTOSCHEDULER ?= $(HALIDE_DISTRIB_PATH)/bin/libautoschedule_$(AUTOSCHEDULER).$(SHARED_EXT) + +GENERATOR_DEPS ?= $(LIB_AUTOSCHEDULER) $(LIB_HALIDE) $(HALIDE_DISTRIB_PATH)/include/Halide.h $(HALIDE_DISTRIB_PATH)/tools/GenGen.cpp GENERATOR_DEPS_STATIC ?= $(LIB_HALIDE_STATIC) $(HALIDE_DISTRIB_PATH)/include/Halide.h $(HALIDE_DISTRIB_PATH)/tools/GenGen.cpp # Generators which use autoscheduler plugin need to specify the linker where to find libHalide.so required by the plugin. -LIBHALIDE_LDFLAGS ?= -Wl,-rpath,$(dir $(LIB_HALIDE)) -L $(dir $(LIB_HALIDE)) -lHalide $(LDFLAGS) +LIBHALIDE_LDFLAGS ?= -Wl,-rpath,$(dir $(LIB_HALIDE)) -L $(dir $(LIB_HALIDE)) -Wl,--no-as-needed -lautoschedule_$(AUTOSCHEDULER) -Wl,--as-needed -lHalide $(LDFLAGS) LIBHALIDE_LDFLAGS_STATIC ?= -L $(dir $(LIB_HALIDE_STATIC)) -lHalide $(LDFLAGS) LIBPNG_LIBS_DEFAULT = $(shell libpng-config --ldflags) diff --git a/src/plugins/autoschedulers/adams2019/Makefile b/src/plugins/autoschedulers/adams2019/Makefile index 908717fc836c..e3ce429b07d2 100644 --- a/src/plugins/autoschedulers/adams2019/Makefile +++ b/src/plugins/autoschedulers/adams2019/Makefile @@ -1,49 +1,146 @@ -include ../support/Makefile.inc -include ../support/autoscheduler.inc +THIS_MAKEFILE = $(realpath $(filter %Makefile, $(MAKEFILE_LIST))) +SRC = $(strip $(shell dirname $(THIS_MAKEFILE))) +HALIDE_SRC_ROOT = $(realpath $(SRC)/../../../../) +COMMON_DIR ?= $(realpath $(SRC)/../common/) + +HALIDE_DISTRIB_PATH ?= $(HALIDE_SRC_ROOT)/distrib + +$(info Looking for Halide distro at $(HALIDE_DISTRIB_PATH). If this is incorrect, set the make variable HALIDE_DISTRIB_PATH) + +include $(HALIDE_SRC_ROOT)/apps/support/Makefile.inc + +CXXFLAGS += -I$(COMMON_DIR) + +AUTOSCHED_WEIGHT_OBJECTS=$(BIN)/baseline_weights.o + +$(BIN)/binary2cpp: $(HALIDE_SRC_ROOT)/tools/binary2cpp.cpp + @mkdir -p $(@D) + $(CXX) $< -o $@ + +$(BIN)/baseline_weights.cpp: $(BIN)/binary2cpp $(SRC)/baseline.weights + @mkdir -p $(@D) + $(BIN)/binary2cpp baseline_weights < $(SRC)/baseline.weights > $@ + +$(BIN)/baseline_weights.o: $(BIN)/baseline_weights.cpp + $(CXX) -c $< -o $@ + +AUTOSCHED_COST_MODEL_LIBS=\ +$(BIN)/cost_model/cost_model.a \ +$(BIN)/cost_model/train_cost_model.a \ + +$(BIN)/cost_model.generator: $(SRC)/cost_model_generator.cpp \ + $(SRC)/cost_model_schedule.h \ + $(SRC)/NetworkSize.h \ + $(GENERATOR_DEPS) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(filter %.cpp,$^) -o $@ $(USE_EXPORT_DYNAMIC) $(LIBHALIDE_LDFLAGS) + +$(BIN)/auto_schedule_runtime.a: $(BIN)/cost_model.generator + @mkdir -p $(@D) + $^ -r auto_schedule_runtime -o $(BIN) target=$(HL_TARGET) + +$(BIN)/cost_model/%.a: $(BIN)/cost_model.generator + @mkdir -p $(@D) + $^ -g $* -o $(BIN)/cost_model -f $* target=$(HL_TARGET)-no_runtime auto_schedule=false -e stmt,static_library,h,assembly + +# It's important to use dynamic lookups for undefined symbols here: all of libHalide +# is expected to be present (in the loading binary), so we explicitly make the symbols +# undefined rather than dependent on libHalide.so. +$(BIN)/libautoschedule_adams2019.so: $(SRC)/AutoSchedule.cpp \ + $(SRC)/ASLog.cpp \ + $(SRC)/DefaultCostModel.h \ + $(SRC)/DefaultCostModel.cpp \ + $(SRC)/Weights.h \ + $(SRC)/Weights.cpp \ + $(SRC)/FunctionDAG.h \ + $(SRC)/FunctionDAG.cpp \ + $(SRC)/LoopNest.h \ + $(SRC)/LoopNest.cpp \ + $(SRC)/Featurization.h \ + $(SRC)/CostModel.h \ + $(SRC)/PerfectHashMap.h \ + $(AUTOSCHED_WEIGHT_OBJECTS) \ + $(AUTOSCHED_COST_MODEL_LIBS) \ + $(GENERATOR_DEPS) \ + $(BIN)/auto_schedule_runtime.a + @mkdir -p $(@D) + $(CXX) -shared $(USE_EXPORT_DYNAMIC) -fPIC -fvisibility=hidden -fvisibility-inlines-hidden $(CXXFLAGS) $(OPTIMIZE) -I $(BIN)/cost_model $(filter-out %.h $(LIBHALIDE_LDFLAGS),$^) -o $@ $(HALIDE_SYSTEM_LIBS) + +$(BIN)/retrain_cost_model: $(SRC)/retrain_cost_model.cpp \ + $(SRC)/ASLog.cpp \ + $(SRC)/DefaultCostModel.h \ + $(SRC)/DefaultCostModel.cpp \ + $(SRC)/Weights.h \ + $(SRC)/Weights.cpp \ + $(SRC)/CostModel.h \ + $(SRC)/NetworkSize.h \ + $(AUTOSCHED_COST_MODEL_LIBS) \ + $(AUTOSCHED_WEIGHT_OBJECTS) \ + $(BIN)/auto_schedule_runtime.a + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) -frtti -Wall -I ../support -I $(BIN)/cost_model $(OPTIMIZE) $(filter-out %.h,$^) -o $@ $(LIBHALIDE_LDFLAGS) $(USE_OPEN_MP) + +$(BIN)/featurization_to_sample: $(SRC)/featurization_to_sample.cpp + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $< $(OPTIMIZE) -o $@ + +$(BIN)/get_host_target: $(SRC)/get_host_target.cpp $(LIB_HALIDE) $(HALIDE_DISTRIB_PATH)/include/Halide.h + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(filter %.cpp,$^) $(LIBHALIDE_LDFLAGS) $(OPTIMIZE) -o $@ + +$(BIN)/weightsdir_to_weightsfile: $(SRC)/weightsdir_to_weightsfile.cpp $(SRC)/Weights.cpp + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $^ $(OPTIMIZE) -o $@ + +# This is the value that machine_params defaults to if no custom value is specified; +# see MachineParams::generic() +HL_MACHINE_PARAMS ?= 32,25165824,160 + # 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: demo_generator.cpp $(GENERATOR_DEPS) +$(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 $(AUTOSCHED_BIN)/libauto_schedule.so +$(BIN)/%/demo.a: $(GENERATOR_BIN)/demo.generator $(BIN)/libautoschedule_adams2019.so @mkdir -p $(@D) - HL_WEIGHTS_DIR=$(AUTOSCHED_SRC)/baseline.weights \ - $(GENERATOR_BIN)/demo.generator -g demo -o $(@D) -f demo target=$* auto_schedule=true -p $(AUTOSCHED_BIN)/libauto_schedule.so -s Adams2019 + HL_WEIGHTS_DIR=$(SRC)/baseline.weights \ + $(GENERATOR_BIN)/demo.generator -g demo -o $(@D) -f demo target=$* auto_schedule=true -p $(BIN)/libautoschedule_adams2019.so -s Adams2019 $(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 $(AUTOSCHED_BIN)/libauto_schedule.so +demo: $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_adams2019.so $< --benchmarks=all --benchmark_min_time=1 --estimate_all # demonstrates an autotuning loop -# (using $(AUTOSCHED_BIN) and $(AUTOSCHED_SRC) here seems overkill, but makes copy-n-paste elsewhere easier) -autotune: $(GENERATOR_BIN)/demo.generator $(AUTOSCHED_BIN)/featurization_to_sample $(AUTOSCHED_BIN)/get_host_target $(AUTOSCHED_BIN)/retrain_cost_model $(AUTOSCHED_BIN)/libauto_schedule.so $(AUTOSCHED_SRC)/autotune_loop.sh - bash $(AUTOSCHED_SRC)/autotune_loop.sh \ +# (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.so $(SRC)/autotune_loop.sh + @mkdir -p $(@D) + bash $(SRC)/autotune_loop.sh \ $(GENERATOR_BIN)/demo.generator \ demo \ "" \ - $(AUTOSCHED_SRC)/baseline.weights \ - $(AUTOSCHED_BIN) \ + $(SRC)/baseline.weights \ + $(BIN) \ $(HALIDE_DISTRIB_PATH) \ - $(AUTOSCHED_SAMPLES_OUT) + $(BIN)/samples -$(BIN)/test_perfect_hash_map: test_perfect_hash_map.cpp PerfectHashMap.h +$(BIN)/test_perfect_hash_map: $(SRC)/test_perfect_hash_map.cpp $(SRC)/PerfectHashMap.h @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $< -o $@ -$(BIN)/test_function_dag: test_function_dag.cpp FunctionDAG.h FunctionDAG.cpp ASLog.h ASLog.cpp +$(BIN)/test_function_dag: $(SRC)/test_function_dag.cpp $(SRC)/FunctionDAG.h $(SRC)/FunctionDAG.cpp $(SRC)/ASLog.h $(SRC)/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: test.cpp $(AUTOSCHED_BIN)/libauto_schedule.so +$(BIN)/%/test: $(SRC)/test.cpp $(BIN)/libautoschedule_adams2019.so @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $(USE_EXPORT_DYNAMIC) $^ -o $@ $(LIBHALIDE_LDFLAGS) $(HALIDE_SYSTEM_LIBS) @@ -54,17 +151,10 @@ test_function_dag: $(BIN)/test_function_dag $^ run_test: $(BIN)/$(HL_TARGET)/test - HL_WEIGHTS_DIR=$(AUTOSCHED_SRC)/baseline.weights LD_LIBRARY_PATH=$(AUTOSCHED_BIN) $< + HL_WEIGHTS_DIR=$(SRC)/baseline.weights LD_LIBRARY_PATH=$(BIN) $< $(BIN)/libautoschedule_adams2019.so .PHONY: test clean -# Note that when running the *test*, we want to ensure that we generate samples -# to a subdir of $(BIN), so that they don't get inadvertently generated into -# our source tree. (Normally we want samples/ to be retained, to avoid data loss; -# for the test target, however, it's imperative it go into a transitory directory, -# to avoid eventually consuming all disk space on the buildbot...) -test: AUTOSCHED_SAMPLES_OUT = $(BIN)/test_samples_out - # 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 @@ -73,12 +163,12 @@ build: $(BIN)/$(HL_TARGET)/test \ $(BIN)/test_function_dag \ $(BIN)/$(HL_TARGET)/included_schedule_file.rungen \ $(GENERATOR_BIN)/demo.generator \ - $(AUTOSCHED_BIN)/featurization_to_sample \ - $(AUTOSCHED_BIN)/get_host_target \ - $(AUTOSCHED_BIN)/retrain_cost_model \ - $(AUTOSCHED_BIN)/libauto_schedule.so + $(BIN)/featurization_to_sample \ + $(BIN)/get_host_target \ + $(BIN)/retrain_cost_model \ + $(BIN)/libautoschedule_adams2019.so -test: run_test test_perfect_hash_map test_function_dag demo included_schedule_file autotune +test: run_test test_perfect_hash_map test_function_dag demo test_included_schedule_file autotune clean: rm -rf $(BIN) @@ -92,17 +182,17 @@ clean: # # We'll use the preprocessor (GENERATING_SCHEDULE) to distinguish between these two. -$(GENERATOR_BIN)/included_schedule_file_none.generator: included_schedule_file_generator.cpp $(GENERATOR_DEPS) +$(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 $(AUTOSCHED_BIN)/libauto_schedule.so +$(BIN)/%/included_schedule_file.schedule.h: $(GENERATOR_BIN)/included_schedule_file_none.generator $(BIN)/libautoschedule_adams2019.so @mkdir -p $(@D) - HL_WEIGHTS_DIR=$(AUTOSCHED_SRC)/baseline.weights \ - $< -g included_schedule_file -o $(@D) -f included_schedule_file target=$* auto_schedule=true -p $(AUTOSCHED_BIN)/libauto_schedule.so -s Adams2019 -e schedule + HL_WEIGHTS_DIR=$(SRC)/baseline.weights \ + $< -g included_schedule_file -o $(@D) -f included_schedule_file target=$* auto_schedule=true -p $(BIN)/libautoschedule_adams2019.so -s Adams2019 -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 @@ -110,7 +200,7 @@ $(BIN)/%/included_schedule_file.schedule.h: $(GENERATOR_BIN)/included_schedule_f # 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: included_schedule_file_generator.cpp included_schedule_file.schedule.h $(GENERATOR_DEPS) +$(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) @@ -125,6 +215,6 @@ $(BIN)/%/included_schedule_file.rungen: $(BIN)/%/RunGenMain.o $(BIN)/%/included_ @mkdir -p $(@D) $(CXX) $(CXXFLAGS) -I$(BIN)/$* $^ -o $@ $(HALIDE_SYSTEM_LIBS) $(IMAGE_IO_FLAGS) -included_schedule_file: $(BIN)/$(HL_TARGET)/included_schedule_file.rungen +test_included_schedule_file: $(BIN)/$(HL_TARGET)/included_schedule_file.rungen $^ --benchmarks=all --benchmark_min_time=1 --estimate_all diff --git a/src/plugins/autoschedulers/adams2019/autotune_loop.sh b/src/plugins/autoschedulers/adams2019/autotune_loop.sh index e3760cac75f7..7f99692402fc 100644 --- a/src/plugins/autoschedulers/adams2019/autotune_loop.sh +++ b/src/plugins/autoschedulers/adams2019/autotune_loop.sh @@ -117,7 +117,7 @@ make_featurization() { target=${HL_TARGET} \ auto_schedule=true \ ${EXTRA_GENERATOR_ARGS} \ - -p ${AUTOSCHED_BIN}/libauto_schedule.so \ + -p ${AUTOSCHED_BIN}/libautoschedule_adams2019.so \ -s Adams2019 \ 2> ${D}/compile_log.txt || echo "Compilation failed or timed out for ${D}" diff --git a/src/plugins/autoschedulers/li2018/Makefile b/src/plugins/autoschedulers/li2018/Makefile index e782f2bf2c26..50c3cb4d7cc3 100644 --- a/src/plugins/autoschedulers/li2018/Makefile +++ b/src/plugins/autoschedulers/li2018/Makefile @@ -1,23 +1,35 @@ -include ../support/Makefile.inc +THIS_MAKEFILE = $(realpath $(filter %Makefile, $(MAKEFILE_LIST))) +SRC = $(strip $(shell dirname $(THIS_MAKEFILE))) +HALIDE_ROOT = $(realpath $(SRC)/../../../../) +COMMON_DIR = $(realpath $(SRC)/../common/) -$(BIN)/libgradient_autoscheduler.so: GradientAutoscheduler.cpp ASLog.cpp $(LIB_HALIDE) +# Assume an in-tree build of a halide distro exists. Most uses of this +# Makefile should probably set this variable explicitly. +HALIDE_DISTRIB_PATH ?= $(realpath $(SRC)/../../../../distrib) + +# The example uses a generator, though the autoscheduler itself does not require one +include $(HALIDE_ROOT)/apps/support/Makefile.inc + +CXXFLAGS += -I$(COMMON_DIR) + +$(BIN)/libautoschedule_li2018.so: $(SRC)/GradientAutoscheduler.cpp $(LIB_HALIDE) @mkdir -p $(@D) $(CXX) -shared $(USE_EXPORT_DYNAMIC) -fPIC -fvisibility=hidden -fvisibility-inlines-hidden $(CXXFLAGS) $(OPTIMIZE) $^ -o $@ $(HALIDE_SYSTEM_LIBS) # Demonstrate a JIT-based use of gradient autoscheuler -$(BIN)/test: test.cpp $(BIN)/libgradient_autoscheduler.so +$(BIN)/test: $(SRC)/test.cpp $(BIN)/libautoschedule_li2018.so @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $(USE_EXPORT_DYNAMIC) test.cpp -o $@ $(LIBHALIDE_LDFLAGS) $(HALIDE_SYSTEM_LIBS) # Demonstrate a generator-based use of gradient autoscheuler -$(GENERATOR_BIN)/demo.generator: demo_generator.cpp $(GENERATOR_DEPS) +$(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)/libgradient_autoscheduler.so +$(BIN)/%/demo.a: $(GENERATOR_BIN)/demo.generator $(BIN)/libautoschedule_li2018.so @mkdir -p $(@D) - $(GENERATOR_BIN)/demo.generator -g demo -o $(@D) -f demo target=$* auto_schedule=true -p $(BIN)/libgradient_autoscheduler.so -s Li2018 + $(GENERATOR_BIN)/demo.generator -g demo -o $(@D) -f demo target=$* auto_schedule=true -p $(BIN)/libautoschedule_li2018.so -s Li2018 $(BIN)/%/demo.rungen: $(BIN)/%/RunGenMain.o $(BIN)/%/demo.registration.cpp $(BIN)/%/demo.a @mkdir -p $(@D) @@ -26,18 +38,18 @@ $(BIN)/%/demo.rungen: $(BIN)/%/RunGenMain.o $(BIN)/%/demo.registration.cpp $(BIN .PHONY: build test clean run_test_cpp run_test_py test_generator # demonstrates single-shot use of the autoscheduler -test_generator: $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libgradient_autoscheduler.so +test_generator: $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.so $< --benchmarks=all --benchmark_min_time=1 --estimate_all run_test_cpp: $(BIN)/test - LD_LIBRARY_PATH=$(BIN) $< + LD_LIBRARY_PATH=$(BIN) $< $(BIN)/libautoschedule_li2018.so -run_test_py: test.py $(BIN)/libgradient_autoscheduler.so +run_test_py: $(SRC)/test.py $(BIN)/libautoschedule_li2018.so PYTHONPATH=$(BIN):$(HALIDE_PYTHON_BINDINGS_PATH):$(HALIDE_DISTRIB_PATH)/bin:$$PYTHONPATH \ LD_LIBRARY_PATH=$(BIN):$(HALIDE_PYTHON_BINDINGS_PATH):$(HALIDE_DISTRIB_PATH)/bin \ $(PYTHON) test.py -build: $(BIN)/test $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libgradient_autoscheduler.so +build: $(BIN)/test $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.so test: run_test_cpp run_test_py test_generator diff --git a/src/plugins/autoschedulers/mullapudi2016/Makefile b/src/plugins/autoschedulers/mullapudi2016/Makefile new file mode 100644 index 000000000000..dce6c8b35bff --- /dev/null +++ b/src/plugins/autoschedulers/mullapudi2016/Makefile @@ -0,0 +1,13 @@ +THIS_MAKEFILE = $(realpath $(filter %Makefile, $(MAKEFILE_LIST))) +SRC = $(strip $(shell dirname $(THIS_MAKEFILE))) +HALIDE_ROOT = $(realpath $(SRC)/../../../../) +COMMON_DIR = $(realpath $(SRC)/../common/) + +HALIDE_DISTRIB_PATH ?= $(realpath $(SRC)/../../../../distrib) +include $(HALIDE_ROOT)/apps/support/Makefile.inc + +CXXFLAGS += -I$(COMMON_DIR) + +$(BIN)/libautoschedule_mullapudi2016.so: $(SRC)/AutoSchedule.cpp $(LIB_HALIDE) + @mkdir -p $(@D) + $(CXX) -shared $(USE_EXPORT_DYNAMIC) -fPIC -fvisibility=hidden -fvisibility-inlines-hidden $(CXXFLAGS) $(OPTIMIZE) $^ -o $@ $(HALIDE_SYSTEM_LIBS) From a4bc526134793da8d95d87f85fcfa97a873fb70a Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Sat, 12 Sep 2020 16:25:21 -0700 Subject: [PATCH 13/31] Makefile test and path fixes for the autoschedulers --- Makefile | 28 ++++++++++++++++------- apps/support/Makefile.inc | 14 +++++++----- src/autoschedulers/adams2019/Makefile | 4 +++- src/autoschedulers/li2018/Makefile | 10 ++++---- src/autoschedulers/li2018/test.py | 2 +- src/autoschedulers/mullapudi2016/Makefile | 4 ++-- 6 files changed, 39 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index afe2fbe0f076..62ac5daeb252 100644 --- a/Makefile +++ b/Makefile @@ -1079,7 +1079,7 @@ 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_opengl: $(OPENGL_TESTS:$(ROOT_DIR)/test/opengl/%.cpp=opengl_%) -test_auto_schedule: $(AUTO_SCHEDULE_TESTS:$(ROOT_DIR)/test/auto_schedule/%.cpp=auto_schedule_%) +test_auto_schedule: test_mullapudi2016 test_li2018 test_adams2019 .PHONY: test_correctness_multi_gpu test_correctness_multi_gpu: correctness_gpu_multi_device @@ -1845,11 +1845,25 @@ tutorial_%: $(BIN_DIR)/tutorial_% $(TMP_DIR)/images/rgb.png $(TMP_DIR)/images/gr cd $(TMP_DIR) ; $(CURDIR)/$< @-echo -auto_schedule_%: $(BIN_DIR)/auto_schedule_% +test_mullapudi2016: $(AUTO_SCHEDULE_TESTS:$(ROOT_DIR)/test/auto_schedule/%.cpp=auto_schedule_%) + +# 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_% $(DISTRIB_DIR)/bin/libautoschedule_mullapudi2016.$(SHARED_EXT) @-mkdir -p $(TMP_DIR) - cd $(TMP_DIR) ; $(CURDIR)/$< + cd $(TMP_DIR) ; $(CURDIR)/$< $(realpath $(DISTRIB_DIR))/bin/libautoschedule_mullapudi2016.$(SHARED_EXT) @-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 build_python_bindings + $(MAKE) -f $(SRC_DIR)/autoschedulers/li2018/Makefile test \ + HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) \ + HALIDE_PYTHON_BINDINGS_PATH=$(CURDIR)/$(BIN_DIR)/python3_bindings + time_compilation_test_%: $(BIN_DIR)/test_% $(TIME_COMPILATION) compile_times_correctness.csv make -f $(THIS_MAKEFILE) $(@:time_compilation_test_%=test_%) @@ -1864,7 +1878,6 @@ time_compilation_generator_%: $(BIN_DIR)/%.generator TEST_APPS=\ HelloMatlab \ - autoscheduler \ bilateral_grid \ bgu \ blur \ @@ -1872,7 +1885,6 @@ TEST_APPS=\ camera_pipe \ conv_layer \ fft \ - gradient_autoscheduler \ hist \ interpolate \ lens_blur \ @@ -2169,17 +2181,17 @@ $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT): \ cp $(BUILD_DIR)/halide_config.* $(DISTRIB_DIR) $(DISTRIB_DIR)/bin/libautoschedule_%.$(SHARED_EXT): $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT) - $(MAKE) -f $(SRC_DIR)/plugins/autoschedulers/$*/Makefile bin/libautoschedule_$*.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(DISTRIB_DIR) + $(MAKE) -f $(SRC_DIR)/autoschedulers/$*/Makefile bin/libautoschedule_$*.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) cp $(BIN_DIR)/libautoschedule_$*.so $(DISTRIB_DIR)/bin; # Adams2019 also includes autotuning tools $(DISTRIB_DIR)/bin/libautoschedule_adams2019.$(SHARED_EXT): $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT) - $(MAKE) -f $(SRC_DIR)/plugins/autoschedulers/adams2019/Makefile bin/libautoschedule_adams2019.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(DISTRIB_DIR) bin/retrain_cost_model bin/featurization_to_sample bin/get_host_target + $(MAKE) -f $(SRC_DIR)/autoschedulers/adams2019/Makefile bin/libautoschedule_adams2019.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) bin/retrain_cost_model bin/featurization_to_sample bin/get_host_target cp $(BIN_DIR)/libautoschedule_adams2019.so $(DISTRIB_DIR)/bin/ cp $(BIN_DIR)/retrain_cost_model $(DISTRIB_DIR)/bin/ cp $(BIN_DIR)/featurization_to_sample $(DISTRIB_DIR)/bin/ cp $(BIN_DIR)/get_host_target $(DISTRIB_DIR)/bin/ - cp $(SRC_DIR)/plugins/autoschedulers/adams2019/autotune_loop.sh $(DISTRIB_DIR)/tools/ + cp $(SRC_DIR)/autoschedulers/adams2019/autotune_loop.sh $(DISTRIB_DIR)/tools/ .PHONY: autoschedulers autoschedulers: \ diff --git a/apps/support/Makefile.inc b/apps/support/Makefile.inc index bbfacd2da136..3fb47b7940f7 100644 --- a/apps/support/Makefile.inc +++ b/apps/support/Makefile.inc @@ -126,18 +126,20 @@ LIB_HALIDE_STATIC = $(HALIDE_DISTRIB_PATH)/lib/libHalide.a LIB_HALIDE = $(HALIDE_DISTRIB_PATH)/bin/libHalide.$(SHARED_EXT) -# Autoschedulers. Mullapudi2016 is currently the default, because it's fast. -AUTOSCHEDULER ?= mullapudi2016 - -LIB_AUTOSCHEDULER ?= $(HALIDE_DISTRIB_PATH)/bin/libautoschedule_$(AUTOSCHEDULER).$(SHARED_EXT) - GENERATOR_DEPS ?= $(LIB_AUTOSCHEDULER) $(LIB_HALIDE) $(HALIDE_DISTRIB_PATH)/include/Halide.h $(HALIDE_DISTRIB_PATH)/tools/GenGen.cpp GENERATOR_DEPS_STATIC ?= $(LIB_HALIDE_STATIC) $(HALIDE_DISTRIB_PATH)/include/Halide.h $(HALIDE_DISTRIB_PATH)/tools/GenGen.cpp # Generators which use autoscheduler plugin need to specify the linker where to find libHalide.so required by the plugin. -LIBHALIDE_LDFLAGS ?= -Wl,-rpath,$(dir $(LIB_HALIDE)) -L $(dir $(LIB_HALIDE)) -Wl,--no-as-needed -lautoschedule_$(AUTOSCHEDULER) -Wl,--as-needed -lHalide $(LDFLAGS) +LIBHALIDE_LDFLAGS ?= -Wl,-rpath,$(dir $(LIB_HALIDE)) -L $(dir $(LIB_HALIDE)) -lHalide $(LDFLAGS) LIBHALIDE_LDFLAGS_STATIC ?= -L $(dir $(LIB_HALIDE_STATIC)) -lHalide $(LDFLAGS) +# Autoschedulers. Mullapudi2016 is currently the default, because it's fast. +AUTOSCHEDULER ?= mullapudi2016 +ifneq ($(AUTOSCHEDULER),) +LIB_AUTOSCHEDULER ?= $(HALIDE_DISTRIB_PATH)/bin/libautoschedule_$(AUTOSCHEDULER).$(SHARED_EXT) +LIBHALIDE_LDFLAGS += -Wl,--no-as-needed -lautoschedule_$(AUTOSCHEDULER) -Wl,--as-needed +endif + LIBPNG_LIBS_DEFAULT = $(shell libpng-config --ldflags) LIBPNG_CXX_FLAGS ?= $(shell libpng-config --cflags) # Workaround for libpng-config pointing to 64-bit versions on linux even when we're building for 32-bit diff --git a/src/autoschedulers/adams2019/Makefile b/src/autoschedulers/adams2019/Makefile index e3ce429b07d2..01cdf42a6ca1 100644 --- a/src/autoschedulers/adams2019/Makefile +++ b/src/autoschedulers/adams2019/Makefile @@ -1,12 +1,14 @@ THIS_MAKEFILE = $(realpath $(filter %Makefile, $(MAKEFILE_LIST))) SRC = $(strip $(shell dirname $(THIS_MAKEFILE))) -HALIDE_SRC_ROOT = $(realpath $(SRC)/../../../../) +HALIDE_SRC_ROOT = $(realpath $(SRC)/../../../) COMMON_DIR ?= $(realpath $(SRC)/../common/) HALIDE_DISTRIB_PATH ?= $(HALIDE_SRC_ROOT)/distrib $(info Looking for Halide distro at $(HALIDE_DISTRIB_PATH). If this is incorrect, set the make variable HALIDE_DISTRIB_PATH) +# Don't include an autoscheduler in the generator deps +AUTOSCHEDULER= include $(HALIDE_SRC_ROOT)/apps/support/Makefile.inc CXXFLAGS += -I$(COMMON_DIR) diff --git a/src/autoschedulers/li2018/Makefile b/src/autoschedulers/li2018/Makefile index 50c3cb4d7cc3..9e96e518dcbd 100644 --- a/src/autoschedulers/li2018/Makefile +++ b/src/autoschedulers/li2018/Makefile @@ -1,14 +1,14 @@ THIS_MAKEFILE = $(realpath $(filter %Makefile, $(MAKEFILE_LIST))) SRC = $(strip $(shell dirname $(THIS_MAKEFILE))) -HALIDE_ROOT = $(realpath $(SRC)/../../../../) +HALIDE_SRC_ROOT = $(realpath $(SRC)/../../../) COMMON_DIR = $(realpath $(SRC)/../common/) # Assume an in-tree build of a halide distro exists. Most uses of this # Makefile should probably set this variable explicitly. -HALIDE_DISTRIB_PATH ?= $(realpath $(SRC)/../../../../distrib) +HALIDE_DISTRIB_PATH ?= $(HALIDE_SRC_ROOT)/distrib # The example uses a generator, though the autoscheduler itself does not require one -include $(HALIDE_ROOT)/apps/support/Makefile.inc +include $(HALIDE_SRC_ROOT)/apps/support/Makefile.inc CXXFLAGS += -I$(COMMON_DIR) @@ -19,7 +19,7 @@ $(BIN)/libautoschedule_li2018.so: $(SRC)/GradientAutoscheduler.cpp $(LIB_HALIDE) # Demonstrate a JIT-based use of gradient autoscheuler $(BIN)/test: $(SRC)/test.cpp $(BIN)/libautoschedule_li2018.so @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $(USE_EXPORT_DYNAMIC) test.cpp -o $@ $(LIBHALIDE_LDFLAGS) $(HALIDE_SYSTEM_LIBS) + $(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) @@ -47,7 +47,7 @@ run_test_cpp: $(BIN)/test run_test_py: $(SRC)/test.py $(BIN)/libautoschedule_li2018.so PYTHONPATH=$(BIN):$(HALIDE_PYTHON_BINDINGS_PATH):$(HALIDE_DISTRIB_PATH)/bin:$$PYTHONPATH \ LD_LIBRARY_PATH=$(BIN):$(HALIDE_PYTHON_BINDINGS_PATH):$(HALIDE_DISTRIB_PATH)/bin \ - $(PYTHON) test.py + $(PYTHON) $(SRC)/test.py build: $(BIN)/test $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.so diff --git a/src/autoschedulers/li2018/test.py b/src/autoschedulers/li2018/test.py index a7483460eaef..438f28fb0547 100644 --- a/src/autoschedulers/li2018/test.py +++ b/src/autoschedulers/li2018/test.py @@ -1,7 +1,7 @@ import halide as hl def main(): - hl.load_plugin("gradient_autoscheduler") + hl.load_plugin("autoschedule_li2018") x = hl.Var('x') f_in = hl.Func('in') diff --git a/src/autoschedulers/mullapudi2016/Makefile b/src/autoschedulers/mullapudi2016/Makefile index dce6c8b35bff..1104ea8c74ab 100644 --- a/src/autoschedulers/mullapudi2016/Makefile +++ b/src/autoschedulers/mullapudi2016/Makefile @@ -1,9 +1,9 @@ THIS_MAKEFILE = $(realpath $(filter %Makefile, $(MAKEFILE_LIST))) SRC = $(strip $(shell dirname $(THIS_MAKEFILE))) -HALIDE_ROOT = $(realpath $(SRC)/../../../../) +HALIDE_ROOT = $(realpath $(SRC)/../../../) COMMON_DIR = $(realpath $(SRC)/../common/) -HALIDE_DISTRIB_PATH ?= $(realpath $(SRC)/../../../../distrib) +HALIDE_DISTRIB_PATH ?= $(HALIDE_SRC_ROOT)/distrib include $(HALIDE_ROOT)/apps/support/Makefile.inc CXXFLAGS += -I$(COMMON_DIR) From 60676eaf89bc742e9c52ac2daa63a5a220435e92 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Sat, 12 Sep 2020 16:42:32 -0700 Subject: [PATCH 14/31] Add autotuning utils to package --- packaging/CMakeLists.txt | 21 ++++++++++++++++++--- src/CMakeLists.txt | 4 ++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index 6b330dfb2773..8986029d998f 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -60,6 +60,11 @@ install(TARGETS Halide_Runtime EXPORT Halide_Interfaces INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +if (TARGET Halide_Adams2019) + install(TARGETS retrain_cost_model featurization_to_sample get_host_target weightsdir_to_weightsfile + EXPORT Halide_Interfaces) +endif () + # Captures both the runtime and Halide.h install(DIRECTORY ${Halide_BINARY_DIR}/include/ TYPE INCLUDE FILES_MATCHING PATTERN "include/*.h") @@ -80,6 +85,7 @@ install(FILES install(DIRECTORY ${Halide_SOURCE_DIR}/tools TYPE DATA + COMPONENT Halide_Development FILES_MATCHING PATTERN "*.h" PATTERN "*.cpp" @@ -88,6 +94,10 @@ install(DIRECTORY ${Halide_SOURCE_DIR}/tools PATTERN "build_halide_h.cpp" EXCLUDE PATTERN "find_inverse.cpp" EXCLUDE) +install(FILES ${Halide_SOURCE_DIR}/src/autoschedulers/adams2019/autotune_loop.sh + DESTINATION ${CMAKE_INSTALL_DATADIR}/tools + COMPONENT Halide_Development) + ## # Tutorial ## @@ -124,7 +134,9 @@ if (Halide_SHARED_LLVM OR (NOT BUILD_SHARED_LIBS AND NOT Halide_BUNDLE_LLVM)) file(APPEND "${depFile}" "find_dependency(LLD CONFIG HINTS \"\${LLVM_DIR}/../lld\")\n") endif () - install(FILES "${depFile}" DESTINATION ${HALIDE_INSTALL_CMAKEDIR}) + install(FILES "${depFile}" + DESTINATION ${HALIDE_INSTALL_CMAKEDIR} + COMPONENT Halide_Development) endif () install(EXPORT Halide_Targets @@ -150,14 +162,17 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/HalideConfigVersion.cmake ${Halide_SOURCE_DIR}/cmake/HalideGeneratorHelpers.cmake ${Halide_SOURCE_DIR}/cmake/HalideTargetHelpers.cmake - DESTINATION ${HALIDE_INSTALL_CMAKEDIR}) + DESTINATION ${HALIDE_INSTALL_CMAKEDIR} + COMPONENT Halide_Development) ## # Documentation ## if (WITH_DOCS) - install(DIRECTORY ${Halide_BINARY_DIR}/doc/html/ TYPE DOC) + install(DIRECTORY ${Halide_BINARY_DIR}/doc/html/ + TYPE DOC + COMPONENT Halide_Documentation) endif () ## diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f75b50e5137..1d3f84a86314 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -474,8 +474,8 @@ endif () ## if (BUILD_SHARED_LIBS) - message(STATUS "Building autoschedulers") + message(STATUS "Building autoschedulers enabled") add_subdirectory(autoschedulers) else () - message(STATUS "Not building autoschedulers (static Halide)") + message(STATUS "Building autoschedulers disabled (static Halide)") endif () From fba78505947e15fc80e38fc72618b5a9ffcb79a6 Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Sat, 12 Sep 2020 16:47:51 -0700 Subject: [PATCH 15/31] autoscheduler Makefile fixes for os x --- Makefile | 6 ++++-- apps/support/Makefile.inc | 4 ++++ src/autoschedulers/adams2019/Makefile | 20 ++++++++++---------- src/autoschedulers/li2018/Makefile | 16 ++++++++-------- src/autoschedulers/mullapudi2016/Makefile | 2 +- 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 62ac5daeb252..b01c50b5245a 100644 --- a/Makefile +++ b/Makefile @@ -2182,16 +2182,18 @@ $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT): \ $(DISTRIB_DIR)/bin/libautoschedule_%.$(SHARED_EXT): $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT) $(MAKE) -f $(SRC_DIR)/autoschedulers/$*/Makefile bin/libautoschedule_$*.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) - cp $(BIN_DIR)/libautoschedule_$*.so $(DISTRIB_DIR)/bin; + cp $(BIN_DIR)/libautoschedule_$*.$(SHARED_EXT) $(DISTRIB_DIR)/bin + install_name_tool -id $(CURDIR)/$@ $(CURDIR)/$@ # Adams2019 also includes autotuning tools $(DISTRIB_DIR)/bin/libautoschedule_adams2019.$(SHARED_EXT): $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT) $(MAKE) -f $(SRC_DIR)/autoschedulers/adams2019/Makefile bin/libautoschedule_adams2019.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) bin/retrain_cost_model bin/featurization_to_sample bin/get_host_target - cp $(BIN_DIR)/libautoschedule_adams2019.so $(DISTRIB_DIR)/bin/ + cp $(BIN_DIR)/libautoschedule_adams2019.$(SHARED_EXT) $(DISTRIB_DIR)/bin/ cp $(BIN_DIR)/retrain_cost_model $(DISTRIB_DIR)/bin/ cp $(BIN_DIR)/featurization_to_sample $(DISTRIB_DIR)/bin/ cp $(BIN_DIR)/get_host_target $(DISTRIB_DIR)/bin/ cp $(SRC_DIR)/autoschedulers/adams2019/autotune_loop.sh $(DISTRIB_DIR)/tools/ + install_name_tool -id $(CURDIR)/$@ $(CURDIR)/$@ .PHONY: autoschedulers autoschedulers: \ diff --git a/apps/support/Makefile.inc b/apps/support/Makefile.inc index 3fb47b7940f7..9e4d43184bed 100644 --- a/apps/support/Makefile.inc +++ b/apps/support/Makefile.inc @@ -137,8 +137,12 @@ LIBHALIDE_LDFLAGS_STATIC ?= -L $(dir $(LIB_HALIDE_STATIC)) -lHalide $(LDFLAGS) AUTOSCHEDULER ?= mullapudi2016 ifneq ($(AUTOSCHEDULER),) LIB_AUTOSCHEDULER ?= $(HALIDE_DISTRIB_PATH)/bin/libautoschedule_$(AUTOSCHEDULER).$(SHARED_EXT) +ifeq ($(UNAME), Darwin) +LIBHALIDE_LDFLAGS += -Wl,-force_load $(HALIDE_DISTRIB_PATH)/bin/libautoschedule_$(AUTOSCHEDULER).$(SHARED_EXT) +else LIBHALIDE_LDFLAGS += -Wl,--no-as-needed -lautoschedule_$(AUTOSCHEDULER) -Wl,--as-needed endif +endif LIBPNG_LIBS_DEFAULT = $(shell libpng-config --ldflags) LIBPNG_CXX_FLAGS ?= $(shell libpng-config --cflags) diff --git a/src/autoschedulers/adams2019/Makefile b/src/autoschedulers/adams2019/Makefile index 01cdf42a6ca1..72a5db04bfa2 100644 --- a/src/autoschedulers/adams2019/Makefile +++ b/src/autoschedulers/adams2019/Makefile @@ -48,7 +48,7 @@ $(BIN)/cost_model/%.a: $(BIN)/cost_model.generator # It's important to use dynamic lookups for undefined symbols here: all of libHalide # is expected to be present (in the loading binary), so we explicitly make the symbols # undefined rather than dependent on libHalide.so. -$(BIN)/libautoschedule_adams2019.so: $(SRC)/AutoSchedule.cpp \ +$(BIN)/libautoschedule_adams2019.$(SHARED_EXT): $(SRC)/AutoSchedule.cpp \ $(SRC)/ASLog.cpp \ $(SRC)/DefaultCostModel.h \ $(SRC)/DefaultCostModel.cpp \ @@ -107,22 +107,22 @@ $(GENERATOR_BIN)/demo.generator: $(SRC)/demo_generator.cpp $(GENERATOR_DEPS) $(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.so +$(BIN)/%/demo.a: $(GENERATOR_BIN)/demo.generator $(BIN)/libautoschedule_adams2019.$(SHARED_EXT) @mkdir -p $(@D) HL_WEIGHTS_DIR=$(SRC)/baseline.weights \ - $(GENERATOR_BIN)/demo.generator -g demo -o $(@D) -f demo target=$* auto_schedule=true -p $(BIN)/libautoschedule_adams2019.so -s Adams2019 + $(GENERATOR_BIN)/demo.generator -g demo -o $(@D) -f demo target=$* auto_schedule=true -p $(BIN)/libautoschedule_adams2019.$(SHARED_EXT) -s Adams2019 $(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.so +demo: $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_adams2019.$(SHARED_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.so $(SRC)/autotune_loop.sh +autotune: $(GENERATOR_BIN)/demo.generator $(BIN)/featurization_to_sample $(BIN)/get_host_target $(BIN)/retrain_cost_model $(BIN)/libautoschedule_adams2019.$(SHARED_EXT) $(SRC)/autotune_loop.sh @mkdir -p $(@D) bash $(SRC)/autotune_loop.sh \ $(GENERATOR_BIN)/demo.generator \ @@ -142,7 +142,7 @@ $(BIN)/test_function_dag: $(SRC)/test_function_dag.cpp $(SRC)/FunctionDAG.h $(SR $(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.so +$(BIN)/%/test: $(SRC)/test.cpp $(BIN)/libautoschedule_adams2019.$(SHARED_EXT) @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $(USE_EXPORT_DYNAMIC) $^ -o $@ $(LIBHALIDE_LDFLAGS) $(HALIDE_SYSTEM_LIBS) @@ -153,7 +153,7 @@ test_function_dag: $(BIN)/test_function_dag $^ run_test: $(BIN)/$(HL_TARGET)/test - HL_WEIGHTS_DIR=$(SRC)/baseline.weights LD_LIBRARY_PATH=$(BIN) $< $(BIN)/libautoschedule_adams2019.so + HL_WEIGHTS_DIR=$(SRC)/baseline.weights LD_LIBRARY_PATH=$(BIN) $< $(BIN)/libautoschedule_adams2019.$(SHARED_EXT) .PHONY: test clean @@ -168,7 +168,7 @@ build: $(BIN)/$(HL_TARGET)/test \ $(BIN)/featurization_to_sample \ $(BIN)/get_host_target \ $(BIN)/retrain_cost_model \ - $(BIN)/libautoschedule_adams2019.so + $(BIN)/libautoschedule_adams2019.$(SHARED_EXT) test: run_test test_perfect_hash_map test_function_dag demo test_included_schedule_file autotune @@ -191,10 +191,10 @@ $(GENERATOR_BIN)/included_schedule_file_none.generator: $(SRC)/included_schedule # 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.so +$(BIN)/%/included_schedule_file.schedule.h: $(GENERATOR_BIN)/included_schedule_file_none.generator $(BIN)/libautoschedule_adams2019.$(SHARED_EXT) @mkdir -p $(@D) HL_WEIGHTS_DIR=$(SRC)/baseline.weights \ - $< -g included_schedule_file -o $(@D) -f included_schedule_file target=$* auto_schedule=true -p $(BIN)/libautoschedule_adams2019.so -s Adams2019 -e schedule + $< -g included_schedule_file -o $(@D) -f included_schedule_file target=$* auto_schedule=true -p $(BIN)/libautoschedule_adams2019.$(SHARED_EXT) -s Adams2019 -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 diff --git a/src/autoschedulers/li2018/Makefile b/src/autoschedulers/li2018/Makefile index 9e96e518dcbd..1b96265957b8 100644 --- a/src/autoschedulers/li2018/Makefile +++ b/src/autoschedulers/li2018/Makefile @@ -12,12 +12,12 @@ include $(HALIDE_SRC_ROOT)/apps/support/Makefile.inc CXXFLAGS += -I$(COMMON_DIR) -$(BIN)/libautoschedule_li2018.so: $(SRC)/GradientAutoscheduler.cpp $(LIB_HALIDE) +$(BIN)/libautoschedule_li2018.$(SHARED_EXT): $(SRC)/GradientAutoscheduler.cpp $(LIB_HALIDE) @mkdir -p $(@D) $(CXX) -shared $(USE_EXPORT_DYNAMIC) -fPIC -fvisibility=hidden -fvisibility-inlines-hidden $(CXXFLAGS) $(OPTIMIZE) $^ -o $@ $(HALIDE_SYSTEM_LIBS) # Demonstrate a JIT-based use of gradient autoscheuler -$(BIN)/test: $(SRC)/test.cpp $(BIN)/libautoschedule_li2018.so +$(BIN)/test: $(SRC)/test.cpp $(BIN)/libautoschedule_li2018.$(SHARED_EXT) @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $(USE_EXPORT_DYNAMIC) $(SRC)/test.cpp -o $@ $(LIBHALIDE_LDFLAGS) $(HALIDE_SYSTEM_LIBS) @@ -27,9 +27,9 @@ $(GENERATOR_BIN)/demo.generator: $(SRC)/demo_generator.cpp $(GENERATOR_DEPS) $(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.so +$(BIN)/%/demo.a: $(GENERATOR_BIN)/demo.generator $(BIN)/libautoschedule_li2018.$(SHARED_EXT) @mkdir -p $(@D) - $(GENERATOR_BIN)/demo.generator -g demo -o $(@D) -f demo target=$* auto_schedule=true -p $(BIN)/libautoschedule_li2018.so -s Li2018 + $(GENERATOR_BIN)/demo.generator -g demo -o $(@D) -f demo target=$* auto_schedule=true -p $(BIN)/libautoschedule_li2018.$(SHARED_EXT) -s Li2018 $(BIN)/%/demo.rungen: $(BIN)/%/RunGenMain.o $(BIN)/%/demo.registration.cpp $(BIN)/%/demo.a @mkdir -p $(@D) @@ -38,18 +38,18 @@ $(BIN)/%/demo.rungen: $(BIN)/%/RunGenMain.o $(BIN)/%/demo.registration.cpp $(BIN .PHONY: build test clean run_test_cpp run_test_py test_generator # demonstrates single-shot use of the autoscheduler -test_generator: $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.so +test_generator: $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.$(SHARED_EXT) $< --benchmarks=all --benchmark_min_time=1 --estimate_all run_test_cpp: $(BIN)/test - LD_LIBRARY_PATH=$(BIN) $< $(BIN)/libautoschedule_li2018.so + LD_LIBRARY_PATH=$(BIN) $< $(BIN)/libautoschedule_li2018.$(SHARED_EXT) -run_test_py: $(SRC)/test.py $(BIN)/libautoschedule_li2018.so +run_test_py: $(SRC)/test.py $(BIN)/libautoschedule_li2018.$(SHARED_EXT) PYTHONPATH=$(BIN):$(HALIDE_PYTHON_BINDINGS_PATH):$(HALIDE_DISTRIB_PATH)/bin:$$PYTHONPATH \ LD_LIBRARY_PATH=$(BIN):$(HALIDE_PYTHON_BINDINGS_PATH):$(HALIDE_DISTRIB_PATH)/bin \ $(PYTHON) $(SRC)/test.py -build: $(BIN)/test $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.so +build: $(BIN)/test $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.$(SHARED_EXT) test: run_test_cpp run_test_py test_generator diff --git a/src/autoschedulers/mullapudi2016/Makefile b/src/autoschedulers/mullapudi2016/Makefile index 1104ea8c74ab..907bd875e8e2 100644 --- a/src/autoschedulers/mullapudi2016/Makefile +++ b/src/autoschedulers/mullapudi2016/Makefile @@ -8,6 +8,6 @@ include $(HALIDE_ROOT)/apps/support/Makefile.inc CXXFLAGS += -I$(COMMON_DIR) -$(BIN)/libautoschedule_mullapudi2016.so: $(SRC)/AutoSchedule.cpp $(LIB_HALIDE) +$(BIN)/libautoschedule_mullapudi2016.$(SHARED_EXT): $(SRC)/AutoSchedule.cpp $(LIB_HALIDE) @mkdir -p $(@D) $(CXX) -shared $(USE_EXPORT_DYNAMIC) -fPIC -fvisibility=hidden -fvisibility-inlines-hidden $(CXXFLAGS) $(OPTIMIZE) $^ -o $@ $(HALIDE_SYSTEM_LIBS) From f2c73e73acb8a49eb9d829305209fc810aa3f4f9 Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Sat, 12 Sep 2020 16:50:38 -0700 Subject: [PATCH 16/31] Don't run install_name_tool on not-osx --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index b01c50b5245a..d10775be2871 100644 --- a/Makefile +++ b/Makefile @@ -2183,7 +2183,9 @@ $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT): \ $(DISTRIB_DIR)/bin/libautoschedule_%.$(SHARED_EXT): $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT) $(MAKE) -f $(SRC_DIR)/autoschedulers/$*/Makefile bin/libautoschedule_$*.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) cp $(BIN_DIR)/libautoschedule_$*.$(SHARED_EXT) $(DISTRIB_DIR)/bin +ifeq ($(UNAME), Darwin) install_name_tool -id $(CURDIR)/$@ $(CURDIR)/$@ +endif # Adams2019 also includes autotuning tools $(DISTRIB_DIR)/bin/libautoschedule_adams2019.$(SHARED_EXT): $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT) @@ -2193,7 +2195,9 @@ $(DISTRIB_DIR)/bin/libautoschedule_adams2019.$(SHARED_EXT): $(DISTRIB_DIR)/bin/l cp $(BIN_DIR)/featurization_to_sample $(DISTRIB_DIR)/bin/ cp $(BIN_DIR)/get_host_target $(DISTRIB_DIR)/bin/ cp $(SRC_DIR)/autoschedulers/adams2019/autotune_loop.sh $(DISTRIB_DIR)/tools/ +ifeq ($(UNAME), Darwin) install_name_tool -id $(CURDIR)/$@ $(CURDIR)/$@ +endif .PHONY: autoschedulers autoschedulers: \ From 0511f61bf56e4db40ddb414e758786508a5732f7 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Sat, 12 Sep 2020 17:29:40 -0700 Subject: [PATCH 17/31] Fix RPATH on macOS/Linux --- packaging/CMakeLists.txt | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index 8986029d998f..8bb6480b89f9 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -60,11 +60,28 @@ install(TARGETS Halide_Runtime EXPORT Halide_Interfaces INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -if (TARGET Halide_Adams2019) - install(TARGETS retrain_cost_model featurization_to_sample get_host_target weightsdir_to_weightsfile - EXPORT Halide_Interfaces) +set(exes "") +foreach (exe IN ITEMS retrain_cost_model featurization_to_sample get_host_target weightsdir_to_weightsfile) + if (TARGET ${exe}) + list(APPEND exes ${exe}) + endif () +endforeach () + +file(RELATIVE_PATH lib_dir + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR} + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) + +if (APPLE) + set(rbase @loader_path) +else () + set(rbase $ORIGIN) endif () +set_target_properties(${exes} PROPERTIES INSTALL_RPATH "${rbase};${rbase}/${lib_dir}") + +install(TARGETS ${exes} + EXPORT Halide_Interfaces) + # Captures both the runtime and Halide.h install(DIRECTORY ${Halide_BINARY_DIR}/include/ TYPE INCLUDE FILES_MATCHING PATTERN "include/*.h") From 7854b52f34f9eb131e4b8762199455cb53efc71a Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Sat, 12 Sep 2020 18:17:10 -0700 Subject: [PATCH 18/31] Enable introspection when compiling with gcc/clang. --- src/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1d3f84a86314..9b07b680b45c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -373,7 +373,10 @@ add_library(Halide::Halide ALIAS Halide) target_link_libraries(Halide PRIVATE Halide::LLVM) target_link_libraries(Halide PUBLIC Halide::LanguageOptions) -target_compile_definitions(Halide PRIVATE $<$,STATIC_LIBRARY>:Halide_STATIC_DEFINE>) +target_compile_definitions(Halide + PRIVATE + $<$,STATIC_LIBRARY>:Halide_STATIC_DEFINE> + $<$:WITH_INTROSPECTION>) set_target_properties(Halide PROPERTIES POSITION_INDEPENDENT_CODE ON From 18197a0747455fa9927b741e8a9bd55517e9bd38 Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Sat, 12 Sep 2020 19:18:08 -0700 Subject: [PATCH 19/31] Move libHalide from bin to lib in distros --- Makefile | 35 ++++++++++++++++++++++------------- apps/support/Makefile.inc | 8 ++++---- python_bindings/Makefile | 2 +- tools/mex_halide.m | 6 +++--- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index d10775be2871..be6ff6ad6663 100644 --- a/Makefile +++ b/Makefile @@ -2138,7 +2138,7 @@ $(BUILD_DIR)/halide_config.%: $(ROOT_DIR)/tools/halide_config.%.tpl | sed -e 's;@HALIDE_LLVM_CXX_FLAGS_RAW@;${LLVM_CXX_FLAGS};g' > $@ -$(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT): \ +$(DISTRIB_DIR)/lib/libHalide.$(SHARED_EXT): \ $(LIB_DIR)/libHalide.a \ $(BIN_DIR)/libHalide.$(SHARED_EXT) \ $(INCLUDE_DIR)/Halide.h \ @@ -2154,7 +2154,7 @@ $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT): \ $(DISTRIB_DIR)/tutorial/images \ $(DISTRIB_DIR)/tools \ $(DISTRIB_DIR)/tutorial/figures - cp $(BIN_DIR)/libHalide.$(SHARED_EXT) $(DISTRIB_DIR)/bin + cp $(BIN_DIR)/libHalide.$(SHARED_EXT) $(DISTRIB_DIR)/lib cp $(LIB_DIR)/libHalide.a $(DISTRIB_DIR)/lib cp $(INCLUDE_DIR)/Halide.h $(DISTRIB_DIR)/include cp $(INCLUDE_DIR)/HalideBuffer.h $(DISTRIB_DIR)/include @@ -2180,20 +2180,29 @@ $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT): \ cp $(ROOT_DIR)/README*.md $(DISTRIB_DIR) cp $(BUILD_DIR)/halide_config.* $(DISTRIB_DIR) -$(DISTRIB_DIR)/bin/libautoschedule_%.$(SHARED_EXT): $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT) +$(DISTRIB_DIR)/lib/libautoschedule_%.$(SHARED_EXT): $(DISTRIB_DIR)/lib/libHalide.$(SHARED_EXT) $(MAKE) -f $(SRC_DIR)/autoschedulers/$*/Makefile bin/libautoschedule_$*.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) - cp $(BIN_DIR)/libautoschedule_$*.$(SHARED_EXT) $(DISTRIB_DIR)/bin + cp $(BIN_DIR)/libautoschedule_$*.$(SHARED_EXT) $(DISTRIB_DIR)/lib ifeq ($(UNAME), Darwin) install_name_tool -id $(CURDIR)/$@ $(CURDIR)/$@ endif # Adams2019 also includes autotuning tools -$(DISTRIB_DIR)/bin/libautoschedule_adams2019.$(SHARED_EXT): $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT) +$(DISTRIB_DIR)/lib/libautoschedule_adams2019.$(SHARED_EXT): $(DISTRIB_DIR)/lib/libHalide.$(SHARED_EXT) $(MAKE) -f $(SRC_DIR)/autoschedulers/adams2019/Makefile bin/libautoschedule_adams2019.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) bin/retrain_cost_model bin/featurization_to_sample bin/get_host_target - cp $(BIN_DIR)/libautoschedule_adams2019.$(SHARED_EXT) $(DISTRIB_DIR)/bin/ - cp $(BIN_DIR)/retrain_cost_model $(DISTRIB_DIR)/bin/ - cp $(BIN_DIR)/featurization_to_sample $(DISTRIB_DIR)/bin/ - cp $(BIN_DIR)/get_host_target $(DISTRIB_DIR)/bin/ + cp $(BIN_DIR)/libautoschedule_adams2019.$(SHARED_EXT) $(DISTRIB_DIR)/lib/ + # Make rpath relative +ifeq ($(UNAME), Darwin) + for TOOL in retrain_cost_model featurization_to_sample get_host_target; do \ + cp $(BIN_DIR)/$${TOOL} $(DISTRIB_DIR)/bin/; \ + install_name_tool -add_rpath '@executable_path/../lib' $(DISTRIB_DIR)/bin/$${TOOL}; \ + done +else + for TOOL in retrain_cost_model featurization_to_sample get_host_target; do \ + cp $(BIN_DIR)/$${TOOL} $(DISTRIB_DIR)/bin/; \ + patchelf --set-rpath '$$ORIGIN/../lib' $(DISTRIB_DIR)/bin/$${TOOL}; \ + done +endif cp $(SRC_DIR)/autoschedulers/adams2019/autotune_loop.sh $(DISTRIB_DIR)/tools/ ifeq ($(UNAME), Darwin) install_name_tool -id $(CURDIR)/$@ $(CURDIR)/$@ @@ -2201,12 +2210,12 @@ endif .PHONY: autoschedulers autoschedulers: \ -$(DISTRIB_DIR)/bin/libautoschedule_mullapudi2016.$(SHARED_EXT) \ -$(DISTRIB_DIR)/bin/libautoschedule_li2018.$(SHARED_EXT) \ -$(DISTRIB_DIR)/bin/libautoschedule_adams2019.$(SHARED_EXT) +$(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) \ +$(DISTRIB_DIR)/lib/libautoschedule_li2018.$(SHARED_EXT) \ +$(DISTRIB_DIR)/lib/libautoschedule_adams2019.$(SHARED_EXT) .PHONY: distrib -distrib: $(DISTRIB_DIR)/bin/libHalide.$(SHARED_EXT) autoschedulers +distrib: $(DISTRIB_DIR)/lib/libHalide.$(SHARED_EXT) autoschedulers $(DISTRIB_DIR)/halide.tgz: distrib ln -sf $(DISTRIB_DIR) halide diff --git a/apps/support/Makefile.inc b/apps/support/Makefile.inc index 9e4d43184bed..cf8203da1011 100644 --- a/apps/support/Makefile.inc +++ b/apps/support/Makefile.inc @@ -124,21 +124,21 @@ LDFLAGS-arm-32-android ?= -llog -fPIE -pie LIB_HALIDE_STATIC = $(HALIDE_DISTRIB_PATH)/lib/libHalide.a -LIB_HALIDE = $(HALIDE_DISTRIB_PATH)/bin/libHalide.$(SHARED_EXT) +LIB_HALIDE = $(HALIDE_DISTRIB_PATH)/lib/libHalide.$(SHARED_EXT) GENERATOR_DEPS ?= $(LIB_AUTOSCHEDULER) $(LIB_HALIDE) $(HALIDE_DISTRIB_PATH)/include/Halide.h $(HALIDE_DISTRIB_PATH)/tools/GenGen.cpp GENERATOR_DEPS_STATIC ?= $(LIB_HALIDE_STATIC) $(HALIDE_DISTRIB_PATH)/include/Halide.h $(HALIDE_DISTRIB_PATH)/tools/GenGen.cpp # Generators which use autoscheduler plugin need to specify the linker where to find libHalide.so required by the plugin. LIBHALIDE_LDFLAGS ?= -Wl,-rpath,$(dir $(LIB_HALIDE)) -L $(dir $(LIB_HALIDE)) -lHalide $(LDFLAGS) -LIBHALIDE_LDFLAGS_STATIC ?= -L $(dir $(LIB_HALIDE_STATIC)) -lHalide $(LDFLAGS) +LIBHALIDE_LDFLAGS_STATIC ?= $(LIB_HALIDE_STATIC) $(LDFLAGS) # Autoschedulers. Mullapudi2016 is currently the default, because it's fast. AUTOSCHEDULER ?= mullapudi2016 ifneq ($(AUTOSCHEDULER),) -LIB_AUTOSCHEDULER ?= $(HALIDE_DISTRIB_PATH)/bin/libautoschedule_$(AUTOSCHEDULER).$(SHARED_EXT) +LIB_AUTOSCHEDULER ?= $(HALIDE_DISTRIB_PATH)/lib/libautoschedule_$(AUTOSCHEDULER).$(SHARED_EXT) ifeq ($(UNAME), Darwin) -LIBHALIDE_LDFLAGS += -Wl,-force_load $(HALIDE_DISTRIB_PATH)/bin/libautoschedule_$(AUTOSCHEDULER).$(SHARED_EXT) +LIBHALIDE_LDFLAGS += -Wl,-force_load $(HALIDE_DISTRIB_PATH)/lib/libautoschedule_$(AUTOSCHEDULER).$(SHARED_EXT) else LIBHALIDE_LDFLAGS += -Wl,--no-as-needed -lautoschedule_$(AUTOSCHEDULER) -Wl,--as-needed endif diff --git a/python_bindings/Makefile b/python_bindings/Makefile index 51e87794a385..b9b165b1f04d 100644 --- a/python_bindings/Makefile +++ b/python_bindings/Makefile @@ -26,7 +26,7 @@ USE_EXPORT_DYNAMIC= endif endif -LIBHALIDE ?= $(HALIDE_DISTRIB_PATH)/bin/libHalide.$(SHARED_EXT) +LIBHALIDE ?= $(HALIDE_DISTRIB_PATH)/lib/libHalide.$(SHARED_EXT) SUFFIX = $(shell $(PYTHON)-config --extension-suffix) diff --git a/tools/mex_halide.m b/tools/mex_halide.m index 9d9d1d0f5e91..b1dba967c5a0 100644 --- a/tools/mex_halide.m +++ b/tools/mex_halide.m @@ -61,9 +61,9 @@ function mex_halide( generator_filename, varargin ) halide_distrib_path = getenv('HALIDE_DISTRIB_PATH'); if ismac - libhalide = fullfile(halide_distrib_path, 'bin', 'libHalide.dylib'); + libhalide = fullfile(halide_distrib_path, 'lib', 'libHalide.dylib'); else - libhalide = fullfile(halide_distrib_path, 'bin', 'libHalide.so'); + libhalide = fullfile(halide_distrib_path, 'lib', 'libHalide.so'); end halide_include = fullfile(halide_distrib_path, 'include'); @@ -73,7 +73,7 @@ function mex_halide( generator_filename, varargin ) end halide_cxx = getenv('HALIDE_CXX'); - ld_library_path = fullfile(halide_distrib_path, 'bin'); + ld_library_path = fullfile(halide_distrib_path, 'lib'); % Build the command to build the generator. gen_bin = fullfile(temp, [function_name, '.generator']); From 26bf23ee7b3d31019006eac809dbb1c1f619c469 Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Sat, 12 Sep 2020 19:19:42 -0700 Subject: [PATCH 20/31] bin -> lib in tutorials --- tutorial/lesson_01_basics.cpp | 8 ++++---- tutorial/lesson_02_input_image.cpp | 8 ++++---- tutorial/lesson_03_debugging_1.cpp | 8 ++++---- tutorial/lesson_04_debugging_2.cpp | 8 ++++---- tutorial/lesson_05_scheduling_1.cpp | 8 ++++---- tutorial/lesson_06_realizing_over_shifted_domains.cpp | 8 ++++---- tutorial/lesson_07_multi_stage_pipelines.cpp | 8 ++++---- tutorial/lesson_08_scheduling_2.cpp | 8 ++++---- tutorial/lesson_09_update_definitions.cpp | 8 ++++---- tutorial/lesson_10_aot_compilation_generate.cpp | 8 ++++---- tutorial/lesson_11_cross_compilation.cpp | 8 ++++---- tutorial/lesson_12_using_the_gpu.cpp | 8 ++++---- tutorial/lesson_13_tuples.cpp | 8 ++++---- tutorial/lesson_14_types.cpp | 8 ++++---- tutorial/lesson_15_generators.cpp | 4 ++-- tutorial/lesson_15_generators_usage.sh | 4 ++-- tutorial/lesson_16_rgb_generate.cpp | 6 +++--- tutorial/lesson_17_predicated_rdom.cpp | 8 ++++---- tutorial/lesson_18_parallel_associative_reductions.cpp | 8 ++++---- tutorial/lesson_19_wrapper_funcs.cpp | 8 ++++---- tutorial/lesson_20_cloning_funcs.cpp | 8 ++++---- tutorial/lesson_21_auto_scheduler_generate.cpp | 6 +++--- 22 files changed, 82 insertions(+), 82 deletions(-) diff --git a/tutorial/lesson_01_basics.cpp b/tutorial/lesson_01_basics.cpp index 793e6200256e..e0092228e301 100644 --- a/tutorial/lesson_01_basics.cpp +++ b/tutorial/lesson_01_basics.cpp @@ -3,12 +3,12 @@ // This lesson demonstrates basic usage of Halide as a JIT compiler for imaging. // On linux, you can compile and run it like so: -// g++ lesson_01*.cpp -g -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_01 -std=c++11 -// LD_LIBRARY_PATH=../bin ./lesson_01 +// g++ lesson_01*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_01 -std=c++11 +// LD_LIBRARY_PATH=../lib ./lesson_01 // On os x: -// g++ lesson_01*.cpp -g -I ../include -L ../bin -lHalide -o lesson_01 -std=c++11 -// DYLD_LIBRARY_PATH=../bin ./lesson_01 +// g++ lesson_01*.cpp -g -I ../include -L ../lib -lHalide -o lesson_01 -std=c++11 +// DYLD_LIBRARY_PATH=../lib ./lesson_01 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_02_input_image.cpp b/tutorial/lesson_02_input_image.cpp index 45b49b1df14e..ffcb6ae598a7 100644 --- a/tutorial/lesson_02_input_image.cpp +++ b/tutorial/lesson_02_input_image.cpp @@ -4,12 +4,12 @@ // them. // On linux, you can compile and run it like so: -// g++ lesson_02*.cpp -g -I ../include -I ../tools -L ../bin -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -o lesson_02 -std=c++11 -// LD_LIBRARY_PATH=../bin ./lesson_02 +// g++ lesson_02*.cpp -g -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -o lesson_02 -std=c++11 +// LD_LIBRARY_PATH=../lib ./lesson_02 // On os x: -// g++ lesson_02*.cpp -g -I ../include -I ../tools -L ../bin -lHalide `libpng-config --cflags --ldflags` -ljpeg -o lesson_02 -std=c++11 -// DYLD_LIBRARY_PATH=../bin ./lesson_02 +// g++ lesson_02*.cpp -g -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -o lesson_02 -std=c++11 +// DYLD_LIBRARY_PATH=../lib ./lesson_02 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_03_debugging_1.cpp b/tutorial/lesson_03_debugging_1.cpp index 2aa1fd1209dd..2bc6abf4335e 100644 --- a/tutorial/lesson_03_debugging_1.cpp +++ b/tutorial/lesson_03_debugging_1.cpp @@ -3,12 +3,12 @@ // This lesson demonstrates how to inspect what the Halide compiler is producing. // On linux, you can compile and run it like so: -// g++ lesson_03*.cpp -g -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_03 -std=c++11 -// LD_LIBRARY_PATH=../bin ./lesson_03 +// g++ lesson_03*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_03 -std=c++11 +// LD_LIBRARY_PATH=../lib ./lesson_03 // On os x: -// g++ lesson_03*.cpp -g -I ../include -L ../bin -lHalide -o lesson_03 -std=c++11 -// DYLD_LIBRARY_PATH=../bin ./lesson_03 +// g++ lesson_03*.cpp -g -I ../include -L ../lib -lHalide -o lesson_03 -std=c++11 +// DYLD_LIBRARY_PATH=../lib ./lesson_03 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_04_debugging_2.cpp b/tutorial/lesson_04_debugging_2.cpp index f46f2eb90df5..67cccebc68e9 100644 --- a/tutorial/lesson_04_debugging_2.cpp +++ b/tutorial/lesson_04_debugging_2.cpp @@ -3,12 +3,12 @@ // This lesson demonstrates how to follow what Halide is doing at runtime. // On linux, you can compile and run it like so: -// g++ lesson_04*.cpp -g -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_04 -std=c++11 -// LD_LIBRARY_PATH=../bin ./lesson_04 +// g++ lesson_04*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_04 -std=c++11 +// LD_LIBRARY_PATH=../lib ./lesson_04 // On os x: -// g++ lesson_04*.cpp -g -I ../include -L ../bin -lHalide -o lesson_04 -std=c++11 -// DYLD_LIBRARY_PATH=../bin ./lesson_04 +// g++ lesson_04*.cpp -g -I ../include -L ../lib -lHalide -o lesson_04 -std=c++11 +// DYLD_LIBRARY_PATH=../lib ./lesson_04 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_05_scheduling_1.cpp b/tutorial/lesson_05_scheduling_1.cpp index 09736064b32b..d0589031c84b 100644 --- a/tutorial/lesson_05_scheduling_1.cpp +++ b/tutorial/lesson_05_scheduling_1.cpp @@ -5,12 +5,12 @@ // parallelization, unrolling, and tiling. // On linux, you can compile and run it like so: -// g++ lesson_05*.cpp -g -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_05 -std=c++11 -// LD_LIBRARY_PATH=../bin ./lesson_05 +// g++ lesson_05*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_05 -std=c++11 +// LD_LIBRARY_PATH=../lib ./lesson_05 // On os x: -// g++ lesson_05*.cpp -g -I ../include -L ../bin -lHalide -o lesson_05 -std=c++11 -// DYLD_LIBRARY_PATH=../bin ./lesson_05 +// g++ lesson_05*.cpp -g -I ../include -L ../lib -lHalide -o lesson_05 -std=c++11 +// DYLD_LIBRARY_PATH=../lib ./lesson_05 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_06_realizing_over_shifted_domains.cpp b/tutorial/lesson_06_realizing_over_shifted_domains.cpp index 52df9c5465e9..46e2e5cba811 100644 --- a/tutorial/lesson_06_realizing_over_shifted_domains.cpp +++ b/tutorial/lesson_06_realizing_over_shifted_domains.cpp @@ -4,12 +4,12 @@ // does not start at (0, 0). // On linux, you can compile and run it like so: -// g++ lesson_06*.cpp -g -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_06 -std=c++11 -// LD_LIBRARY_PATH=../bin ./lesson_06 +// g++ lesson_06*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_06 -std=c++11 +// LD_LIBRARY_PATH=../lib ./lesson_06 // On os x: -// g++ lesson_06*.cpp -g -I ../include -L ../bin -lHalide -o lesson_06 -std=c++11 -// DYLD_LIBRARY_PATH=../bin ./lesson_06 +// g++ lesson_06*.cpp -g -I ../include -L ../lib -lHalide -o lesson_06 -std=c++11 +// DYLD_LIBRARY_PATH=../lib ./lesson_06 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_07_multi_stage_pipelines.cpp b/tutorial/lesson_07_multi_stage_pipelines.cpp index 68a5869eb775..88354c7fb5eb 100644 --- a/tutorial/lesson_07_multi_stage_pipelines.cpp +++ b/tutorial/lesson_07_multi_stage_pipelines.cpp @@ -1,12 +1,12 @@ // Halide tutorial lesson 7: Multi-stage pipelines // On linux, you can compile and run it like so: -// g++ lesson_07*.cpp -g -std=c++11 -I ../include -I ../tools -L ../bin -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -o lesson_07 -// LD_LIBRARY_PATH=../bin ./lesson_07 +// g++ lesson_07*.cpp -g -std=c++11 -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -o lesson_07 +// LD_LIBRARY_PATH=../lib ./lesson_07 // On os x: -// g++ lesson_07*.cpp -g -std=c++11 -I ../include -I ../tools -L ../bin -lHalide `libpng-config --cflags --ldflags` -ljpeg -o lesson_07 -// DYLD_LIBRARY_PATH=../bin ./lesson_07 +// g++ lesson_07*.cpp -g -std=c++11 -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -o lesson_07 +// DYLD_LIBRARY_PATH=../lib ./lesson_07 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_08_scheduling_2.cpp b/tutorial/lesson_08_scheduling_2.cpp index 32ea325f7510..227146b54989 100644 --- a/tutorial/lesson_08_scheduling_2.cpp +++ b/tutorial/lesson_08_scheduling_2.cpp @@ -1,12 +1,12 @@ // Halide tutorial lesson 8: Scheduling multi-stage pipelines // On linux, you can compile and run it like so: -// g++ lesson_08*.cpp -g -std=c++11 -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_08 -// LD_LIBRARY_PATH=../bin ./lesson_08 +// g++ lesson_08*.cpp -g -std=c++11 -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_08 +// LD_LIBRARY_PATH=../lib ./lesson_08 // On os x: -// g++ lesson_08*.cpp -g -std=c++11 -I ../include -L ../bin -lHalide -o lesson_08 -// DYLD_LIBRARY_PATH=../bin ./lesson_08 +// g++ lesson_08*.cpp -g -std=c++11 -I ../include -L ../lib -lHalide -o lesson_08 +// DYLD_LIBRARY_PATH=../lib ./lesson_08 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_09_update_definitions.cpp b/tutorial/lesson_09_update_definitions.cpp index 799cb4ef152a..914759306581 100644 --- a/tutorial/lesson_09_update_definitions.cpp +++ b/tutorial/lesson_09_update_definitions.cpp @@ -1,12 +1,12 @@ // Halide tutorial lesson 9: Multi-pass Funcs, update definitions, and reductions // On linux, you can compile and run it like so: -// g++ lesson_09*.cpp -g -std=c++11 -I ../include -I ../tools -L ../bin -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -fopenmp -o lesson_09 -// LD_LIBRARY_PATH=../bin ./lesson_09 +// g++ lesson_09*.cpp -g -std=c++11 -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -fopenmp -o lesson_09 +// LD_LIBRARY_PATH=../lib ./lesson_09 // On os x (will only work if you actually have g++, not Apple's pretend g++ which is actually clang): -// g++ lesson_09*.cpp -g -std=c++11 -I ../include -I ../tools -L ../bin -lHalide `libpng-config --cflags --ldflags` -ljpeg -fopenmp -o lesson_09 -// DYLD_LIBRARY_PATH=../bin ./lesson_09 +// g++ lesson_09*.cpp -g -std=c++11 -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -fopenmp -o lesson_09 +// DYLD_LIBRARY_PATH=../lib ./lesson_09 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_10_aot_compilation_generate.cpp b/tutorial/lesson_10_aot_compilation_generate.cpp index 9ead4ded78f1..92ab1bd6af26 100644 --- a/tutorial/lesson_10_aot_compilation_generate.cpp +++ b/tutorial/lesson_10_aot_compilation_generate.cpp @@ -10,14 +10,14 @@ // compiling this code is a multi-step process. // On linux, you can compile and run it like so: -// g++ lesson_10*generate.cpp -g -std=c++11 -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_10_generate -// LD_LIBRARY_PATH=../bin ./lesson_10_generate +// g++ lesson_10*generate.cpp -g -std=c++11 -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_10_generate +// LD_LIBRARY_PATH=../lib ./lesson_10_generate // g++ lesson_10*run.cpp lesson_10_halide.a -std=c++11 -I ../include -lpthread -ldl -o lesson_10_run // ./lesson_10_run // On os x: -// g++ lesson_10*generate.cpp -g -std=c++11 -I ../include -L ../bin -lHalide -o lesson_10_generate -// DYLD_LIBRARY_PATH=../bin ./lesson_10_generate +// g++ lesson_10*generate.cpp -g -std=c++11 -I ../include -L ../lib -lHalide -o lesson_10_generate +// DYLD_LIBRARY_PATH=../lib ./lesson_10_generate // g++ lesson_10*run.cpp lesson_10_halide.a -o lesson_10_run -I ../include // ./lesson_10_run diff --git a/tutorial/lesson_11_cross_compilation.cpp b/tutorial/lesson_11_cross_compilation.cpp index 6b479cdea942..ec6fc4608c02 100644 --- a/tutorial/lesson_11_cross_compilation.cpp +++ b/tutorial/lesson_11_cross_compilation.cpp @@ -4,12 +4,12 @@ // generate code for any platform from any platform. // On linux, you can compile and run it like so: -// g++ lesson_11*.cpp -g -std=c++11 -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_11 -// LD_LIBRARY_PATH=../bin ./lesson_11 +// g++ lesson_11*.cpp -g -std=c++11 -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_11 +// LD_LIBRARY_PATH=../lib ./lesson_11 // On os x: -// g++ lesson_11*.cpp -g -std=c++11 -I ../include -L ../bin -lHalide -o lesson_11 -// DYLD_LIBRARY_PATH=../bin ./lesson_11 +// g++ lesson_11*.cpp -g -std=c++11 -I ../include -L ../lib -lHalide -o lesson_11 +// DYLD_LIBRARY_PATH=../lib ./lesson_11 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_12_using_the_gpu.cpp b/tutorial/lesson_12_using_the_gpu.cpp index a6ed49ccfb37..28f78df8cafc 100644 --- a/tutorial/lesson_12_using_the_gpu.cpp +++ b/tutorial/lesson_12_using_the_gpu.cpp @@ -3,12 +3,12 @@ // This lesson demonstrates how to use Halide to run code on a GPU using OpenCL. // On linux, you can compile and run it like so: -// g++ lesson_12*.cpp -g -std=c++11 -I ../include -I ../tools -L ../bin -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -o lesson_12 -// LD_LIBRARY_PATH=../bin ./lesson_12 +// g++ lesson_12*.cpp -g -std=c++11 -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -o lesson_12 +// LD_LIBRARY_PATH=../lib ./lesson_12 // On os x: -// g++ lesson_12*.cpp -g -std=c++11 -I ../include -I ../tools -L ../bin -lHalide `libpng-config --cflags --ldflags` -ljpeg -o lesson_12 -// DYLD_LIBRARY_PATH=../bin ./lesson_12 +// g++ lesson_12*.cpp -g -std=c++11 -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -o lesson_12 +// DYLD_LIBRARY_PATH=../lib ./lesson_12 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_13_tuples.cpp b/tutorial/lesson_13_tuples.cpp index 03d717e166cc..060063080a53 100644 --- a/tutorial/lesson_13_tuples.cpp +++ b/tutorial/lesson_13_tuples.cpp @@ -4,12 +4,12 @@ // values. // On linux, you can compile and run it like so: -// g++ lesson_13*.cpp -g -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_13 -std=c++11 -// LD_LIBRARY_PATH=../bin ./lesson_13 +// g++ lesson_13*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_13 -std=c++11 +// LD_LIBRARY_PATH=../lib ./lesson_13 // On os x: -// g++ lesson_13*.cpp -g -I ../include -L ../bin -lHalide -o lesson_13 -std=c++11 -// DYLD_LIBRARY_PATH=../bin ./lesson_13 +// g++ lesson_13*.cpp -g -I ../include -L ../lib -lHalide -o lesson_13 -std=c++11 +// DYLD_LIBRARY_PATH=../lib ./lesson_13 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_14_types.cpp b/tutorial/lesson_14_types.cpp index abde0858896f..cfe5a2c45fc4 100644 --- a/tutorial/lesson_14_types.cpp +++ b/tutorial/lesson_14_types.cpp @@ -3,12 +3,12 @@ // This lesson more precisely describes Halide's type system. // On linux, you can compile and run it like so: -// g++ lesson_14*.cpp -g -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_14 -std=c++11 -// LD_LIBRARY_PATH=../bin ./lesson_14 +// g++ lesson_14*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_14 -std=c++11 +// LD_LIBRARY_PATH=../lib ./lesson_14 // On os x: -// g++ lesson_14*.cpp -g -I ../include -L ../bin -lHalide -o lesson_14 -std=c++11 -// DYLD_LIBRARY_PATH=../bin ./lesson_14 +// g++ lesson_14*.cpp -g -I ../include -L ../lib -lHalide -o lesson_14 -std=c++11 +// DYLD_LIBRARY_PATH=../lib ./lesson_14 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_15_generators.cpp b/tutorial/lesson_15_generators.cpp index 7451aeeae312..7288f9c12142 100644 --- a/tutorial/lesson_15_generators.cpp +++ b/tutorial/lesson_15_generators.cpp @@ -4,11 +4,11 @@ // reusable components called generators. // On linux, you can compile and run it like so: -// g++ lesson_15*.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_15_generate +// g++ lesson_15*.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_15_generate // bash lesson_15_generators_usage.sh // On os x: -// g++ lesson_15*.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../bin -lHalide -o lesson_15_generate +// g++ lesson_15*.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../lib -lHalide -o lesson_15_generate // bash lesson_15_generators_usage.sh // If you have the entire Halide source tree, you can also build it by diff --git a/tutorial/lesson_15_generators_usage.sh b/tutorial/lesson_15_generators_usage.sh index 7ddf2a360361..f8bf34eebbdf 100644 --- a/tutorial/lesson_15_generators_usage.sh +++ b/tutorial/lesson_15_generators_usage.sh @@ -37,8 +37,8 @@ check_symbol() #set -e # Set up LD_LIBRARY_PATH so that we can find libHalide.so -export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../bin -export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:../bin +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../lib +export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:../lib ######################### # Basic generator usage # diff --git a/tutorial/lesson_16_rgb_generate.cpp b/tutorial/lesson_16_rgb_generate.cpp index 53db6242cf38..f5bc9c368a69 100644 --- a/tutorial/lesson_16_rgb_generate.cpp +++ b/tutorial/lesson_16_rgb_generate.cpp @@ -6,9 +6,9 @@ // On linux or os x, you can compile and run it like so: -// g++ lesson_16_rgb_generate.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_16_generate -// export LD_LIBRARY_PATH=../bin # For linux -// export DYLD_LIBRARY_PATH=../bin # For OS X +// g++ lesson_16_rgb_generate.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_16_generate +// export LD_LIBRARY_PATH=../lib # For linux +// export DYLD_LIBRARY_PATH=../lib # For OS X // ./lesson_16_generate -g brighten -o . -f brighten_planar target=host layout=planar // ./lesson_16_generate -g brighten -o . -f brighten_interleaved target=host layout=interleaved // ./lesson_16_generate -g brighten -o . -f brighten_either target=host layout=either diff --git a/tutorial/lesson_17_predicated_rdom.cpp b/tutorial/lesson_17_predicated_rdom.cpp index 39a4d4f42c1b..c954bc80afc5 100644 --- a/tutorial/lesson_17_predicated_rdom.cpp +++ b/tutorial/lesson_17_predicated_rdom.cpp @@ -4,12 +4,12 @@ // subsets of a reduction domain using predicates. // On linux, you can compile and run it like so: -// g++ lesson_17*.cpp -g -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_17 -std=c++11 -// LD_LIBRARY_PATH=../bin ./lesson_17 +// g++ lesson_17*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_17 -std=c++11 +// LD_LIBRARY_PATH=../lib ./lesson_17 // On os x: -// g++ lesson_17*.cpp -g -I ../include -L ../bin -lHalide -o lesson_17 -std=c++11 -// DYLD_LIBRARY_PATH=../bin ./lesson_17 +// g++ lesson_17*.cpp -g -I ../include -L ../lib -lHalide -o lesson_17 -std=c++11 +// DYLD_LIBRARY_PATH=../lib ./lesson_17 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_18_parallel_associative_reductions.cpp b/tutorial/lesson_18_parallel_associative_reductions.cpp index 321be8bc43d8..76dd71b234c4 100644 --- a/tutorial/lesson_18_parallel_associative_reductions.cpp +++ b/tutorial/lesson_18_parallel_associative_reductions.cpp @@ -4,12 +4,12 @@ // reduction using the scheduling directive 'rfactor'. // On linux, you can compile and run it like so: -// g++ lesson_18*.cpp -g -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_18 -std=c++11 -// LD_LIBRARY_PATH=../bin ./lesson_18 +// g++ lesson_18*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_18 -std=c++11 +// LD_LIBRARY_PATH=../lib ./lesson_18 // On os x: -// g++ lesson_18*.cpp -g -I ../include -L ../bin -lHalide -o lesson_18 -std=c++11 -// DYLD_LIBRARY_PATH=../bin ./lesson_18 +// g++ lesson_18*.cpp -g -I ../include -L ../lib -lHalide -o lesson_18 -std=c++11 +// DYLD_LIBRARY_PATH=../lib ./lesson_18 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_19_wrapper_funcs.cpp b/tutorial/lesson_19_wrapper_funcs.cpp index dad723a988ac..b781fb23c5cf 100644 --- a/tutorial/lesson_19_wrapper_funcs.cpp +++ b/tutorial/lesson_19_wrapper_funcs.cpp @@ -5,12 +5,12 @@ // from a Func or an ImageParam. // On linux, you can compile and run it like so: -// g++ lesson_19*.cpp -g -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_19 -std=c++11 -// LD_LIBRARY_PATH=../bin ./lesson_19 +// g++ lesson_19*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_19 -std=c++11 +// LD_LIBRARY_PATH=../lib ./lesson_19 // On os x: -// g++ lesson_19*.cpp -g -I ../include -L ../bin -lHalide -o lesson_19 -std=c++11 -// DYLD_LIBRARY_PATH=../bin ./lesson_19 +// g++ lesson_19*.cpp -g -I ../include -L ../lib -lHalide -o lesson_19 -std=c++11 +// DYLD_LIBRARY_PATH=../lib ./lesson_19 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_20_cloning_funcs.cpp b/tutorial/lesson_20_cloning_funcs.cpp index 23f3fb4f040d..8710a761deab 100644 --- a/tutorial/lesson_20_cloning_funcs.cpp +++ b/tutorial/lesson_20_cloning_funcs.cpp @@ -4,12 +4,12 @@ // a Func. // On linux, you can compile and run it like so: -// g++ lesson_20*.cpp -g -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_20 -std=c++11 -// LD_LIBRARY_PATH=../bin ./lesson_20 +// g++ lesson_20*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_20 -std=c++11 +// LD_LIBRARY_PATH=../lib ./lesson_20 // On os x: -// g++ lesson_20*.cpp -g -I ../include -L ../bin -lHalide -o lesson_20 -std=c++11 -// DYLD_LIBRARY_PATH=../bin ./lesson_20 +// g++ lesson_20*.cpp -g -I ../include -L ../lib -lHalide -o lesson_20 -std=c++11 +// DYLD_LIBRARY_PATH=../lib ./lesson_20 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_21_auto_scheduler_generate.cpp b/tutorial/lesson_21_auto_scheduler_generate.cpp index 732d1b6c4e87..52091ab6e1b0 100644 --- a/tutorial/lesson_21_auto_scheduler_generate.cpp +++ b/tutorial/lesson_21_auto_scheduler_generate.cpp @@ -7,9 +7,9 @@ // On linux or os x, you can compile and run it like so: -// g++ lesson_21_auto_scheduler_generate.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../bin -lHalide -lpthread -ldl -o lesson_21_generate -// export LD_LIBRARY_PATH=../bin # For linux -// export DYLD_LIBRARY_PATH=../bin # For OS X +// g++ lesson_21_auto_scheduler_generate.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_21_generate +// export LD_LIBRARY_PATH=../lib # For linux +// export DYLD_LIBRARY_PATH=../lib # For OS X // ./lesson_21_generate -o . -g auto_schedule_gen -f auto_schedule_false -e static_library,h,schedule target=host auto_schedule=false // ./lesson_21_generate -o . -g auto_schedule_gen -f auto_schedule_true -e static_library,h,schedule target=host auto_schedule=true machine_params=32,16777216,40 // g++ lesson_21_auto_scheduler_run.cpp -std=c++11 -I ../include -I ../tools auto_schedule_false.a auto_schedule_true.a -ldl -lpthread -o lesson_21_run From a6a560dece7d226b254ea7ab50824678dc2dd34d Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Sat, 12 Sep 2020 20:02:30 -0700 Subject: [PATCH 21/31] Make distrib folder moveable on OS X --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index be6ff6ad6663..a99459aa6116 100644 --- a/Makefile +++ b/Makefile @@ -2179,6 +2179,9 @@ $(DISTRIB_DIR)/lib/libHalide.$(SHARED_EXT): \ cp $(ROOT_DIR)/tools/halide_trace_config.h $(DISTRIB_DIR)/tools cp $(ROOT_DIR)/README*.md $(DISTRIB_DIR) cp $(BUILD_DIR)/halide_config.* $(DISTRIB_DIR) +ifeq ($(UNAME), Darwin) + install_name_tool -id @rpath/libHalide.$(SHARED_EXT) $(DISTRIB_DIR)/lib/libHalide.$(SHARED_EXT) +endif $(DISTRIB_DIR)/lib/libautoschedule_%.$(SHARED_EXT): $(DISTRIB_DIR)/lib/libHalide.$(SHARED_EXT) $(MAKE) -f $(SRC_DIR)/autoschedulers/$*/Makefile bin/libautoschedule_$*.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) From 284b845751d598b6dbfc9ba861ac3d7cf3bad36c Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Sat, 12 Sep 2020 20:09:29 -0700 Subject: [PATCH 22/31] Make autoscheduler distro libs moveable --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a99459aa6116..c03a2d54ece7 100644 --- a/Makefile +++ b/Makefile @@ -2187,7 +2187,7 @@ $(DISTRIB_DIR)/lib/libautoschedule_%.$(SHARED_EXT): $(DISTRIB_DIR)/lib/libHalide $(MAKE) -f $(SRC_DIR)/autoschedulers/$*/Makefile bin/libautoschedule_$*.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) cp $(BIN_DIR)/libautoschedule_$*.$(SHARED_EXT) $(DISTRIB_DIR)/lib ifeq ($(UNAME), Darwin) - install_name_tool -id $(CURDIR)/$@ $(CURDIR)/$@ + install_name_tool -id @rpath/$(@F) $(CURDIR)/$@ endif # Adams2019 also includes autotuning tools @@ -2208,7 +2208,7 @@ else endif cp $(SRC_DIR)/autoschedulers/adams2019/autotune_loop.sh $(DISTRIB_DIR)/tools/ ifeq ($(UNAME), Darwin) - install_name_tool -id $(CURDIR)/$@ $(CURDIR)/$@ + install_name_tool -id @rpath/$(@F) $(CURDIR)/$@ endif .PHONY: autoschedulers From 482ab0872c832058fefb1dbd1cb8414a6fa16e32 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Sat, 12 Sep 2020 20:10:27 -0700 Subject: [PATCH 23/31] fix perms --- apps/support/viz_auto.sh | 0 src/autoschedulers/adams2019/autotune_loop.sh | 0 tutorial/figures/generate_figures_17.sh | 0 tutorial/figures/generate_figures_18.sh | 0 tutorial/figures/generate_figures_19.sh | 0 tutorial/figures/generate_figures_5.sh | 0 tutorial/figures/generate_figures_8.sh | 0 tutorial/figures/generate_figures_9.sh | 0 tutorial/figures/generate_output_snippets.sh | 0 tutorial/lesson_15_generators_usage.sh | 0 10 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 apps/support/viz_auto.sh mode change 100644 => 100755 src/autoschedulers/adams2019/autotune_loop.sh mode change 100644 => 100755 tutorial/figures/generate_figures_17.sh mode change 100644 => 100755 tutorial/figures/generate_figures_18.sh mode change 100644 => 100755 tutorial/figures/generate_figures_19.sh mode change 100644 => 100755 tutorial/figures/generate_figures_5.sh mode change 100644 => 100755 tutorial/figures/generate_figures_8.sh mode change 100644 => 100755 tutorial/figures/generate_figures_9.sh mode change 100644 => 100755 tutorial/figures/generate_output_snippets.sh mode change 100644 => 100755 tutorial/lesson_15_generators_usage.sh diff --git a/apps/support/viz_auto.sh b/apps/support/viz_auto.sh old mode 100644 new mode 100755 diff --git a/src/autoschedulers/adams2019/autotune_loop.sh b/src/autoschedulers/adams2019/autotune_loop.sh old mode 100644 new mode 100755 diff --git a/tutorial/figures/generate_figures_17.sh b/tutorial/figures/generate_figures_17.sh old mode 100644 new mode 100755 diff --git a/tutorial/figures/generate_figures_18.sh b/tutorial/figures/generate_figures_18.sh old mode 100644 new mode 100755 diff --git a/tutorial/figures/generate_figures_19.sh b/tutorial/figures/generate_figures_19.sh old mode 100644 new mode 100755 diff --git a/tutorial/figures/generate_figures_5.sh b/tutorial/figures/generate_figures_5.sh old mode 100644 new mode 100755 diff --git a/tutorial/figures/generate_figures_8.sh b/tutorial/figures/generate_figures_8.sh old mode 100644 new mode 100755 diff --git a/tutorial/figures/generate_figures_9.sh b/tutorial/figures/generate_figures_9.sh old mode 100644 new mode 100755 diff --git a/tutorial/figures/generate_output_snippets.sh b/tutorial/figures/generate_output_snippets.sh old mode 100644 new mode 100755 diff --git a/tutorial/lesson_15_generators_usage.sh b/tutorial/lesson_15_generators_usage.sh old mode 100644 new mode 100755 From 29e3a58b049c6635452979879e41c312d4a0ac90 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Sat, 12 Sep 2020 20:27:15 -0700 Subject: [PATCH 24/31] Correct permissions on installed autotune_loop.sh --- packaging/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index 8bb6480b89f9..b2ae240a8bf0 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -113,6 +113,10 @@ install(DIRECTORY ${Halide_SOURCE_DIR}/tools install(FILES ${Halide_SOURCE_DIR}/src/autoschedulers/adams2019/autotune_loop.sh DESTINATION ${CMAKE_INSTALL_DATADIR}/tools + PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE COMPONENT Halide_Development) ## From 3b3a218b911ca03f34e9e2b13a1caeda7da15c97 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Sun, 13 Sep 2020 13:20:08 -0700 Subject: [PATCH 25/31] Disable autograd test on wasm, like before. --- test/generator/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/generator/CMakeLists.txt b/test/generator/CMakeLists.txt index d5eeeb29f619..ccb1a0abf96d 100644 --- a/test/generator/CMakeLists.txt +++ b/test/generator/CMakeLists.txt @@ -153,7 +153,7 @@ halide_define_aot_test(async_parallel # autograd_aottest.cpp # autograd_generator.cpp -halide_define_aot_test(autograd ENABLE_IF TARGET Halide::Mullapudi2016) +halide_define_aot_test(autograd ENABLE_IF TARGET Halide::Mullapudi2016 AND NOT ${USING_WASM}) if (TARGET generator_aot_autograd) add_halide_library(autograd_grad GRADIENT_DESCENT From 0b4773d7ad5726d33742ded273045147c5d33a37 Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Mon, 14 Sep 2020 12:00:46 -0700 Subject: [PATCH 26/31] Set correct rpath to begin with instead of patching it --- Makefile | 9 --------- src/autoschedulers/adams2019/Makefile | 7 +++++++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index be6ff6ad6663..8df406025770 100644 --- a/Makefile +++ b/Makefile @@ -2191,18 +2191,9 @@ endif $(DISTRIB_DIR)/lib/libautoschedule_adams2019.$(SHARED_EXT): $(DISTRIB_DIR)/lib/libHalide.$(SHARED_EXT) $(MAKE) -f $(SRC_DIR)/autoschedulers/adams2019/Makefile bin/libautoschedule_adams2019.$(SHARED_EXT) HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) bin/retrain_cost_model bin/featurization_to_sample bin/get_host_target cp $(BIN_DIR)/libautoschedule_adams2019.$(SHARED_EXT) $(DISTRIB_DIR)/lib/ - # Make rpath relative -ifeq ($(UNAME), Darwin) - for TOOL in retrain_cost_model featurization_to_sample get_host_target; do \ - cp $(BIN_DIR)/$${TOOL} $(DISTRIB_DIR)/bin/; \ - install_name_tool -add_rpath '@executable_path/../lib' $(DISTRIB_DIR)/bin/$${TOOL}; \ - done -else for TOOL in retrain_cost_model featurization_to_sample get_host_target; do \ cp $(BIN_DIR)/$${TOOL} $(DISTRIB_DIR)/bin/; \ - patchelf --set-rpath '$$ORIGIN/../lib' $(DISTRIB_DIR)/bin/$${TOOL}; \ done -endif cp $(SRC_DIR)/autoschedulers/adams2019/autotune_loop.sh $(DISTRIB_DIR)/tools/ ifeq ($(UNAME), Darwin) install_name_tool -id $(CURDIR)/$@ $(CURDIR)/$@ diff --git a/src/autoschedulers/adams2019/Makefile b/src/autoschedulers/adams2019/Makefile index 72a5db04bfa2..2fa69e600e8d 100644 --- a/src/autoschedulers/adams2019/Makefile +++ b/src/autoschedulers/adams2019/Makefile @@ -11,6 +11,13 @@ $(info Looking for Halide distro at $(HALIDE_DISTRIB_PATH). If this is incorrect AUTOSCHEDULER= include $(HALIDE_SRC_ROOT)/apps/support/Makefile.inc +# Add the relative location of libHalide.so in the rpath in a distro +ifeq ($(UNAME), Darwin) +LIBHALIDE_LDFLAGS += '-Wl,-rpath,@executable_path/../lib' +else +LIBHALIDE_LDFLAGS += '-Wl,-rpath,$$ORIGIN/../lib' +endif + CXXFLAGS += -I$(COMMON_DIR) AUTOSCHED_WEIGHT_OBJECTS=$(BIN)/baseline_weights.o From f97c4234fc2d66acacf8d283270cc67f69f0d484 Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Mon, 14 Sep 2020 12:09:53 -0700 Subject: [PATCH 27/31] Add autoschedulers to the tests that need them --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 8df406025770..47565438fd71 100644 --- a/Makefile +++ b/Makefile @@ -1498,9 +1498,9 @@ $(FILTERS_DIR)/external_code.halide_generated.cpp: $(BIN_DIR)/external_code.gene @mkdir -p $(@D) $(CURDIR)/$< -g external_code -e c_source -o $(CURDIR)/$(FILTERS_DIR) target=$(TARGET)-no_runtime external_code_is_bitcode=false -$(FILTERS_DIR)/autograd_grad.a: $(BIN_DIR)/autograd.generator +$(FILTERS_DIR)/autograd_grad.a: $(BIN_DIR)/autograd.generator $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) @mkdir -p $(@D) - $(CURDIR)/$< -g autograd $(GEN_AOT_OUTPUTS) -o $(CURDIR)/$(FILTERS_DIR) -f autograd_grad -d 1 target=$(TARGET)-no_runtime auto_schedule=true + $(CURDIR)/$< -g autograd $(GEN_AOT_OUTPUTS) -o $(CURDIR)/$(FILTERS_DIR) -f autograd_grad -d 1 target=$(TARGET)-no_runtime auto_schedule=true -p $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) -s Mullapudi2016 # Usually, it's considered best practice to have one Generator per # .cpp file, with the generator-name and filename matching; @@ -1753,11 +1753,11 @@ $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate: $(ROOT_DIR)/tutorial/less # ...in that order. LESSON_21_MACHINE_PARAMS = 32,16777216,40 -$(BIN_DIR)/tutorial_lesson_21_auto_scheduler_run: $(ROOT_DIR)/tutorial/lesson_21_auto_scheduler_run.cpp $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate +$(BIN_DIR)/tutorial_lesson_21_auto_scheduler_run: $(ROOT_DIR)/tutorial/lesson_21_auto_scheduler_run.cpp $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) @-mkdir -p $(TMP_DIR) # Run the generator $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate -g auto_schedule_gen -o $(TMP_DIR) -e static_library,c_header,schedule -f auto_schedule_false target=host auto_schedule=false - $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate -g auto_schedule_gen -o $(TMP_DIR) -e static_library,c_header,schedule -f auto_schedule_true target=host-no_runtime auto_schedule=true machine_params=$(LESSON_21_MACHINE_PARAMS) + $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate -g auto_schedule_gen -o $(TMP_DIR) -e static_library,c_header,schedule -f auto_schedule_true target=host-no_runtime auto_schedule=true machine_params=$(LESSON_21_MACHINE_PARAMS) -p $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) -s Mullapudi2016 # Compile the runner $(CXX) $(TUTORIAL_CXX_FLAGS) $(IMAGE_IO_CXX_FLAGS) $(OPTIMIZE_FOR_BUILD_TIME) $< \ -I$(INCLUDE_DIR) -L$(BIN_DIR) -I $(TMP_DIR) $(TMP_DIR)/auto_schedule_*.a \ From a3c0f0b2ed156ae73b7c9e137719f261bb6ca811 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Mon, 14 Sep 2020 13:10:45 -0700 Subject: [PATCH 28/31] package share/Halide path. fix wasm by marking certain libraries to not cross compile --- src/autoschedulers/adams2019/CMakeLists.txt | 6 +++++- src/autoschedulers/li2018/CMakeLists.txt | 1 + tools/package-unix.sh | 2 ++ tools/package-windows.bat | 1 + tutorial/CMakeLists.txt | 2 ++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/autoschedulers/adams2019/CMakeLists.txt b/src/autoschedulers/adams2019/CMakeLists.txt index 55c1800057f3..928d603ce572 100644 --- a/src/autoschedulers/adams2019/CMakeLists.txt +++ b/src/autoschedulers/adams2019/CMakeLists.txt @@ -14,8 +14,10 @@ add_custom_command(OUTPUT ${WF_CPP} add_executable(cost_model.generator cost_model_generator.cpp) target_link_libraries(cost_model.generator PRIVATE Halide::Generator) -add_halide_library(cost_model FROM cost_model.generator) +add_halide_library(cost_model FROM cost_model.generator + TARGETS cmake) add_halide_library(train_cost_model FROM cost_model.generator + TARGETS cmake USE_RUNTIME cost_model.runtime) # retrain_cost_model @@ -54,6 +56,7 @@ add_executable(demo.generator demo_generator.cpp) target_link_libraries(demo.generator PRIVATE Halide::Generator) add_halide_library(demo FROM demo.generator + TARGETS cmake AUTOSCHEDULER Halide::Adams2019 REGISTRATION DEMO_REGISTRATION_FILE) @@ -74,6 +77,7 @@ add_executable(included_schedule_file.generator included_schedule_file_generator target_link_libraries(included_schedule_file.generator PRIVATE Halide::Generator) add_halide_library(included_schedule_file FROM included_schedule_file.generator + TARGETS cmake AUTOSCHEDULER Halide::Adams2019 REGISTRATION included_schedule_reg) diff --git a/src/autoschedulers/li2018/CMakeLists.txt b/src/autoschedulers/li2018/CMakeLists.txt index 1a6aaad5dc72..809689012b35 100644 --- a/src/autoschedulers/li2018/CMakeLists.txt +++ b/src/autoschedulers/li2018/CMakeLists.txt @@ -7,6 +7,7 @@ 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 diff --git a/tools/package-unix.sh b/tools/package-unix.sh index d2e33de91059..ee351454ba38 100755 --- a/tools/package-unix.sh +++ b/tools/package-unix.sh @@ -24,6 +24,7 @@ cmake -G Ninja \ -DWITH_DOCS=YES \ -DWITH_UTILS=NO \ -DWITH_PYTHON_BINDINGS=NO \ + -DCMAKE_INSTALL_DATADIR="share/Halide" \ -S "$halide_source" \ -B "$halide_build_root/shared-Release" @@ -40,6 +41,7 @@ cmake -G Ninja \ -DWITH_DOCS=YES \ -DWITH_UTILS=NO \ -DWITH_PYTHON_BINDINGS=NO \ + -DCMAKE_INSTALL_DATADIR="share/Halide" \ -S "$halide_source" \ -B "$halide_build_root/static-Release" diff --git a/tools/package-windows.bat b/tools/package-windows.bat index bbab5fd2e849..51154acacb0a 100644 --- a/tools/package-windows.bat +++ b/tools/package-windows.bat @@ -57,6 +57,7 @@ cmake -G "Visual Studio 16 2019" -Thost=x64 -A "%halide_arch%" ^ "-DCMAKE_INSTALL_BINDIR=bin/$" ^ "-DCMAKE_INSTALL_LIBDIR=lib/$" ^ "-DHALIDE_INSTALL_CMAKEDIR=lib" ^ + "-DHALIDE_INSTALL_DATADIR=share/Halide" ^ -S "%halide_source%" ^ -B "%halide_build_root%" if ERRORLEVEL 1 goto error diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt index 1f5dfc439d07..cff1c8d1ff7b 100644 --- a/tutorial/CMakeLists.txt +++ b/tutorial/CMakeLists.txt @@ -193,8 +193,10 @@ if (TARGET Halide::Mullapudi2016) target_link_libraries(lesson_21_auto_scheduler_generate PRIVATE Halide::Generator) add_halide_library(auto_schedule_false FROM lesson_21_auto_scheduler_generate + TARGETS cmake GENERATOR auto_schedule_gen PARAMS auto_schedule=false) add_halide_library(auto_schedule_true FROM lesson_21_auto_scheduler_generate + TARGETS cmake AUTOSCHEDULER Halide::Mullapudi2016 GENERATOR auto_schedule_gen PARAMS machine_params=32,16777216,40) From b90afd06a3a44d0cc43c5f92f955a21ffbdb8654 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Mon, 14 Sep 2020 14:02:39 -0700 Subject: [PATCH 29/31] Fix comments in tutorials. --- tutorial/lesson_01_basics.cpp | 8 ++++---- tutorial/lesson_02_input_image.cpp | 8 ++++---- tutorial/lesson_03_debugging_1.cpp | 8 ++++---- tutorial/lesson_04_debugging_2.cpp | 8 ++++---- tutorial/lesson_05_scheduling_1.cpp | 8 ++++---- .../lesson_06_realizing_over_shifted_domains.cpp | 8 ++++---- tutorial/lesson_07_multi_stage_pipelines.cpp | 8 ++++---- tutorial/lesson_08_scheduling_2.cpp | 8 ++++---- tutorial/lesson_09_update_definitions.cpp | 8 ++++---- tutorial/lesson_10_aot_compilation_generate.cpp | 12 ++++++------ tutorial/lesson_11_cross_compilation.cpp | 8 ++++---- tutorial/lesson_12_using_the_gpu.cpp | 8 ++++---- tutorial/lesson_13_tuples.cpp | 8 ++++---- tutorial/lesson_14_types.cpp | 8 ++++---- tutorial/lesson_15_generators.cpp | 4 ++-- tutorial/lesson_16_rgb_generate.cpp | 6 +++--- tutorial/lesson_17_predicated_rdom.cpp | 8 ++++---- .../lesson_18_parallel_associative_reductions.cpp | 8 ++++---- tutorial/lesson_19_wrapper_funcs.cpp | 8 ++++---- tutorial/lesson_20_cloning_funcs.cpp | 8 ++++---- tutorial/lesson_21_auto_scheduler_generate.cpp | 10 +++++----- 21 files changed, 84 insertions(+), 84 deletions(-) diff --git a/tutorial/lesson_01_basics.cpp b/tutorial/lesson_01_basics.cpp index e0092228e301..38d949c4cd62 100644 --- a/tutorial/lesson_01_basics.cpp +++ b/tutorial/lesson_01_basics.cpp @@ -3,12 +3,12 @@ // This lesson demonstrates basic usage of Halide as a JIT compiler for imaging. // On linux, you can compile and run it like so: -// g++ lesson_01*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_01 -std=c++11 -// LD_LIBRARY_PATH=../lib ./lesson_01 +// g++ lesson_01*.cpp -g -I -L -lHalide -lpthread -ldl -o lesson_01 -std=c++11 +// LD_LIBRARY_PATH= ./lesson_01 // On os x: -// g++ lesson_01*.cpp -g -I ../include -L ../lib -lHalide -o lesson_01 -std=c++11 -// DYLD_LIBRARY_PATH=../lib ./lesson_01 +// g++ lesson_01*.cpp -g -I -L -lHalide -o lesson_01 -std=c++11 +// DYLD_LIBRARY_PATH= ./lesson_01 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_02_input_image.cpp b/tutorial/lesson_02_input_image.cpp index ffcb6ae598a7..20f9485cfc63 100644 --- a/tutorial/lesson_02_input_image.cpp +++ b/tutorial/lesson_02_input_image.cpp @@ -4,12 +4,12 @@ // them. // On linux, you can compile and run it like so: -// g++ lesson_02*.cpp -g -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -o lesson_02 -std=c++11 -// LD_LIBRARY_PATH=../lib ./lesson_02 +// g++ lesson_02*.cpp -g -I -I -L -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -o lesson_02 -std=c++11 +// LD_LIBRARY_PATH= ./lesson_02 // On os x: -// g++ lesson_02*.cpp -g -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -o lesson_02 -std=c++11 -// DYLD_LIBRARY_PATH=../lib ./lesson_02 +// g++ lesson_02*.cpp -g -I -I -L -lHalide `libpng-config --cflags --ldflags` -ljpeg -o lesson_02 -std=c++11 +// DYLD_LIBRARY_PATH= ./lesson_02 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_03_debugging_1.cpp b/tutorial/lesson_03_debugging_1.cpp index 2bc6abf4335e..11f7a4211ecc 100644 --- a/tutorial/lesson_03_debugging_1.cpp +++ b/tutorial/lesson_03_debugging_1.cpp @@ -3,12 +3,12 @@ // This lesson demonstrates how to inspect what the Halide compiler is producing. // On linux, you can compile and run it like so: -// g++ lesson_03*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_03 -std=c++11 -// LD_LIBRARY_PATH=../lib ./lesson_03 +// g++ lesson_03*.cpp -g -I -L -lHalide -lpthread -ldl -o lesson_03 -std=c++11 +// LD_LIBRARY_PATH= ./lesson_03 // On os x: -// g++ lesson_03*.cpp -g -I ../include -L ../lib -lHalide -o lesson_03 -std=c++11 -// DYLD_LIBRARY_PATH=../lib ./lesson_03 +// g++ lesson_03*.cpp -g -I -L -lHalide -o lesson_03 -std=c++11 +// DYLD_LIBRARY_PATH= ./lesson_03 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_04_debugging_2.cpp b/tutorial/lesson_04_debugging_2.cpp index 67cccebc68e9..49cd17df0a9b 100644 --- a/tutorial/lesson_04_debugging_2.cpp +++ b/tutorial/lesson_04_debugging_2.cpp @@ -3,12 +3,12 @@ // This lesson demonstrates how to follow what Halide is doing at runtime. // On linux, you can compile and run it like so: -// g++ lesson_04*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_04 -std=c++11 -// LD_LIBRARY_PATH=../lib ./lesson_04 +// g++ lesson_04*.cpp -g -I -L -lHalide -lpthread -ldl -o lesson_04 -std=c++11 +// LD_LIBRARY_PATH= ./lesson_04 // On os x: -// g++ lesson_04*.cpp -g -I ../include -L ../lib -lHalide -o lesson_04 -std=c++11 -// DYLD_LIBRARY_PATH=../lib ./lesson_04 +// g++ lesson_04*.cpp -g -I -L -lHalide -o lesson_04 -std=c++11 +// DYLD_LIBRARY_PATH= ./lesson_04 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_05_scheduling_1.cpp b/tutorial/lesson_05_scheduling_1.cpp index d0589031c84b..2ac3930a1306 100644 --- a/tutorial/lesson_05_scheduling_1.cpp +++ b/tutorial/lesson_05_scheduling_1.cpp @@ -5,12 +5,12 @@ // parallelization, unrolling, and tiling. // On linux, you can compile and run it like so: -// g++ lesson_05*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_05 -std=c++11 -// LD_LIBRARY_PATH=../lib ./lesson_05 +// g++ lesson_05*.cpp -g -I -L -lHalide -lpthread -ldl -o lesson_05 -std=c++11 +// LD_LIBRARY_PATH= ./lesson_05 // On os x: -// g++ lesson_05*.cpp -g -I ../include -L ../lib -lHalide -o lesson_05 -std=c++11 -// DYLD_LIBRARY_PATH=../lib ./lesson_05 +// g++ lesson_05*.cpp -g -I -L -lHalide -o lesson_05 -std=c++11 +// DYLD_LIBRARY_PATH= ./lesson_05 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_06_realizing_over_shifted_domains.cpp b/tutorial/lesson_06_realizing_over_shifted_domains.cpp index 46e2e5cba811..283df77365ab 100644 --- a/tutorial/lesson_06_realizing_over_shifted_domains.cpp +++ b/tutorial/lesson_06_realizing_over_shifted_domains.cpp @@ -4,12 +4,12 @@ // does not start at (0, 0). // On linux, you can compile and run it like so: -// g++ lesson_06*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_06 -std=c++11 -// LD_LIBRARY_PATH=../lib ./lesson_06 +// g++ lesson_06*.cpp -g -I -L -lHalide -lpthread -ldl -o lesson_06 -std=c++11 +// LD_LIBRARY_PATH= ./lesson_06 // On os x: -// g++ lesson_06*.cpp -g -I ../include -L ../lib -lHalide -o lesson_06 -std=c++11 -// DYLD_LIBRARY_PATH=../lib ./lesson_06 +// g++ lesson_06*.cpp -g -I -L -lHalide -o lesson_06 -std=c++11 +// DYLD_LIBRARY_PATH= ./lesson_06 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_07_multi_stage_pipelines.cpp b/tutorial/lesson_07_multi_stage_pipelines.cpp index 88354c7fb5eb..49df7a804675 100644 --- a/tutorial/lesson_07_multi_stage_pipelines.cpp +++ b/tutorial/lesson_07_multi_stage_pipelines.cpp @@ -1,12 +1,12 @@ // Halide tutorial lesson 7: Multi-stage pipelines // On linux, you can compile and run it like so: -// g++ lesson_07*.cpp -g -std=c++11 -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -o lesson_07 -// LD_LIBRARY_PATH=../lib ./lesson_07 +// g++ lesson_07*.cpp -g -std=c++11 -I -I -L -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -o lesson_07 +// LD_LIBRARY_PATH= ./lesson_07 // On os x: -// g++ lesson_07*.cpp -g -std=c++11 -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -o lesson_07 -// DYLD_LIBRARY_PATH=../lib ./lesson_07 +// g++ lesson_07*.cpp -g -std=c++11 -I -I -L -lHalide `libpng-config --cflags --ldflags` -ljpeg -o lesson_07 +// DYLD_LIBRARY_PATH= ./lesson_07 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_08_scheduling_2.cpp b/tutorial/lesson_08_scheduling_2.cpp index 227146b54989..80db19489b7e 100644 --- a/tutorial/lesson_08_scheduling_2.cpp +++ b/tutorial/lesson_08_scheduling_2.cpp @@ -1,12 +1,12 @@ // Halide tutorial lesson 8: Scheduling multi-stage pipelines // On linux, you can compile and run it like so: -// g++ lesson_08*.cpp -g -std=c++11 -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_08 -// LD_LIBRARY_PATH=../lib ./lesson_08 +// g++ lesson_08*.cpp -g -std=c++11 -I -L -lHalide -lpthread -ldl -o lesson_08 +// LD_LIBRARY_PATH= ./lesson_08 // On os x: -// g++ lesson_08*.cpp -g -std=c++11 -I ../include -L ../lib -lHalide -o lesson_08 -// DYLD_LIBRARY_PATH=../lib ./lesson_08 +// g++ lesson_08*.cpp -g -std=c++11 -I -L -lHalide -o lesson_08 +// DYLD_LIBRARY_PATH= ./lesson_08 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_09_update_definitions.cpp b/tutorial/lesson_09_update_definitions.cpp index 914759306581..f48480b3c2fc 100644 --- a/tutorial/lesson_09_update_definitions.cpp +++ b/tutorial/lesson_09_update_definitions.cpp @@ -1,12 +1,12 @@ // Halide tutorial lesson 9: Multi-pass Funcs, update definitions, and reductions // On linux, you can compile and run it like so: -// g++ lesson_09*.cpp -g -std=c++11 -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -fopenmp -o lesson_09 -// LD_LIBRARY_PATH=../lib ./lesson_09 +// g++ lesson_09*.cpp -g -std=c++11 -I -I -L -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -fopenmp -o lesson_09 +// LD_LIBRARY_PATH= ./lesson_09 // On os x (will only work if you actually have g++, not Apple's pretend g++ which is actually clang): -// g++ lesson_09*.cpp -g -std=c++11 -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -fopenmp -o lesson_09 -// DYLD_LIBRARY_PATH=../lib ./lesson_09 +// g++ lesson_09*.cpp -g -std=c++11 -I -I -L -lHalide `libpng-config --cflags --ldflags` -ljpeg -fopenmp -o lesson_09 +// DYLD_LIBRARY_PATH= ./lesson_09 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_10_aot_compilation_generate.cpp b/tutorial/lesson_10_aot_compilation_generate.cpp index 92ab1bd6af26..989dff124bfa 100644 --- a/tutorial/lesson_10_aot_compilation_generate.cpp +++ b/tutorial/lesson_10_aot_compilation_generate.cpp @@ -10,15 +10,15 @@ // compiling this code is a multi-step process. // On linux, you can compile and run it like so: -// g++ lesson_10*generate.cpp -g -std=c++11 -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_10_generate -// LD_LIBRARY_PATH=../lib ./lesson_10_generate -// g++ lesson_10*run.cpp lesson_10_halide.a -std=c++11 -I ../include -lpthread -ldl -o lesson_10_run +// g++ lesson_10*generate.cpp -g -std=c++11 -I -L -lHalide -lpthread -ldl -o lesson_10_generate +// LD_LIBRARY_PATH= ./lesson_10_generate +// g++ lesson_10*run.cpp lesson_10_halide.a -std=c++11 -I -lpthread -ldl -o lesson_10_run // ./lesson_10_run // On os x: -// g++ lesson_10*generate.cpp -g -std=c++11 -I ../include -L ../lib -lHalide -o lesson_10_generate -// DYLD_LIBRARY_PATH=../lib ./lesson_10_generate -// g++ lesson_10*run.cpp lesson_10_halide.a -o lesson_10_run -I ../include +// g++ lesson_10*generate.cpp -g -std=c++11 -I -L -lHalide -o lesson_10_generate +// DYLD_LIBRARY_PATH= ./lesson_10_generate +// g++ lesson_10*run.cpp lesson_10_halide.a -o lesson_10_run -I // ./lesson_10_run // The benefits of this approach are that the final program: diff --git a/tutorial/lesson_11_cross_compilation.cpp b/tutorial/lesson_11_cross_compilation.cpp index ec6fc4608c02..617dbeb5a210 100644 --- a/tutorial/lesson_11_cross_compilation.cpp +++ b/tutorial/lesson_11_cross_compilation.cpp @@ -4,12 +4,12 @@ // generate code for any platform from any platform. // On linux, you can compile and run it like so: -// g++ lesson_11*.cpp -g -std=c++11 -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_11 -// LD_LIBRARY_PATH=../lib ./lesson_11 +// g++ lesson_11*.cpp -g -std=c++11 -I -L -lHalide -lpthread -ldl -o lesson_11 +// LD_LIBRARY_PATH= ./lesson_11 // On os x: -// g++ lesson_11*.cpp -g -std=c++11 -I ../include -L ../lib -lHalide -o lesson_11 -// DYLD_LIBRARY_PATH=../lib ./lesson_11 +// g++ lesson_11*.cpp -g -std=c++11 -I -L -lHalide -o lesson_11 +// DYLD_LIBRARY_PATH= ./lesson_11 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_12_using_the_gpu.cpp b/tutorial/lesson_12_using_the_gpu.cpp index 28f78df8cafc..682a7ff81410 100644 --- a/tutorial/lesson_12_using_the_gpu.cpp +++ b/tutorial/lesson_12_using_the_gpu.cpp @@ -3,12 +3,12 @@ // This lesson demonstrates how to use Halide to run code on a GPU using OpenCL. // On linux, you can compile and run it like so: -// g++ lesson_12*.cpp -g -std=c++11 -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -o lesson_12 -// LD_LIBRARY_PATH=../lib ./lesson_12 +// g++ lesson_12*.cpp -g -std=c++11 -I -I -L -lHalide `libpng-config --cflags --ldflags` -ljpeg -lpthread -ldl -o lesson_12 +// LD_LIBRARY_PATH= ./lesson_12 // On os x: -// g++ lesson_12*.cpp -g -std=c++11 -I ../include -I ../tools -L ../lib -lHalide `libpng-config --cflags --ldflags` -ljpeg -o lesson_12 -// DYLD_LIBRARY_PATH=../lib ./lesson_12 +// g++ lesson_12*.cpp -g -std=c++11 -I -I -L -lHalide `libpng-config --cflags --ldflags` -ljpeg -o lesson_12 +// DYLD_LIBRARY_PATH= ./lesson_12 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_13_tuples.cpp b/tutorial/lesson_13_tuples.cpp index 060063080a53..5218cb01e652 100644 --- a/tutorial/lesson_13_tuples.cpp +++ b/tutorial/lesson_13_tuples.cpp @@ -4,12 +4,12 @@ // values. // On linux, you can compile and run it like so: -// g++ lesson_13*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_13 -std=c++11 -// LD_LIBRARY_PATH=../lib ./lesson_13 +// g++ lesson_13*.cpp -g -I -L -lHalide -lpthread -ldl -o lesson_13 -std=c++11 +// LD_LIBRARY_PATH= ./lesson_13 // On os x: -// g++ lesson_13*.cpp -g -I ../include -L ../lib -lHalide -o lesson_13 -std=c++11 -// DYLD_LIBRARY_PATH=../lib ./lesson_13 +// g++ lesson_13*.cpp -g -I -L -lHalide -o lesson_13 -std=c++11 +// DYLD_LIBRARY_PATH= ./lesson_13 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_14_types.cpp b/tutorial/lesson_14_types.cpp index cfe5a2c45fc4..8a370c1084f2 100644 --- a/tutorial/lesson_14_types.cpp +++ b/tutorial/lesson_14_types.cpp @@ -3,12 +3,12 @@ // This lesson more precisely describes Halide's type system. // On linux, you can compile and run it like so: -// g++ lesson_14*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_14 -std=c++11 -// LD_LIBRARY_PATH=../lib ./lesson_14 +// g++ lesson_14*.cpp -g -I -L -lHalide -lpthread -ldl -o lesson_14 -std=c++11 +// LD_LIBRARY_PATH= ./lesson_14 // On os x: -// g++ lesson_14*.cpp -g -I ../include -L ../lib -lHalide -o lesson_14 -std=c++11 -// DYLD_LIBRARY_PATH=../lib ./lesson_14 +// g++ lesson_14*.cpp -g -I -L -lHalide -o lesson_14 -std=c++11 +// DYLD_LIBRARY_PATH= ./lesson_14 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_15_generators.cpp b/tutorial/lesson_15_generators.cpp index 7288f9c12142..2f194248f79d 100644 --- a/tutorial/lesson_15_generators.cpp +++ b/tutorial/lesson_15_generators.cpp @@ -4,11 +4,11 @@ // reusable components called generators. // On linux, you can compile and run it like so: -// g++ lesson_15*.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_15_generate +// g++ lesson_15*.cpp /GenGen.cpp -g -std=c++11 -fno-rtti -I -L -lHalide -lpthread -ldl -o lesson_15_generate // bash lesson_15_generators_usage.sh // On os x: -// g++ lesson_15*.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../lib -lHalide -o lesson_15_generate +// g++ lesson_15*.cpp /GenGen.cpp -g -std=c++11 -fno-rtti -I -L -lHalide -o lesson_15_generate // bash lesson_15_generators_usage.sh // If you have the entire Halide source tree, you can also build it by diff --git a/tutorial/lesson_16_rgb_generate.cpp b/tutorial/lesson_16_rgb_generate.cpp index f5bc9c368a69..5b57548994f3 100644 --- a/tutorial/lesson_16_rgb_generate.cpp +++ b/tutorial/lesson_16_rgb_generate.cpp @@ -6,9 +6,9 @@ // On linux or os x, you can compile and run it like so: -// g++ lesson_16_rgb_generate.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_16_generate -// export LD_LIBRARY_PATH=../lib # For linux -// export DYLD_LIBRARY_PATH=../lib # For OS X +// g++ lesson_16_rgb_generate.cpp /GenGen.cpp -g -std=c++11 -fno-rtti -I -L -lHalide -lpthread -ldl -o lesson_16_generate +// export LD_LIBRARY_PATH= # For linux +// export DYLD_LIBRARY_PATH= # For OS X // ./lesson_16_generate -g brighten -o . -f brighten_planar target=host layout=planar // ./lesson_16_generate -g brighten -o . -f brighten_interleaved target=host layout=interleaved // ./lesson_16_generate -g brighten -o . -f brighten_either target=host layout=either diff --git a/tutorial/lesson_17_predicated_rdom.cpp b/tutorial/lesson_17_predicated_rdom.cpp index c954bc80afc5..a781fe2bc038 100644 --- a/tutorial/lesson_17_predicated_rdom.cpp +++ b/tutorial/lesson_17_predicated_rdom.cpp @@ -4,12 +4,12 @@ // subsets of a reduction domain using predicates. // On linux, you can compile and run it like so: -// g++ lesson_17*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_17 -std=c++11 -// LD_LIBRARY_PATH=../lib ./lesson_17 +// g++ lesson_17*.cpp -g -I -L -lHalide -lpthread -ldl -o lesson_17 -std=c++11 +// LD_LIBRARY_PATH= ./lesson_17 // On os x: -// g++ lesson_17*.cpp -g -I ../include -L ../lib -lHalide -o lesson_17 -std=c++11 -// DYLD_LIBRARY_PATH=../lib ./lesson_17 +// g++ lesson_17*.cpp -g -I -L -lHalide -o lesson_17 -std=c++11 +// DYLD_LIBRARY_PATH= ./lesson_17 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_18_parallel_associative_reductions.cpp b/tutorial/lesson_18_parallel_associative_reductions.cpp index 76dd71b234c4..db628a662f90 100644 --- a/tutorial/lesson_18_parallel_associative_reductions.cpp +++ b/tutorial/lesson_18_parallel_associative_reductions.cpp @@ -4,12 +4,12 @@ // reduction using the scheduling directive 'rfactor'. // On linux, you can compile and run it like so: -// g++ lesson_18*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_18 -std=c++11 -// LD_LIBRARY_PATH=../lib ./lesson_18 +// g++ lesson_18*.cpp -g -I -L -lHalide -lpthread -ldl -o lesson_18 -std=c++11 +// LD_LIBRARY_PATH= ./lesson_18 // On os x: -// g++ lesson_18*.cpp -g -I ../include -L ../lib -lHalide -o lesson_18 -std=c++11 -// DYLD_LIBRARY_PATH=../lib ./lesson_18 +// g++ lesson_18*.cpp -g -I -L -lHalide -o lesson_18 -std=c++11 +// DYLD_LIBRARY_PATH= ./lesson_18 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_19_wrapper_funcs.cpp b/tutorial/lesson_19_wrapper_funcs.cpp index b781fb23c5cf..47daa4831968 100644 --- a/tutorial/lesson_19_wrapper_funcs.cpp +++ b/tutorial/lesson_19_wrapper_funcs.cpp @@ -5,12 +5,12 @@ // from a Func or an ImageParam. // On linux, you can compile and run it like so: -// g++ lesson_19*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_19 -std=c++11 -// LD_LIBRARY_PATH=../lib ./lesson_19 +// g++ lesson_19*.cpp -g -I -L -lHalide -lpthread -ldl -o lesson_19 -std=c++11 +// LD_LIBRARY_PATH= ./lesson_19 // On os x: -// g++ lesson_19*.cpp -g -I ../include -L ../lib -lHalide -o lesson_19 -std=c++11 -// DYLD_LIBRARY_PATH=../lib ./lesson_19 +// g++ lesson_19*.cpp -g -I -L -lHalide -o lesson_19 -std=c++11 +// DYLD_LIBRARY_PATH= ./lesson_19 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_20_cloning_funcs.cpp b/tutorial/lesson_20_cloning_funcs.cpp index 8710a761deab..452977272762 100644 --- a/tutorial/lesson_20_cloning_funcs.cpp +++ b/tutorial/lesson_20_cloning_funcs.cpp @@ -4,12 +4,12 @@ // a Func. // On linux, you can compile and run it like so: -// g++ lesson_20*.cpp -g -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_20 -std=c++11 -// LD_LIBRARY_PATH=../lib ./lesson_20 +// g++ lesson_20*.cpp -g -I -L -lHalide -lpthread -ldl -o lesson_20 -std=c++11 +// LD_LIBRARY_PATH= ./lesson_20 // On os x: -// g++ lesson_20*.cpp -g -I ../include -L ../lib -lHalide -o lesson_20 -std=c++11 -// DYLD_LIBRARY_PATH=../lib ./lesson_20 +// g++ lesson_20*.cpp -g -I -L -lHalide -o lesson_20 -std=c++11 +// DYLD_LIBRARY_PATH= ./lesson_20 // If you have the entire Halide source tree, you can also build it by // running: diff --git a/tutorial/lesson_21_auto_scheduler_generate.cpp b/tutorial/lesson_21_auto_scheduler_generate.cpp index 52091ab6e1b0..652637e89858 100644 --- a/tutorial/lesson_21_auto_scheduler_generate.cpp +++ b/tutorial/lesson_21_auto_scheduler_generate.cpp @@ -7,12 +7,12 @@ // On linux or os x, you can compile and run it like so: -// g++ lesson_21_auto_scheduler_generate.cpp ../tools/GenGen.cpp -g -std=c++11 -fno-rtti -I ../include -L ../lib -lHalide -lpthread -ldl -o lesson_21_generate -// export LD_LIBRARY_PATH=../lib # For linux -// export DYLD_LIBRARY_PATH=../lib # For OS X +// g++ lesson_21_auto_scheduler_generate.cpp /GenGen.cpp -g -std=c++11 -fno-rtti -I -L -lHalide -lpthread -ldl -o lesson_21_generate +// export LD_LIBRARY_PATH= # For linux +// export DYLD_LIBRARY_PATH= # For OS X // ./lesson_21_generate -o . -g auto_schedule_gen -f auto_schedule_false -e static_library,h,schedule target=host auto_schedule=false -// ./lesson_21_generate -o . -g auto_schedule_gen -f auto_schedule_true -e static_library,h,schedule target=host auto_schedule=true machine_params=32,16777216,40 -// g++ lesson_21_auto_scheduler_run.cpp -std=c++11 -I ../include -I ../tools auto_schedule_false.a auto_schedule_true.a -ldl -lpthread -o lesson_21_run +// ./lesson_21_generate -o . -g auto_schedule_gen -f auto_schedule_true -e static_library,h,schedule -p -S Mullapudi2016 target=host auto_schedule=true machine_params=32,16777216,40 +// g++ lesson_21_auto_scheduler_run.cpp -std=c++11 -I -I auto_schedule_false.a auto_schedule_true.a -ldl -lpthread -o lesson_21_run // ./lesson_21_run // If you have the entire Halide source tree, you can also build it by From 5ceeffba03ac6bb7d47a8b5c434d415797f60144 Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Mon, 14 Sep 2020 14:07:32 -0700 Subject: [PATCH 30/31] Makefile rpath fixes for os x --- Makefile | 12 +++++++++--- python_bindings/Makefile | 4 +--- src/autoschedulers/adams2019/Makefile | 15 ++++++++------- src/autoschedulers/li2018/Makefile | 10 ++++++++-- src/autoschedulers/mullapudi2016/Makefile | 9 ++++++++- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 6e84c05708ca..2af3cc7ae8a2 100644 --- a/Makefile +++ b/Makefile @@ -1500,7 +1500,13 @@ $(FILTERS_DIR)/external_code.halide_generated.cpp: $(BIN_DIR)/external_code.gene $(FILTERS_DIR)/autograd_grad.a: $(BIN_DIR)/autograd.generator $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) @mkdir -p $(@D) - $(CURDIR)/$< -g autograd $(GEN_AOT_OUTPUTS) -o $(CURDIR)/$(FILTERS_DIR) -f autograd_grad -d 1 target=$(TARGET)-no_runtime auto_schedule=true -p $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) -s Mullapudi2016 + # FIXME: The autoscheduler looks for libHalide in the same + # directory, which is normally a distro. But the generator + # tests use bin/libHalide.so instead of a distro. For now, + # just copy the autoscheduler to a place where it won't + # confuse the linker. + cp $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) $(BIN_DIR) + $(CURDIR)/$< -g autograd $(GEN_AOT_OUTPUTS) -o $(CURDIR)/$(FILTERS_DIR) -f autograd_grad target=$(TARGET)-no_runtime auto_schedule=true -d 1 -p $(BIN_DIR)/libautoschedule_mullapudi2016.$(SHARED_EXT) -s Mullapudi2016 # Usually, it's considered best practice to have one Generator per # .cpp file, with the generator-name and filename matching; @@ -1849,9 +1855,9 @@ test_mullapudi2016: $(AUTO_SCHEDULE_TESTS:$(ROOT_DIR)/test/auto_schedule/%.cpp=a # 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_% $(DISTRIB_DIR)/bin/libautoschedule_mullapudi2016.$(SHARED_EXT) +auto_schedule_%: $(BIN_DIR)/auto_schedule_% $(BIN_DIR)/libautoschedule_mullapudi2016.$(SHARED_EXT) @-mkdir -p $(TMP_DIR) - cd $(TMP_DIR) ; $(CURDIR)/$< $(realpath $(DISTRIB_DIR))/bin/libautoschedule_mullapudi2016.$(SHARED_EXT) + cd $(TMP_DIR) ; $(CURDIR)/$< $(realpath $(BIN_DIR))/libautoschedule_mullapudi2016.$(SHARED_EXT) @-echo # The other autoschedulers contain their own tests diff --git a/python_bindings/Makefile b/python_bindings/Makefile index b9b165b1f04d..590ac613eda8 100644 --- a/python_bindings/Makefile +++ b/python_bindings/Makefile @@ -46,9 +46,7 @@ CCFLAGS := $(filter-out -Wstrict-prototypes,$(CCFLAGS)) # DON'T link libpython* - leave those symbols to lazily resolve at load time # Cf. https://github.com/pybind/pybind11/blob/master/docs/compiling.rst#building-manually LDFLAGS += -lz $(USE_EXPORT_DYNAMIC) -ifeq ($(UNAME), Linux) - LDFLAGS += -Wl,-rpath=$(dir $(LIBHALIDE)) -endif +LDFLAGS += -Wl,-rpath,$(dir $(LIBHALIDE)) PY_SRCS=$(shell ls $(ROOT_DIR)/src/*.cpp) PY_OBJS=$(PY_SRCS:$(ROOT_DIR)/src/%.cpp=$(BIN)/src/%.o) diff --git a/src/autoschedulers/adams2019/Makefile b/src/autoschedulers/adams2019/Makefile index 2fa69e600e8d..6e3d972f6258 100644 --- a/src/autoschedulers/adams2019/Makefile +++ b/src/autoschedulers/adams2019/Makefile @@ -13,9 +13,11 @@ include $(HALIDE_SRC_ROOT)/apps/support/Makefile.inc # Add the relative location of libHalide.so in the rpath in a distro ifeq ($(UNAME), Darwin) -LIBHALIDE_LDFLAGS += '-Wl,-rpath,@executable_path/../lib' +HALIDE_RPATH_FOR_BIN = '-Wl,-rpath,@executable_path/../lib' +HALIDE_RPATH_FOR_LIB = '-Wl,-rpath,@loader_path' else -LIBHALIDE_LDFLAGS += '-Wl,-rpath,$$ORIGIN/../lib' +HALIDE_RPATH_FOR_BIN = '-Wl,-rpath,$$ORIGIN/../lib' +HALIDE_RPATH_FOR_LIB = '-Wl,-rpath,$$ORIGIN' endif CXXFLAGS += -I$(COMMON_DIR) @@ -73,7 +75,7 @@ $(BIN)/libautoschedule_adams2019.$(SHARED_EXT): $(SRC)/AutoSchedule.cpp \ $(GENERATOR_DEPS) \ $(BIN)/auto_schedule_runtime.a @mkdir -p $(@D) - $(CXX) -shared $(USE_EXPORT_DYNAMIC) -fPIC -fvisibility=hidden -fvisibility-inlines-hidden $(CXXFLAGS) $(OPTIMIZE) -I $(BIN)/cost_model $(filter-out %.h $(LIBHALIDE_LDFLAGS),$^) -o $@ $(HALIDE_SYSTEM_LIBS) + $(CXX) -shared $(USE_EXPORT_DYNAMIC) -fPIC -fvisibility=hidden -fvisibility-inlines-hidden $(CXXFLAGS) $(OPTIMIZE) -I $(BIN)/cost_model $(filter-out %.h $(LIBHALIDE_LDFLAGS),$^) -o $@ $(HALIDE_SYSTEM_LIBS) $(HALIDE_RPATH_FOR_LIB) $(BIN)/retrain_cost_model: $(SRC)/retrain_cost_model.cpp \ $(SRC)/ASLog.cpp \ @@ -87,16 +89,15 @@ $(BIN)/retrain_cost_model: $(SRC)/retrain_cost_model.cpp \ $(AUTOSCHED_WEIGHT_OBJECTS) \ $(BIN)/auto_schedule_runtime.a @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -frtti -Wall -I ../support -I $(BIN)/cost_model $(OPTIMIZE) $(filter-out %.h,$^) -o $@ $(LIBHALIDE_LDFLAGS) $(USE_OPEN_MP) + $(CXX) $(CXXFLAGS) -frtti -Wall -I ../support -I $(BIN)/cost_model $(OPTIMIZE) $(filter-out %.h,$^) -o $@ $(LIBHALIDE_LDFLAGS) $(USE_OPEN_MP) $(HALIDE_RPATH_FOR_BIN) $(BIN)/featurization_to_sample: $(SRC)/featurization_to_sample.cpp @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $< $(OPTIMIZE) -o $@ + $(CXX) $(CXXFLAGS) $< $(OPTIMIZE) -o $@ $(BIN)/get_host_target: $(SRC)/get_host_target.cpp $(LIB_HALIDE) $(HALIDE_DISTRIB_PATH)/include/Halide.h @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $(filter %.cpp,$^) $(LIBHALIDE_LDFLAGS) $(OPTIMIZE) -o $@ - + $(CXX) $(CXXFLAGS) $(filter %.cpp,$^) $(LIBHALIDE_LDFLAGS) $(OPTIMIZE) -o $@ $(HALIDE_RPATH_FOR_BIN) $(BIN)/weightsdir_to_weightsfile: $(SRC)/weightsdir_to_weightsfile.cpp $(SRC)/Weights.cpp @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $^ $(OPTIMIZE) -o $@ diff --git a/src/autoschedulers/li2018/Makefile b/src/autoschedulers/li2018/Makefile index 1b96265957b8..db11cd90768e 100644 --- a/src/autoschedulers/li2018/Makefile +++ b/src/autoschedulers/li2018/Makefile @@ -12,9 +12,15 @@ include $(HALIDE_SRC_ROOT)/apps/support/Makefile.inc CXXFLAGS += -I$(COMMON_DIR) +ifeq ($(UNAME), Darwin) +HALIDE_RPATH_FOR_LIB += '-Wl,-rpath,@loader_path' +else +HALIDE_RPATH_FOR_LIB += '-Wl,-rpath,$$ORIGIN' +endif + $(BIN)/libautoschedule_li2018.$(SHARED_EXT): $(SRC)/GradientAutoscheduler.cpp $(LIB_HALIDE) @mkdir -p $(@D) - $(CXX) -shared $(USE_EXPORT_DYNAMIC) -fPIC -fvisibility=hidden -fvisibility-inlines-hidden $(CXXFLAGS) $(OPTIMIZE) $^ -o $@ $(HALIDE_SYSTEM_LIBS) + $(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.$(SHARED_EXT) @@ -49,7 +55,7 @@ run_test_py: $(SRC)/test.py $(BIN)/libautoschedule_li2018.$(SHARED_EXT) LD_LIBRARY_PATH=$(BIN):$(HALIDE_PYTHON_BINDINGS_PATH):$(HALIDE_DISTRIB_PATH)/bin \ $(PYTHON) $(SRC)/test.py -build: $(BIN)/test $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.$(SHARED_EXT) +\build: $(BIN)/test $(BIN)/$(HL_TARGET)/demo.rungen $(BIN)/libautoschedule_li2018.$(SHARED_EXT) test: run_test_cpp run_test_py test_generator diff --git a/src/autoschedulers/mullapudi2016/Makefile b/src/autoschedulers/mullapudi2016/Makefile index 907bd875e8e2..14eddc0e1128 100644 --- a/src/autoschedulers/mullapudi2016/Makefile +++ b/src/autoschedulers/mullapudi2016/Makefile @@ -6,8 +6,15 @@ COMMON_DIR = $(realpath $(SRC)/../common/) HALIDE_DISTRIB_PATH ?= $(HALIDE_SRC_ROOT)/distrib include $(HALIDE_ROOT)/apps/support/Makefile.inc +# Add the relative location of libHalide.so in the rpath in a distro so that the autoscheduler library can find libHalide +ifeq ($(UNAME), Darwin) +HALIDE_RPATH_FOR_LIB += '-Wl,-rpath,@loader_path' +else +HALIDE_RPATH_FOR_LIB += '-Wl,-rpath,$$ORIGIN' +endif + CXXFLAGS += -I$(COMMON_DIR) $(BIN)/libautoschedule_mullapudi2016.$(SHARED_EXT): $(SRC)/AutoSchedule.cpp $(LIB_HALIDE) @mkdir -p $(@D) - $(CXX) -shared $(USE_EXPORT_DYNAMIC) -fPIC -fvisibility=hidden -fvisibility-inlines-hidden $(CXXFLAGS) $(OPTIMIZE) $^ -o $@ $(HALIDE_SYSTEM_LIBS) + $(CXX) -shared $(USE_EXPORT_DYNAMIC) -fPIC -fvisibility=hidden -fvisibility-inlines-hidden $(CXXFLAGS) $(OPTIMIZE) $^ -o $@ $(HALIDE_RPATH_FOR_LIB) From 2ed3e143e837879174e1a614108c9a0d1a35289e Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Mon, 14 Sep 2020 17:35:51 -0700 Subject: [PATCH 31/31] More expedient hackery to handle rpath on OS X issues --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2af3cc7ae8a2..010ab920e9f3 100644 --- a/Makefile +++ b/Makefile @@ -1763,7 +1763,9 @@ $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_run: $(ROOT_DIR)/tutorial/lesson_21 @-mkdir -p $(TMP_DIR) # Run the generator $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate -g auto_schedule_gen -o $(TMP_DIR) -e static_library,c_header,schedule -f auto_schedule_false target=host auto_schedule=false - $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate -g auto_schedule_gen -o $(TMP_DIR) -e static_library,c_header,schedule -f auto_schedule_true target=host-no_runtime auto_schedule=true machine_params=$(LESSON_21_MACHINE_PARAMS) -p $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) -s Mullapudi2016 + # FIXME: The relative path of the autoscheduler and libHalide must be preserved on OS X, or it tries to load the wrong libHalide.dylib + cp $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) $(BIN_DIR) + $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate -g auto_schedule_gen -o $(TMP_DIR) -e static_library,c_header,schedule -f auto_schedule_true target=host-no_runtime auto_schedule=true machine_params=$(LESSON_21_MACHINE_PARAMS) -p $(BIN_DIR)/libautoschedule_mullapudi2016.$(SHARED_EXT) -s Mullapudi2016 # Compile the runner $(CXX) $(TUTORIAL_CXX_FLAGS) $(IMAGE_IO_CXX_FLAGS) $(OPTIMIZE_FOR_BUILD_TIME) $< \ -I$(INCLUDE_DIR) -L$(BIN_DIR) -I $(TMP_DIR) $(TMP_DIR)/auto_schedule_*.a \