Commit 77c72a0a authored by gbalduzz's avatar gbalduzz
Browse files

Reverts MagmaQueue move constructor to avoid an extra Cuda stream creation.

parent 76324771
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -33,10 +33,10 @@ public:
  CudaStream(const CudaStream& other) = delete;
  CudaStream& operator=(const CudaStream& other) = delete;

  CudaStream(CudaStream&& other) {
  CudaStream(CudaStream&& other) noexcept {
    swap(other);
  }
  CudaStream& operator=(CudaStream&& other) {
  CudaStream& operator=(CudaStream&& other) noexcept {
    swap(other);
    return *this;
  }
@@ -54,7 +54,7 @@ public:
    return stream_;
  }

  void swap(CudaStream& other) {
  void swap(CudaStream& other) noexcept {
    std::swap(stream_, other.stream_);
  }

+10 −10
Original line number Diff line number Diff line
@@ -39,12 +39,13 @@ public:
  MagmaQueue(const MagmaQueue& rhs) = delete;
  MagmaQueue& operator=(const MagmaQueue& rhs) = delete;

  MagmaQueue(MagmaQueue&& rhs) {
    swap(rhs);
  MagmaQueue(MagmaQueue&& rhs) noexcept : CudaStream(std::move(rhs)) {
    swapMembers(rhs);
  }

  MagmaQueue& operator=(MagmaQueue&& rhs) {
    swap(rhs);
  MagmaQueue& operator=(MagmaQueue&& rhs) noexcept {
    CudaStream::operator=(std::move(rhs));
    swapMembers(rhs);
    return *this;
  }

@@ -58,14 +59,13 @@ public:
    return queue_;
  }

  void swap(MagmaQueue& other) {
    static_cast<CudaStream&>(*this).swap(static_cast<CudaStream&>(other));
    std::swap(cublas_handle_, other.cublas_handle_);
    std::swap(cusparse_handle_, other.cusparse_handle_);
    std::swap(queue_, other.queue_);
private:
  void swapMembers(MagmaQueue& rhs) noexcept {
    std::swap(cublas_handle_, rhs.cublas_handle_);
    std::swap(cusparse_handle_, rhs.cusparse_handle_);
    std::swap(queue_, rhs.queue_);
  }

private:
  magma_queue_t queue_ = nullptr;
  cublasHandle_t cublas_handle_ = nullptr;
  cusparseHandle_t cusparse_handle_ = nullptr;