Commit 05158add authored by Pavel Burovskiy's avatar Pavel Burovskiy

Removing dependency on NIST Sparse Blas v0.9

parent 82fef746
......@@ -160,7 +160,6 @@ ENDIF ()
INCLUDE (ThirdPartyTinyxml)
INCLUDE (ThirdPartyLoki)
INCLUDE (ThirdPartyMetis)
INCLUDE (ThirdPartySpblastk)
INCLUDE (ThirdPartyBoost)
INCLUDE (ThirdPartyZlib)
INCLUDE (ThirdPartyFFTW)
......@@ -288,7 +287,6 @@ INSTALL(FILES ${CMAKE_BINARY_DIR}/Nektar++Config.cmake
${CMAKE_SOURCE_DIR}/cmake/FindCHUDFramework.cmake
${CMAKE_SOURCE_DIR}/cmake/FindACML.cmake
${CMAKE_SOURCE_DIR}/cmake/FindArpack.cmake
${CMAKE_SOURCE_DIR}/cmake/FindNistSparseBlas.cmake
${CMAKE_SOURCE_DIR}/cmake/FindOpenBlas.cmake
${CMAKE_SOURCE_DIR}/cmake/FindNativeBlasLapack.cmake
${CMAKE_SOURCE_DIR}/cmake/FindMKL.cmake
......
# Use NIST_SPARSE_BLAS_ADDITIONAL_INCLUDE_DIRS to add additional search directories.
SET(NIST_SPARSE_BLAS_SEARCH_PATHS
${NIST_SPARSE_BLAS_ADDITIONAL_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/ThirdParty/spblastk0.9b/lib
${CMAKE_SOURCE_DIR}/../ThirdParty/spblastk0.9b/lib
${CMAKE_SOURCE_DIR}/ThirdParty/dist/lib
${CMAKE_SOURCE_DIR}/../ThirdParty/dist/lib)
FIND_LIBRARY(NIST_SPARSE_BLAS NAMES sbtk PATHS ${NIST_SPARSE_BLAS_SEARCH_PATHS})
FIND_LIBRARY(NIST_SPARSE_BLAS_DEBUG NAMES sbtk-g PATHS ${NIST_SPARSE_BLAS_SEARCH_PATHS})
GET_FILENAME_COMPONENT(NIST_SPARSE_BLAS_LIB_PATH ${NIST_SPARSE_BLAS} PATH CACHE)
SET(NIST_SPARSE_BLAS_INCLUDE_DIR ${NIST_SPARSE_BLAS_LIB_PATH}/../include CACHE FILEPATH "Sparse matrix solve include directory.")
MARK_AS_ADVANCED(NIST_SPARSE_BLAS)
MARK_AS_ADVANCED(NIST_SPARSE_BLAS_DEBUG)
MARK_AS_ADVANCED(NIST_SPARSE_BLAS_INCLUDE_DIR)
MARK_AS_ADVANCED(NIST_SPARSE_BLAS_LIB_PATH)
IF (NIST_SPARSE_BLAS)
SET(NIST_SPARSE_BLAS_FOUND ON)
ENDIF (NIST_SPARSE_BLAS)
IF (NIST_SPARSE_BLAS_FOUND)
IF (NOT NIST_SPARSE_BLAS_FIND_QUIETLY)
MESSAGE(STATUS "Found NIST Sparse Blas")
ENDIF (NOT NIST_SPARSE_BLAS_FIND_QUIETLY)
ELSE(NIST_SPARSE_BLAS_FOUND)
IF (NIST_SPARSE_BLAS_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find NIST sparse blas library.")
ENDIF (NIST_SPARSE_BLAS_FIND_REQUIRED)
ENDIF (NIST_SPARSE_BLAS_FOUND)
......@@ -51,13 +51,6 @@ INCLUDE(${NEKTAR++_ROOT_DIR}/FindLoki.cmake)
SET(TINYXML_ADDITIONAL_INCLUDE_DIRS "@TINYXML_BASE@")
INCLUDE(${NEKTAR++_ROOT_DIR}/FindTinyXml.cmake)
SET(NIST_SPARSE_BLAS_ADDITIONAL_INCLUDE_DIRS "@NIST_SPARSE_BLAS_INCLUDE_DIR@")
SET(NIST_SPARSE_BLAS "@NIST_SPARSE_BLAS@")
SET(NIST_SPARSE_BLAS_DEBUG "@NIST_SPARSE_BLAS_DEBUG@")
SET(NIST_SPARSE_BLAS_INCLUDE_DIR "@NIST_SPARSE_BLAS_INCLUDE_DIR@")
SET(NEKTAR_USE_NIST_SPARSE_BLAS_TOOLKIT "@NEKTAR_USE_NIST_SPARSE_BLAS_TOOLKIT@")
MARK_AS_ADVANCED(NEKTAR_USE_NIST_SPARSE_BLAS_TOOLKIT)
SET(NEKTAR_USE_ACML "@NEKTAR_USE_ACML@")
SET(ACML_USE_SHARED_LIBRARIES "@ACML_USE_SHARED_LIBRARIES@")
SET(ACML_USE_OPENMP_LIBRARIES "@ACML_USE_OPENMP_LIBRARIES@")
......@@ -163,7 +156,7 @@ IF(NEKTAR_USE_ARPACK)
ENDIF(NEKTAR_USE_ARPACK)
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${LOKI_INCLUDE_DIR} ${TINYXML_BASE} ${NIST_SPARSE_BLAS_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${LOKI_INCLUDE_DIR} ${TINYXML_BASE} )
SET(NEKTAR_PACKAGE_GENERATOR "@NEKTAR_PACKAGE_GENERATOR@")
SET(NEKTAR_USING_BLAS "@NEKTAR_USING_BLAS@")
......
......@@ -47,10 +47,6 @@ MACRO(SET_LAPACK_LINK_LIBRARIES name)
ENDIF( NEKTAR_USE_BLAS_LAPACK )
IF( NEKTAR_USE_NIST_SPARSE_BLAS_TOOLKIT AND NIST_SPARSE_BLAS_FOUND )
TARGET_LINK_LIBRARIES(${name} ${NIST_SPARSE_BLAS} )
ENDIF( NEKTAR_USE_NIST_SPARSE_BLAS_TOOLKIT AND NIST_SPARSE_BLAS_FOUND )
IF( NEKTAR_USE_METIS )
TARGET_LINK_LIBRARIES(${name} optimized ${METIS_LIB} debug
${METIS_LIB} )
......@@ -238,10 +234,8 @@ ENDMACRO(ADD_NEKTAR_EXECUTABLE name component sources)
MACRO(ADD_NEKTAR_LIBRARY name component type)
ADD_LIBRARY(${name} ${type} ${ARGN})
# NIST Sparse BLAS only static, so link into Nektar libraries directly.
TARGET_LINK_LIBRARIES( ${name} ${NIST_SPARSE_BLAS} ${METIS_LIB})
ADD_DEPENDENCIES(${name} spblastk0.9b modmetis-5.1.0 boost tinyxml
zlib-1.2.7)
TARGET_LINK_LIBRARIES( ${name} ${METIS_LIB} )
ADD_DEPENDENCIES(${name} modmetis-5.1.0 boost tinyxml zlib-1.2.7)
SET_PROPERTY(TARGET ${name} PROPERTY FOLDER ${component})
IF (NEKTAR_USE_MPI)
TARGET_LINK_LIBRARIES( ${name} ${GSMPI_LIBRARY} ${XXT_LIBRARY})
......
OPTION(THIRDPARTY_BUILD_NIST_SPBLASTK
"Build NIST Sparse BLAS" ON)
IF (THIRDPARTY_BUILD_NIST_SPBLASTK)
INCLUDE(ExternalProject)
EXTERNALPROJECT_ADD(
spblastk0.9b
PREFIX ${TPSRC}
URL ${TPURL}/spblastk0.9b.tar.bz2
URL_MD5 "93469940f03554939a4600f431eb4d99"
DOWNLOAD_DIR ${TPSRC}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX:PATH=${TPSRC}/dist
${TPSRC}/src/spblastk0.9b
)
SET(NIST_SPARSE_BLAS sbtk CACHE FILEPATH
"Path to NIST Sparse BLAS." FORCE)
MARK_AS_ADVANCED(NIST_SPARSE_BLAS)
LINK_DIRECTORIES(${TPSRC}/dist/lib)
MESSAGE(STATUS "Build NIST Sparse BLAS: ${TPSRC}/dist/lib/lib${NIST_SPARSE_BLAS}.a")
ELSE (THIRDPARTY_BUILD_NIST_SPBLASTK)
INCLUDE(FindNistSparseBlas)
ENDIF (THIRDPARTY_BUILD_NIST_SPBLASTK)
......@@ -182,10 +182,7 @@ SET(LinearAlgebraHeaders
./LinearAlgebra/StandardMatrix.hpp
./LinearAlgebra/TransF77.hpp
./LinearAlgebra/NistSparseBlas.hpp
./LinearAlgebra/StorageSmvBsr.hpp
./LinearAlgebra/StorageNistBsr.hpp
./LinearAlgebra/StorageNistCsr.hpp
./LinearAlgebra/NistSparseDescriptors.hpp
./LinearAlgebra/SparseDiagBlkMatrix.hpp
./LinearAlgebra/SparseMatrix.hpp
......@@ -209,8 +206,6 @@ SET(LinearAlgebraSources
./LinearAlgebra/StandardMatrix.cpp
./LinearAlgebra/SparseUtils.cpp
./LinearAlgebra/StorageSmvBsr.cpp
./LinearAlgebra/StorageNistBsr.cpp
./LinearAlgebra/StorageNistCsr.cpp
./LinearAlgebra/SparseDiagBlkMatrix.cpp
./LinearAlgebra/SparseMatrix.cpp
)
......
This diff is collapsed.
......@@ -44,8 +44,6 @@
#include <LibUtilities/LinearAlgebra/NistSparseDescriptors.hpp>
#include <LibUtilities/LinearAlgebra/SparseMatrixFwd.hpp>
#include <LibUtilities/LinearAlgebra/SparseDiagBlkMatrix.hpp>
#include <LibUtilities/LinearAlgebra/StorageNistCsr.hpp>
#include <LibUtilities/LinearAlgebra/StorageNistBsr.hpp>
#include <LibUtilities/LinearAlgebra/StorageSmvBsr.hpp>
#include <boost/lexical_cast.hpp>
......@@ -530,8 +528,6 @@ namespace Nektar
// explicit instantiation
template class NekSparseDiagBlkMatrix<StorageNistCsr<NekDouble> >;
template class NekSparseDiagBlkMatrix<StorageNistBsr<NekDouble> >;
template class NekSparseDiagBlkMatrix<StorageSmvBsr<NekDouble> >;
......
......@@ -44,8 +44,6 @@
#include <LibUtilities/LinearAlgebra/NistSparseDescriptors.hpp>
#include <LibUtilities/LinearAlgebra/SparseMatrixFwd.hpp>
#include <LibUtilities/LinearAlgebra/SparseMatrix.hpp>
#include <LibUtilities/LinearAlgebra/StorageNistCsr.hpp>
#include <LibUtilities/LinearAlgebra/StorageNistBsr.hpp>
#include <LibUtilities/LinearAlgebra/StorageSmvBsr.hpp>
#include <boost/lexical_cast.hpp>
......@@ -270,8 +268,6 @@ namespace Nektar
// explicit instantiation
template class NekSparseMatrix<StorageNistCsr<NekDouble> >;
template class NekSparseMatrix<StorageNistBsr<NekDouble> >;
template class NekSparseMatrix<StorageSmvBsr<NekDouble> >;
......
......@@ -68,8 +68,6 @@ namespace Nektar
typedef Array<OneD, BCOMatType> BCOMatVector;
template<typename DataType> class StorageNistCsr;
template<typename DataType> class StorageNistBsr;
template<typename DataType> class StorageSmvBsr;
template<typename SparseStorageType> class NekSparseMatrix;
......
......@@ -40,8 +40,6 @@
#include <LibUtilities/LinearAlgebra/SparseUtils.hpp>
#include <LibUtilities/LinearAlgebra/SparseMatrix.hpp>
#include <LibUtilities/LinearAlgebra/SparseDiagBlkMatrix.hpp>
#include <LibUtilities/LinearAlgebra/StorageNistCsr.hpp>
#include <LibUtilities/LinearAlgebra/StorageNistBsr.hpp>
#include <LibUtilities/LinearAlgebra/StorageSmvBsr.hpp>
......@@ -141,11 +139,7 @@ namespace Nektar{
return os;
}
template std::ostream& operator<<(std::ostream& os, const NekSparseMatrix<StorageNistCsr<NekDouble> >& rhs);
template std::ostream& operator<<(std::ostream& os, const NekSparseMatrix<StorageNistBsr<NekDouble> >& rhs);
template std::ostream& operator<<(std::ostream& os, const NekSparseMatrix<StorageSmvBsr<NekDouble> >& rhs);
template std::ostream& operator<<(std::ostream& os, const NekSparseDiagBlkMatrix<StorageNistCsr<NekDouble> >& rhs);
template std::ostream& operator<<(std::ostream& os, const NekSparseDiagBlkMatrix<StorageNistBsr<NekDouble> >& rhs);
template std::ostream& operator<<(std::ostream& os, const NekSparseDiagBlkMatrix<StorageSmvBsr<NekDouble> >& rhs);
} // namespace
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////////
//
// File: StorageNistBsr.hpp
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Interface to NIST BSR sparse matrix storage.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STORAGE_NIST_BSR_HPP
#define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STORAGE_NIST_BSR_HPP
#include <map>
#include <vector>
#include <utility>
#include <fstream>
#include <LibUtilities/LinearAlgebra/MatrixStorageType.h>
#include <LibUtilities/LinearAlgebra/SparseMatrixFwd.hpp>
#include <boost/call_traits.hpp>
namespace Nektar
{
/*
* This class is an interface to NIST BSR sparse matrix storage.
* The BSR sparse format assumes sparse matrix is a CSR collection of
* dense square blocks of same size. Indexing is partially 1-based.
* The constructor takes input matrix in block coordinate storage
* (BCO) sparse format.
*
* Multiply kernels are provided by NIST Sparse BLAS v 0.9
*
*/
template<typename T>
class StorageNistBsr
{
public:
typedef T DataType;
typedef Array<OneD, DataType> DataVectorType;
typedef Array<OneD, const DataType> ConstDataVectorType;
typedef Array<OneD, IndexType> IndexVectorType;
/// \internal
/// \brief Forward iterator through nonzero (double) elements of the matrix
/// that mimics forward iteration of BCOMatType.
/// It's a dirty hack, not a real iterator in the C++ sense.
class const_iterator
{
struct IterType
{
CoordType first; //< (row, column)
DataType second; //< value
IndexType nnzindex; //< index of this nnz entry
IndexType storageindex;//< offset of this nnz entry in the storage
};
public:
const_iterator( MatrixStorage matType,
IndexType begin,
IndexType end,
IndexType blkDim,
const DataVectorType& val,
const IndexVectorType& indx,
const IndexVectorType& pntr);
const_iterator(const const_iterator& src);
~const_iterator();
const_iterator operator++(int);
const_iterator& operator++();
const IterType& operator*();
const IterType* operator->();
const bool operator==(const const_iterator& rhs);
const bool operator!=(const const_iterator& rhs);
// one way conversion: iterator -> const_iterator
// operator const_iterator<T const, Tag>() const;
private:
void forward();
CoordType storageIndexToFullCoord(IndexType storageIndex);
MatrixStorage m_matType;
IterType m_iter;
IndexType m_begin;
IndexType m_end;
IndexType m_blkDim;
const DataVectorType& m_val;
const IndexVectorType& m_indx;
const IndexVectorType& m_pntr;
};
public:
// Constructs BSR sparse matrix based on input BCO storage
LIB_UTILITIES_EXPORT StorageNistBsr( const IndexType blkRows,
const IndexType blkCols,
const IndexType blkDim,
const BCOMatType& bcoMat,
const MatrixStorage matType = eFULL);
// Copy constructor
LIB_UTILITIES_EXPORT StorageNistBsr(const StorageNistBsr& src);
LIB_UTILITIES_EXPORT ~StorageNistBsr();
LIB_UTILITIES_EXPORT const IndexType GetRows() const;
LIB_UTILITIES_EXPORT const IndexType GetColumns() const;
LIB_UTILITIES_EXPORT const IndexType GetNumNonZeroEntries() const;
LIB_UTILITIES_EXPORT const IndexType GetNumStoredDoubles() const;
LIB_UTILITIES_EXPORT const IndexType GetBlkSize() const;
LIB_UTILITIES_EXPORT const DataType GetFillInRatio() const;
LIB_UTILITIES_EXPORT const size_t GetMemoryUsage(IndexType nnz, IndexType nRows) const;
LIB_UTILITIES_EXPORT const_iterator begin() const;
LIB_UTILITIES_EXPORT const_iterator end() const;
LIB_UTILITIES_EXPORT const typename boost::call_traits<DataType>::const_reference
GetValue(IndexType row, IndexType column) const;
LIB_UTILITIES_EXPORT void Multiply(const DataType* in,
DataType* out);
LIB_UTILITIES_EXPORT void Multiply(const DataVectorType &in,
DataVectorType &out);
LIB_UTILITIES_EXPORT void MultiplyLight(const DataVectorType &in,
DataVectorType &out);
LIB_UTILITIES_EXPORT void MultiplyLightSymm(const DataVectorType &in,
DataVectorType &out);
protected:
// converts input vector of BCO blocks
// to the internal Nist BSR representation
void processBcoInput(
const IndexType blkRows,
const IndexType blkColumns,
const IndexType blkDim,
const BCOMatType& bcoMat);
MatrixStorage m_matType;
IndexType m_blkRows; // number of block rows
IndexType m_blkCols; // number of block columns
IndexType m_blkDim; // rank of each block
IndexType m_bnnz; //< number of nonzero blocks
IndexType m_nnz; //< number of factual nonzero entries in the sparse matrix
DataVectorType m_val; // values of non-zero entries
IndexVectorType m_indx; // column indices of non-zero entries
IndexVectorType m_pntr; // m_pntr(i) contains index in m_val of first non-zero element in row i
private:
};
} // namespace
#endif //NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STORAGE_NIST_BSR_HPP
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////////
//
// File: StorageNistCsr.hpp
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Interface to NIST CSR sparse matrix storage.
///////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STORAGE_NIST_CSR_HPP
#define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STORAGE_NIST_CSR_HPP
#include <map>
#include <vector>
#include <utility>
#include <fstream>
#include <LibUtilities/LinearAlgebra/MatrixStorageType.h>
#include <LibUtilities/LinearAlgebra/SparseMatrixFwd.hpp>
#include <boost/call_traits.hpp>
namespace Nektar
{
/*
* This class is an interface to NIST CSR sparse matrix storage.
* The CSR (Compressed Sparse Row) sparse format assumes sparse
* matrix is a collection of individual non-zero entries with
* additional indexing: one index array stores column indices of
* non-zero entries row by row; another one stores offsets of each
* row in the first indexing array. Indexing is 0-based.
*
* The constructor takes input matrix in coordinate storage
* (COO) sparse format.
*
* Multiply kernels are provided by NIST Sparse BLAS v 0.9
*
*/
template<typename T>
class StorageNistCsr
{
public:
typedef T DataType;
typedef Array<OneD, DataType> DataVectorType;
typedef Array<OneD, const DataType> ConstDataVectorType;
typedef Array<OneD, IndexType> IndexVectorType;
/// \internal
/// \brief Forward iterator through nonzero elements of the matrix
/// that mimics forward iteration of COOMatType.
/// It's a dirty hack, not a real iterator in the C++ sense.
class const_iterator
{
struct IterType
{
CoordType first; //< (row, column)
DataType second; //< value
IndexType nnzindex; //< index of this nnz entry
};
public:
const_iterator( MatrixStorage matType,
IndexType begin,
IndexType end,
const DataVectorType& val,
const IndexVectorType& indx,
const IndexVectorType& pntr);
const_iterator(const const_iterator& src);
~const_iterator();
const_iterator operator++(int);
const_iterator& operator++();
const IterType& operator*();
const IterType* operator->();
const bool operator==(const const_iterator& rhs);
const bool operator!=(const const_iterator& rhs);
// one way conversion: iterator -> const_iterator
// operator const_iterator<T const, Tag>() const;
private:
void forward();
MatrixStorage m_matType;
IterType m_iter;
IndexType m_begin;
IndexType m_end;
const DataVectorType& m_val;
const IndexVectorType& m_indx;
const IndexVectorType& m_pntr;
};
public:
// Construct a CSR sparse matrix based on input COO storage
LIB_UTILITIES_EXPORT StorageNistCsr( const IndexType rows,
const IndexType columns,
const COOMatType& cooMat,
const MatrixStorage matType = eFULL);
// Copy constructor
LIB_UTILITIES_EXPORT StorageNistCsr(const StorageNistCsr& src);
LIB_UTILITIES_EXPORT ~StorageNistCsr();
LIB_UTILITIES_EXPORT const IndexType GetRows() const;
LIB_UTILITIES_EXPORT const IndexType GetColumns() const;
// NumNonZeroEntries == NumStoredDoubles for CSR, but
// not for all sparse storages.
LIB_UTILITIES_EXPORT const IndexType GetNumNonZeroEntries() const;
LIB_UTILITIES_EXPORT const IndexType GetNumStoredDoubles() const;
LIB_UTILITIES_EXPORT const IndexType GetBlkSize() const;
LIB_UTILITIES_EXPORT const DataType GetFillInRatio() const;
LIB_UTILITIES_EXPORT const size_t GetMemoryUsage(IndexType nnz, IndexType nRows) const;
LIB_UTILITIES_EXPORT const_iterator begin() const;
LIB_UTILITIES_EXPORT const_iterator end() const;
LIB_UTILITIES_EXPORT const typename boost::call_traits<DataType>::const_reference
GetValue(IndexType row, IndexType column) const;
LIB_UTILITIES_EXPORT void Multiply(const DataType* in,
DataType* out);
LIB_UTILITIES_EXPORT void Multiply(const DataVectorType &in,
DataVectorType &out);
LIB_UTILITIES_EXPORT void MultiplyLight(const DataVectorType &in,
DataVectorType &out);
LIB_UTILITIES_EXPORT void MultiplyLightSymm(const DataVectorType &in,
DataVectorType &out);
protected:
// converts input vector of COO blocks
// to the internal Nist CSR representation
void processCooInput(
const IndexType nRows,
const IndexType nColumns,
const COOMatType& cooMat);
MatrixStorage m_matType;
unsigned long m_mulCallsCounter;
IndexType m_rows;
IndexType m_columns;
IndexType m_nnz; //< number of nonzero entries in the sparse matrix
DataVectorType m_val; //< values of non-zero entries
IndexVectorType m_indx; //< column indices of non-zero entries
IndexVectorType m_pntr; //< m_pntr(i) contains index in m_val of first non-zero element in row i
private:
};
} // namespace
#endif //NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_STORAGE_NIST_CSR_HPP
......@@ -42,7 +42,6 @@
#include <LibUtilities/BasicConst/NektarUnivConsts.hpp>
#include <LibUtilities/LinearAlgebra/Blas.hpp>
#include <LibUtilities/LinearAlgebra/NistSparseBlas.hpp>
#include <LibUtilities/LinearAlgebra/StorageSmvBsr.hpp>
#include <LibUtilities/LinearAlgebra/NistSparseDescriptors.hpp>
......
......@@ -34,8 +34,6 @@
///////////////////////////////////////////////////////////////////////////////
#include <MultiRegions/GlobalMatrix.h>
#include <LibUtilities/LinearAlgebra/StorageNistCsr.hpp>
#include <LibUtilities/LinearAlgebra/StorageNistBsr.hpp>
#include <LibUtilities/LinearAlgebra/StorageSmvBsr.hpp>
#include <LibUtilities/LinearAlgebra/SparseMatrix.hpp>
#include <LibUtilities/LinearAlgebra/SparseUtils.hpp>
......@@ -49,12 +47,8 @@ namespace Nektar
namespace MultiRegions
{
std::string GlobalMatrix::def = LibUtilities::SessionReader::
RegisterDefaultSolverInfo("GlobalMatrixStorageType","NistCSR");
RegisterDefaultSolverInfo("GlobalMatrixStorageType","SmvBSR");
std::string GlobalMatrix::lookupIds[3] = {
LibUtilities::SessionReader::RegisterEnumValue(
"GlobalMatrixStorageType", "NistCSR", MultiRegions::eNistCSR),
LibUtilities::SessionReader::RegisterEnumValue(
"GlobalMatrixStorageType", "NistBSR", MultiRegions::eNistBSR),
LibUtilities::SessionReader::RegisterEnumValue(
"GlobalMatrixStorageType", "SmvBSR", MultiRegions::eSmvBSR)
};
......@@ -77,8 +71,6 @@ namespace Nektar
unsigned int columns,
const COOMatType &cooMat,
const MatrixStorage& matStorage):
m_csrmatrix(),
m_bsrmatrix(),
m_smvbsrmatrix(),
m_rows(rows),
m_cols(columns),
......@@ -94,74 +86,36 @@ namespace Nektar
BCOMatType bcoMat;
if (storageType != eNistCSR)
// assuming current sparse format allows
// block-sparse data representation
if(pSession->DefinesParameter("SparseBlockSize"))
{
if(pSession->DefinesParameter("SparseBlockSize"))
{
pSession->LoadParameter("SparseBlockSize", block_size);
ASSERTL1(block_size > 0,"SparseBlockSize parameter must to be positive");
}
else
{
// Size of dense matrix sub-blocks
block_size = 2;
}
cout << "block_size = " << block_size << endl;
brows = rows / block_size + (rows % block_size > 0);
bcols = columns / block_size + (columns % block_size > 0);
if (rows % block_size > 0) m_copyOp = true;
if (m_copyOp)
{
m_tmpin = Array<OneD, NekDouble> (brows*block_size, 0.0);
m_tmpout = Array<OneD, NekDouble> (brows*block_size, 0.0);
}
convertCooToBco(brows, bcols, block_size, cooMat, bcoMat);
pSession->LoadParameter("SparseBlockSize", block_size);
ASSERTL1(block_size > 0,"SparseBlockSize parameter must to be positive");
}
size_t matBytes;
switch(storageType)
else
{
case eNistCSR:
{
// Create NIST CSR sparse storage holder
DNekCsrMat::SparseStorageSharedPtr sparseStorage =
MemoryManager<DNekCsrMat::StorageType>::
AllocateSharedPtr(
rows, columns, cooMat, matStorage );
// Create sparse matrix
m_csrmatrix = MemoryManager<DNekCsrMat>::
AllocateSharedPtr( sparseStorage );
matBytes = m_csrmatrix->GetMemoryFootprint();
}
break;
case eNistBSR:
{