#ifndef HPC_MPI_GEMATRIX_H #define HPC_MPI_GEMATRIX_H 1 #include #include #include #include #include #include #include #include #include #include #include namespace hpc { namespace mpi { template struct GeMatrix { typedef T ElementType; typedef I Index; using StorageOrder = hpc::matvec::StorageOrder; GeMatrix(Index numRows, Index numCols, Grid grid) : numRows(numRows), numCols(numCols), grid(grid), buffer(getNumRows(grid.nodeRow), getNumCols(grid.nodeCol)) { } Index getRowOffset(Index nodeRow) const { Index mb = (numRows+grid.numNodeRows-1)/grid.numNodeRows; return mb*nodeRow; } Index getColOffset(Index nodeCol) const { Index nb = (numCols+grid.numNodeCols-1)/grid.numNodeCols; return nb*nodeCol; } Index getNumRows(Index nodeRow) const { return numRows - getRowOffset(nodeRow); } Index getNumCols(Index nodeCol) const { return numCols - getColOffset(nodeCol); } Index numRows, numCols; Grid grid; hpc::matvec::GeMatrix buffer; }; } } // namespaces mpi, hpc #endif // HPC_MPI_GEMATRIX_H