LAMA
lama::OpenMPCSRUtils Class Reference

This class provides routines on compressed sparse row data. More...

#include <OpenMPCSRUtils.hpp>

Static Public Member Functions

static IndexType countNonEmptyRowsByOffsets (const IndexType offsets[], const IndexType numRows)
 This method computes the total number of non-zero rows by the offset array.
static void setNonEmptyRowsByOffsets (IndexType rowIndexes[], const IndexType numNonEmptyRows, const IndexType offsets[], const IndexType numRows)
 Build a vector of indexes for non-empty rows.
static IndexType scan (IndexType array[], const IndexType numValues)
 This function build an offset array from a counter array.
static IndexType sizes2offsets (IndexType sizes[], const IndexType numRows)
 Implementation for CSRUtilsInterface::Offsets::sizes2offsets.
static void offsets2sizes (IndexType sizes[], const IndexType offsets[], const IndexType n)
 Implementation for CSRUtilsInterface::Offsets::offsets2sizes.
static void offsets2sizesGather (IndexType sizes[], const IndexType offsets[], const IndexType rowIndexes[], const IndexType numRows)
 offset2sizes for indexed rows
static bool validOffsets (const IndexType array[], const IndexType n, const IndexType total)
 Implementation for CSRUtilsInterface::Offsets::validOffsets.
static bool hasDiagonalProperty (const IndexType numDiagonals, const IndexType csrIA[], const IndexType csrJA[])
 This function checks if csr data has diagonal property.
template<typename ValueType >
static void sortRowElements (IndexType csrJA[], ValueType csrValues[], const IndexType csrIA[], const IndexType numRows, const bool diagonalFlag)
 This function sorts the column indexes of each row in ascending order.
template<typename ValueType >
static void convertCSR2CSC (IndexType cscIA[], IndexType cscJA[], ValueType cscValues[], const IndexType csrIA[], const IndexType csrJA[], const ValueType csrValues[], IndexType numRows, IndexType numColumns, IndexType numValues)
 Implementation for CSRUtilsInterface::Transpose::convertCSR2CSC.
template<typename ValueType1 , typename ValueType2 >
static void scaleRows (ValueType1 csrValues[], const IndexType csrIA[], const IndexType numRows, const ValueType2 values[])
 Implementation for CSRUtilsInterface::Mult::scaleRows.
template<typename ValueType >
static void normalGEMV (ValueType result[], const ValueType alpha, const ValueType x[], const ValueType beta, const ValueType y[], const IndexType numRows, const IndexType csrIA[], const IndexType csrJA[], const ValueType csrValues[], SyncToken *syncToken)
 Implementation for CSRUtilsInterface::Mult::normalGEMV.
template<typename ValueType >
static void sparseGEMV (ValueType result[], const ValueType alpha, const ValueType x[], const IndexType numNonZeroRows, const IndexType rowIndexes[], const IndexType csrIA[], const IndexType csrJA[], const ValueType csrValues[], SyncToken *syncToken)
 Implementation for CSRUtilsInterface::Mult::sparseGEMV.
template<typename ValueType >
static void gemm (ValueType result[], const ValueType alpha, const ValueType x[], const ValueType beta, const ValueType y[], const IndexType m, const IndexType n, const IndexType p, const IndexType csrIA[], const IndexType csrJA[], const ValueType csrValues[], class SyncToken *syncToken)
 Implementation for CSRUtilsInterface::Mult::gemm.
template<typename ValueType >
static void jacobi (ValueType *const solution, const IndexType csrIA[], const IndexType csrJA[], const ValueType csrValues[], const ValueType rhs[], const ValueType oldSolution[], const ValueType omega, const IndexType numRows, SyncToken *syncToken)
 Implementation for CSRUtilsInterface::Jacobi::jacobi(Async/Halo)
template<typename ValueType >
static void jacobiHalo (ValueType solution[], const IndexType localIA[], const ValueType localValues[], const IndexType haloIA[], const IndexType haloJA[], const ValueType haloValues[], const IndexType haloRowIndexes[], const ValueType oldSolution[], const ValueType omega, const IndexType numNonEmptyRows)
static void matrixAddSizes (IndexType cSizes[], const IndexType numRows, const IndexType numColumns, bool diagonalProperty, const IndexType aIA[], const IndexType aJA[], const IndexType bIA[], const IndexType bJA[])
 Implementation for CSRUtilsInterface::Offsets::matrixAddSizes.
static void matrixMultiplySizes (IndexType cSizes[], const IndexType numRows, const IndexType numColumns, bool diagonalProperty, const IndexType aIA[], const IndexType aJA[], const IndexType bIA[], const IndexType bJA[])
 Implementation for CSRUtilsInterface::Offsets::matrixMultiplySizes.
static void matrixMultiplyJA (IndexType cJA[], const IndexType cIA[], const IndexType numRows, const IndexType numColumns, bool diagonalProperty, const IndexType aIA[], const IndexType aJA[], const IndexType bIA[], const IndexType bJA[])
 Implementation for CSRUtilsInterface::Offsets::matrixMultiplyJA.
template<typename ValueType >
static void matrixAdd (IndexType cJA[], ValueType cValues[], const IndexType cIA[], const IndexType numRows, const IndexType numColumns, bool diagonalProperty, const ValueType alpha, const IndexType aIA[], const IndexType aJA[], const ValueType aValues[], const ValueType beta, const IndexType bIA[], const IndexType bJA[], const ValueType bValues[])
 Implementation for CSRUtilsInterface::Mult::matrixAdd.
template<typename ValueType >
static void matrixMultiply (ValueType cValues[], const IndexType cIA[], const IndexType cJA[], const IndexType numRows, const ValueType alpha, const IndexType aIA[], const IndexType aJA[], const ValueType aValues[], const IndexType bIA[], const IndexType bJA[], const ValueType bValues[])
 Implementation for CSRUtilsInterface::Mult::matrixMultiply.
template<typename ValueType >
static ValueType absMaxDiffVal (IndexType numRows, bool sortedRows, const IndexType csrIA1[], const IndexType csrJA1[], const ValueType csrValues1[], const IndexType csrIA2[], const IndexType csrJA2[], const ValueType csrValues2[])
 Implementation for CSRUtilsInterface::Reductions::absMaxDiffVal.
static void setInterface (struct CSRUtilsInterface &CSRUtils)
 Routine that registers all routines of this class at the LAMA interface.

Protected Member Functions

 LAMA_LOG_DECL_STATIC_LOGGER (logger)

Static Private Member Functions

static IndexType scanSerial (IndexType array[], const IndexType numValues)
static IndexType scanParallel (PartitionId numThreads, IndexType array[], const IndexType numValues)
template<typename ValueType >
static void normalGEMV (ValueType result[], const ValueType alpha, const ValueType x[], const ValueType beta, const ValueType y[], const IndexType numRows, const IndexType csrIA[], const IndexType csrJA[], const ValueType csrValues[])
template<typename ValueType >
static void sparseGEMV (ValueType result[], const ValueType alpha, const ValueType x[], const IndexType numNonZeroRows, const IndexType rowIndexes[], const IndexType csrIA[], const IndexType csrJA[], const ValueType csrValues[])
template<typename ValueType >
static ValueType absMaxDiffRowSorted (const IndexType n1, const IndexType csrJA1[], const ValueType csrValues1[], const IndexType n2, const IndexType csrJA2[], const ValueType csrValues2[])
template<typename ValueType >
static ValueType absMaxDiffRowUnsorted (const IndexType n1, const IndexType csrJA1[], const ValueType csrValues1[], const IndexType n2, const IndexType csrJA2[], const ValueType csrValues2[])

Detailed Description

This class provides routines on compressed sparse row data.


Member Function Documentation

template<typename ValueType >
ValueType lama::OpenMPCSRUtils::absMaxDiffRowSorted ( const IndexType  n1,
const IndexType  csrJA1[],
const ValueType  csrValues1[],
const IndexType  n2,
const IndexType  csrJA2[],
const ValueType  csrValues2[] 
) [static, private]

References lama::abs(), and LAMA_ASSERT_ERROR.

template<typename ValueType >
ValueType lama::OpenMPCSRUtils::absMaxDiffRowUnsorted ( const IndexType  n1,
const IndexType  csrJA1[],
const ValueType  csrValues1[],
const IndexType  n2,
const IndexType  csrJA2[],
const ValueType  csrValues2[] 
) [static, private]
template<typename ValueType >
ValueType lama::OpenMPCSRUtils::absMaxDiffVal ( IndexType  numRows,
bool  sortedRows,
const IndexType  csrIA1[],
const IndexType  csrJA1[],
const ValueType  csrValues1[],
const IndexType  csrIA2[],
const IndexType  csrJA2[],
const ValueType  csrValues2[] 
) [static]
template<typename ValueType >
void lama::OpenMPCSRUtils::convertCSR2CSC ( IndexType  cscIA[],
IndexType  cscJA[],
ValueType  cscValues[],
const IndexType  csrIA[],
const IndexType  csrJA[],
const ValueType  csrValues[],
IndexType  numRows,
IndexType  numColumns,
IndexType  numValues 
) [static]
IndexType lama::OpenMPCSRUtils::countNonEmptyRowsByOffsets ( const IndexType  offsets[],
const IndexType  numRows 
) [static]

This method computes the total number of non-zero rows by the offset array.

Referenced by lama::CSRStorage< T >::buildRowIndexes().

template<typename ValueType >
void lama::OpenMPCSRUtils::gemm ( ValueType  result[],
const ValueType  alpha,
const ValueType  x[],
const ValueType  beta,
const ValueType  y[],
const IndexType  m,
const IndexType  n,
const IndexType  p,
const IndexType  csrIA[],
const IndexType  csrJA[],
const ValueType  csrValues[],
class SyncToken syncToken 
) [static]

Implementation for CSRUtilsInterface::Mult::gemm.

References LAMA_THROWEXCEPTION.

Referenced by setInterface().

bool lama::OpenMPCSRUtils::hasDiagonalProperty ( const IndexType  numDiagonals,
const IndexType  csrIA[],
const IndexType  csrJA[] 
) [static]

This function checks if csr data has diagonal property.

Parameters:
[in]numDiagonalsis min( numRows, numColumns )
[in]csrIAis the csr offset array
[in]csrJAis array with column indexes

Referenced by lama::CSRStorage< T >::setCSRDataImpl(), lama::COOStorage< T >::setCSRDataImpl(), lama::DIAStorage< T >::setCSRDataImpl(), and setInterface().

template<typename ValueType >
void lama::OpenMPCSRUtils::jacobi ( ValueType *const  solution,
const IndexType  csrIA[],
const IndexType  csrJA[],
const ValueType  csrValues[],
const ValueType  rhs[],
const ValueType  oldSolution[],
const ValueType  omega,
const IndexType  numRows,
SyncToken syncToken 
) [static]

Implementation for CSRUtilsInterface::Jacobi::jacobi(Async/Halo)

References LAMA_THROWEXCEPTION.

Referenced by setInterface().

template<typename ValueType >
void lama::OpenMPCSRUtils::jacobiHalo ( ValueType  solution[],
const IndexType  localIA[],
const ValueType  localValues[],
const IndexType  haloIA[],
const IndexType  haloJA[],
const ValueType  haloValues[],
const IndexType  haloRowIndexes[],
const ValueType  oldSolution[],
const ValueType  omega,
const IndexType  numNonEmptyRows 
) [static]

Referenced by setInterface().

template<typename ValueType >
void lama::OpenMPCSRUtils::matrixAdd ( IndexType  cJA[],
ValueType  cValues[],
const IndexType  cIA[],
const IndexType  numRows,
const IndexType  numColumns,
bool  diagonalProperty,
const ValueType  alpha,
const IndexType  aIA[],
const IndexType  aJA[],
const ValueType  aValues[],
const ValueType  beta,
const IndexType  bIA[],
const IndexType  bJA[],
const ValueType  bValues[] 
) [static]
void lama::OpenMPCSRUtils::matrixAddSizes ( IndexType  cSizes[],
const IndexType  numRows,
const IndexType  numColumns,
bool  diagonalProperty,
const IndexType  aIA[],
const IndexType  aJA[],
const IndexType  bIA[],
const IndexType  bJA[] 
) [static]
template<typename ValueType >
void lama::OpenMPCSRUtils::matrixMultiply ( ValueType  cValues[],
const IndexType  cIA[],
const IndexType  cJA[],
const IndexType  numRows,
const ValueType  alpha,
const IndexType  aIA[],
const IndexType  aJA[],
const ValueType  aValues[],
const IndexType  bIA[],
const IndexType  bJA[],
const ValueType  bValues[] 
) [static]
void lama::OpenMPCSRUtils::matrixMultiplyJA ( IndexType  cJA[],
const IndexType  cIA[],
const IndexType  numRows,
const IndexType  numColumns,
bool  diagonalProperty,
const IndexType  aIA[],
const IndexType  aJA[],
const IndexType  bIA[],
const IndexType  bJA[] 
) [static]
void lama::OpenMPCSRUtils::matrixMultiplySizes ( IndexType  cSizes[],
const IndexType  numRows,
const IndexType  numColumns,
bool  diagonalProperty,
const IndexType  aIA[],
const IndexType  aJA[],
const IndexType  bIA[],
const IndexType  bJA[] 
) [static]
template<typename ValueType >
void lama::OpenMPCSRUtils::normalGEMV ( ValueType  result[],
const ValueType  alpha,
const ValueType  x[],
const ValueType  beta,
const ValueType  y[],
const IndexType  numRows,
const IndexType  csrIA[],
const IndexType  csrJA[],
const ValueType  csrValues[],
SyncToken syncToken 
) [static]

Implementation for CSRUtilsInterface::Mult::normalGEMV.

References LAMA_THROWEXCEPTION.

Referenced by setInterface().

template<typename ValueType >
static void lama::OpenMPCSRUtils::normalGEMV ( ValueType  result[],
const ValueType  alpha,
const ValueType  x[],
const ValueType  beta,
const ValueType  y[],
const IndexType  numRows,
const IndexType  csrIA[],
const IndexType  csrJA[],
const ValueType  csrValues[] 
) [static, private]
void lama::OpenMPCSRUtils::offsets2sizesGather ( IndexType  sizes[],
const IndexType  offsets[],
const IndexType  rowIndexes[],
const IndexType  numRows 
) [static]

offset2sizes for indexed rows

Referenced by lama::StorageMethods< T >::exchangeHaloCSR().

template<typename ValueType1 , typename ValueType2 >
void lama::OpenMPCSRUtils::scaleRows ( ValueType1  csrValues[],
const IndexType  csrIA[],
const IndexType  numRows,
const ValueType2  values[] 
) [static]
IndexType lama::OpenMPCSRUtils::scan ( IndexType  array[],
const IndexType  numValues 
) [static]

This function build an offset array from a counter array.

Parameters:
[in,out]arraycontains counter values and later the offsets
[in]numValuesis the number of values, array must contain one additional value
Returns:
the total number of values
    array  :    3    7   8   4   2   
    array  :    0   10  15  12  16    -> returns 18 

CSR sparse representation of matrices store the sum of all values at an additional position at the end of the array.

References lama::minThreads, scanParallel(), and scanSerial().

Referenced by sizes2offsets().

IndexType lama::OpenMPCSRUtils::scanParallel ( PartitionId  numThreads,
IndexType  array[],
const IndexType  numValues 
) [static, private]

References scanSerial().

Referenced by scan().

IndexType lama::OpenMPCSRUtils::scanSerial ( IndexType  array[],
const IndexType  numValues 
) [static, private]

Referenced by scan(), and scanParallel().

void lama::OpenMPCSRUtils::setNonEmptyRowsByOffsets ( IndexType  rowIndexes[],
const IndexType  numNonEmptyRows,
const IndexType  offsets[],
const IndexType  numRows 
) [static]

Build a vector of indexes for non-empty rows.

References LAMA_ASSERT_EQUAL_DEBUG.

Referenced by lama::CSRStorage< T >::buildRowIndexes().

template<typename ValueType >
void lama::OpenMPCSRUtils::sortRowElements ( IndexType  csrJA[],
ValueType  csrValues[],
const IndexType  csrIA[],
const IndexType  numRows,
const bool  diagonalFlag 
) [static]

This function sorts the column indexes of each row in ascending order.

If the diagonal flag is set, the first entry in the row will be the diagonal element ( if available ).

References LAMA_ASSERT_DEBUG.

Referenced by lama::StorageIO< T >::readCSRFromMMFile(), and setInterface().

template<typename ValueType >
void lama::OpenMPCSRUtils::sparseGEMV ( ValueType  result[],
const ValueType  alpha,
const ValueType  x[],
const IndexType  numNonZeroRows,
const IndexType  rowIndexes[],
const IndexType  csrIA[],
const IndexType  csrJA[],
const ValueType  csrValues[],
SyncToken syncToken 
) [static]

Implementation for CSRUtilsInterface::Mult::sparseGEMV.

References LAMA_THROWEXCEPTION.

Referenced by setInterface().

template<typename ValueType >
static void lama::OpenMPCSRUtils::sparseGEMV ( ValueType  result[],
const ValueType  alpha,
const ValueType  x[],
const IndexType  numNonZeroRows,
const IndexType  rowIndexes[],
const IndexType  csrIA[],
const IndexType  csrJA[],
const ValueType  csrValues[] 
) [static, private]

The documentation for this class was generated from the following files: