Skip to content

Commit

Permalink
DeviceTensor's move ctro/assignment can just move buffer (?)
Browse files Browse the repository at this point in the history
  • Loading branch information
evaleev committed Jul 24, 2024
1 parent a36a88b commit c8c2b95
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions examples/spmm/spmm_cuda.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,7 @@ struct DeviceTensor : public ttg::TTValue<DeviceTensor<_T, _Range, _Storage>>
DeviceTensor(DeviceTensor&& x) noexcept
: ttvalue_type(std::move(x))
, tensor_type(static_cast<tensor_type&&>(x))
/* Grrrr, moving a Tensor does not guarantee to move the pointer */
, b((this->size() == 0 ||
this->data() == x.b.host_ptr()) ? std::move(x.b)
: ttg::Buffer<_T>(this->size() ? this->data()
: nullptr,
this->size()))
, b(std::move(x.b))
{
assert(this->data() == b.host_ptr());
//std::cout << "DeviceTensor move ctor" << std::endl;
Expand Down Expand Up @@ -238,12 +233,7 @@ struct DeviceTensor : public ttg::TTValue<DeviceTensor<_T, _Range, _Storage>>
DeviceTensor& operator=(DeviceTensor&& x) noexcept {
ttvalue_type::operator=(std::move(x));
tensor_type::operator=(static_cast<tensor_type&&>(x));
if (this->size() == 0 || this->data() == x.b.host_ptr()){
b = std::move(x.b);
} else {
b = ttg::Buffer<_T>(this->size() ? this->data() : nullptr, this->size());
}
//std::swap(x.b, b);
b = std::move(x.b);
//std::cout << "DeviceTensor move ctor" << std::endl;
return *this;
}
Expand Down

0 comments on commit c8c2b95

Please sign in to comment.