Halide 19.0.0
Halide compiler and libraries
|
Halide uses CTest as its primary test platform and runner.
Halide's tests are organized beneath the top-level test/
directory. These folders are described below:
Folder | Description |
---|---|
autoschedulers/$AS | Test for the $AS (e.g. adams2019 ) autoscheduler |
common | Code that may be shared across multiple tests |
correctness | Tests that check correctness of various compiler properties |
error | Tests that expect an exception to be thrown (or abort() to be called) |
failing_with_issue | Correctness tests that are associated with a particular issue on GitHub |
fuzz | Fuzz tests. Read more at FuzzTesting.md |
generator | Tests of Halide's AOT compilation infrastructure. |
integration | Tests of Halide's CMake package for downstream use, including cross compilation. |
performance | Tests that check that certain schedules indeed improve performance. |
runtime | Unit tests for the Halide runtime library |
warning | Tests that expected warnings are indeed issued. |
The tests in each of these directories are given CTest labels corresponding to the directory name. Thus, one can use ctest -L generator
to run only the generator
tests. The performance
tests configure CTest to not run them concurrently with other tests (including each other).
The vast majority of our tests are simple C++ executables that link to Halide, perform some checks, and print the special line Success!
upon successful completion. There are three main exceptions to this:
First, the warning
tests are expected to print a line that reads Warning:
and do not look for Success!
.
Second, some tests cannot run in all scenarios; for example, a test that measures CUDA performance requires a CUDA-capable GPU. In these cases, tests are expected to print [SKIP]
and exit and not print Success!
or Warning:
.
Finally, the error
tests are expected to throw an (uncaught) exception that is not a Halide::InternalError
(i.e. from a failing internal_assert
). The logic for translating uncaught exceptions into successful tests is in test/common/expect_abort.cpp
.
We provide helpers for pretty-printing Halide's IR types in LLDB. The .lldbinit
file at the repository root will load automatically if you launch lldb
from this directory and your ~/.lldbinit
file contains the line,
If you prefer to avoid such global configuration, you can directly load the helpers with the LLDB command,
again assuming that the repository root is your current working directory.
To see the benefit of using these helpers, let us debug correctness_bounds
:
Now we can try to inspect the Func h
. Without the helpers, we see:
But if we load the helpers and try again, we get a much more useful output:
The amount of output here is maybe a bit too much, but we gain the ability to more narrowly inspect data about the func:
These helpers are particularly useful when using graphical debuggers, such as the one found in CLion.