Commit 8c17519f authored by Jakub Klinkovský's avatar Jakub Klinkovský Committed by Tomáš Oberhuber
Browse files

Started porting DistributedMatrix to segments

parent c6d1173d
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@

#include <type_traits>

#include <TNL/Matrices/Legacy/SparseRow.h>
#include <TNL/Communicators/MpiCommunicator.h>
#include <TNL/Containers/Subrange.h>
#include <TNL/Containers/DistributedVector.h>
@@ -56,8 +55,8 @@ public:

   using CompressedRowLengthsVector = Containers::DistributedVector< IndexType, DeviceType, IndexType, CommunicatorType >;

   using MatrixRow = Matrices::Legacy::SparseRow< RealType, IndexType >;
   using ConstMatrixRow = Matrices::Legacy::SparseRow< std::add_const_t< RealType >, std::add_const_t< IndexType > >;
   using MatrixRow = typename Matrix::RowView;
   using ConstMatrixRow = typename Matrix::ConstRowView;

   template< typename _Real = RealType,
             typename _Device = DeviceType,
@@ -125,16 +124,16 @@ public:
   RealType getElementFast( IndexType row,
                            IndexType column ) const;

   __cuda_callable__
   bool setRowFast( IndexType row,
                    const IndexType* columnIndexes,
                    const RealType* values,
                    IndexType elements );
//   __cuda_callable__
//   bool setRowFast( IndexType row,
//                    const IndexType* columnIndexes,
//                    const RealType* values,
//                    IndexType elements );

   __cuda_callable__
   void getRowFast( IndexType row,
                    IndexType* columns,
                    RealType* values ) const;
//   __cuda_callable__
//   void getRowFast( IndexType row,
//                    IndexType* columns,
//                    RealType* values ) const;

   __cuda_callable__
   MatrixRow getRow( IndexType row );
+26 −26
Original line number Diff line number Diff line
@@ -234,32 +234,32 @@ getElementFast( IndexType row,
   return localMatrix.getElementFast( localRow, column );
}

template< typename Matrix,
          typename Communicator >
__cuda_callable__
bool
DistributedMatrix< Matrix, Communicator >::
setRowFast( IndexType row,
            const IndexType* columnIndexes,
            const RealType* values,
            IndexType elements )
{
   const IndexType localRow = localRowRange.getLocalIndex( row );
   return localMatrix.setRowFast( localRow, columnIndexes, values, elements );
}

template< typename Matrix,
          typename Communicator >
__cuda_callable__
void
DistributedMatrix< Matrix, Communicator >::
getRowFast( IndexType row,
            IndexType* columns,
            RealType* values ) const
{
   const IndexType localRow = localRowRange.getLocalIndex( row );
   return localMatrix.getRowFast( localRow, columns, values );
}
//template< typename Matrix,
//          typename Communicator >
//__cuda_callable__
//bool
//DistributedMatrix< Matrix, Communicator >::
//setRowFast( IndexType row,
//            const IndexType* columnIndexes,
//            const RealType* values,
//            IndexType elements )
//{
//   const IndexType localRow = localRowRange.getLocalIndex( row );
//   return localMatrix.setRowFast( localRow, columnIndexes, values, elements );
//}

//template< typename Matrix,
//          typename Communicator >
//__cuda_callable__
//void
//DistributedMatrix< Matrix, Communicator >::
//getRowFast( IndexType row,
//            IndexType* columns,
//            RealType* values ) const
//{
//   const IndexType localRow = localRowRange.getLocalIndex( row );
//   return localMatrix.getRowFast( localRow, columns, values );
//}

template< typename Matrix,
          typename Communicator >
+2 −2
Original line number Diff line number Diff line
@@ -85,8 +85,8 @@ public:
         const auto row = localMatrix->getRow( i );
         bool comm_left = false;
         bool comm_right = false;
         for( IndexType c = 0; c < row.getLength(); c++ ) {
            const IndexType j = row.getElementColumn( c );
         for( IndexType c = 0; c < row.getSize(); c++ ) {
            const IndexType j = row.getColumnIndex( c );
            if( j < columns ) {
               const int owner = Partitioner::getOwner( j, columns, nproc );
               // atomic assignment
+5 −5
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
#include <TNL/Communicators/NoDistrCommunicator.h>
#include <TNL/Matrices/DistributedMatrix.h>
#include <TNL/Containers/Partitioner.h>
#include <TNL/Matrices/Legacy/CSR.h>
#include <TNL/Matrices/SparseMatrix.h>

using namespace TNL;

@@ -103,12 +103,12 @@ protected:

// types for which DistributedMatrixTest is instantiated
using DistributedMatrixTypes = ::testing::Types<
   Matrices::DistributedMatrix< Matrices::Legacy::CSR< double, Devices::Host, int >, Communicators::MpiCommunicator >,
   Matrices::DistributedMatrix< Matrices::Legacy::CSR< double, Devices::Host, int >, Communicators::NoDistrCommunicator >
   Matrices::DistributedMatrix< Matrices::SparseMatrix< double, Devices::Host, int >, Communicators::MpiCommunicator >,
   Matrices::DistributedMatrix< Matrices::SparseMatrix< double, Devices::Host, int >, Communicators::NoDistrCommunicator >
#ifdef HAVE_CUDA
   ,
   Matrices::DistributedMatrix< Matrices::Legacy::CSR< double, Devices::Cuda, int >, Communicators::MpiCommunicator >,
   Matrices::DistributedMatrix< Matrices::Legacy::CSR< double, Devices::Cuda, int >, Communicators::NoDistrCommunicator >
   Matrices::DistributedMatrix< Matrices::SparseMatrix< double, Devices::Cuda, int >, Communicators::MpiCommunicator >,
   Matrices::DistributedMatrix< Matrices::SparseMatrix< double, Devices::Cuda, int >, Communicators::NoDistrCommunicator >
#endif
>;