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

Implementing the SlicedEllpack matrix.

parent d5668ae4
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -294,7 +294,10 @@ bool tnlEllpackMatrix< Real, Device, Index > :: setRowFast( const IndexType row,
      return false;
   for( Index i = 0; i < elements; i++ )
   {
      this->columnIndexes[ elementPointer ] = columnIndexes[ i ];
      const IndexType column = columnIndexes[ i ];
      if( column < 0 || column >= this->getColumns() )
         return false;
      this->columnIndexes[ elementPointer ] = column;
      this->values[ elementPointer ] = values[ i ];
      elementPointer += step;
   }
@@ -324,7 +327,10 @@ bool tnlEllpackMatrix< Real, Device, Index > :: setRow( const IndexType row,

   for( IndexType i = 0; i < elements; i++ )
   {
      this->columnIndexes.setElement( elementPointer, columnIndexes[ i ] );
      const IndexType column = columnIndexes[ i ];
      if( column < 0 || column >= this->getColumns() )
         return false;
      this->columnIndexes.setElement( elementPointer, column );
      this->values.setElement( elementPointer, values[ i ] );
      elementPointer += step;
   }
+19 −12
Original line number Diff line number Diff line
@@ -303,6 +303,9 @@ bool tnlSlicedEllpackMatrix< Real, Device, Index, SliceSize > :: setRowFast( con

   for( IndexType i = 0; i < elements; i++ )
   {
      const IndexType column = columnIndexes[ i ];
      if( column < 0 || column >= this->getColumns() )
         return false;
      this->columnIndexes[ elementPointer ] = columnIndexes[ i ];
      this->values[ elementPointer ] = values[ i ];
      elementPointer += step;
@@ -330,12 +333,15 @@ bool tnlSlicedEllpackMatrix< Real, Device, Index, SliceSize > :: setRow( const I
      return false;

   Index elementPointer, rowEnd, step;
   DeviceDependentCode::initRowTraverseFast( *this, row, elementPointer, rowEnd, step );
   DeviceDependentCode::initRowTraverse( *this, row, elementPointer, rowEnd, step );

   for( IndexType i = 0; i < elements; i++ )
   {
      this->columnIndexes.setElement( elementPointer, this->columnIndexes.getElement( i ) );
      this->values.setElement( elementPointer, this->values.getElement( i ) );
      const IndexType column = columnIndexes[ i ];
      if( column < 0 || column >= this->getColumns() )
         return false;
      this->columnIndexes.setElement( elementPointer, column );
      this->values.setElement( elementPointer, values[ i ] );
      elementPointer += step;
   }
   for( IndexType i = elements; i < rowLength; i++ )
@@ -618,11 +624,11 @@ void tnlSlicedEllpackMatrix< Real, Device, Index, SliceSize >::print( ostream& s
   {
      str <<"Row: " << row << " -> ";
      const IndexType sliceIdx = row / SliceSize;
      const IndexType rowLength = this->sliceRowLengths[ sliceIdx ];
      IndexType elementPtr = this->slicePointers[ sliceIdx ] +
      const IndexType rowLength = this->sliceRowLengths.getElement( sliceIdx );
      IndexType elementPtr = this->slicePointers.getElement( sliceIdx ) +
                             rowLength * ( row - sliceIdx * SliceSize );
      const IndexType rowEnd( elementPtr + rowLength );
      while( elementPtr < rowEnd && this->columnIndexes[ elementPtr ] < this->columns )
      while( elementPtr < rowEnd && this->columnIndexes.getElement( elementPtr ) < this->columns )
      {
         const Index column = this->columnIndexes.getElement( elementPtr );
         str << " Col:" << column << "->" << this->values.getElement( elementPtr ) << "\t";
@@ -749,9 +755,9 @@ class tnlSlicedEllpackMatrixDeviceDependentCode< tnlCuda >
         const Index slicePointer = matrix.slicePointers.getElement( sliceIdx );
         const Index rowLength = matrix.sliceRowLengths.getElement( sliceIdx );

         rowBegin = slicePointer + rowLength * ( row - sliceIdx * SliceSize );
         rowEnd = rowBegin + rowLength;
         step = 1;
         rowBegin = slicePointer + row - sliceIdx * SliceSize;
         rowEnd = rowBegin + rowLength * SliceSize;
         step = SliceSize;
      }

      template< typename Real,
@@ -770,9 +776,10 @@ class tnlSlicedEllpackMatrixDeviceDependentCode< tnlCuda >
         const Index slicePointer = matrix.slicePointers[ sliceIdx ];
         const Index rowLength = matrix.sliceRowLengths[ sliceIdx ];

         rowBegin = slicePointer + rowLength * ( row - sliceIdx * SliceSize );
         rowEnd = rowBegin + rowLength;
         step = 1;
         rowBegin = slicePointer + row - sliceIdx * SliceSize;
         rowEnd = rowBegin + rowLength * SliceSize;
         step = SliceSize;

      }

      template< typename Real,
+7 −1
Original line number Diff line number Diff line
@@ -77,6 +77,12 @@ if( BUILD_CUDA )
   ADD_TEST( matrices/tnlEllpackMatrixTest-cuda${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlEllpackMatrixTest-cuda${mpiExt}${debugExt} )
   SET_TESTS_PROPERTIES ( matrices/tnlEllpackMatrixTest-cuda${mpiExt}${debugExt} PROPERTIES DEPENDS core/cuda/tnlMultidiagonalMatrixTest-cuda${mpiExt}${debugExt} )
   
   ADD_TEST( matrices/tnlSlicedEllpackMatrixTest-cuda${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlSlicedEllpackMatrixTest-cuda${mpiExt}${debugExt} )
   SET_TESTS_PROPERTIES ( matrices/tnlSlicedEllpackMatrixTest-cuda${mpiExt}${debugExt} PROPERTIES DEPENDS core/cuda/tnlEllpackMatrixTest-cuda${mpiExt}${debugExt} )         
   
   ADD_TEST( matrices/tnlChunkedEllpackMatrixTest-cuda${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlChunkedEllpackMatrixTest-cuda${mpiExt}${debugExt} )
   SET_TESTS_PROPERTIES ( matrices/tnlChunkedEllpackMatrixTest-cuda${mpiExt}${debugExt} PROPERTIES DEPENDS core/cuda/tnlSlicedEllpackMatrixTest-cuda${mpiExt}${debugExt} )                     
            
endif()

ADD_TEST( tnl-unit-tests${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnl-unit-tests${mpiExt}${debugExt}  )                                                                       
+11 −11
Original line number Diff line number Diff line
@@ -60,17 +60,17 @@ if( BUILD_CUDA )
                                                                      tnl${mpiExt}${debugExt}-0.1 )
endif()

#ADD_EXECUTABLE( tnlChunkedEllpackMatrixTest${mpiExt}${debugExt} ${headers} tnlChunkedEllpackMatrixTest.cpp )
#TARGET_LINK_LIBRARIES( tnlChunkedEllpackMatrixTest${mpiExt}${debugExt} ${CPPUNIT_LIBRARIES}
#                                                              tnl${mpiExt}${debugExt}-0.1 )
#
#if( BUILD_CUDA )                                                           
#   CUDA_ADD_EXECUTABLE( tnlChunkedEllpackMatrixTest-cuda${mpiExt}${debugExt} ${headers} tnlChunkedEllpackMatrixTest.cu
#                        OPTIONS -arch sm_20 )
#   TARGET_LINK_LIBRARIES( tnlChunkedEllpackMatrixTest-cuda${mpiExt}${debugExt} ${CPPUNIT_LIBRARIES}
#                                                                      tnl${mpiExt}${debugExt}-0.1 )
#endif()              
#        
ADD_EXECUTABLE( tnlChunkedEllpackMatrixTest${mpiExt}${debugExt} ${headers} tnlChunkedEllpackMatrixTest.cpp )
TARGET_LINK_LIBRARIES( tnlChunkedEllpackMatrixTest${mpiExt}${debugExt} ${CPPUNIT_LIBRARIES}
                                                              tnl${mpiExt}${debugExt}-0.1 )

if( BUILD_CUDA )                                                           
   CUDA_ADD_EXECUTABLE( tnlChunkedEllpackMatrixTest-cuda${mpiExt}${debugExt} ${headers} tnlChunkedEllpackMatrixTest.cu
                        OPTIONS -arch sm_20 )
   TARGET_LINK_LIBRARIES( tnlChunkedEllpackMatrixTest-cuda${mpiExt}${debugExt} ${CPPUNIT_LIBRARIES}
                                                                      tnl${mpiExt}${debugExt}-0.1 )
endif()              
        
#ADD_EXECUTABLE( tnlCSRMatrixTest${mpiExt}${debugExt} ${headers} tnlCSRMatrixTest.cpp )
#TARGET_LINK_LIBRARIES( tnlCSRMatrixTest${mpiExt}${debugExt} ${CPPUNIT_LIBRARIES}
#                                                              tnl${mpiExt}${debugExt}-0.1 )
+14 −13
Original line number Diff line number Diff line
@@ -17,26 +17,27 @@

#include <tnlConfig.h>
#include <core/tnlHost.h>
#include <matrices/tnlChunkedEllpackMatrix.h>
#include <cstdlib>

#include "tnlChunkedEllpackMatrixTester.h"
#include "tnlSparseMatrixTester.h"
#include "../tnlUnitTestStarter.h"

int main( int argc, char* argv[] )
{
#ifdef HAVE_CPPUNIT
   if( ! tnlUnitTestStarter :: run< tnlChunkedEllpackMatrixTester< float, tnlHost, int, 4, 2 > >() ||
       ! tnlUnitTestStarter :: run< tnlChunkedEllpackMatrixTester< double, tnlHost, int, 4, 2 > >() ||
       ! tnlUnitTestStarter :: run< tnlChunkedEllpackMatrixTester< float, tnlHost, long int, 4, 2 > >() ||
       ! tnlUnitTestStarter :: run< tnlChunkedEllpackMatrixTester< double, tnlHost, long int, 4, 2 > >() ||
       ! tnlUnitTestStarter :: run< tnlChunkedEllpackMatrixTester< float, tnlHost, int, 16, 2 > >() ||
       ! tnlUnitTestStarter :: run< tnlChunkedEllpackMatrixTester< double, tnlHost, int, 16, 2 > >() ||
       ! tnlUnitTestStarter :: run< tnlChunkedEllpackMatrixTester< float, tnlHost, long int, 16, 2 > >() ||
       ! tnlUnitTestStarter :: run< tnlChunkedEllpackMatrixTester< double, tnlHost, long int, 16, 2 > >() ||
       ! tnlUnitTestStarter :: run< tnlChunkedEllpackMatrixTester< float, tnlHost, int, 2, 16 > >() ||
       ! tnlUnitTestStarter :: run< tnlChunkedEllpackMatrixTester< double, tnlHost, int, 2, 16 > >() ||
       ! tnlUnitTestStarter :: run< tnlChunkedEllpackMatrixTester< float, tnlHost, long int, 2, 16 > >() ||
       ! tnlUnitTestStarter :: run< tnlChunkedEllpackMatrixTester< double, tnlHost, long int, 2, 16 > >()
   if( ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlChunkedEllpackMatrix< float, tnlHost, int, 4, 2 > > >() ||
       ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlChunkedEllpackMatrix< double, tnlHost, int, 4, 2 > > >() ||
       ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlChunkedEllpackMatrix< float, tnlHost, long int, 4, 2 > > >() ||
       ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlChunkedEllpackMatrix< double, tnlHost, long int, 4, 2 > > >() ||
       ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlChunkedEllpackMatrix< float, tnlHost, int, 16, 2 > > >() ||
       ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlChunkedEllpackMatrix< double, tnlHost, int, 16, 2 > > >() ||
       ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlChunkedEllpackMatrix< float, tnlHost, long int, 16, 2 > > >() ||
       ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlChunkedEllpackMatrix< double, tnlHost, long int, 16, 2 > > >() ||
       ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlChunkedEllpackMatrix< float, tnlHost, int, 2, 16 > > >() ||
       ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlChunkedEllpackMatrix< double, tnlHost, int, 2, 16 > > >() ||
       ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlChunkedEllpackMatrix< float, tnlHost, long int, 2, 16 > > >() ||
       ! tnlUnitTestStarter :: run< tnlSparseMatrixTester< tnlChunkedEllpackMatrix< double, tnlHost, long int, 2, 16 > > >()
       )
     return EXIT_FAILURE;
   return EXIT_SUCCESS;
Loading