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

Merge branch 'develop' into periodic-bc

parents c7c565fb fbceed2d
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -30,10 +30,14 @@ stages:
#        - 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"
        # ninja does not have -l
#        - export MAKEFLAGS="-l$(echo 1.5*$NUM_CORES | bc) -j$NUM_CORES"
        - export NINJAFLAGS="-j$NUM_CORES"
        - export CTEST_OUTPUT_ON_FAILURE=1
        - mkdir -p "./builddir/$CI_JOB_NAME"
        - pushd "./builddir/$CI_JOB_NAME"
        - cmake ../..
                -G Ninja
                -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
                -DCMAKE_INSTALL_PREFIX=$(pwd)/${BUILD_TYPE}_install_prefix
                -DWITH_OPENMP=${WITH_OPENMP}
@@ -43,9 +47,12 @@ stages:
                -DWITH_TESTS=${WITH_TESTS}
                -DWITH_COVERAGE=${WITH_COVERAGE}
                -DWITH_EXAMPLES=${WITH_EXAMPLES}
        - make
        - make test CTEST_OUTPUT_ON_FAILURE=1
        - make install
#        - make
#        - make test
#        - make install
        - ninja ${NINJAFLAGS}
        - ninja test
        - ninja install
        - popd
    variables:
        <<: *default_cmake_flags
+11 −8
Original line number Diff line number Diff line
@@ -97,8 +97,8 @@ if( CXX_COMPILER_NAME MATCHES "icpc" )
endif()

# force colorized output in continuous integration
if( DEFINED ENV{CI_JOB_NAME} )
   message(STATUS "Continuous integration detected -- forcing compilers to produce colorized output.")
if( DEFINED ENV{CI_JOB_NAME} OR ${CMAKE_GENERATOR} STREQUAL "Ninja" )
   message(STATUS "Continuous integration or Ninja detected -- forcing compilers to produce colorized output.")
   if( CXX_COMPILER_NAME MATCHES "clang" )
      set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics" )
   else()
@@ -405,15 +405,18 @@ INCLUDE_DIRECTORIES( src )
INCLUDE_DIRECTORIES( ${PROJECT_BUILD_PATH} )
LINK_DIRECTORIES( ${LIBRARY_OUTPUT_PATH} )

#Pokracujeme dalsimi podadresari
add_subdirectory( src )
add_subdirectory( share )
if( WITH_TESTS STREQUAL "yes" )
    add_subdirectory( tests )
endif( WITH_TESTS STREQUAL "yes" )
# Add all subdirectories
# Note that it is important to start building examples as soon as possible,
# because they take the longest time and other stuff can be pipelined before
# they are finished (at least with Ninja).
if( WITH_EXAMPLES STREQUAL "yes" )
   add_subdirectory( examples )
endif( WITH_EXAMPLES STREQUAL "yes" )
if( WITH_TESTS STREQUAL "yes" )
    add_subdirectory( tests )
endif( WITH_TESTS STREQUAL "yes" )
add_subdirectory( src )
add_subdirectory( share )

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Template Numerical Library")
set(CPACK_PACKAGE_VENDOR "MMG")
+87 −63
Original line number Diff line number Diff line
#!/bin/bash

set -e

TARGET=TNL
PREFIX=${HOME}/.local
INSTALL="no"
@@ -78,8 +80,7 @@ do
    esac
done

if test ${HELP} = "yes";
then
if [[ ${HELP} == "yes" ]]; then
    echo "TNL build options:"
    echo ""
    echo "   --build=Debug/Release                 Build type."
@@ -96,8 +97,8 @@ then
    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."
    echo "   --with-tools=yes/no                   Compile the 'tools' directory. 'yes' by default."
    echo "   --with-python=yes/no                  Compile with the python bindings. 'yes' by default."
    echo "   --with-tools=yes/no                   Compile the 'src/Tools' directory. 'yes' by default."
    echo "   --with-python=yes/no                  Compile the Python bindings. '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."
@@ -107,63 +108,91 @@ then
    exit 1
fi

if test ${WITH_CLANG} = "yes";
then
if [[ ${WITH_CLANG} == "yes" ]]; then
   export CXX=clang++
   export CC=clang
fi

if test ${WITH_MPI} = "yes";
then
    if ! [ -x  "$(command -v mpic++)" ]; then
if [[ ${WITH_MPI} == "yes" ]]; then
    if [[ ! -x  "$(command -v mpic++)" ]]; then
       echo "Warning:mpic++ is not installed on this system. MPI support is turned off." 
    else
       # instruct OpenMPI to use the original compiler
       # reference: https://www.open-mpi.org/faq/?category=mpi-apps#override-wrappers-after-v1.0
       # FIXME: this does not work with CUDA_HOST_COMPILER=mpic++
#       if [ -n "$CXX" ]; then
#          export OMPI_CXX="$CXX"
#       fi
       export CXX=mpic++
       export CUDA_HOST_COMPILER=mpic++
    fi
    if ! [ -x  "$(command -v mpicc)" ]; then
    if [[ ! -x  "$(command -v mpicc)" ]]; then
       echo "Warning: mpicc is not installed on this system." 
    else
       # instruct OpenMPI to use the original compiler
       # reference: https://www.open-mpi.org/faq/?category=mpi-apps#override-wrappers-after-v1.0
#       if [ -n "$CC" ]; then
#          export OMPI_CC="$CC"
#       fi
       export CC=mpicc
    fi
fi

if hash ninja 2>/dev/null; then
   generator=Ninja
   make=ninja
   check_file="build.ninja"
else
   generator="Unix Makefiles"
   make=make
   check_file="Makefile"
fi

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} \
         -DWITH_TOOLS=${WITH_TOOLS} \
         -DWITH_PYTHON=${WITH_PYTHON} \
         -DDCMTK_DIR=${DCMTK_DIR} \
         -DWITH_TEMPLATE_INSTANTIATION=${WITH_TEMPLATE_INSTANTIATION} \
         -DINSTANTIATE_FLOAT=${INSTANTIATE_FLOAT} \
         -DINSTANTIATE_DOUBLE=${INSTANTIATE_DOUBLE} \
         -DINSTANTIATE_LONG_DOUBLE=${INSTANTIATE_LONG_DOUBLE} \
         -DINSTANTIATE_INT=${INSTANTIATE_INT} \
         -DINSTANTIATE_LONG_INT=${INSTANTIATE_LONG_INT} \
cmake_command=(
   ${CMAKE} ${ROOT_DIR}
         -G "${generator}"
         -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}
         -DWITH_TOOLS=${WITH_TOOLS}
         -DWITH_PYTHON=${WITH_PYTHON}
         -DDCMTK_DIR=${DCMTK_DIR}
         -DWITH_TEMPLATE_INSTANTIATION=${WITH_TEMPLATE_INSTANTIATION}
         -DINSTANTIATE_FLOAT=${INSTANTIATE_FLOAT}
         -DINSTANTIATE_DOUBLE=${INSTANTIATE_DOUBLE}
         -DINSTANTIATE_LONG_DOUBLE=${INSTANTIATE_LONG_DOUBLE}
         -DINSTANTIATE_INT=${INSTANTIATE_INT}
         -DINSTANTIATE_LONG_INT=${INSTANTIATE_LONG_INT}
         -DOPTIMIZED_VECTOR_HOST_OPERATIONS=${OPTIMIZED_VECTOR_HOST_OPERATIONS}
)

if test $? != 0; then
    echo "Error: cmake exited with error code."
    exit 1
# Skip running cmake if it was already run and the cmake command is the same.
# The build system (e.g. make) will call it automatically if necessary (e.g.
# when some CMakeLists.txt changes).
if [[ -f ".cmake_command" ]]; then
   last_cmake_command=$(cat ".cmake_command" 2>/dev/null)
else
   last_cmake_command=""
fi
if [[ ! -f "$check_file" ]] || [[ "$last_cmake_command" != "${cmake_command[@]}" ]]; then
   echo "Configuring ${BUILD} $TARGET ..."
   "${cmake_command[@]}"
   echo -n "${cmake_command[@]}" > ".cmake_command"
fi

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

if [[ "$make" == "make" ]]; then
   if [[ -n ${BUILD_JOBS} ]]; then
      # override $MAKEFLAGS from parent environment
      export MAKEFLAGS=-j${BUILD_JOBS}
@@ -172,6 +201,12 @@ elif [[ -z ${MAKEFLAGS} ]]; then
      BUILD_JOBS=$(grep "core id" /proc/cpuinfo | sort -u | wc -l)
      export MAKEFLAGS=-j${BUILD_JOBS}
   fi
else
   if [[ -z ${BUILD_JOBS} ]]; then
      BUILD_JOBS=$(grep "core id" /proc/cpuinfo | sort -u | wc -l)
   fi
   make="$make -j$BUILD_JOBS"
fi

if [[ -n ${BUILD_JOBS} ]]; then
   echo "Building ${BUILD} $TARGET using $BUILD_JOBS processors ..."
@@ -187,19 +222,8 @@ else
   make_target="all"
fi

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


if test ${WITH_TESTS} = "yes";
then
    make test CTEST_OUTPUT_ON_FAILURE=1
    if test $? != 0; then
        echo "Error: Some test did not pass successfuly."
    fi
if [[ ${WITH_TESTS} == "yes" ]]; then
   CTEST_OUTPUT_ON_FAILURE=1 $make test
fi

exit 0
+8 −8
Original line number Diff line number Diff line
if( WITH_PYTHON STREQUAL "yes" )
   ADD_SUBDIRECTORY( Python )
endif( WITH_PYTHON STREQUAL "yes" )

ADD_SUBDIRECTORY( TNL )

if( WITH_TOOLS STREQUAL "yes" )
if( ${WITH_TOOLS} )
   ADD_SUBDIRECTORY( Tools )
endif( WITH_TOOLS STREQUAL "yes" )
endif()

if( WITH_TESTS STREQUAL "yes" )
if( ${WITH_TESTS} )
   ADD_SUBDIRECTORY( UnitTests )
endif( WITH_TESTS STREQUAL "yes" )
endif()

if( ${WITH_PYTHON} )
   ADD_SUBDIRECTORY( Python )
endif()
+32 −12
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ class MpiCommunicator
            TNL_ASSERT_TRUE(IsInitialized(), "Fatal Error - MPI communicator is not initialized");
            TNL_ASSERT_NE(group, NullGroup, "ISend cannot be called with NullGroup");
            Request req;
            MPI_Isend((void*) data, count, MPIDataType(data) , dest, 0, group, &req);
            MPI_Isend((const void*) data, count, MPIDataType(data) , dest, 0, group, &req);
            return req;
#else
            throw Exceptions::MPISupportMissing();
@@ -285,7 +285,7 @@ class MpiCommunicator
        }

         template <typename T>
         static Request IRecv( const T *data, int count, int src, CommunicationGroup group)
         static Request IRecv( T* data, int count, int src, CommunicationGroup group)
         {
#ifdef HAVE_MPI
            TNL_ASSERT_TRUE(IsInitialized(), "Fatal Error - MPI communicator is not initialized");
@@ -337,7 +337,7 @@ class MpiCommunicator


         template< typename T >
         static void Reduce( T* data,
         static void Reduce( const T* data,
                    T* reduced_data,
                    int count,
                    MPI_Op &op,
@@ -346,14 +346,14 @@ class MpiCommunicator
         {
#ifdef HAVE_MPI
            TNL_ASSERT_NE(group, NullGroup, "Reduce cannot be called with NullGroup");
            MPI_Reduce( (void*) data, (void*) reduced_data,count,MPIDataType(data),op,root,group);
            MPI_Reduce( (const void*) data, (void*) reduced_data,count,MPIDataType(data),op,root,group);
#else
            throw Exceptions::MPISupportMissing();
#endif
        }

         template< typename T >
         static void SendReceive( T* sendData,
         static void SendReceive( const T* sendData,
                                  int sendCount,
                                  int destination,
                                  int sendTag,
@@ -366,7 +366,7 @@ class MpiCommunicator
#ifdef HAVE_MPI
            TNL_ASSERT_NE(group, NullGroup, "SendReceive cannot be called with NullGroup");
            MPI_Status status;
            MPI_Sendrecv( ( void* ) sendData,
            MPI_Sendrecv( ( const void* ) sendData,
                          sendCount,
                          MPIDataType( sendData ),
                          destination,
@@ -383,6 +383,27 @@ class MpiCommunicator
#endif
         }

         template< typename T >
         static void Alltoall( const T* sendData,
                               int sendCount,
                               T* receiveData,
                               int receiveCount,
                               CommunicationGroup group )
         {
#ifdef HAVE_MPI
            TNL_ASSERT_NE(group, NullGroup, "SendReceive cannot be called with NullGroup");
            MPI_Alltoall( ( const void* ) sendData,
                          sendCount,
                          MPIDataType( sendData ),
                          ( void* ) receiveData,
                          receiveCount,
                          MPIDataType( receiveData ),
                          group );
#else
            throw Exceptions::MPISupportMissing();
#endif
         }


      static void writeProlog( Logger& logger )
      {
@@ -428,10 +449,9 @@ class MpiCommunicator
      {
#ifdef HAVE_MPI
    #ifdef HAVE_CUDA
        	int count,rank, gpuCount, gpuNumber;
         MPI_Comm_size(MPI_COMM_WORLD,&count);
         MPI_Comm_rank(MPI_COMM_WORLD,&rank);

         const int count = GetSize(AllGroup);
         const int rank = GetRank(AllGroup);
         int gpuCount;
         cudaGetDeviceCount(&gpuCount);

         procName names[count];
@@ -454,7 +474,7 @@ class MpiCommunicator
               nodeRank++;
         }

         gpuNumber=nodeRank % gpuCount;
         const int gpuNumber = nodeRank % gpuCount;

         cudaSetDevice(gpuNumber);
         TNL_CHECK_CUDA_DEVICE;
Loading