From f8cd57132355baa9195998d86b8e1779072f9ff1 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Fri, 24 Jan 2020 07:00:49 +0200 Subject: [PATCH] Now CMake and compilation flags are functionally equivalent with the current master branch, not taking into account the deprecated flags. Also various small improvements to building. Deprecated flags: * BUILD_DEBUG. This was redundant since CMake also has such flag. The build type can now be switched by passing -DCMAKE_BUILD_TYPE= to cmake. See CMake documentation on CMAKE_BUILD_TYPE on all av * BUILD_UTILS. The utility library is now always built along the core library. We can reintroduce this flag if needed when the library grows larger. Currently MPI functions depend on Utils and without the flag we don't have to worr * BUILD_RT_VISUALIZATION. RT visualization has been dormant for a while and I'm not even sure if it works any more. Eventually the RT library should be generalized and moved to Utils at some point. Disabled the build flag for the t --- CMakeLists.txt | 43 ++++++++++++++++++++++++++++++++----------- acc/CMakeLists.txt | 1 + src/core/device.cc | 12 +++++++++++- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95ee620..1593cb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,11 +8,16 @@ project(astaroth C CXX CUDA) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) ## Project-wide compilation flags -set(COMMON_WARNING_FLAGS "-Wall -Wextra -Werror -Wdouble-promotion -Wfloat-conversion -Wshadow") -set(COMMON_WARNING_FLAGS_CUDA "-Wall,-Wextra,-Werror,-Wdouble-promotion,-Wfloat-conversion,-Wshadow") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_WARNING_FLAGS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_WARNING_FLAGS}") -set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -gencode arch=compute_60,code=sm_60 -gencode arch=compute_70,code=sm_70 --compiler-options=${COMMON_WARNING_FLAGS_CUDA}") +set(COMMON_FLAGS "-mavx -Wall -Wextra -Werror -Wdouble-promotion -Wfloat-conversion -Wshadow") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}") + +find_package(CUDA) # Still required for various macros, such as cuda_select_nvcc_... +cuda_select_nvcc_arch_flags(ARCHLIST Maxwell Pascal Volta Turing) +string(REPLACE ";" " " CUDA_ARCH_FLAGS "${ARCHLIST}") +set(COMMON_FLAGS_CUDA "-mavx,-Wall,-Wextra,-Werror,-Wdouble-promotion,-Wfloat-conversion,-Wshadow ") +set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} ${CUDA_ARCH_FLAGS} -ccbin=${CMAKE_CXX_COMPILER} --compiler-options=${COMMON_FLAGS_CUDA}") + ## Build type if(NOT CMAKE_BUILD_TYPE) @@ -21,9 +26,16 @@ endif() message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) ## Options -option(DOUBLE_PRECISION "Generates double precision code." OFF) -option(BUILD_SAMPLES "Builds projects in samples subdirectory" ON) -option(BUILD_STANDALONE "Builds standalone Astaroth" ON) +option(DOUBLE_PRECISION "Generates double precision code." OFF) +option(BUILD_SAMPLES "Builds projects in samples subdirectory" OFF) +option(BUILD_STANDALONE "Builds standalone Astaroth" ON) +option(MPI_ENABLED "Enables additional functions for MPI communciation" OFF) + +## Options (DEPRECATED) +# option(BUILD_DEBUG "Builds the program with extensive error checking" OFF) +# option(BUILD_UTILS "Builds the utility library" ON) +# option(BUILD_RT_VISUALIZATION "Builds the module for real-time visualization using SDL2" OFF) +option(MULTIGPU_ENABLED "If enabled, uses all the available GPUs (Affects Legacy & Node layers only)" OFF) ## Compile ACC add_subdirectory(acc) @@ -55,10 +67,19 @@ endif () add_definitions(-DAC_DEFAULT_CONFIG="${CMAKE_SOURCE_DIR}/config/astaroth.conf") +if (MULTIGPU_ENABLED) # Deprecated + add_definitions(-DAC_MULTIGPU_ENABLED=1) +endif () + +if (MPI_ENABLED) + add_definitions(-DAC_MPI_ENABLED=1) +endif() + ## Includes -include_directories(include) # Library headers -include_directories(src/common) # Common headers -include_directories(${CMAKE_BINARY_DIR}) # DSL headers +include_directories(include) # Library headers +include_directories(src/common) # Common headers +include_directories(${CMAKE_BINARY_DIR}) # DSL headers +include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) # CUDA headers ## Subdirectories add_subdirectory(src/utils) diff --git a/acc/CMakeLists.txt b/acc/CMakeLists.txt index 7877538..7808a04 100644 --- a/acc/CMakeLists.txt +++ b/acc/CMakeLists.txt @@ -7,6 +7,7 @@ project(acc C) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_WARNING_FLAGS} -Wno-error=sign-compare") include_directories(src) add_subdirectory(src) diff --git a/src/core/device.cc b/src/core/device.cc index 33b241f..11f9d17 100644 --- a/src/core/device.cc +++ b/src/core/device.cc @@ -1,6 +1,5 @@ #include "astaroth.h" -#include #include #include "astaroth_utils.h" @@ -458,6 +457,9 @@ acDeviceReduceVec(const Device device, const Stream stream, const ReductionType return AC_SUCCESS; } +#if AC_MPI_ENABLED +#include + static int mod(const int a, const int b) { @@ -1488,3 +1490,11 @@ acDeviceRunMPITest(void) ////////////////////////////////////////////////////////////// return AC_SUCCESS; } +#else +AcResult +acDeviceRunMPITest(void) +{ + WARNING("MPI was not enabled but acDeviceRunMPITest() was called"); + return AC_FAILURE; +} +#endif // AC_MPI_ENABLED