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

Implementing tnlPDESolver.

Adding explicit template instantiation.
Moving some _impl.h files into implementation dir.
parent 2a52773d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ if( CMAKE_BUILD_TYPE STREQUAL "Debug")
    set( LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/Debug/lib )
    set( EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/Debug/bin )
    set( debugExt -dbg )
    AddCompilerFlag( "-std=gnu++0x" )
    AddCompilerFlag( "-std=gnu++0x -DTEMPLATE_EXPLICIT_INSTANTIATION" )
else()
    set( PROJECT_BUILD_PATH ${PROJECT_SOURCE_DIR}/Release/src )
    set( PROJECT_TESTS_PATH ${PROJECT_SOURCE_DIR}/Release/tests )
@@ -25,7 +25,7 @@ else()
    set( EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/Release/bin)
    #set( CXX_OPTIMIZE_FLAGS "-O3")
    OptimizeForArchitecture()
    AddCompilerFlag( "-std=gnu++0x -O3 -DNDEBUG" )
    AddCompilerFlag( "-std=gnu++0x -O3 -DNDEBUG -DTEMPLATE_EXPLICIT_INSTANTIATION" )
endif()

#####
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ fi

cd Debug
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${HOME}/local -DCUDA_ARCHITECTURE=${CUDA_ARCHITECTURE} -DWITH_CUDA=${WITH_CUDA} -DWITH_CUSPARSE=${WITH_CUSPARSE} -DPETSC_DIR=${PETSC_DIR}
make -j${CPUS} VERBOSE=1
make -j${CPUS} #VERBOSE=1
make -j${CPUS} test
make -j${CPUS} install

+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ ADD_SUBDIRECTORY( implementation )
ADD_LIBRARY( tnl${debugExt}-${tnlVersion} SHARED 
               ${tnl_config_SOURCES}
               ${tnl_core_SOURCES}
               ${tnl_implementation_SOURCES}
               ${tnl_debug_SOURCES}
               ${tnl_matrix_SOURCES} )
SET_TARGET_PROPERTIES( tnl${debugExt}-${tnlVersion} PROPERTIES 
@@ -26,6 +27,7 @@ IF( BUILD_MPI )
  ADD_LIBRARY( tnl-mpi${debugExt}-${tnlVersion} SHARED
                 ${tnl_config_SOURCES}
                 ${tnl_core_SOURCES}
                 ${tnl_implementation_SOURCES}
                 ${tnl_debug_SOURCES}
                 ${tnl_matrix_SOURCES} )
  SET_TARGET_PROPERTIES( tnl-mpi${debugExt}-${tnlVersion} PROPERTIES
+0 −16
Original line number Diff line number Diff line
add_subdirectory( implementation )

set (headers tnlArray.h
             tnlAssert.h               
             tnlCurve.h
@@ -32,20 +30,6 @@ set (headers tnlArray.h
   		    param-types.h
    )

SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/core )    
set( tnl_core_SOURCES
     ${CURRENT_DIR}/tnlFile.cpp
     ${CURRENT_DIR}/tnlFlopsCounter.cpp 
     ${CURRENT_DIR}/tnlLogger.cpp 
     ${CURRENT_DIR}/tnlObject.cpp 
     ${CURRENT_DIR}/tnlStatistics.cpp
     ${CURRENT_DIR}/tnlString.cpp 
     ${CURRENT_DIR}/tnlTimerCPU.cpp  
     ${CURRENT_DIR}/tnlTimerRT.cpp   
     ${CURRENT_DIR}/mfilename.cpp 
     ${CURRENT_DIR}/mpi-supp.cpp 
    PARENT_SCOPE )

SET( libtnlcoreincludedir ${TNL_INCLUDE_DIR}/core )
SET( libtnlcoreinclude_HEADERS ${headers} )
INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/core )
+0 −262
Original line number Diff line number Diff line
/***************************************************************************
                          tnlMultiArray_impl.h  -  description
                             -------------------
    begin                : Nov 13, 2012
    copyright            : (C) 2012 by Tomas Oberhuber
    email                : tomas.oberhuber@fjfi.cvut.cz
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef TNLMULTIARRAY_IMPL_H_
#define TNLMULTIARRAY_IMPL_H_



template< typename Element, typename Device, typename Index >
tnlMultiArray< 1, Element, Device, Index > :: tnlMultiArray()
{
}

template< typename Element, typename Device, typename Index >
tnlString tnlMultiArray< 1, Element, Device, Index > :: getType() const
{
   return tnlString( "tnlMultiArray< ") +
          tnlString( Dimensions ) +
          tnlString( ", " ) +
          tnlString( getParameterType< Element >() ) +
          tnlString( ", " ) +
          tnlString( Device :: getDeviceType() ) +
          tnlString( ", " ) +
          tnlString( getParameterType< Index >() ) +
          tnlString( " >" );
}

template< typename Element, typename Device, typename Index >
bool tnlMultiArray< 1, Element, Device, Index > :: setDimensions( const Index xSize )
{
   tnlAssert( xSize > 0,
              cerr << "xSize = " << xSize );
   dimensions[ 0 ] = xSize;
   return tnlArray< Element, Device, Index > :: setSize( xSize );
}

template< typename Element, typename Device, typename Index >
bool tnlMultiArray< 1, Element, Device, Index > :: setDimensions( const tnlTuple< 1, Index >& dimensions )
{
   tnlAssert( xSize > 0,
              cerr << "xSize = " << xSize );
   this -> dimensions = dimensions;
   return tnlArray< Element, Device, Index > :: setSize( this -> dimensions[ 0 ] );
}

template< typename Element, typename Device, typename Index >
   template< typename MultiArray >
bool tnlMultiArray< 1, Element, Device, Index > :: setLike( const tnlMultiArray& multiArray )
{
   return setDimensions( multiArray. getDimensions() );
}

template< typename Element, typename Device, typename Index >
void tnlMultiArray< 1, Element, Device, Index > :: getDimensions( Index& xSize ) const
{
   xSize = this -> dimensions[ 0 ];
}

template< typename Element, typename Device, typename Index >
const tnlTuple< 1, Index >& tnlMultiArray< 1, Element, Device, Index > :: getDimensions() const
{
   return this -> dimensions;
}

template< typename Element, typename Device, typename Index >
Index tnlMultiArray< 1, Element, Device, Index > :: getElementIndex( const Index i ) const
{
   tnlAssert( xSize > 0,
              cerr << "i = " << i );
   return i;
}

template< typename Element, typename Device, typename Index >
Element tnlMultiArray< 1, Element, Device, Index > :: getElement( const Index i ) const
{
   return tnlArray< Element, Device, Index > :: getElement( getLongVectorIndex( i ) );
}

template< typename Element, typename Device, typename Index >
void tnlMultiArray< 1, Element, Device, Index > :: setElement( const Index i, Element value )
{
   tnlArray< Element, Device, Index > :: setElement( getElementIndex( i ), value );
}


template< typename Element, typename Device, typename Index >
Element& tnlMultiArray< 1, Element, Device, Index > :: operator()( const Index element )
{
   return tnlArray< Element, Device, Index > :: operator[]( getLongVectorIndex( element ) );
}

template< typename Element, typename Device, typename Index >
const Element& tnlMultiArray< 1, Element, Device, Index > :: operator()( const Index element ) const
{
   return tnlArray< Element, Device, Index > :: operator[]( getLongVectorIndex( element ) );
}

template< typename Element, typename Device, typename Index >
   template< typename MultiArray >
bool tnlMultiArray< 1, Element, Device, Index > :: operator == ( const MultiArray& array ) const
{
   // TODO: Static assert on dimensions
   tnlAssert( this -> getDimensions() == array. getDimensions(),
              cerr << "You are attempting to compare two arrays with different dimensions." << endl
                   << "First array name is " << this -> getName()
                   << " dimensions are ( " << this -> getDimensions() << " )" << endl
                   << "Second array is " << array. getName()
                   << " dimensions are ( " << array. getDimensions() << " )" << endl; );
   return tnlArray< Element, Device, Index > :: operator == ( array );
}

template< typename Element, typename Device, typename Index >
   template< typename MultiArray >
bool tnlMultiArray< 1, Element, Device, Index > :: operator != ( const MultiArray& array ) const
{
   return ! ( (* this ) == array );
}

template< typename Element, typename Device, typename Index >
tnlMultiArray< 1, Element, Device, Index >&
   tnlMultiArray< 1, Element, Device, Index > :: operator = ( const tnlMultiArray< 1, Element, Device, Index >& array )
{
   // TODO: Static assert on dimensions
   tnlAssert( this -> getDimensions() == array. getDimensions(),
              cerr << "You are attempting to assign two arrays with different dimensions." << endl
                   << "First array name is " << this -> getName()
                   << " dimensions are ( " << this -> getDimensions() << " )" << endl
                   << "Second array is " << array. getName()
                   << " dimensions are ( " << array. getDimensions() << " )" << endl; );
   tnlArray< Element, Device, Index > :: operator = ( array );
   return ( *this );
}

template< typename Element, typename Device, typename Index >
   template< typename MultiArray >
tnlMultiArray< 1, Element, Device, Index >&
   tnlMultiArray< 1, Element, Device, Index > :: operator = ( const MultiArray& array )
{
   // TODO: Static assert on dimensions
   tnlAssert( this -> getDimensions() == array. getDimensions(),
              cerr << "You are attempting to assign two arrays with different dimensions." << endl
                   << "First array name is " << this -> getName()
                   << " dimensions are ( " << this -> getDimensions() << " )" << endl
                   << "Second array is " << array. getName()
                   << " dimensions are ( " << array. getDimensions() << " )" << endl; );
   tnlArray< Element, Device, Index > :: operator = ( array );
   return ( *this );
}

template< typename Element, typename Device, typename Index >
bool tnlMultiArray< 1, Element, Device, Index > :: save( tnlFile& file ) const
{
   if( ! tnlArray< Element, Device, Index > :: save( file ) )
   {
      cerr << "I was not able to write the tnlArray of tnlMultiArray "
           << this -> getName() << endl;
      return false;
   }
   if( ! dimensions. save( file ) )
   {
      cerr << "I was not able to write the dimensions of tnlMultiArray "
           << this -> getName() << endl;
      return false;
   }
   return true;
}

template< typename Element, typename Device, typename Index >
bool tnlMultiArray< 1, Element, Device, Index > :: load( tnlFile& file )
{
   if( ! tnlArray< Element, Device, Index > :: load( file ) )
   {
      cerr << "I was not able to read the tnlArray of tnlMultiArray "
           << this -> getName() << endl;
      return false;
   }
   if( ! dimensions. load( file ) )
   {
      cerr << "I was not able to read the dimensions of tnlMultiArray "
           << this -> getName() << endl;
      return false;
   }
   return true;
}

template< typename Element, typename Device, typename Index >
ostream& operator << ( ostream& str, const tnlMultiArray< 1, Element, Device, Index >& array )
{
   for( Index i = 0; i < array. getDimensions()[ 0 ]; i ++ )
   {
      str << array. getElement( i ) << " ";
   }
   return str;
}

/*
template< typename Element, typename Device, typename Index >
ostream& operator << ( ostream& str, const tnlMultiArray< 2, Element, Device, Index >& array )
{
   tnlTuple< 2, Index > dims = array. getDimensions();
   for( Index i = 0; i < dims[ tnlX ]; i ++ )
   {
      for( Index j = 0; j < dims[ tnlY ]; j ++ )
      {
         tnlTuple< 2, Index > ind;
         ind[ 0 ] = i;
         ind[ 1 ] = j;
         str << array. getElement( ind ) << " ";
      }
      str << endl;
   }
   return str;
}

template< typename Element, typename Device, typename Index >
ostream& operator << ( ostream& str, const tnlMultiArray< 3, Element, Device, Index >& array )
{
   tnlTuple< 3, Index > dims = array. getDimensions();
   for( Index i = 0; i < dims[ tnlX ]; i ++ )
   {
      for( Index j = 0; j < dims[ tnlY ]; j ++ )
      {
         for( Index k = 0; k < dims[ tnlZ ]; k ++ )
         {
            tnlTuple< 3, Index > ind;
            ind[ 0 ] = i;
            ind[ 1 ] = j;
            ind[ 2 ] = k;
            str << array. getElement( ind ) << " ";
         }
         str << endl;
      }
      str << endl;
   }
   return str;
}

template< typename Element, typename Device, typename Index >
ostream& operator << ( ostream& str, const tnlMultiArray< 1, Element, Device, Index >& array )
{
   tnlAssert( false,
              cerr << "Operator << is not yet implemented for arrays with the dimensions greater than 3." << endl; );
   return str;
};
*/


#endif /* TNLMULTIARRAY_IMPL_H_ */
Loading