1

I believe that the auto-scheduler adopted in lesson_21_auto_scheduler_generate.cpp is a classical Mullapudi2016 algorithm. How do I switch this auto-scheduler to Adam2019 or Li2018 for this lesson ?

Is Adam2019 still in experimental stage ? According to the paper, the result is very much better than that of Mullapudi2016. Perhaps, Halide developers should add a lesson for using Adam2019 to the tutorial.

prgbenz
  • 1,129
  • 4
  • 13
  • 27

1 Answers1

1

Is Adam2019 still in experimental stage?

It is not! It's ready to use.

How do I switch this auto-scheduler to Adam2019 or Li2018 for this lesson?

This is done when running the generator. Run your generator without arguments to see the help text, which will show you how to load the auto_schedule.so plugin. If you're on Windows or if you're otherwise using the new CMake build, it's quite easy. After building and installing Halide to a local directory, just:

cmake_minimum_required(VERSION 3.16)
project(Lesson21)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)

find_package(Halide REQUIRED)

# Add the generator
add_executable(lesson_21_auto_scheduler_generate lesson_21_auto_scheduler_generate.cpp)
target_link_libraries(lesson_21_auto_scheduler_generate PRIVATE Halide::Generator)

# Use the generator to create the two variants that the runner expects
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
                   GENERATOR auto_schedule_gen 
                   PARAMS auto_schedule=true
                   AUTOSCHEDULER Halide::Adams2019)

# Link them to the runner executable
add_executable(lesson_21_auto_scheduler_run lesson_21_auto_scheduler_run.cpp)
target_link_libraries(lesson_21_auto_scheduler_run
                      PRIVATE
                      auto_schedule_false 
                      auto_schedule_true
                      Halide::Tools)

The add_halide_library function manages running generators to produce static libraries. The AUTOSCHEDULER argument lets you select between Halide::Adams2019 and Halide::Li2018. At time of writing, you omit it completely to select the classic (default) autoscheduler. It will be renamed in the future to Halide::Mullapudi2016. You do still need to pass auto_schedule=true in the PARAMS list.

Then build with:

$ cd build
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/path/to/Halide-install ..
$ cmake --build .
$ ./lesson_21_auto_scheduler_run
Manual schedule: 9.31708ms
Auto schedule: 1.64732ms

Perhaps, Halide developers should add a lesson for using Adam2019 to the tutorial.

I have been meaning to add a tutorial for using Halide from CMake for a while, now. No promises on the timeline, but hopefully I can get to it soon.

Alex Reinking
  • 16,724
  • 5
  • 52
  • 86