Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use add_halide_generator() everywhere in apps/ #6554

Merged
merged 8 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions apps/HelloWasm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ configure_file(index.html index.html COPYONLY)
set(EMCC_FLAGS -s WASM=1 -s USE_SDL=2 -s TOTAL_MEMORY=512MB -O3)
set(EMCC_FLAGS_threads -pthread -matomics)

add_executable(reaction_diffusion_generator reaction_diffusion_generator.cpp)
target_link_libraries(reaction_diffusion_generator PRIVATE Halide::Generator)
add_halide_generator(reaction_diffusion_generator SOURCES reaction_diffusion_generator.cpp)

set(features_simd -wasm_simd128)
set(features_threads -wasm_threads)
Expand Down
3 changes: 1 addition & 2 deletions apps/bgu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(bgu.generator bgu_generator.cpp)
target_link_libraries(bgu.generator PRIVATE Halide::Generator Halide::Tools)
add_halide_generator(bgu.generator SOURCES bgu_generator.cpp)
alexreinking marked this conversation as resolved.
Show resolved Hide resolved

# Filters
add_halide_library(bgu FROM bgu.generator)
alexreinking marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
5 changes: 3 additions & 2 deletions apps/bilateral_grid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(bilateral_grid.generator bilateral_grid_generator.cpp)
target_link_libraries(bilateral_grid.generator PRIVATE Halide::Generator Halide::Tools)
add_halide_generator(bilateral_grid.generator
SOURCES bilateral_grid_generator.cpp
LINK_LIBRARIES Halide::Tools)

# Filters
add_halide_library(bilateral_grid FROM bilateral_grid.generator
Expand Down
3 changes: 1 addition & 2 deletions apps/blur/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ find_package(Halide REQUIRED)
find_package(OpenMP)

# Generator
add_executable(blur.generator halide_blur_generator.cpp)
target_link_libraries(blur.generator PRIVATE Halide::Generator)
add_halide_generator(blur.generator SOURCES halide_blur_generator.cpp)

# Filters
add_halide_library(halide_blur FROM blur.generator)
Expand Down
6 changes: 2 additions & 4 deletions apps/c_backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator(s)
add_executable(pipeline.generator pipeline_generator.cpp)
target_link_libraries(pipeline.generator PRIVATE Halide::Generator)
add_halide_generator(pipeline.generator SOURCES pipeline_generator.cpp)

add_halide_library(pipeline_c FROM pipeline.generator
C_BACKEND
GENERATOR pipeline)
add_halide_library(pipeline_native FROM pipeline.generator
GENERATOR pipeline)

add_executable(pipeline_cpp.generator pipeline_cpp_generator.cpp)
target_link_libraries(pipeline_cpp.generator PRIVATE Halide::Generator)
add_halide_generator(pipeline_cpp.generator SOURCES pipeline_cpp_generator.cpp)

add_halide_library(pipeline_cpp_cpp FROM pipeline_cpp.generator
C_BACKEND
Expand Down
8 changes: 3 additions & 5 deletions apps/camera_pipe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(camera_pipe.generator camera_pipe_generator.cpp)
target_link_libraries(camera_pipe.generator
PRIVATE
Halide::Generator
Halide::Tools)
add_halide_generator(camera_pipe.generator
SOURCES camera_pipe_generator.cpp
LINK_LIBRARIES Halide::Tools)

# Filters
add_halide_library(camera_pipe FROM camera_pipe.generator)
Expand Down
5 changes: 1 addition & 4 deletions apps/conv_layer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(conv_layer.generator conv_layer_generator.cpp)
target_link_libraries(conv_layer.generator
PRIVATE
Halide::Generator)
add_halide_generator(conv_layer.generator SOURCES conv_layer_generator.cpp)

# Filters
add_halide_library(conv_layer FROM conv_layer.generator)
Expand Down
3 changes: 1 addition & 2 deletions apps/cuda_mat_mul/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(mat_mul.generator mat_mul_generator.cpp)
target_link_libraries(mat_mul.generator PRIVATE Halide::Generator)
add_halide_generator(mat_mul.generator SOURCES mat_mul_generator.cpp)

# Filters
add_halide_library(mat_mul FROM mat_mul.generator
Expand Down
5 changes: 1 addition & 4 deletions apps/depthwise_separable_conv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(depthwise_separable_conv.generator depthwise_separable_conv_generator.cpp)
target_link_libraries(depthwise_separable_conv.generator
PRIVATE
Halide::Generator)
add_halide_generator(depthwise_separable_conv.generator SOURCES depthwise_separable_conv_generator.cpp)

# Filters
add_halide_library(depthwise_separable_conv FROM depthwise_separable_conv.generator)
Expand Down
3 changes: 1 addition & 2 deletions apps/fft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(fft.generator fft_generator.cpp fft.cpp)
target_link_libraries(fft.generator PRIVATE Halide::Generator)
add_halide_generator(fft.generator SOURCES fft_generator.cpp fft.cpp)

# Filters
add_halide_library(fft_forward_r2c FROM fft.generator
Expand Down
3 changes: 1 addition & 2 deletions apps/harris/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(harris.generator harris_generator.cpp)
target_link_libraries(harris.generator PRIVATE Halide::Generator Halide::Tools)
add_halide_generator(harris.generator SOURCES harris_generator.cpp)
alexreinking marked this conversation as resolved.
Show resolved Hide resolved

# Filters
add_halide_library(harris FROM harris.generator)
Expand Down
3 changes: 1 addition & 2 deletions apps/hist/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(hist.generator hist_generator.cpp)
target_link_libraries(hist.generator PRIVATE Halide::Generator Halide::Tools)
add_halide_generator(hist.generator SOURCES hist_generator.cpp)
alexreinking marked this conversation as resolved.
Show resolved Hide resolved

# Filters
add_halide_library(hist FROM hist.generator)
Expand Down
3 changes: 1 addition & 2 deletions apps/iir_blur/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(iir_blur.generator iir_blur_generator.cpp)
target_link_libraries(iir_blur.generator PRIVATE Halide::Generator)
add_halide_generator(iir_blur.generator SOURCES iir_blur_generator.cpp)

# Filters
add_halide_library(iir_blur FROM iir_blur.generator)
Expand Down
3 changes: 1 addition & 2 deletions apps/interpolate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(interpolate.generator interpolate_generator.cpp)
target_link_libraries(interpolate.generator PRIVATE Halide::Generator Halide::Tools)
add_halide_generator(interpolate.generator SOURCES interpolate_generator.cpp)
alexreinking marked this conversation as resolved.
Show resolved Hide resolved

# Filters
add_halide_library(interpolate FROM interpolate.generator)
Expand Down
3 changes: 1 addition & 2 deletions apps/lens_blur/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(lens_blur.generator lens_blur_generator.cpp)
target_link_libraries(lens_blur.generator PRIVATE Halide::Generator Halide::Tools)
add_halide_generator(lens_blur.generator SOURCES lens_blur_generator.cpp)
alexreinking marked this conversation as resolved.
Show resolved Hide resolved

# Filters
add_halide_library(lens_blur FROM lens_blur.generator)
Expand Down
3 changes: 1 addition & 2 deletions apps/linear_algebra/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ add_library(halide_blas halide_blas.cpp)
target_include_directories(halide_blas PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

# Define all our generators
add_executable(blas.generator blas_l1_generators.cpp blas_l2_generators.cpp blas_l3_generators.cpp)
target_link_libraries(blas.generator PRIVATE Halide::Generator)
add_halide_generator(blas.generator SOURCES blas_l1_generators.cpp blas_l2_generators.cpp blas_l3_generators.cpp)

# Function to reduce boilerplate
function(add_halide_blas_library)
Expand Down
5 changes: 3 additions & 2 deletions apps/local_laplacian/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(local_laplacian.generator local_laplacian_generator.cpp)
target_link_libraries(local_laplacian.generator PRIVATE Halide::Generator Halide::Tools)
add_halide_generator(local_laplacian.generator
SOURCES local_laplacian_generator.cpp
LINK_LIBRARIES Halide::Tools)

# Filters
add_halide_library(local_laplacian FROM local_laplacian.generator)
Expand Down
3 changes: 1 addition & 2 deletions apps/max_filter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(max_filter.generator max_filter_generator.cpp)
target_link_libraries(max_filter.generator PRIVATE Halide::Generator Halide::Tools)
add_halide_generator(max_filter.generator SOURCES max_filter_generator.cpp)
alexreinking marked this conversation as resolved.
Show resolved Hide resolved

# Filters
add_halide_library(max_filter FROM max_filter.generator)
Expand Down
3 changes: 1 addition & 2 deletions apps/nl_means/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(nl_means.generator nl_means_generator.cpp)
target_link_libraries(nl_means.generator PRIVATE Halide::Generator Halide::Tools)
add_halide_generator(nl_means.generator SOURCES nl_means_generator.cpp)
alexreinking marked this conversation as resolved.
Show resolved Hide resolved

# Filters
add_halide_library(nl_means FROM nl_means.generator)
Expand Down
3 changes: 1 addition & 2 deletions apps/resize/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(resize.generator resize_generator.cpp)
target_link_libraries(resize.generator PRIVATE Halide::Generator)
add_halide_generator(resize.generator SOURCES resize_generator.cpp)

# Filters
list(APPEND VARIANTS
Expand Down
3 changes: 1 addition & 2 deletions apps/stencil_chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(stencil_chain.generator stencil_chain_generator.cpp)
target_link_libraries(stencil_chain.generator PRIVATE Halide::Generator Halide::Tools)
add_halide_generator(stencil_chain.generator SOURCES stencil_chain_generator.cpp)
alexreinking marked this conversation as resolved.
Show resolved Hide resolved

# Filters
add_halide_library(stencil_chain FROM stencil_chain.generator)
Expand Down
3 changes: 1 addition & 2 deletions apps/unsharp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(unsharp.generator unsharp_generator.cpp)
target_link_libraries(unsharp.generator PRIVATE Halide::Generator Halide::Tools)
add_halide_generator(unsharp.generator SOURCES unsharp_generator.cpp)
alexreinking marked this conversation as resolved.
Show resolved Hide resolved

# Filters
add_halide_library(unsharp FROM unsharp.generator)
Expand Down
12 changes: 6 additions & 6 deletions apps/wavelet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ set(CMAKE_CXX_EXTENSIONS NO)
find_package(Halide REQUIRED)

# Generator
add_executable(wavelet.generator
daubechies_x_generator.cpp
inverse_daubechies_x_generator.cpp
haar_x_generator.cpp
inverse_haar_x_generator.cpp)
target_link_libraries(wavelet.generator PRIVATE Halide::Generator)
add_halide_generator(wavelet.generator
SOURCES
daubechies_x_generator.cpp
inverse_daubechies_x_generator.cpp
haar_x_generator.cpp
inverse_haar_x_generator.cpp)

# Filters
add_halide_library(daubechies_x FROM wavelet.generator)
Expand Down
14 changes: 12 additions & 2 deletions cmake/HalideGeneratorHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define_property(TARGET PROPERTY Halide_GENERATOR_HAS_POST_BUILD
function(add_halide_generator TARGET)
set(options "")
set(oneValueArgs PACKAGE_NAME PACKAGE_NAMESPACE EXPORT_FILE)
set(multiValueArgs SOURCES)
set(multiValueArgs SOURCES LINK_LIBRARIES)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if (NOT ARG_PACKAGE_NAME)
Expand Down Expand Up @@ -55,7 +55,7 @@ function(add_halide_generator TARGET)

add_executable(${TARGET} ${ARG_SOURCES})
add_executable(${gen} ALIAS ${TARGET})
target_link_libraries(${TARGET} PRIVATE Halide::Generator)
target_link_libraries(${TARGET} PRIVATE Halide::Generator ${ARG_LINK_LIBRARIES})

add_dependencies("${ARG_PACKAGE_NAME}" ${TARGET})
export(TARGETS ${TARGET}
Expand Down Expand Up @@ -148,6 +148,16 @@ function(add_halide_library TARGET)
message(FATAL_ERROR "Missing FROM argument specifying a Halide generator target")
endif ()

if (NOT TARGET ${ARG_FROM})
# FROM is usually an unqualified name; if we are crosscompiling, we might need a
# fully-qualified name, so add the default package name and retry
set(FQ_ARG_FROM "${PROJECT_NAME}::halide_generators::${ARG_FROM}")
if (NOT TARGET ${FQ_ARG_FROM})
message(FATAL_ERROR "Unable to locate FROM as either ${ARG_FROM} or ${FQ_ARG_FROM}")
endif ()
set(ARG_FROM "${FQ_ARG_FROM}")
endif ()

_Halide_place_dll(${ARG_FROM})

if (ARG_C_BACKEND)
Expand Down