13#ifndef EIGEN_GPU_CUSPARSE_SUPPORT_H
14#define EIGEN_GPU_CUSPARSE_SUPPORT_H
17#include "./InternalHeaderCheck.h"
19#include "./GpuSupport.h"
30#if defined(CUSPARSE_VERSION) && CUSPARSE_VERSION >= 12603
31#define EIGEN_HAS_CUSPARSE_BSR 1
33#define EIGEN_HAS_CUSPARSE_BSR 0
40#define EIGEN_CUSPARSE_CHECK(x) \
42 const cusparseStatus_t _s = (x); \
43 if (_s != CUSPARSE_STATUS_SUCCESS) EIGEN_GPU_CHECK_FAILED(cusparseGetErrorName(_s), #x, __FILE__, __LINE__); \
49template <
typename Scalar>
50constexpr cusparseOperation_t to_cusparse_op(GpuOp op) {
51 const auto op_ = (op == GpuOp::ConjTrans && !NumTraits<Scalar>::IsComplex) ? GpuOp::Trans : op;
54 return CUSPARSE_OPERATION_TRANSPOSE;
55 case GpuOp::ConjTrans:
56 return CUSPARSE_OPERATION_CONJUGATE_TRANSPOSE;
58 return CUSPARSE_OPERATION_NON_TRANSPOSE;
68template <
typename SpMatType,
typename InputType, require_same_t<SpMatType, InputType> = 0>
69const SpMatType& bind_sparse(
const InputType& A, SpMatType& storage) {
70 if (A.isCompressed())
return A;
72 storage.makeCompressed();
76template <
typename SpMatType,
typename InputType, require_not_same_t<SpMatType, InputType> = 0>
77const SpMatType& bind_sparse(
const InputType& A, SpMatType& storage) {
79 storage.makeCompressed();
85template <
typename StorageIndex>
86inline void check_storage_index_bounds(Index rows, Index cols, Index nnz) {
87 const Index max_storage_index =
static_cast<Index
>((std::numeric_limits<StorageIndex>::max)());
88 eigen_assert(rows <= max_storage_index && cols <= max_storage_index && nnz <= max_storage_index &&
89 "matrix dimensions or nonzeros exceed the index range supported by the CUDA sparse libraries");
90 EIGEN_UNUSED_VARIABLE(rows);
91 EIGEN_UNUSED_VARIABLE(cols);
92 EIGEN_UNUSED_VARIABLE(nnz);
93 EIGEN_UNUSED_VARIABLE(max_storage_index);
Namespace containing all symbols from the Eigen library.