acc is now built with cmake instead of the old build script. This was mainly done to fix compilation on Puhti where I had problems linking flex even though it is available. As an added bonus the code is now safer to build since all dependencies are now rigorously tracked by cmake and make, and f.ex. change in the compiler now forces also the whole library to be rebuilt (which is the behaviour we want)
This commit is contained in:
@@ -28,13 +28,9 @@ option(BUILD_MPI_TEST "Builds a C program to test whether MPI works"
|
||||
option(DOUBLE_PRECISION "Generates double precision code" OFF)
|
||||
option(MULTIGPU_ENABLED "If enabled, uses all the available GPUs" ON)
|
||||
|
||||
## Compile the Astaroth Code compiler
|
||||
find_package(FLEX)
|
||||
find_package(BISON)
|
||||
execute_process (
|
||||
COMMAND ./build_acc.sh
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/acc
|
||||
)
|
||||
## Compile the Astaroth Code Compiler
|
||||
add_subdirectory(acc)
|
||||
|
||||
# NOTE: Manually defined DSL_MODULE_DIR must be set relative to the project root, not the actual
|
||||
# build directory!
|
||||
# NO! ../acc/mhd_solver
|
||||
@@ -50,12 +46,13 @@ 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}"
|
||||
COMMENT "Building ACC 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})
|
||||
add_dependencies(dsl_headers acc)
|
||||
|
||||
## Build types
|
||||
# Available types (case-sensitive):
|
||||
|
12
acc/CMakeLists.txt
Normal file
12
acc/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
## CMake settings
|
||||
cmake_minimum_required (VERSION 3.5.1)
|
||||
find_program(CMAKE_C_COMPILER NAMES $ENV{CC} gcc PATHS ENV PATH NO_DEFAULT_PATH)
|
||||
|
||||
## Project settings
|
||||
project(acc C)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
|
||||
include_directories(src)
|
||||
add_subdirectory(src)
|
@@ -1,16 +1,16 @@
|
||||
#!/bin/bash
|
||||
# Usage ./compile <source file> <gcc preprocessor flags, f.ex. -I some/path>
|
||||
|
||||
# Usage ./compile <acc binary> <source file> <gcc preprocessor flags, f.ex. -I some/path>
|
||||
ACC_DIR=`dirname $0`
|
||||
ACC_BINARY=$1
|
||||
|
||||
FULL_NAME=$(basename -- $1)
|
||||
FULL_NAME=$(basename -- $2)
|
||||
FILENAME="${FULL_NAME%.*}"
|
||||
EXTENSION="${FULL_NAME##*.}"
|
||||
|
||||
if [ "${EXTENSION}" = "sas" ]; then
|
||||
COMPILE_FLAGS="-sas" # Generate stencil assembly stage
|
||||
CUH_FILENAME="stencil_assembly.cuh"
|
||||
echo "-- Generating stencil assembly stage: ${FILENAME}.sas -> ${CUH_FILENAME}"
|
||||
echo "-- Generating stencil assembly stage: ${FILENAME}.sas -> ${CUH_FILENAME}"
|
||||
elif [ "${EXTENSION}" = "sps" ]; then
|
||||
COMPILE_FLAGS="-sps" # Generate stencil processing stage
|
||||
CUH_FILENAME="stencil_process.cuh"
|
||||
@@ -18,11 +18,11 @@ elif [ "${EXTENSION}" = "sps" ]; then
|
||||
elif [ "${EXTENSION}" = "sdh" ]; then
|
||||
COMPILE_FLAGS="-sdh" # Generate stencil definition header
|
||||
CUH_FILENAME="stencil_defines.h"
|
||||
echo "-- Generating stencil definition header: ${FILENAME}.sdh -> ${CUH_FILENAME}"
|
||||
echo "-- Generating stencil definition header: ${FILENAME}.sdh -> ${CUH_FILENAME}"
|
||||
else
|
||||
echo "-- Error: unknown extension" ${EXTENSION} "of file" ${FULL_NAME}
|
||||
echo "-- Extension should be either .sas, .sps or .sdh"
|
||||
exit
|
||||
fi
|
||||
|
||||
${ACC_DIR}/preprocess.sh $@ | ${ACC_DIR}/build/acc ${COMPILE_FLAGS} > ${CUH_FILENAME}
|
||||
${ACC_DIR}/preprocess.sh ${@:2} | ${ACC_BINARY} ${COMPILE_FLAGS} > ${CUH_FILENAME}
|
||||
|
11
acc/src/CMakeLists.txt
Normal file
11
acc/src/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
## Compile the Astaroth Code compiler
|
||||
find_package(BISON)
|
||||
find_package(FLEX 2.5.5 REQUIRED)
|
||||
|
||||
bison_target(acc_parser acc.y ${CMAKE_CURRENT_BINARY_DIR}/acc.tab.c)
|
||||
flex_target(acc_lexer acc.l ${CMAKE_CURRENT_BINARY_DIR}/acc.yy.c)
|
||||
add_flex_bison_dependency(acc_lexer acc_parser)
|
||||
|
||||
add_executable(acc code_generator.c ${BISON_acc_parser_OUTPUTS} ${FLEX_acc_lexer_OUTPUTS})
|
||||
target_include_directories(acc PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(acc ${FLEX_LIBRARIES})
|
@@ -1,9 +1,11 @@
|
||||
#!/bin/bash
|
||||
ACC_DIR=$(readlink -f $(dirname $0)/../acc)
|
||||
ACC_BINARY_DIR=$(pwd)/acc
|
||||
MODULE_DIR=$(readlink -f $1)
|
||||
|
||||
echo "-- Compiling project in "${MODULE_DIR}
|
||||
echo "-- ACC binary dir: ${ACC_BINARY_DIR}"
|
||||
echo "-- ACC project dir: ${MODULE_DIR}"
|
||||
for source in ${MODULE_DIR}/*.sas ${MODULE_DIR}/*.sps ${MODULE_DIR}/*.sdh
|
||||
do
|
||||
${ACC_DIR}/compile.sh $source -I ${MODULE_DIR}
|
||||
${ACC_DIR}/compile.sh ${ACC_BINARY_DIR}/acc $source -I ${MODULE_DIR}
|
||||
done
|
||||
|
Reference in New Issue
Block a user