Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GHA workflow to test packaging and usage on Ubuntu
- Loading branch information
1 parent
d2bacde
commit 43aed56
Showing
8 changed files
with
317 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Packaging | ||
on: [ 'pull_request' ] | ||
jobs: | ||
package-ubuntu: | ||
name: Package for Ubuntu | ||
runs-on: ubuntu-20.04 | ||
env: | ||
CMAKE_CXX_COMPILER_LAUNCHER: ccache | ||
CMAKE_C_COMPILER_LAUNCHER: ccache | ||
steps: | ||
- name: Install dependencies | ||
run: | | ||
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \ | ||
| gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null | ||
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main' | ||
sudo apt update | ||
sudo apt install cmake ninja-build doxygen ccache | ||
sudo apt install llvm-11-dev liblld-11-dev clang-11 libclang-11-dev libjpeg-dev libpng-dev | ||
sudo apt install lintian dpkg-dev | ||
- name: Check out sources | ||
uses: actions/checkout@v2 | ||
- name: Set up ccache | ||
uses: hendrikmuhs/ccache-action@v1 | ||
- name: Run Ubuntu packaging script | ||
run: ./packaging/ubuntu/package.sh . ubuntu | ||
- name: Upload packages | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: packages | ||
path: ubuntu/*.deb | ||
test-ubuntu: | ||
name: Test Ubuntu package | ||
needs: package-ubuntu | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Install dependencies | ||
# Specifically use the CMake version that comes with Ubuntu. | ||
run: sudo apt install cmake ninja-build | ||
- name: Check out sources | ||
uses: actions/checkout@v2 | ||
- name: Download Halide Ubuntu packages | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: packages | ||
- name: Install Halide Ubuntu packages | ||
run: sudo apt install ./*.deb | ||
- name: Test integration | ||
run: | | ||
cmake -S test/integration -B build | ||
cd build && ctest -j$(nproc) --output-on-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(integration_tests NONE) | ||
|
||
enable_testing() | ||
|
||
## | ||
# Single-linkage JIT integration tests. | ||
## | ||
|
||
foreach (bsl IN ITEMS "" "-DBUILD_SHARED_LIBS=NO" "-DBUILD_SHARED_LIBS=YES") | ||
foreach (hsl IN ITEMS "" "-DHalide_SHARED_LIBS=NO" "-DHalide_SHARED_LIBS=YES") | ||
foreach (comp IN ITEMS "" "-Djit_HALIDE_COMPONENTS=static" "-Djit_HALIDE_COMPONENTS=shared") | ||
# Compute whether we expect to link to static or shared Halide given the relevant variables. | ||
# Explicitly listing a component always wins. Then Halide_SHARED_LIBS takes over. If that's | ||
# not available, it consults BUILD_SHARED_LIBS. If that's not defined, it defaults to shared, | ||
# rather than static, because that's less likely to lead to pathologies with generators. | ||
if (comp MATCHES "shared") | ||
set(expect_shared TRUE) | ||
elseif (comp MATCHES "static") | ||
set(expect_shared FALSE) | ||
elseif (hsl MATCHES "YES") | ||
set(expect_shared TRUE) | ||
elseif (hsl MATCHES "NO") | ||
set(expect_shared FALSE) | ||
elseif (bsl MATCHES "YES") | ||
set(expect_shared TRUE) | ||
elseif (bsl MATCHES "NO") | ||
set(expect_shared FALSE) | ||
else () | ||
set(expect_shared TRUE) | ||
endif () | ||
|
||
set(test_name "${bsl} ${hsl} ${comp}") | ||
string(REPLACE "-D" "" test_name "${test_name}") | ||
string(STRIP "${test_name}" test_name) | ||
string(MAKE_C_IDENTIFIER "jit_${test_name}" test_name) | ||
|
||
set(build_step "check_builds_${test_name}") | ||
set(check_link_step "check_linkage_${test_name}") | ||
|
||
set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/jit/${test_name}") | ||
|
||
# This builds and runs the tiny example app. | ||
add_test(NAME "${build_step}" | ||
COMMAND | ||
${CMAKE_CTEST_COMMAND} | ||
--build-and-test "${CMAKE_CURRENT_LIST_DIR}/jit" "${build_dir}" | ||
--build-generator Ninja | ||
--build-options ${bsl} ${hsl} ${comp} -DCMAKE_BUILD_TYPE=Release | ||
--test-command ${CMAKE_CTEST_COMMAND}) | ||
|
||
# Run ldd on the output binary. The pass/fail regexes are set later. | ||
add_test(NAME "${check_link_step}" | ||
COMMAND ldd "${build_dir}/main") | ||
|
||
# Make sure we don't run ldd before building... | ||
set_tests_properties("${build_step}" PROPERTIES FIXTURES_SETUP "${test_name}") | ||
set_tests_properties("${check_link_step}" PROPERTIES FIXTURES_REQUIRED "${test_name}") | ||
|
||
if (expect_shared) | ||
set_tests_properties("${check_link_step}" PROPERTIES PASS_REGULAR_EXPRESSION "libHalide") | ||
else () | ||
set_tests_properties("${check_link_step}" PROPERTIES FAIL_REGULAR_EXPRESSION "libHalide") | ||
endif () | ||
endforeach () | ||
endforeach () | ||
endforeach () | ||
|
||
## | ||
# AOT integration tests | ||
## | ||
|
||
add_test(NAME aot_shared_generator | ||
COMMAND | ||
${CMAKE_CTEST_COMMAND} | ||
--build-and-test "${CMAKE_CURRENT_LIST_DIR}/aot" "${CMAKE_CURRENT_BINARY_DIR}/aot-shared" | ||
--build-generator Ninja | ||
--build-options -DCMAKE_BUILD_TYPE=Release | ||
--test-command ${CMAKE_CTEST_COMMAND}) | ||
|
||
add_test(NAME aot_static_generator | ||
COMMAND | ||
${CMAKE_CTEST_COMMAND} | ||
--build-and-test "${CMAKE_CURRENT_LIST_DIR}/aot" "${CMAKE_CURRENT_BINARY_DIR}/aot-static" | ||
--build-generator Ninja | ||
--build-options -DHalide_SHARED_LIBS=NO -DCMAKE_BUILD_TYPE=Release | ||
--test-command ${CMAKE_CTEST_COMMAND}) | ||
|
||
add_test(NAME aot_shared_generator_adams2019 | ||
COMMAND | ||
${CMAKE_CTEST_COMMAND} | ||
--build-and-test "${CMAKE_CURRENT_LIST_DIR}/aot" "${CMAKE_CURRENT_BINARY_DIR}/aot-shared-auto" | ||
--build-generator Ninja | ||
--build-options -DCMAKE_BUILD_TYPE=Release -Daot_USE_AUTOSCHEDULER=YES | ||
--test-command ${CMAKE_CTEST_COMMAND}) | ||
|
||
add_test(NAME aot_static_generator_adams2019 | ||
COMMAND | ||
${CMAKE_CTEST_COMMAND} | ||
--build-and-test "${CMAKE_CURRENT_LIST_DIR}/aot" "${CMAKE_CURRENT_BINARY_DIR}/aot-static-auto" | ||
--build-generator Ninja | ||
--build-options -DHalide_SHARED_LIBS=NO -DCMAKE_BUILD_TYPE=Release -Daot_USE_AUTOSCHEDULER=YES | ||
--test-command ${CMAKE_CTEST_COMMAND}) | ||
|
||
# Cannot use autoscheduler with generators linked to STATIC Halide | ||
set_tests_properties(aot_static_generator_adams2019 | ||
PROPERTIES | ||
WILL_FAIL TRUE | ||
FAIL_REGULAR_EXPRESSION "Autoscheduler Halide::[A-Za-z0-9_]+ does not exist") | ||
|
||
## | ||
# Multiple-linkage JIT integration test | ||
## | ||
|
||
add_test(NAME jit-both | ||
COMMAND | ||
${CMAKE_CTEST_COMMAND} | ||
--build-and-test "${CMAKE_CURRENT_LIST_DIR}/jit-both" "${CMAKE_CURRENT_BINARY_DIR}/jit-both" | ||
--build-generator Ninja | ||
--build-options -DCMAKE_BUILD_TYPE=Release | ||
--test-command ${CMAKE_CTEST_COMMAND}) | ||
|
||
set_tests_properties(jit-both PROPERTIES FIXTURES_SETUP jit-both) | ||
|
||
add_test(NAME jit-both-check-shared | ||
COMMAND ldd "${CMAKE_CURRENT_BINARY_DIR}/jit-both/main-shared") | ||
|
||
set_tests_properties(jit-both-check-shared | ||
PROPERTIES FIXTURES_REQUIRED jit-both | ||
PASS_REGULAR_EXPRESSION "libHalide") | ||
|
||
add_test(NAME jit-both-check-static | ||
COMMAND ldd "${CMAKE_CURRENT_BINARY_DIR}/jit-both/main-static") | ||
|
||
set_tests_properties(jit-both-check-static | ||
PROPERTIES FIXTURES_REQUIRED jit-both | ||
FAIL_REGULAR_EXPRESSION "libHalide") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(aot) | ||
|
||
enable_testing() | ||
|
||
find_package(Halide REQUIRED) | ||
|
||
option(aot_USE_AUTOSCHEDULER "Use the autoscheduler" OFF) | ||
if (aot_USE_AUTOSCHEDULER) | ||
set(extra_options AUTOSCHEDULER Halide::Adams2019) | ||
endif () | ||
|
||
add_executable(add_gen add.cpp) | ||
target_link_libraries(add_gen PRIVATE Halide::Generator) | ||
|
||
add_halide_library(add FROM add_gen | ||
${extra_options} | ||
REGISTRATION add_registration) | ||
|
||
add_executable(run_add ${add_registration}) | ||
target_link_libraries(run_add PRIVATE Halide::RunGenMain add) | ||
|
||
add_test(NAME benchmark | ||
COMMAND run_add --benchmarks=all --output_extents=[64,64]) | ||
|
||
set_tests_properties(benchmark PROPERTIES PASS_REGULAR_EXPRESSION "Best output throughput") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <Halide.h> | ||
using namespace Halide; | ||
|
||
struct Add : Generator<Add> { | ||
Output<Buffer<int32_t>> output{"output", 2}; | ||
|
||
void generate() { | ||
Var x, y; | ||
output(x, y) = x + y; | ||
|
||
output.set_estimates({{0, 64}, {0, 64}}); | ||
} | ||
}; | ||
|
||
HALIDE_REGISTER_GENERATOR(Add, add); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(jit) | ||
|
||
enable_testing() | ||
|
||
set(jit_HALIDE_VERSION "" | ||
CACHE STRING "Optional version argument to find_package(Halide)") | ||
|
||
find_package(Halide ${jit_HALIDE_VERSION} REQUIRED static shared) | ||
|
||
add_executable(main-shared main.cpp) | ||
target_link_libraries(main-shared PRIVATE Halide::shared::Halide) | ||
|
||
add_executable(main-static main.cpp) | ||
target_link_libraries(main-static PRIVATE Halide::static::Halide) | ||
|
||
add_test(NAME validate-shared COMMAND main-shared) | ||
set_tests_properties(validate-shared PROPERTIES PASS_REGULAR_EXPRESSION "Success!") | ||
|
||
add_test(NAME validate-static COMMAND main-static) | ||
set_tests_properties(validate-static PROPERTIES PASS_REGULAR_EXPRESSION "Success!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <Halide.h> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
using namespace Halide; | ||
|
||
int main() { | ||
Var x{"x"}, y{"y"}; | ||
Func test{"test"}; | ||
|
||
test(x, y) = x + y; | ||
Buffer<int> output = test.realize({4, 4}); | ||
|
||
for (int i = 0; i < 4; ++i) { | ||
for (int j = 0; j < 4; ++j) { | ||
if (output(i, j) != (i + j)) { | ||
fprintf(stderr, "output(%d, %d) = %d, expected %d", i, j, output(i, j), i + j); | ||
return EXIT_FAILURE; | ||
} | ||
} | ||
} | ||
|
||
printf("Success!\n"); | ||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(jit) | ||
|
||
enable_testing() | ||
|
||
set(jit_HALIDE_VERSION "" | ||
CACHE STRING "Optional version argument to find_package(Halide)") | ||
|
||
set(jit_HALIDE_COMPONENTS "" | ||
CACHE STRING "Optional required-components argument to find_package(Halide)") | ||
|
||
find_package(Halide ${jit_HALIDE_VERSION} REQUIRED ${jit_HALIDE_COMPONENTS}) | ||
|
||
add_executable(main main.cpp) | ||
target_link_libraries(main PRIVATE Halide::Halide) | ||
|
||
add_test(NAME validate COMMAND main) | ||
|
||
set_tests_properties(validate PROPERTIES PASS_REGULAR_EXPRESSION "Success!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <Halide.h> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
using namespace Halide; | ||
|
||
int main() { | ||
Var x{"x"}, y{"y"}; | ||
Func test{"test"}; | ||
|
||
test(x, y) = x + y; | ||
Buffer<int> output = test.realize({4, 4}); | ||
|
||
for (int i = 0; i < 4; ++i) { | ||
for (int j = 0; j < 4; ++j) { | ||
if (output(i, j) != (i + j)) { | ||
fprintf(stderr, "output(%d, %d) = %d, expected %d", i, j, output(i, j), i + j); | ||
return EXIT_FAILURE; | ||
} | ||
} | ||
} | ||
|
||
printf("Success!\n"); | ||
return EXIT_SUCCESS; | ||
} |