Skip to content
Prev Previous commit
Next Next commit
fix sonar issues
  • Loading branch information
yhmtsai committed Oct 17, 2019
commit 18df52366e0c0013bfa59ccde8ad1ff4b6d8ab10
35 changes: 19 additions & 16 deletions benchmark/utils/cuda_linops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,17 @@ class CuspBase : public gko::LinOp {
this->initialize_descr();
}

~CuspBase() = default;

CuspBase(const CuspBase &other) = delete;

CuspBase &operator=(const CuspBase &other)
{
gko::LinOp::operator=(other);
this->gpu_exec_ = other.gpu_exec_;
this->initialize_descr();
if (this != &other) {
gko::LinOp::operator=(other);
this->gpu_exec_ = other.gpu_exec_;
this->initialize_descr();
}
return *this;
}

Expand Down Expand Up @@ -312,16 +318,14 @@ class CuspCsrEx
const auto id = this->get_gpu_exec()->get_device_id();
gko::device_guard g{id};
if (set_buffer_) {
try {
GKO_ASSERT_NO_CUDA_ERRORS(cudaFree(buffer_));
} catch (const std::exception &e) {
std::cerr
<< "Error when unallocating CuspCsrEx temporary buffer: "
<< e.what() << std::endl;
}
GKO_ASSERT_NO_CUDA_ERRORS(cudaFree(buffer_));
}
}

CuspCsrEx(const CuspCsrEx &other) = delete;

CuspCsrEx &operator=(const CuspCsrEx &other) = default;

protected:
void apply_impl(const gko::LinOp *b, gko::LinOp *x) const override
{
Expand Down Expand Up @@ -418,14 +422,13 @@ class CuspHybrid
{
const auto id = this->get_gpu_exec()->get_device_id();
gko::device_guard g{id};
try {
GKO_ASSERT_NO_CUSPARSE_ERRORS(cusparseDestroyHybMat(hyb_));
} catch (const std::exception &e) {
std::cerr << "Error when unallocating CuspHybrid hyb_ matrix: "
<< e.what() << std::endl;
}
GKO_ASSERT_NO_CUSPARSE_ERRORS(cusparseDestroyHybMat(hyb_));
}

CuspHybrid(const CuspHybrid &other) = delete;

CuspHybrid &operator=(const CuspHybrid &other) = default;

protected:
void apply_impl(const gko::LinOp *b, gko::LinOp *x) const override
{
Expand Down