LAMA
|
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[]) |
This class provides routines on compressed sparse row data.
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.
ValueType lama::OpenMPCSRUtils::absMaxDiffRowUnsorted | ( | const IndexType | n1, |
const IndexType | csrJA1[], | ||
const ValueType | csrValues1[], | ||
const IndexType | n2, | ||
const IndexType | csrJA2[], | ||
const ValueType | csrValues2[] | ||
) | [static, private] |
References lama::abs(), lama::findCol(), and lama::nIndex.
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] |
Implementation for CSRUtilsInterface::Reductions::absMaxDiffVal.
Referenced by setInterface().
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] |
Implementation for CSRUtilsInterface::Transpose::convertCSR2CSC.
References LAMA_ASSERT_DEBUG, LAMA_ASSERT_EQUAL_DEBUG, and sizes2offsets().
Referenced by setInterface().
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().
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.
[in] | numDiagonals | is min( numRows, numColumns ) |
[in] | csrIA | is the csr offset array |
[in] | csrJA | is array with column indexes |
Referenced by lama::CSRStorage< T >::setCSRDataImpl(), lama::COOStorage< T >::setCSRDataImpl(), lama::DIAStorage< T >::setCSRDataImpl(), and setInterface().
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().
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().
lama::OpenMPCSRUtils::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [protected] |
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] |
Implementation for CSRUtilsInterface::Mult::matrixAdd.
References LAMA_ASSERT_EQUAL_DEBUG.
Referenced by lama::CSRStorage< T >::matrixAddMatrixCSR(), and setInterface().
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] |
Implementation for CSRUtilsInterface::Offsets::matrixAddSizes.
Referenced by lama::CSRStorage< T >::matrixAddMatrixCSR(), and setInterface().
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] |
Implementation for CSRUtilsInterface::Mult::matrixMultiply.
Referenced by lama::CSRStorage< T >::matrixTimesMatrixCSR(), and setInterface().
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] |
Implementation for CSRUtilsInterface::Offsets::matrixMultiplyJA.
References LAMA_ASSERT_EQUAL_DEBUG.
Referenced by lama::CSRStorage< T >::matrixTimesMatrixCSR(), and setInterface().
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] |
Implementation for CSRUtilsInterface::Offsets::matrixMultiplySizes.
References LAMA_ASSERT_DEBUG.
Referenced by lama::CSRStorage< T >::matrixTimesMatrixCSR(), and setInterface().
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().
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::offsets2sizes | ( | IndexType | sizes[], |
const IndexType | offsets[], | ||
const IndexType | n | ||
) | [static] |
Implementation for CSRUtilsInterface::Offsets::offsets2sizes.
Referenced by lama::StorageMethods< T >::redistributeCSR(), lama::StorageMethods< T >::replicateCSR(), and setInterface().
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().
void lama::OpenMPCSRUtils::scaleRows | ( | ValueType1 | csrValues[], |
const IndexType | csrIA[], | ||
const IndexType | numRows, | ||
const ValueType2 | values[] | ||
) | [static] |
Implementation for CSRUtilsInterface::Mult::scaleRows.
Referenced by lama::CSRStorage< T >::scaleImpl(), and setInterface().
IndexType lama::OpenMPCSRUtils::scan | ( | IndexType | array[], |
const IndexType | numValues | ||
) | [static] |
This function build an offset array from a counter array.
[in,out] | array | contains counter values and later the offsets |
[in] | numValues | is the number of values, array must contain one additional value |
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::setInterface | ( | struct CSRUtilsInterface & | CSRUtils | ) | [static] |
Routine that registers all routines of this class at the LAMA interface.
References absMaxDiffVal(), convertCSR2CSC(), gemm(), hasDiagonalProperty(), jacobi(), jacobiHalo(), LAMA_INTERFACE_REGISTER, LAMA_INTERFACE_REGISTER_T, LAMA_INTERFACE_REGISTER_TT, matrixAdd(), matrixAddSizes(), matrixMultiply(), matrixMultiplyJA(), matrixMultiplySizes(), normalGEMV(), offsets2sizes(), scaleRows(), sizes2offsets(), sortRowElements(), sparseGEMV(), and validOffsets().
Referenced by lama::OpenMPInterface::OpenMPInterface().
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().
IndexType lama::OpenMPCSRUtils::sizes2offsets | ( | IndexType | sizes[], |
const IndexType | numRows | ||
) | [static] |
Implementation for CSRUtilsInterface::Offsets::sizes2offsets.
References scan().
Referenced by lama::COOStorage< T >::buildCSR(), lama::DIAStorage< T >::buildCSR(), lama::DenseStorageView< T >::buildCSR(), convertCSR2CSC(), lama::StorageMethods< T >::exchangeHaloCSR(), lama::StorageMethods< T >::joinCSR(), lama::StorageMethods< T >::localizeCSR(), lama::CSRStorage< T >::matrixAddMatrixCSR(), lama::CSRStorage< T >::matrixTimesMatrixCSR(), lama::StorageMethods< T >::redistributeCSR(), lama::StorageMethods< T >::replicateCSR(), setInterface(), and lama::StorageMethods< T >::splitCSR().
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().
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().
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] |
bool lama::OpenMPCSRUtils::validOffsets | ( | const IndexType | array[], |
const IndexType | n, | ||
const IndexType | total | ||
) | [static] |