Commit 097a0d04 authored by gbalduzz's avatar gbalduzz
Browse files

Avoid potential calls to cudaMemset when instantiating static matrices and vectors.

parent 5c31983c
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -292,8 +292,10 @@ Matrix<ScalarType, device_name>::Matrix(const std::string& name, std::pair<int,
  assert(capacity_.first >= capacity.first && capacity_.second >= capacity.second);

  data_ = Allocator::allocate(nrElements(capacity_));
  if (nrElements(capacity_)) {  // Avoid cuda calls when initializing static matrices.
    util::Memory<device_name>::setToZero(data_, nrElements(capacity_));
  }
}

template <typename ScalarType, DeviceType device_name>
Matrix<ScalarType, device_name>::Matrix(const Matrix<ScalarType, device_name>& rhs,
+3 −1
Original line number Diff line number Diff line
@@ -206,8 +206,10 @@ Vector<ScalarType, device_name, Allocator>::Vector(const std::string& name, size
    : name_(name), size_(size), capacity_(capacity), data_(nullptr) {
  assert(capacity_ >= size_);
  data_ = Allocator::allocate(capacity_);
  if(size) { // Avoid cuda calls when initializing static vectors.
      util::Memory<device_name>::setToZero(data_, capacity_);
  }
}

template <typename ScalarType, DeviceType device_name, class Allocator>
Vector<ScalarType, device_name, Allocator>::Vector(const ThisType& rhs, const std::string& name)