Commit 323dd294 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Merge branch 'develop' of geraldine.fjfi.cvut.cz:/local/projects/tnl/tnl into develop

Conflicts:
	examples/advection/LaxFridrichs_impl.h
	examples/inviscid-flow/1d/LaxFridrichsContinuity_impl.h
	examples/inviscid-flow/1d/LaxFridrichsEnergy_impl.h
	examples/inviscid-flow/1d/LaxFridrichsMomentum_impl.h
	examples/inviscid-flow/2d/EulerPressureGetter_impl.h
	examples/inviscid-flow/2d/EulerVelGetter_impl.h
	examples/inviscid-flow/2d/EulerVelXGetter_impl.h
	examples/inviscid-flow/2d/EulerVelYGetter_impl.h
	examples/inviscid-flow/2d/LaxFridrichsContinuity_impl .h
	examples/inviscid-flow/2d/LaxFridrichsEnergy_impl.h
	examples/inviscid-flow/2d/LaxFridrichsMomentumX_impl.h
	examples/inviscid-flow/2d/LaxFridrichsMomentumY_impl.h
	src/TNL/Meshes/GridDetails/Grid2D_impl.h
	src/TNL/Meshes/GridDetails/NeighbourGridEntitiesStorage.h
	src/TNL/Meshes/GridEntity.h
	src/TNL/Meshes/GridEntityConfig.h
	src/TNL/Operators/NeumannBoundaryConditions.h
parents 75704c85 4f2d9832
Loading
Loading
Loading
Loading

CMakeLists.txt

100755 → 100644
+31 −32
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
# Vladimir Klement
# Jakub Klinkovsky

cmake_minimum_required( VERSION 3.4 )
cmake_minimum_required( VERSION 3.5.1 )

project( tnl )

@@ -21,28 +21,25 @@ set( tnlVersion "0.1" )
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

include( OptimizeForArchitecture )
include( UseCodeCoverage )

####
# Settings for debug/release version
#
if( CMAKE_BUILD_TYPE STREQUAL "Debug")
    set( PROJECT_BUILD_PATH ${PROJECT_SOURCE_DIR}/Debug/src/TNL )
    set( PROJECT_TESTS_PATH ${PROJECT_SOURCE_DIR}/Debug/src/Tests )
    set( PROJECT_BUILD_PATH ${PROJECT_SOURCE_DIR}/Debug/src )
    set( PROJECT_TOOLS_PATH ${PROJECT_SOURCE_DIR}/Debug/bin )
    set( LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/Debug/lib )
    set( EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/Debug/bin )
    set( debugExt -dbg )
else()
    set( PROJECT_BUILD_PATH ${PROJECT_SOURCE_DIR}/Release/src/TNL )
    set( PROJECT_TESTS_PATH ${PROJECT_SOURCE_DIR}/Release/src/Tests )
    set( PROJECT_BUILD_PATH ${PROJECT_SOURCE_DIR}/Release/src )
    set( PROJECT_TOOLS_PATH ${PROJECT_SOURCE_DIR}/Release/bin )
    set( LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/Release/lib )
    set( EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/Release/bin )
endif()

# set Debug/Release options
set( CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-unused-local-typedefs -Wno-unused-variable" )
set( CMAKE_CXX_FLAGS "-std=c++11 -pthread -Wall -Wno-unused-local-typedefs -Wno-unused-variable" )
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" )
@@ -51,12 +48,6 @@ set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" )
set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_DEBUG "-rdynamic" )
set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_RELEASE "" )

get_filename_component( CXX_COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME )
if( CXX_COMPILER_NAME MATCHES "icpc" )
   message( "Intel compiler detected..."    )
   set( CMAKE_CXX_FLAGS "${CXXFLAGS} -DHAVE_ICPC ")
endif()

#####
# Check for CUDA
#
@@ -67,12 +58,19 @@ if( WITH_CUDA STREQUAL "yes" )
        set(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF)
        set(BUILD_SHARED_LIBS ON)
        set(CUDA_SEPARABLE_COMPILATION ON)        
        # Use the CUDA_HOST_COMPILER environment variable if the user specified it.
        if( NOT $ENV{CUDA_HOST_COMPILER} STREQUAL "" )
            message( "-- Setting CUDA_HOST_COMPILER to '$ENV{CUDA_HOST_COMPILER}'" )
            set( CUDA_HOST_COMPILER $ENV{CUDA_HOST_COMPILER} )
        else()
            message( "-- Setting CUDA_HOST_COMPILER to '${CMAKE_CXX_COMPILER}'" )
            set( CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER} )
        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
        #   list of possible tokens: http://www.ssl.berkeley.edu/~jimm/grizzly_docs/SSL/opt/intel/cc/9.0/lib/locale/en_US/mcpcom.msg
        set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; -Wno-deprecated-gpu-targets --expt-relaxed-constexpr -Xcudafe "\"--diag_suppress=code_is_unreachable --diag_suppress=implicit_return_from_non_void_function\"")
        #AddCompilerFlag( "-DHAVE_NOT_CXX11" ) # -U_GLIBCXX_ATOMIC_BUILTINS -U_GLIBCXX_USE_INT128 " )
        set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; -Wno-deprecated-gpu-targets --expt-relaxed-constexpr --expt-extended-lambda -Xcudafe "\"--diag_suppress=code_is_unreachable --diag_suppress=implicit_return_from_non_void_function\"")
        set( ALL_CUDA_ARCHS -gencode arch=compute_20,code=sm_20
                            -gencode arch=compute_30,code=sm_30
                            -gencode arch=compute_32,code=sm_32 
@@ -115,9 +113,6 @@ if( WITH_CUDA STREQUAL "yes" )
        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 )
        # TODO: workaround for a bug in cmake 3.5.0 (fixed in 3.5.1)
        set( CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; -ccbin "${CMAKE_CXX_COMPILER}" )
        set( CUDA_HOST_COMPILER "" )

        ####
        # Check for cuBLAS
@@ -234,7 +229,7 @@ if( ${SYS_TIME_INCLUDE_DIR} STREQUAL "SYS_TIME_INCLUDE_DIR-NOTFOUND" )
    message(  "Missing header file sys/time.h" )
    set( HAVE_SYS_TIME_H "//#define HAVE_SYS_TIME_H 1" )
else()
    include_directories( ${SYS_TIME_INCLUDE_DIR}/tnl-${tnlVersion} )
    #include_directories( ${SYS_TIME_INCLUDE_DIR} )
    set( HAVE_SYS_TIME_H "#define HAVE_SYS_TIME_H 1" )
endif()

@@ -246,7 +241,7 @@ if( ${SYS_RESOURCE_INCLUDE_DIR} STREQUAL "SYS_RESOURCE_INCLUDE_DIR-NOTFOUND" )
    message( "Missing header file sys/time.h" )
    set( HAVE_SYS_RESOURCE_H "//#define HAVE_SYS_RESOURCE_H 1" )
else()
    include_directories( ${SYS_RESOURCE_INCLUDE_DIR}/tnl-${tnlVersion} )
    #include_directories( ${SYS_RESOURCE_INCLUDE_DIR} )
    set( HAVE_SYS_RESOURCE_H "#define HAVE_SYS_RESOURCE_H 1" )
endif()

@@ -258,15 +253,20 @@ if( ${SYS_IOCTL_INCLUDE_DIR} STREQUAL "SYS_IOCTL_INCLUDE_DIR-NOTFOUND" )
    message( "Missing header file sys/time.h" )
    set( HAVE_SYS_IOCTL_H "//#define HAVE_SYS_IOCTL_H 1" )
else()
    include_directories( ${SYS_IOCTL_INCLUDE_DIR}/tnl-${tnlVersion} )
    #include_directories( ${SYS_IOCTL_INCLUDE_DIR} )
    set( HAVE_SYS_IOCTL_H "#define HAVE_SYS_IOCTL_H 1" )
endif()

if( WITH_TESTS STREQUAL "yes" )
   find_package( GTest )
   if( GTEST_FOUND )
      set( CXX_TESTS_FLAGS "-DHAVE_GTEST" )
   endif( GTEST_FOUND )
   enable_testing()

   # build gtest libs
   include( BuildGtest )

   if( WITH_COVERAGE STREQUAL "yes" AND CMAKE_BUILD_TYPE STREQUAL "Debug" )
      # enable code coverage reports
      include( UseCodeCoverage )
   endif()
endif( WITH_TESTS STREQUAL "yes" )

find_package( PythonInterp 3 )
@@ -327,9 +327,6 @@ if( OPTIMIZED_VECTOR_HOST_OPERATIONS STREQUAL "yes" )
   AddCompilerFlag( "-DOPTIMIZED_VECTOR_HOST_OPERATIONS " )
endif()

set( CXX_TEST_FLAGS "-fprofile-arcs -ftest-coverage" )
set( LD_TEST_FLAGS "-lgcov -coverage" )

set( configDirectory \"${CMAKE_INSTALL_PREFIX}/share/tnl-${tnlVersion}/\")
set( sourceDirectory \"${PROJECT_SOURCE_DIR}/\" )
set( testsDirectory \"${PROJECT_TESTS_PATH}/\" )
@@ -342,7 +339,6 @@ endif( PYTHONINTERP_FOUND )

#Nastavime cesty k hlavickovym souborum a knihovnam
INCLUDE_DIRECTORIES( src )
INCLUDE_DIRECTORIES( tests )
INCLUDE_DIRECTORIES( ${PROJECT_BUILD_PATH} )
LINK_DIRECTORIES( ${LIBRARY_OUTPUT_PATH} )

@@ -350,7 +346,10 @@ LINK_DIRECTORIES( ${LIBRARY_OUTPUT_PATH} )
add_subdirectory( src )
add_subdirectory( share )
add_subdirectory( tests )

if( WITH_EXAMPLES STREQUAL "yes" )
   add_subdirectory( examples )
endif()

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Template Numerical Library")
set(CPACK_PACKAGE_VENDOR "MMG")
+1 −1
Original line number Diff line number Diff line
MIT License

Copyright (c) 2004-2016 Tomáš Oberhuber et al.
Copyright (c) 2004-2017 Tomáš Oberhuber et al.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+5 −3
Original line number Diff line number Diff line
@@ -16,9 +16,6 @@ TODO:


TODO:
 - zrejme bude potreba udrzovat ke kazdemu objektu jeho obraz na GPU/MIC
 - to by zarizovala metoda syncToDevice() napr. kazdy objekt by mel promennou modified, ktera by rikala, jestli se zmenil a zda je nutne ho
   prekopirovavat

TODO:
 - zavest namespaces
@@ -31,6 +28,11 @@ TODO: CUDA unified memory
se s nimi pracovat postaru
 - bylo by dobre to obalit unique poinetry, aby se nemusela delat dealokace rucne

TODO: shared pointery
 - mohli bysme pomoci nich odstranit Shared objekty
 - asi by bylo lepsi datcounter z shared pointeru primo do array a tento counter by se alokoval az po porvnim sdileni dat
 - diky tomu by se array mohlo vytvaret i na gpu bez nutnosti dynamicke alokace, jen by nebylo mozne delat bind (nebo nejaky zjednoduseny)

TODO: Mesh
 * vsechny traits zkusit presunout do jednotneho MeshTraits, tj. temer MeshConfigTraits ale pojmenovat jako MeshTraits
 * omezit tnlDimesnionsTag - asi to ale nepujde
+46 −28
Original line number Diff line number Diff line
@@ -2,35 +2,50 @@

TARGET=TNL
PREFIX=${HOME}/.local
INSTALL="no"
ROOT_DIR="."
DCMTK_DIR="/usr/include/dcmtk"
BUILD=""
BUILD_JOBS=""
CMAKE="cmake"
CMAKE_ONLY="no"
HELP="no"
VERBOSE=""

WITH_CLANG="no"
WITH_CUDA="yes"
WITH_CUDA_ARCH="auto"
WITH_TESTS="yes"
WITH_COVERAGE="no"
WITH_EXAMPLES="yes"

WITH_CUDA_ARCH="auto"
WITH_TEMPLATE_INSTANTIATION="yes"
WITH_TEMPLATE_INSTANTIATION="no"
INSTANTIATE_LONG_INT="no"
INSTANTIATE_INT="yes"
INSTANTIATE_LONG_DOUBLE="no"
INSTANTIATE_DOUBLE="yes"
INSTANTIATE_FLOAT="no"
OPTIMIZED_VECTOR_HOST_OPERATIONS="no"
CMAKE="cmake"
CMAKE_ONLY="no"
HELP="no"
VERBOSE=""
ROOT_DIR="."
DCMTK_DIR="/usr/include/dcmtk"
BUILD_JOBS=""

for option in "$@"
do
    case $option in
        --prefix=*                       ) PREFIX="${option#*=}" ;;
        --install=*                      ) INSTALL="${option#*=}" ;;
        --root-dir=*                     ) ROOT_DIR="${option#*=}" ;;
        --dcmtk-dir=*                    ) DCMTK_DIR="${option#*=}" ;;
        --build=*                        ) BUILD="${option#*=}" ;;
        --build-jobs=*                   ) BUILD_JOBS="${option#*=}" ;;
        --cmake=*                        ) CMAKE="${option#*=}" ;;
        --cmake-only=*                   ) CMAKE_ONLY="${option#*=}" ;;
        --verbose                        ) VERBOSE="VERBOSE=1" ;;
        --help                           ) HELP="yes" ;;
        --with-clang=*                   ) WITH_CLANG="${option#*=}" ;;
        --with-tests=*                   ) WITH_TESTS="${option#*=}" ;;
        --with-cuda=*                    ) WITH_CUDA="${option#*=}" ;;
        --with-cuda-arch=*               ) WITH_CUDA_ARCH="${option#*=}";;
        --with-tests=*                   ) WITH_TESTS="${option#*=}" ;;
        --with-coverage=*                ) WITH_COVERAGE="${option#*=}" ;;
        --with-examples=*                ) WITH_EXAMPLES="${option#*=}" ;;
        --with-templates-instantiation=* ) WITH_TEMPLATE_INSTANTIATION="${option#*=}" ;;
        --instantiate-long-int=*         ) INSTANTIATE_LONG_INT="${option#*=}" ;;
        --instantiate-int=*              ) INSTANTIATE_INT="${option#*=}" ;;
@@ -44,13 +59,6 @@ do
                                           INSTANTIATE_FLOAT="no"
                                           WITH_CUDA_ARCH="auto" ;;
        --optimize-vector-host-operations=* ) OPTIMIZED_VECTOR_HOST_OPERATIONS="yes" ;;
        --with-cmake=*                   ) CMAKE="${option#*=}" ;;
        --build-jobs=*                   ) BUILD_JOBS="${option#*=}" ;;
        --cmake-only=*                   ) CMAKE_ONLY="${option#*=}" ;;
        --verbose                        ) VERBOSE="VERBOSE=1" ;;
        --root-dir=*                     ) ROOT_DIR="${option#*=}" ;;
        --dcmtk-dir=*                    ) DCMTK_DIR="${option#*=}" ;;
        --help                           ) HELP="yes" ;;
        *                                ) 
           echo "Unknown option ${option}. Use --help for more information."
           exit 1 ;;
@@ -61,15 +69,17 @@ if test ${HELP} = "yes";
then
    echo "TNL build options:"
    echo ""
    echo "   --prefix=PATH                         Prefix for the installation directory. ${HOME}/local by default."
    echo "   --build=Debug/Release                 Build type."
    echo "   --with-tests=yes/no                   Enable unit tests. 'yes' by default (libcppunit-dev is required)."
    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 "   --with-cuda=yes/no                    Enable CUDA. 'yes' by default (CUDA Toolkit is required)."
    echo "   --with-cuda-arch=all/auto/30/35/...   Choose CUDA architecture."   
    echo "   --with-templates-instantiation=yes/no Some TNL templates are precompiled during the build. 'yes' by default."
    echo "   --full-build                          Instantiate all -- long int indexing, float and long double floating point arithmetics."
    echo "   --with-cmake=CMAKE                    Path to cmake. 'cmake' by default."
    echo "   --build-jobs=NUM                      Number of processes to be used for the build. It is set to a number of CPU cores by default."
    echo "   --with-cuda-arch=all/auto/30/35/...   Choose CUDA architecture. 'auto' by default."
    echo "   --with-tests=yes/no                   Enable unit tests. 'yes' by default."
    echo "   --with-coverage=yes/no                Enable code coverage reports for unit tests. 'no' by default (lcov is required)."
    echo "   --with-examples=yes/no                Compile the 'examples' directory. 'yes' by default."
    echo "   --with-templates-instantiation=yes/no Precompiles some TNL templates during the build. 'no' by default."
    echo "   --cmake=CMAKE                         Path to cmake. 'cmake' by default."
    echo "   --verbose                             It enables verbose build."
    echo "   --root-dir=PATH                       Path to the TNL source code root dir."
    echo "   --dcmtk-dir=PATH                      Path to the DCMTK (Dicom Toolkit) root dir."
@@ -92,7 +102,8 @@ ${CMAKE} ${ROOT_DIR} \
         -DWITH_CUDA=${WITH_CUDA} \
         -DWITH_CUDA_ARCH=${WITH_CUDA_ARCH} \
         -DWITH_TESTS=${WITH_TESTS} \
         -DPETSC_DIR=${PETSC_DIR} \
         -DWITH_COVERAGE=${WITH_COVERAGE} \
         -DWITH_EXAMPLES=${WITH_EXAMPLES} \
         -DDCMTK_DIR=${DCMTK_DIR} \
         -DWITH_TEMPLATE_INSTANTIATION=${WITH_TEMPLATE_INSTANTIATION} \
         -DINSTANTIATE_FLOAT=${INSTANTIATE_FLOAT} \
@@ -109,7 +120,7 @@ fi

if test ${CMAKE_ONLY} = "yes";
then
    exit 1
    exit 0
fi

if [[ -n ${BUILD_JOBS} ]]; then
@@ -128,14 +139,21 @@ else
    echo "Building ${BUILD} $TARGET ..."
fi

make ${VERBOSE}
if [[ "$INSTALL" == "yes" ]]; then
   # install implies all
   make_target="install"
else
   make_target="all"
fi

make ${VERBOSE} $make_target
if test $? != 0; then
    echo "Error: Build process failed."
    exit 1
fi


if test WITH_TESTS = "yes";
if test ${WITH_TESTS} = "yes";
then
    make test
    if test $? != 0; then

cmake/BuildGtest.cmake

0 → 100644
+45 −0
Original line number Diff line number Diff line
# Gtest developers recommend to build the gtest libraries directly from
# the projects' build systems, see
# https://github.com/google/googletest/tree/master/googletest#incorporating-into-an-existing-cmake-project

#find_package( GTest )
#if( GTEST_FOUND )
#   set( CXX_TESTS_FLAGS "${CXX_TESTS_FLAGS} -DHAVE_GTEST" )
#endif( GTEST_FOUND )


# compatibility with the GTest package
set( GTEST_BOTH_LIBRARIES gtest gtest_main )
set( CXX_TESTS_FLAGS ${CXX_TESTS_FLAGS} -DHAVE_GTEST )


# Download and unpack googletest at configure time
configure_file(cmake/Gtest.cmake.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
 RESULT_VARIABLE result
 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
if(result)
 message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
 RESULT_VARIABLE result
 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
if(result)
 message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()

# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
                ${CMAKE_BINARY_DIR}/googletest-build)

# The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves.
if (CMAKE_VERSION VERSION_LESS 2.8.11)
    include_directories("${gtest_SOURCE_DIR}/include")
endif()
Loading