The Astaroth Code Compiler (acc) is now built with cmake. Additionally, make is now used to generate the CUDA headers from DSL sources. The headers are also properly regenerated whenever a DSL file has been changed. With this commit, the DSL is now seamlessly integrated to the library and we no longer need complicated scripts to figure out the correct files. The current workflow for using custom DSL sources is to pass the DSL module directory to cmake, f.ex. cmake -DDSL_MODULE_DIR=/acc/mhd_solver. Note that the path must be absolute or then given relative to the CMakeLists.txt directory. f.ex cd build && cmake -DDSL_MODULE_DIR=../acc/mhd_solver does not work. CMake then takes all DSL files in that directory and handles the rest.

This commit is contained in:
jpekkila
2019-09-18 17:28:29 +03:00
parent bce3e4de03
commit 3bb6ca1712
7 changed files with 55 additions and 13 deletions

View File

@@ -29,6 +29,35 @@ option(DOUBLE_PRECISION "Generates double precision code"
option(MULTIGPU_ENABLED "If enabled, uses all the available GPUs" ON)
option(ALTER_CONF "If enabled, loads astaroth.conf from the build directory" OFF)
## Compile the Astaroth Code compiler
find_package(FLEX)
find_package(BISON)
execute_process (
COMMAND ./build_acc.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/acc
)
# NOTE: Manually defined DSL_MODULE_DIR must be set relative to the project root, not the actual
# build directory!
# NO! ../acc/mhd_solver
# YES! acc/mhd_solver
if (NOT DEFINED DSL_MODULE_DIR)
set(DSL_MODULE_DIR ${CMAKE_SOURCE_DIR}/acc/mhd_solver)
endif ()
get_filename_component(DSL_MODULE_DIR ${DSL_MODULE_DIR} REALPATH)
message(STATUS "DSL module dir: ${DSL_MODULE_DIR}")
set(DSL_SOURCES ${DSL_MODULE_DIR}/*)
set(DSL_HEADERS "${PROJECT_BINARY_DIR}/stencil_assembly.cuh"
"${PROJECT_BINARY_DIR}/stencil_process.cuh"
"${PROJECT_BINARY_DIR}/stencil_defines.h")
add_custom_command (
COMMENT "Building AC objects ${DSL_MODULE_DIR}"
COMMAND ${CMAKE_SOURCE_DIR}/scripts/compile_acc_module.sh ${DSL_MODULE_DIR}
DEPENDS ${DSL_SOURCES}
OUTPUT ${DSL_HEADERS}
)
add_custom_target(dsl_headers ALL DEPENDS ${DSL_HEADERS})
## Build types
# Available types (case-sensitive):
# RELEASE (best performance)