Loading .gitlab-ci.yml +4 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,10 @@ stages: .build_template_def: &build_template stage: build script: - export NUM_CORES=$(grep "core id" /proc/cpuinfo | wc -l) # all cores including hyperthreading # - export NUM_CORES=$(grep "core id" /proc/cpuinfo | wc -l) # # all pyhsical cores - export NUM_CORES=$(grep "core id" /proc/cpuinfo | sort -u | wc -l) - export MAKEFLAGS="-l$(echo 1.5*$NUM_CORES | bc) -j$NUM_CORES" - mkdir -p "./builddir/$CI_JOB_NAME" - pushd "./builddir/$CI_JOB_NAME" Loading CMakeLists.txt +109 −42 Original line number Diff line number Diff line Loading @@ -18,6 +18,20 @@ project( tnl ) set( tnlVersion "0.1" ) # declare all custom build options option(OFFLINE_BUILD "Offline build (i.e. without downloading libraries such as pybind11)" OFF) option(WITH_MIC "Build with MIC support" OFF) option(WITH_CUDA "Build with CUDA support" ON) set(WITH_CUDA_ARCH "auto" CACHE STRING "Build for these CUDA architectures") option(WITH_OPENMP "Build with OpenMP support" ON) option(WITH_GMP "Build with GMP support" OFF) option(WITH_TESTS "Build tests" ON) option(WITH_COVERAGE "Enable code coverage reports from unit tests" OFF) option(WITH_EXAMPLES "Compile the 'examples' directory" ON) option(WITH_TOOLS "Compile the 'src/Tools' directory" ON) option(WITH_PYTHON "Compile the Python bindings" ON) option(WITH_TEMPLATES_INSTANTIATION "Enable explicit template instantiation" OFF) # install paths relative to the cmake's prefix set( TNL_TARGET_INCLUDE_DIRECTORY "include/TNL" ) set( TNL_TARGET_DATA_DIRECTORY "share/TNL" ) Loading Loading @@ -50,13 +64,19 @@ endif() # set Debug/Release options set( CMAKE_CXX_FLAGS "-std=c++11 -pthread -Wall -Wno-unused-local-typedefs -Wno-unused-variable" ) set( CMAKE_CXX_FLAGS_DEBUG "-g -rdynamic -ftemplate-backtrace-limit=0" ) set( CMAKE_CXX_FLAGS_DEBUG "-g" ) set( CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -mtune=native -DNDEBUG" ) #set( CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -mtune=native -DNDEBUG -ftree-vectorizer-verbose=1 -ftree-vectorize -fopt-info-vec-missed -funroll-loops" ) # pass -rdynamic only in Debug mode set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" ) set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_DEBUG "-rdynamic" ) set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_RELEASE "" ) set( CMAKE_EXE_LINKER_FLAGS "" ) set( CMAKE_EXE_LINKER_FLAGS_DEBUG "-rdynamic" ) set( CMAKE_EXE_LINKER_FLAGS_RELEASE "" ) set( CMAKE_SHARED_LINKER_FLAGS "" ) set( CMAKE_SHARED_LINKER_FLAGS_DEBUG "-rdynamic" ) set( CMAKE_SHARED_LINKER_FLAGS_RELEASE "" ) get_filename_component( CXX_COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME ) if( CXX_COMPILER_NAME MATCHES "icpc" ) Loading @@ -65,12 +85,12 @@ if( CXX_COMPILER_NAME MATCHES "icpc" ) ##### # Check for MIC # if( WITH_MIC STREQUAL "yes" ) message( "Compile MIC support..." ) if( ${WITH_MIC} ) message( "Enabled MIC support." ) set( MIC_CXX_FLAGS "-DHAVE_MIC") # build all tests with MIC support set( CXX_TESTS_FLAGS ${CXX_TESTS_FLAGS} -DHAVE_MIC ) set( WITH_CUDA "no") set( WITH_CUDA OFF CACHE BOOL "Build with CUDA support" ) else() set( MIC_CXX_FLAGS "") endif() Loading @@ -93,7 +113,6 @@ if( ${CXX_COMPILER_NAME} STREQUAL "mpic++" ) message( "MPI compiler detected." ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_MPI" ) set( CUDA_HOST_COMPILER "mpic++" ) endif() #### Loading @@ -110,7 +129,7 @@ endif() ##### # Check for CUDA # if( WITH_CUDA STREQUAL "yes" ) if( ${WITH_CUDA} ) find_package( CUDA ) if( CUDA_FOUND ) set( BUILD_CUDA TRUE) Loading @@ -130,6 +149,22 @@ if( WITH_CUDA STREQUAL "yes" ) set( CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER} ) endif() endif() # An extra CUDA_ARCH_HOST_COMPILER variable for compiling tnl-cuda-arch alone, # because it SHOULD NOT be compiled using mpic++, which would cause weird # RPATH_CHANGE error in cmake. # FIXME: find better solution to switch between MPI-enabled and MPI-disabled binaries in cmake if( NOT $ENV{CUDA_ARCH_HOST_COMPILER} STREQUAL "" ) message( "-- Setting CUDA_ARCH_HOST_COMPILER to '$ENV{CUDA_ARCH_HOST_COMPILER}'" ) set( CUDA_ARCH_HOST_COMPILER $ENV{CUDA_ARCH_HOST_COMPILER} ) else() if( EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/bin/g++" ) message( "-- Setting CUDA_ARCH_HOST_COMPILER to '${CUDA_TOOLKIT_ROOT_DIR}/bin/g++'" ) set( CUDA_ARCH_HOST_COMPILER "${CUDA_TOOLKIT_ROOT_DIR}/bin/g++" ) else() message( "-- Setting CUDA_ARCH_HOST_COMPILER to '${CMAKE_CXX_COMPILER}'" ) set( CUDA_ARCH_HOST_COMPILER ${CMAKE_CXX_COMPILER} ) endif() endif() set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ;-DHAVE_CUDA) # disable false compiler warnings # reference for the -Xcudafe flag: http://stackoverflow.com/questions/14831051/how-to-disable-compiler-warnings-with-nvcc/17095910#17095910 Loading @@ -153,7 +188,7 @@ if( WITH_CUDA STREQUAL "yes" ) set( CUDA_ARCH_SOURCE ${PROJECT_SOURCE_DIR}/src/Tools/tnl-cuda-arch.cu) message( "Compiling tnl-cuda-arch ..." ) file( MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} ) execute_process( COMMAND nvcc --compiler-bindir ${CUDA_HOST_COMPILER} --std=c++11 ${CUDA_ARCH_SOURCE} -o ${CUDA_ARCH_EXECUTABLE} execute_process( COMMAND nvcc --compiler-bindir ${CUDA_ARCH_HOST_COMPILER} --std=c++11 ${CUDA_ARCH_SOURCE} -o ${CUDA_ARCH_EXECUTABLE} RESULT_VARIABLE CUDA_ARCH_RESULT OUTPUT_VARIABLE CUDA_ARCH_OUTPUT ERROR_VARIABLE CUDA_ARCH_OUTPUT ) Loading @@ -178,37 +213,18 @@ if( WITH_CUDA STREQUAL "yes" ) endif() endif() endif() set( CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; ${CUDA_ARCH} -D_FORCE_INLINES -lineinfo ) set( CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; ${CUDA_ARCH} -D_FORCE_INLINES ) # TODO: this is necessary only due to a bug in cmake set( CUDA_ADD_LIBRARY_OPTIONS -shared ) #### # Check for CUSPARSE # if( NOT WITH_CUSPARSE STREQUAL "no" ) find_path( CUSPARSE_INCLUDE_DIR cusparse.h /usr/local/cuda/include ${CUDA_INCLUDE_DIRS} DOC "CUSPARSE headers." ) if( ${CUSPARSE_INCLUDE_DIR} STREQUAL "CUSPARSE_INCLUDE_DIR-NOTFOUND" ) message( "CUSPARSE not found." ) set( HAVE_CUSPARSE "//#define HAVE_CUSPARSE 1" ) else() message( "CUSPARSE found. -- ${CUSPARSE_INCLUDE_DIR}" ) set( HAVE_CUSPARSE "#define HAVE_CUSPARSE 1" ) cuda_include_directories( ${CUSPARSE_INCLUDE_DIR} ) set( CUSPARSE_LIBRARY "${CUDA_cusparse_LIBRARY}" ) endif() endif( NOT WITH_CUSPARSE STREQUAL "no" ) endif( CUDA_FOUND ) endif( WITH_CUDA STREQUAL "yes" ) endif() #### # Check for OpenMP # if( OPENMP_FOUND AND WITH_OPENMP STREQUAL "yes" ) message( "Compiler supports OpenMP." ) if( OPENMP_FOUND AND ${WITH_OPENMP} ) message( "Enabled OpenMP support." ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENMP ${OpenMP_CXX_FLAGS}" ) endif() Loading Loading @@ -243,6 +259,36 @@ else() set( JPEG_LIBRARIES "" ) endif() #### # Test for GMP # if( ${WITH_GMP} ) if (GMP_INCLUDES AND GMP_LIBRARIES) set(GMP_FIND_QUIETLY TRUE) endif (GMP_INCLUDES AND GMP_LIBRARIES) find_path(GMP_INCLUDES NAMES gmp.h PATHS $ENV{GMPDIR} ${INCLUDE_INSTALL_DIR} ) find_library(GMP_LIBRARIES gmp PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GMP DEFAULT_MSG GMP_INCLUDES GMP_LIBRARIES) if( ${GMP_INCLUDES} STREQUAL "GMP_INCLUDES-NOTFOUND" OR ${GMP_LIBRARIES} STREQUAL "GMP_LIBRARIES-NOTFOUND" ) message( "GMP was not found. Some tests for higher precision arithmetics will not be passed." ) else() set( HAVE_GMP ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${GMP_INCLUDES} -DHAVE_GMP" ) set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GMP_LIBRARIES}" ) mark_as_advanced(GMP_INCLUDES GMP_LIBRARIES) endif() endif() #### # Check for some system header Loading Loading @@ -283,17 +329,17 @@ else() set( HAVE_SYS_IOCTL_H "#define HAVE_SYS_IOCTL_H 1" ) endif() if( WITH_TESTS STREQUAL "yes" ) if( ${WITH_TESTS} ) enable_testing() # build gtest libs include( BuildGtest ) if( WITH_COVERAGE STREQUAL "yes" AND CMAKE_BUILD_TYPE STREQUAL "Debug" ) if( ${WITH_COVERAGE} AND CMAKE_BUILD_TYPE STREQUAL "Debug" ) # enable code coverage reports include( UseCodeCoverage ) endif() endif( WITH_TESTS STREQUAL "yes" ) endif() #if( BUILD_MPI ) # FIND_PATH( PETSC_INCLUDE_DIR petsc.h Loading Loading @@ -323,7 +369,7 @@ endif( WITH_TESTS STREQUAL "yes" ) #### # Explicit template instantiation # #if( WITH_TEMPLATE_INSTANTIATION STREQUAL "yes" ) #if( ${WITH_TEMPLATE_INSTANTIATION} ) # AddCompilerFlag( "-DTEMPLATE_EXPLICIT_INSTANTIATION " ) # # if( INSTANTIATE_INT STREQUAL "yes" ) Loading Loading @@ -397,6 +443,20 @@ set(CPACK_SOURCE_STRIP_FILES "Release") #set(CPACK_PACKAGE_EXECUTABLES "MyExecutable" "My Executable") INCLUDE( CPack ) # Print custom build options message( "-- Build options:" ) message( " OFFLINE_BUILD=${OFFLINE_BUILD}" ) message( " WITH_MIC=${WITH_MIC}" ) message( " WITH_CUDA=${WITH_CUDA}" ) message( " WITH_CUDA_ARCH=${WITH_CUDA_ARCH}" ) message( " WITH_OPENMP=${WITH_OPENMP}" ) message( " WITH_GMP=${WITH_GMP}" ) message( " WITH_TESTS=${WITH_TESTS}" ) message( " WITH_COVERAGE=${WITH_COVERAGE}" ) message( " WITH_EXAMPLES=${WITH_EXAMPLES}" ) message( " WITH_TOOLS=${WITH_TOOLS}" ) message( " WITH_PYTHON=${WITH_PYTHON}" ) message( " WITH_TEMPLATES_INSTANTIATION=${WITH_TEMPLATES_INSTANTIATION}" ) # Print compiler options message( "-- Compiler options:" ) message( " CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}" ) Loading @@ -405,4 +465,11 @@ message( " CMAKE_CXX_FLAGS_RELEASE = ${CMAKE_CXX_FLAGS_RELEASE}" ) message( " CMAKE_SHARED_LIBRARY_LINK_C_FLAGS = ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}" ) message( " CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_DEBUG = ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_DEBUG}" ) message( " CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_RELEASE = ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_RELEASE}" ) message( " CMAKE_EXE_LINKER_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}" ) message( " CMAKE_EXE_LINKER_FLAGS_DEBUG = ${CMAKE_EXE_LINKER_FLAGS_DEBUG}" ) message( " CMAKE_EXE_LINKER_FLAGS_RELEASE = ${CMAKE_EXE_LINKER_FLAGS_RELEASE}" ) message( " CMAKE_SHARED_LINKER_FLAGS = ${CMAKE_SHARED_LINKER_FLAGS}" ) message( " CMAKE_SHARED_LINKER_FLAGS_DEBUG = ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" ) message( " CMAKE_SHARED_LINKER_FLAGS_RELEASE = ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}" ) message( " CUDA_NVCC_FLAGS = ${CUDA_NVCC_FLAGS}" ) message( " GMP_LIBRARIES = ${GMP_LIBRARIES}" ) build +9 −0 Original line number Diff line number Diff line Loading @@ -11,15 +11,18 @@ CMAKE="cmake" CMAKE_ONLY="no" HELP="no" VERBOSE="" OFFLINE_BUILD="no" WITH_CLANG="no" WITH_MPI="yes" WITH_CUDA="yes" WITH_CUDA_ARCH="auto" WITH_OPENMP="yes" WITH_GMP="no" WITH_TESTS="yes" WITH_COVERAGE="no" WITH_EXAMPLES="yes" WITH_PYTHON="yes" WITH_TOOLS="yes" WITH_TEMPLATE_INSTANTIATION="no" Loading @@ -43,12 +46,14 @@ do --cmake-only=* ) CMAKE_ONLY="${option#*=}" ;; --verbose ) VERBOSE="VERBOSE=1" ;; --help ) HELP="yes" ;; --offline-build ) OFFLINE_BUILD="yes" ;; --with-clang=* ) WITH_CLANG="${option#*=}" ;; --with-mpi=* ) WITH_MPI="${option#*=}" ;; --with-mic=* ) WITH_MIC="${option#*=}" ;; --with-cuda=* ) WITH_CUDA="${option#*=}" ;; --with-cuda-arch=* ) WITH_CUDA_ARCH="${option#*=}";; --with-openmp=* ) WITH_OPENMP="${option#*=}" ;; --with-gmp=* ) WITH_GMP="${option#*=}" ;; --with-tests=* ) WITH_TESTS="${option#*=}" ;; --with-coverage=* ) WITH_COVERAGE="${option#*=}" ;; --with-examples=* ) WITH_EXAMPLES="${option#*=}" ;; Loading Loading @@ -81,11 +86,13 @@ then echo " --build-jobs=NUM Number of processes to be used for the build. It is set to the number of available CPU cores by default." echo " --prefix=PATH Prefix for the installation directory. ${HOME}/local by default." echo " --install=yes/no Enables the installation of TNL files." echo " --offline-build=yes/no Disables online updates during the build. 'no' by default." echo " --with-mpi=yes/no Enables MPI. 'no' by default (Intel Compiler required)." echo " --with-mic=yes/no Enables MIC (Intel Xeon Phi). 'no' by default (Intel Compiler required)." echo " --with-cuda=yes/no Enables CUDA. 'yes' by default (CUDA Toolkit is required)." echo " --with-cuda-arch=all/auto/30/35/... Chooses CUDA architecture. 'auto' by default." echo " --with-openmp=yes/no Enables OpenMP. 'yes' by default." echo " --with-gmp=yes/no Enables the wrapper for GNU Multiple Precision Arithmetic Library. 'no' by default." echo " --with-tests=yes/no Enables unit tests. 'yes' by default." echo " --with-coverage=yes/no Enables code coverage reports for unit tests. 'no' by default (lcov is required)." echo " --with-examples=yes/no Compile the 'examples' directory. 'yes' by default." Loading Loading @@ -127,10 +134,12 @@ echo "Configuring ${BUILD} $TARGET ..." ${CMAKE} ${ROOT_DIR} \ -DCMAKE_BUILD_TYPE=${BUILD} \ -DCMAKE_INSTALL_PREFIX=${PREFIX} \ -DOFFLINE_BUILD=${OFFLINE_BUILD} \ -DWITH_MIC=${WITH_MIC} \ -DWITH_CUDA=${WITH_CUDA} \ -DWITH_CUDA_ARCH=${WITH_CUDA_ARCH} \ -DWITH_OPENMP=${WITH_OPENMP} \ -DWITH_GMP=${WITH_GMP} \ -DWITH_TESTS=${WITH_TESTS} \ -DWITH_COVERAGE=${WITH_COVERAGE} \ -DWITH_EXAMPLES=${WITH_EXAMPLES} \ Loading cmake/Gtest.cmake.in +3 −0 Original line number Diff line number Diff line Loading @@ -19,4 +19,7 @@ ExternalProject_Add(googletest BUILD_COMMAND "" INSTALL_COMMAND "" TEST_COMMAND "" # Disable update of the external project in an offline build # reference: https://stackoverflow.com/a/40423683 UPDATE_DISCONNECTED ${OFFLINE_BUILD} ) examples/CMakeLists.txt +2 −2 Original line number Diff line number Diff line add_subdirectory( heat-equation ) add_subdirectory( transport-equation ) add_subdirectory( navier-stokes ) add_subdirectory( inviscid-flow ) #add_subdirectory( mean-curvature-flow ) #add_subdirectory( hamilton-jacobi ) Loading @@ -9,7 +10,6 @@ add_subdirectory( navier-stokes ) #add_subdirectory( hamilton-jacobi-parallel-map ) #add_subdirectory( fast-sweeping-map ) #add_subdirectory( narrow-band ) add_subdirectory( inviscid-flow ) #add_subdirectory( incompressible-navier-stokes ) #add_subdirectory( mean-curvature-flow ) Loading
.gitlab-ci.yml +4 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,10 @@ stages: .build_template_def: &build_template stage: build script: - export NUM_CORES=$(grep "core id" /proc/cpuinfo | wc -l) # all cores including hyperthreading # - export NUM_CORES=$(grep "core id" /proc/cpuinfo | wc -l) # # all pyhsical cores - export NUM_CORES=$(grep "core id" /proc/cpuinfo | sort -u | wc -l) - export MAKEFLAGS="-l$(echo 1.5*$NUM_CORES | bc) -j$NUM_CORES" - mkdir -p "./builddir/$CI_JOB_NAME" - pushd "./builddir/$CI_JOB_NAME" Loading
CMakeLists.txt +109 −42 Original line number Diff line number Diff line Loading @@ -18,6 +18,20 @@ project( tnl ) set( tnlVersion "0.1" ) # declare all custom build options option(OFFLINE_BUILD "Offline build (i.e. without downloading libraries such as pybind11)" OFF) option(WITH_MIC "Build with MIC support" OFF) option(WITH_CUDA "Build with CUDA support" ON) set(WITH_CUDA_ARCH "auto" CACHE STRING "Build for these CUDA architectures") option(WITH_OPENMP "Build with OpenMP support" ON) option(WITH_GMP "Build with GMP support" OFF) option(WITH_TESTS "Build tests" ON) option(WITH_COVERAGE "Enable code coverage reports from unit tests" OFF) option(WITH_EXAMPLES "Compile the 'examples' directory" ON) option(WITH_TOOLS "Compile the 'src/Tools' directory" ON) option(WITH_PYTHON "Compile the Python bindings" ON) option(WITH_TEMPLATES_INSTANTIATION "Enable explicit template instantiation" OFF) # install paths relative to the cmake's prefix set( TNL_TARGET_INCLUDE_DIRECTORY "include/TNL" ) set( TNL_TARGET_DATA_DIRECTORY "share/TNL" ) Loading Loading @@ -50,13 +64,19 @@ endif() # set Debug/Release options set( CMAKE_CXX_FLAGS "-std=c++11 -pthread -Wall -Wno-unused-local-typedefs -Wno-unused-variable" ) set( CMAKE_CXX_FLAGS_DEBUG "-g -rdynamic -ftemplate-backtrace-limit=0" ) set( CMAKE_CXX_FLAGS_DEBUG "-g" ) set( CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -mtune=native -DNDEBUG" ) #set( CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -mtune=native -DNDEBUG -ftree-vectorizer-verbose=1 -ftree-vectorize -fopt-info-vec-missed -funroll-loops" ) # pass -rdynamic only in Debug mode set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" ) set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_DEBUG "-rdynamic" ) set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_RELEASE "" ) set( CMAKE_EXE_LINKER_FLAGS "" ) set( CMAKE_EXE_LINKER_FLAGS_DEBUG "-rdynamic" ) set( CMAKE_EXE_LINKER_FLAGS_RELEASE "" ) set( CMAKE_SHARED_LINKER_FLAGS "" ) set( CMAKE_SHARED_LINKER_FLAGS_DEBUG "-rdynamic" ) set( CMAKE_SHARED_LINKER_FLAGS_RELEASE "" ) get_filename_component( CXX_COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME ) if( CXX_COMPILER_NAME MATCHES "icpc" ) Loading @@ -65,12 +85,12 @@ if( CXX_COMPILER_NAME MATCHES "icpc" ) ##### # Check for MIC # if( WITH_MIC STREQUAL "yes" ) message( "Compile MIC support..." ) if( ${WITH_MIC} ) message( "Enabled MIC support." ) set( MIC_CXX_FLAGS "-DHAVE_MIC") # build all tests with MIC support set( CXX_TESTS_FLAGS ${CXX_TESTS_FLAGS} -DHAVE_MIC ) set( WITH_CUDA "no") set( WITH_CUDA OFF CACHE BOOL "Build with CUDA support" ) else() set( MIC_CXX_FLAGS "") endif() Loading @@ -93,7 +113,6 @@ if( ${CXX_COMPILER_NAME} STREQUAL "mpic++" ) message( "MPI compiler detected." ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_MPI" ) set( CUDA_HOST_COMPILER "mpic++" ) endif() #### Loading @@ -110,7 +129,7 @@ endif() ##### # Check for CUDA # if( WITH_CUDA STREQUAL "yes" ) if( ${WITH_CUDA} ) find_package( CUDA ) if( CUDA_FOUND ) set( BUILD_CUDA TRUE) Loading @@ -130,6 +149,22 @@ if( WITH_CUDA STREQUAL "yes" ) set( CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER} ) endif() endif() # An extra CUDA_ARCH_HOST_COMPILER variable for compiling tnl-cuda-arch alone, # because it SHOULD NOT be compiled using mpic++, which would cause weird # RPATH_CHANGE error in cmake. # FIXME: find better solution to switch between MPI-enabled and MPI-disabled binaries in cmake if( NOT $ENV{CUDA_ARCH_HOST_COMPILER} STREQUAL "" ) message( "-- Setting CUDA_ARCH_HOST_COMPILER to '$ENV{CUDA_ARCH_HOST_COMPILER}'" ) set( CUDA_ARCH_HOST_COMPILER $ENV{CUDA_ARCH_HOST_COMPILER} ) else() if( EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/bin/g++" ) message( "-- Setting CUDA_ARCH_HOST_COMPILER to '${CUDA_TOOLKIT_ROOT_DIR}/bin/g++'" ) set( CUDA_ARCH_HOST_COMPILER "${CUDA_TOOLKIT_ROOT_DIR}/bin/g++" ) else() message( "-- Setting CUDA_ARCH_HOST_COMPILER to '${CMAKE_CXX_COMPILER}'" ) set( CUDA_ARCH_HOST_COMPILER ${CMAKE_CXX_COMPILER} ) endif() endif() set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ;-DHAVE_CUDA) # disable false compiler warnings # reference for the -Xcudafe flag: http://stackoverflow.com/questions/14831051/how-to-disable-compiler-warnings-with-nvcc/17095910#17095910 Loading @@ -153,7 +188,7 @@ if( WITH_CUDA STREQUAL "yes" ) set( CUDA_ARCH_SOURCE ${PROJECT_SOURCE_DIR}/src/Tools/tnl-cuda-arch.cu) message( "Compiling tnl-cuda-arch ..." ) file( MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} ) execute_process( COMMAND nvcc --compiler-bindir ${CUDA_HOST_COMPILER} --std=c++11 ${CUDA_ARCH_SOURCE} -o ${CUDA_ARCH_EXECUTABLE} execute_process( COMMAND nvcc --compiler-bindir ${CUDA_ARCH_HOST_COMPILER} --std=c++11 ${CUDA_ARCH_SOURCE} -o ${CUDA_ARCH_EXECUTABLE} RESULT_VARIABLE CUDA_ARCH_RESULT OUTPUT_VARIABLE CUDA_ARCH_OUTPUT ERROR_VARIABLE CUDA_ARCH_OUTPUT ) Loading @@ -178,37 +213,18 @@ if( WITH_CUDA STREQUAL "yes" ) endif() endif() endif() set( CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; ${CUDA_ARCH} -D_FORCE_INLINES -lineinfo ) set( CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; ${CUDA_ARCH} -D_FORCE_INLINES ) # TODO: this is necessary only due to a bug in cmake set( CUDA_ADD_LIBRARY_OPTIONS -shared ) #### # Check for CUSPARSE # if( NOT WITH_CUSPARSE STREQUAL "no" ) find_path( CUSPARSE_INCLUDE_DIR cusparse.h /usr/local/cuda/include ${CUDA_INCLUDE_DIRS} DOC "CUSPARSE headers." ) if( ${CUSPARSE_INCLUDE_DIR} STREQUAL "CUSPARSE_INCLUDE_DIR-NOTFOUND" ) message( "CUSPARSE not found." ) set( HAVE_CUSPARSE "//#define HAVE_CUSPARSE 1" ) else() message( "CUSPARSE found. -- ${CUSPARSE_INCLUDE_DIR}" ) set( HAVE_CUSPARSE "#define HAVE_CUSPARSE 1" ) cuda_include_directories( ${CUSPARSE_INCLUDE_DIR} ) set( CUSPARSE_LIBRARY "${CUDA_cusparse_LIBRARY}" ) endif() endif( NOT WITH_CUSPARSE STREQUAL "no" ) endif( CUDA_FOUND ) endif( WITH_CUDA STREQUAL "yes" ) endif() #### # Check for OpenMP # if( OPENMP_FOUND AND WITH_OPENMP STREQUAL "yes" ) message( "Compiler supports OpenMP." ) if( OPENMP_FOUND AND ${WITH_OPENMP} ) message( "Enabled OpenMP support." ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENMP ${OpenMP_CXX_FLAGS}" ) endif() Loading Loading @@ -243,6 +259,36 @@ else() set( JPEG_LIBRARIES "" ) endif() #### # Test for GMP # if( ${WITH_GMP} ) if (GMP_INCLUDES AND GMP_LIBRARIES) set(GMP_FIND_QUIETLY TRUE) endif (GMP_INCLUDES AND GMP_LIBRARIES) find_path(GMP_INCLUDES NAMES gmp.h PATHS $ENV{GMPDIR} ${INCLUDE_INSTALL_DIR} ) find_library(GMP_LIBRARIES gmp PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GMP DEFAULT_MSG GMP_INCLUDES GMP_LIBRARIES) if( ${GMP_INCLUDES} STREQUAL "GMP_INCLUDES-NOTFOUND" OR ${GMP_LIBRARIES} STREQUAL "GMP_LIBRARIES-NOTFOUND" ) message( "GMP was not found. Some tests for higher precision arithmetics will not be passed." ) else() set( HAVE_GMP ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${GMP_INCLUDES} -DHAVE_GMP" ) set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GMP_LIBRARIES}" ) mark_as_advanced(GMP_INCLUDES GMP_LIBRARIES) endif() endif() #### # Check for some system header Loading Loading @@ -283,17 +329,17 @@ else() set( HAVE_SYS_IOCTL_H "#define HAVE_SYS_IOCTL_H 1" ) endif() if( WITH_TESTS STREQUAL "yes" ) if( ${WITH_TESTS} ) enable_testing() # build gtest libs include( BuildGtest ) if( WITH_COVERAGE STREQUAL "yes" AND CMAKE_BUILD_TYPE STREQUAL "Debug" ) if( ${WITH_COVERAGE} AND CMAKE_BUILD_TYPE STREQUAL "Debug" ) # enable code coverage reports include( UseCodeCoverage ) endif() endif( WITH_TESTS STREQUAL "yes" ) endif() #if( BUILD_MPI ) # FIND_PATH( PETSC_INCLUDE_DIR petsc.h Loading Loading @@ -323,7 +369,7 @@ endif( WITH_TESTS STREQUAL "yes" ) #### # Explicit template instantiation # #if( WITH_TEMPLATE_INSTANTIATION STREQUAL "yes" ) #if( ${WITH_TEMPLATE_INSTANTIATION} ) # AddCompilerFlag( "-DTEMPLATE_EXPLICIT_INSTANTIATION " ) # # if( INSTANTIATE_INT STREQUAL "yes" ) Loading Loading @@ -397,6 +443,20 @@ set(CPACK_SOURCE_STRIP_FILES "Release") #set(CPACK_PACKAGE_EXECUTABLES "MyExecutable" "My Executable") INCLUDE( CPack ) # Print custom build options message( "-- Build options:" ) message( " OFFLINE_BUILD=${OFFLINE_BUILD}" ) message( " WITH_MIC=${WITH_MIC}" ) message( " WITH_CUDA=${WITH_CUDA}" ) message( " WITH_CUDA_ARCH=${WITH_CUDA_ARCH}" ) message( " WITH_OPENMP=${WITH_OPENMP}" ) message( " WITH_GMP=${WITH_GMP}" ) message( " WITH_TESTS=${WITH_TESTS}" ) message( " WITH_COVERAGE=${WITH_COVERAGE}" ) message( " WITH_EXAMPLES=${WITH_EXAMPLES}" ) message( " WITH_TOOLS=${WITH_TOOLS}" ) message( " WITH_PYTHON=${WITH_PYTHON}" ) message( " WITH_TEMPLATES_INSTANTIATION=${WITH_TEMPLATES_INSTANTIATION}" ) # Print compiler options message( "-- Compiler options:" ) message( " CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}" ) Loading @@ -405,4 +465,11 @@ message( " CMAKE_CXX_FLAGS_RELEASE = ${CMAKE_CXX_FLAGS_RELEASE}" ) message( " CMAKE_SHARED_LIBRARY_LINK_C_FLAGS = ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}" ) message( " CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_DEBUG = ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_DEBUG}" ) message( " CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_RELEASE = ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_RELEASE}" ) message( " CMAKE_EXE_LINKER_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}" ) message( " CMAKE_EXE_LINKER_FLAGS_DEBUG = ${CMAKE_EXE_LINKER_FLAGS_DEBUG}" ) message( " CMAKE_EXE_LINKER_FLAGS_RELEASE = ${CMAKE_EXE_LINKER_FLAGS_RELEASE}" ) message( " CMAKE_SHARED_LINKER_FLAGS = ${CMAKE_SHARED_LINKER_FLAGS}" ) message( " CMAKE_SHARED_LINKER_FLAGS_DEBUG = ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" ) message( " CMAKE_SHARED_LINKER_FLAGS_RELEASE = ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}" ) message( " CUDA_NVCC_FLAGS = ${CUDA_NVCC_FLAGS}" ) message( " GMP_LIBRARIES = ${GMP_LIBRARIES}" )
build +9 −0 Original line number Diff line number Diff line Loading @@ -11,15 +11,18 @@ CMAKE="cmake" CMAKE_ONLY="no" HELP="no" VERBOSE="" OFFLINE_BUILD="no" WITH_CLANG="no" WITH_MPI="yes" WITH_CUDA="yes" WITH_CUDA_ARCH="auto" WITH_OPENMP="yes" WITH_GMP="no" WITH_TESTS="yes" WITH_COVERAGE="no" WITH_EXAMPLES="yes" WITH_PYTHON="yes" WITH_TOOLS="yes" WITH_TEMPLATE_INSTANTIATION="no" Loading @@ -43,12 +46,14 @@ do --cmake-only=* ) CMAKE_ONLY="${option#*=}" ;; --verbose ) VERBOSE="VERBOSE=1" ;; --help ) HELP="yes" ;; --offline-build ) OFFLINE_BUILD="yes" ;; --with-clang=* ) WITH_CLANG="${option#*=}" ;; --with-mpi=* ) WITH_MPI="${option#*=}" ;; --with-mic=* ) WITH_MIC="${option#*=}" ;; --with-cuda=* ) WITH_CUDA="${option#*=}" ;; --with-cuda-arch=* ) WITH_CUDA_ARCH="${option#*=}";; --with-openmp=* ) WITH_OPENMP="${option#*=}" ;; --with-gmp=* ) WITH_GMP="${option#*=}" ;; --with-tests=* ) WITH_TESTS="${option#*=}" ;; --with-coverage=* ) WITH_COVERAGE="${option#*=}" ;; --with-examples=* ) WITH_EXAMPLES="${option#*=}" ;; Loading Loading @@ -81,11 +86,13 @@ then echo " --build-jobs=NUM Number of processes to be used for the build. It is set to the number of available CPU cores by default." echo " --prefix=PATH Prefix for the installation directory. ${HOME}/local by default." echo " --install=yes/no Enables the installation of TNL files." echo " --offline-build=yes/no Disables online updates during the build. 'no' by default." echo " --with-mpi=yes/no Enables MPI. 'no' by default (Intel Compiler required)." echo " --with-mic=yes/no Enables MIC (Intel Xeon Phi). 'no' by default (Intel Compiler required)." echo " --with-cuda=yes/no Enables CUDA. 'yes' by default (CUDA Toolkit is required)." echo " --with-cuda-arch=all/auto/30/35/... Chooses CUDA architecture. 'auto' by default." echo " --with-openmp=yes/no Enables OpenMP. 'yes' by default." echo " --with-gmp=yes/no Enables the wrapper for GNU Multiple Precision Arithmetic Library. 'no' by default." echo " --with-tests=yes/no Enables unit tests. 'yes' by default." echo " --with-coverage=yes/no Enables code coverage reports for unit tests. 'no' by default (lcov is required)." echo " --with-examples=yes/no Compile the 'examples' directory. 'yes' by default." Loading Loading @@ -127,10 +134,12 @@ echo "Configuring ${BUILD} $TARGET ..." ${CMAKE} ${ROOT_DIR} \ -DCMAKE_BUILD_TYPE=${BUILD} \ -DCMAKE_INSTALL_PREFIX=${PREFIX} \ -DOFFLINE_BUILD=${OFFLINE_BUILD} \ -DWITH_MIC=${WITH_MIC} \ -DWITH_CUDA=${WITH_CUDA} \ -DWITH_CUDA_ARCH=${WITH_CUDA_ARCH} \ -DWITH_OPENMP=${WITH_OPENMP} \ -DWITH_GMP=${WITH_GMP} \ -DWITH_TESTS=${WITH_TESTS} \ -DWITH_COVERAGE=${WITH_COVERAGE} \ -DWITH_EXAMPLES=${WITH_EXAMPLES} \ Loading
cmake/Gtest.cmake.in +3 −0 Original line number Diff line number Diff line Loading @@ -19,4 +19,7 @@ ExternalProject_Add(googletest BUILD_COMMAND "" INSTALL_COMMAND "" TEST_COMMAND "" # Disable update of the external project in an offline build # reference: https://stackoverflow.com/a/40423683 UPDATE_DISCONNECTED ${OFFLINE_BUILD} )
examples/CMakeLists.txt +2 −2 Original line number Diff line number Diff line add_subdirectory( heat-equation ) add_subdirectory( transport-equation ) add_subdirectory( navier-stokes ) add_subdirectory( inviscid-flow ) #add_subdirectory( mean-curvature-flow ) #add_subdirectory( hamilton-jacobi ) Loading @@ -9,7 +10,6 @@ add_subdirectory( navier-stokes ) #add_subdirectory( hamilton-jacobi-parallel-map ) #add_subdirectory( fast-sweeping-map ) #add_subdirectory( narrow-band ) add_subdirectory( inviscid-flow ) #add_subdirectory( incompressible-navier-stokes ) #add_subdirectory( mean-curvature-flow )