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

Cleanup & simplify CMake files. #3

Open
wants to merge 13 commits into
base: impala
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
build
build*
*.ll
*.bc
55 changes: 21 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(STINCILLA CXX)
enable_testing()

find_package(AnyDSL-runtime REQUIRED)
include(${ANYDSL_RUNTIME_CMAKE_DIR}/Runtime.cmake)
include_directories(${ANYDSL_RUNTIME_DIR}/src)
find_package(Impala REQUIRED)

set(BACKEND ${BACKEND} CACHE STRING "select the backend from the following: CPU, AVX, NVVM, CUDA, OPENCL")
if(NOT BACKEND)
Expand All @@ -14,7 +12,7 @@ endif()
string(TOLOWER "${BACKEND}" BACKEND)
message(STATUS "Selected backend: ${BACKEND}")

set(BACKEND_FILE intrinsics_${BACKEND}.impala)
set(BACKEND_FILE ${CMAKE_CURRENT_SOURCE_DIR}/intrinsics_${BACKEND}.impala)

if(BACKEND STREQUAL "cpu" OR BACKEND STREQUAL "avx")
set(DEVICE "cpu")
Expand All @@ -28,6 +26,21 @@ set(IMPALA_FLAGS --log-level info)
set(STINCILLA_COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/common/pnm_image)
include_directories(${STINCILLA_COMMON_INCLUDE_DIRS})

function (add_test_sample _name)
CMAKE_PARSE_ARGUMENTS ( "PARGS" "" "" "CXX;IMPALA" ${ARGN} )
set(_infiles ${PARGS_IMPALA})
set(_cxxfiles ${PARGS_CXX})
if (NOT (_infiles OR _cxxfiles))
set(_infiles ${PARGS_UNPARSED_ARGUMENTS})
endif()
set(_backend_file ${BACKEND_FILE})
source_group("Impala Files" REGULAR_EXPRESSION "[.]impala$")
wrap_impala_sources(_outfiles OUTPUT_NAME ${_name} CLANG_FLAGS ${CLANG_FLAGS} IMPALA_FLAGS ${IMPALA_FLAGS} FILES ${_infiles} ${_backend_file})
add_executable(${_name} ${_outfiles} ${_infiles} ${_backend_file} ${_cxxfiles})
target_link_libraries(${_name} ${Impala_RUNTIME_LIBRARIES})
add_test("${_name}" ${_name})
endfunction()

add_subdirectory(aobench)
add_subdirectory(bilateral_grid)
add_subdirectory(harris_corner)
Expand All @@ -37,35 +50,9 @@ add_subdirectory(sorting_networks)
add_subdirectory(vcycle)

# simple CPU-based examples
anydsl_runtime_wrap(MATMUL_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ${BACKEND_FILE} utils.impala matmul.impala)
add_executable(matmul ${MATMUL_PROGRAM})
target_link_libraries(matmul ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test("matmul" matmul)
add_test_sample(matmul utils.impala matmul.impala)

# examples based on the "mapping"
anydsl_runtime_wrap(GAUSSIAN_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ${BACKEND_FILE} utils.impala stencil_lib.impala mapping_${DEVICE}.impala gaussian.impala)
add_executable(gaussian ${GAUSSIAN_PROGRAM})
target_link_libraries(gaussian ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test("gaussian" gaussian)

anydsl_runtime_wrap(BILATERAL_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ${BACKEND_FILE} utils.impala stencil_lib.impala mapping_${DEVICE}.impala bilateral.impala)
add_executable(bilateral ${BILATERAL_PROGRAM})
target_link_libraries(bilateral ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test("bilateral" bilateral)

anydsl_runtime_wrap(JACOBI_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ${BACKEND_FILE} utils.impala stencil_lib.impala mapping_${DEVICE}.impala jacobi.impala)
add_executable(jacobi ${JACOBI_PROGRAM})
target_link_libraries(jacobi ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test("jacobi" jacobi)
add_test_sample(gaussian utils.impala stencil_lib.impala mapping_${DEVICE}.impala gaussian.impala)
add_test_sample(bilateral utils.impala stencil_lib.impala mapping_${DEVICE}.impala bilateral.impala)
add_test_sample(jacobi utils.impala stencil_lib.impala mapping_${DEVICE}.impala jacobi.impala)
10 changes: 3 additions & 7 deletions aobench/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
anydsl_runtime_wrap(AOBENCH_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ../${BACKEND_FILE} ../utils.impala mapping_${DEVICE}.impala aobench.impala)
add_executable(aobench main.cpp ${AOBENCH_PROGRAM})
target_link_libraries(aobench ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test_sample(aobench
CXX main.cpp
IMPALA ../utils.impala mapping_${DEVICE}.impala aobench.impala)
set_target_properties(aobench PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON)
add_test("aobench" aobench)
14 changes: 14 additions & 0 deletions aobench/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ void saveppm(uint8_t* img, int width, int height) {
write_pnm_image(img, width, height, "aobench.ppm", pnm_t::P6);
}

// polyfill of non-standard drand48()
#ifdef _MSC_VER

#include <random>
static std::mt19937_64 std_gen64;
static std::uniform_real_distribution<double> std_dist64(0., 1.);
extern "C" void srand48(int64_t seed) { std_gen64.seed(seed); }
extern "C" double drand48() { return std_dist64(std_gen64); }

static std::uniform_int_distribution<int64_t> std_disti64(-(1 << 31), 1 << 31);
extern "C" int64_t mrand48() { return std_disti64(std_gen64); }

#endif // _MSC_VER

/*************************************************************************
* Main function *
*************************************************************************/
Expand Down
10 changes: 3 additions & 7 deletions bilateral_grid/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
anydsl_runtime_wrap(BILATERAL_GRID_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ../${BACKEND_FILE} ../utils.impala mapping_${DEVICE}.impala bilateral_grid.impala)
add_executable(bilateral_grid main.cpp ${BILATERAL_GRID_PROGRAM})
target_link_libraries(bilateral_grid ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test_sample(bilateral_grid
CXX main.cpp
IMPALA ../utils.impala mapping_${DEVICE}.impala bilateral_grid.impala)
set_target_properties(bilateral_grid PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON)
add_test("bilateral_grid" bilateral_grid)
configure_file(../common/lena.pgm ${CMAKE_CURRENT_BINARY_DIR}/lena.pgm COPYONLY)
10 changes: 3 additions & 7 deletions harris_corner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
anydsl_runtime_wrap(HARRIS_CORNER_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ../${BACKEND_FILE} ../utils.impala ../stencil_lib.impala ../mapping_${DEVICE}.impala harris_corner.impala)
add_executable(harris_corner main.cpp ${HARRIS_CORNER_PROGRAM})
target_link_libraries(harris_corner ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test_sample(harris_corner
CXX main.cpp
IMPALA ../utils.impala ../stencil_lib.impala ../mapping_${DEVICE}.impala harris_corner.impala)
set_target_properties(harris_corner PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON)
add_test("harris_corner" harris_corner)
configure_file(../common/lena.pgm ${CMAKE_CURRENT_BINARY_DIR}/lena.pgm COPYONLY)
10 changes: 3 additions & 7 deletions image_sharpening/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
anydsl_runtime_wrap(SHARPENING_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ../${BACKEND_FILE} ../utils.impala ../stencil_lib.impala ../mapping_${DEVICE}.impala mapping_${DEVICE}.impala sharpening.impala)
add_executable(sharpening main.cpp ${SHARPENING_PROGRAM})
target_link_libraries(sharpening ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test_sample(sharpening
CXX main.cpp
IMPALA ../utils.impala ../stencil_lib.impala ../mapping_${DEVICE}.impala mapping_${DEVICE}.impala sharpening.impala)
set_target_properties(sharpening PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON)
add_test("sharpening" sharpening)
configure_file(goldhill.pgm ${CMAKE_CURRENT_BINARY_DIR}/goldhill.pgm COPYONLY)
9 changes: 2 additions & 7 deletions sorting_networks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
anydsl_runtime_wrap(MEDIAN_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ../${BACKEND_FILE} ../utils.impala ../stencil_lib.impala ../mapping_${DEVICE}.impala mapping_${DEVICE}.impala oddeven.impala median.impala)
add_executable(median ${MEDIAN_PROGRAM})
target_link_libraries(median ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test("median" median)
add_test_sample(median
../utils.impala ../stencil_lib.impala ../mapping_${DEVICE}.impala mapping_${DEVICE}.impala oddeven.impala median.impala)
54 changes: 12 additions & 42 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,51 +1,21 @@
anydsl_runtime_wrap(STENCIL_INT_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
wrap_impala_sources(STENCIL_INT_PROGRAM
FILES stencil_dsl.impala)
add_executable(stencil_dsl ${STENCIL_INT_PROGRAM})
target_link_libraries(stencil_dsl ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
target_link_libraries(stencil_dsl ${Impala_RUNTIME_LIBRARIES})
add_test("stencil_dsl" stencil_dsl)

if(NOT (BACKEND STREQUAL "cpu" OR BACKEND STREQUAL "avx"))
anydsl_runtime_wrap(MULTI_GPU_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ../${BACKEND_FILE} ../utils.impala multi_gpu.impala)
add_executable(multi_gpu ${MULTI_GPU_PROGRAM})
target_link_libraries(multi_gpu ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test("multi_gpu" multi_gpu)

anydsl_runtime_wrap(ALLOC_GPU_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ../${BACKEND_FILE} alloc_gpu.impala)
add_executable(alloc_gpu ${ALLOC_GPU_PROGRAM})
target_link_libraries(alloc_gpu ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test("alloc_gpu" alloc_gpu)

anydsl_runtime_wrap(ALLOC_GPU_UNIFIED_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ../${BACKEND_FILE} alloc_gpu_unified.impala)
add_executable(alloc_gpu_unified ${ALLOC_GPU_UNIFIED_PROGRAM})
target_link_libraries(alloc_gpu_unified ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test("alloc_gpu_unified" alloc_gpu_unified)

anydsl_runtime_wrap(RESERVE_SHARED_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ../${BACKEND_FILE} reserve_shared.impala)
add_executable(reserve_shared ${RESERVE_SHARED_PROGRAM})
target_link_libraries(reserve_shared ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test("reserve_shared" reserve_shared)
add_test_sample(multi_gpu ../utils.impala multi_gpu.impala)
add_test_sample(alloc_gpu alloc_gpu.impala)
add_test_sample(alloc_gpu_unified alloc_gpu_unified.impala)
add_test_sample(reserve_shared reserve_shared.impala)

if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
anydsl_runtime_wrap(HALF_FLOAT_GPU_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ../${BACKEND_FILE} half_float_gpu.impala)
add_executable(half_float_gpu ${HALF_FLOAT_GPU_PROGRAM})
target_link_libraries(half_float_gpu ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test("half_float_gpu" half_float_gpu)
# wrap_impala_sources(HALF_FLOAT_GPU_PROGRAM
# FILES ../${BACKEND_FILE} half_float_gpu.impala)
# add_executable(half_float_gpu ${HALF_FLOAT_GPU_PROGRAM})
# target_link_libraries(half_float_gpu ${IMPALA_RUNTIME_LIBRARIES})
# add_test("half_float_gpu" half_float_gpu)
add_test_sample(half_float_gpu half_float_gpu.impala)
endif()
endif()
10 changes: 3 additions & 7 deletions vcycle/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
anydsl_runtime_wrap(VCYCLE_PROGRAM
CLANG_FLAGS ${CLANG_FLAGS}
IMPALA_FLAGS ${IMPALA_FLAGS}
FILES ../${BACKEND_FILE} ../utils.impala ../stencil_lib.impala ../mapping_${DEVICE}.impala mapping_${DEVICE}.impala vcycle.impala)
add_executable(vcycle main.cpp ${VCYCLE_PROGRAM})
target_link_libraries(vcycle ${ANYDSL_RUNTIME_LIBRARY} ${ANYDSL_RUNTIME_LIBRARIES})
add_test_sample(vcycle
CXX main.cpp
IMPALA ../utils.impala ../stencil_lib.impala ../mapping_${DEVICE}.impala mapping_${DEVICE}.impala vcycle.impala)
set_target_properties(vcycle PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON)
add_test("vcycle" vcycle)
configure_file(../common/lena.pgm ${CMAKE_CURRENT_BINARY_DIR}/lena.pgm COPYONLY)