Skip to content

Commit

Permalink
Get rid of VectorSpaceVector in the Cuda Vector class.
Browse files Browse the repository at this point in the history
  • Loading branch information
bangerth committed Jul 3, 2023
1 parent bd1bf2c commit 78d062c
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 138 deletions.
64 changes: 30 additions & 34 deletions include/deal.II/lac/cuda_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,20 @@ namespace LinearAlgebra
namespace CUDAWrappers
{
/**
* This class implements a vector using CUDA for use on Nvidia GPUs. This
* class is derived from the LinearAlgebra::VectorSpaceVector class.
* This class implements a vector using CUDA for use on Nvidia GPUs.
*
* @note Only float and double are supported.
*
* @see CUDAWrappers
* @ingroup Vectors
*/
template <typename Number>
class Vector : public VectorSpaceVector<Number>
class Vector
{
public:
using value_type = typename VectorSpaceVector<Number>::value_type;
using size_type = typename VectorSpaceVector<Number>::size_type;
using real_type = typename VectorSpaceVector<Number>::real_type;
using value_type = Number;
using size_type = types::global_dof_index;
using real_type = typename numbers::NumberTraits<Number>::real_type;

/**
* Constructor. Create a vector of dimension zero.
Expand Down Expand Up @@ -128,9 +127,8 @@ namespace LinearAlgebra
* Change the dimension to that of the vector V. The elements of V are not
* copied.
*/
virtual void
reinit(const VectorSpaceVector<Number> &V,
const bool omit_zeroing_entries = false) override;
void
reinit(const Vector<Number> &V, const bool omit_zeroing_entries = false);

/**
* Import all the element from the input vector @p V.
Expand Down Expand Up @@ -181,20 +179,20 @@ namespace LinearAlgebra
/**
* Add the vector @p V to the present one.
*/
virtual Vector<Number> &
operator+=(const VectorSpaceVector<Number> &V) override;
Vector<Number> &
operator+=(const Vector<Number> &V);

/**
* Subtract the vector @p V from the present one.
*/
virtual Vector<Number> &
operator-=(const VectorSpaceVector<Number> &V) override;
Vector<Number> &
operator-=(const Vector<Number> &V);

/**
* Return the scalar product of two vectors.
*/
virtual Number
operator*(const VectorSpaceVector<Number> &V) const override;
Number
operator*(const Vector<Number> &V) const;

/**
* Add @p to all components. Note that @p a is a scalar not a vector.
Expand All @@ -205,40 +203,38 @@ namespace LinearAlgebra
/**
* Simple addition of a multiple of a vector, i.e. <tt>*this += a*V</tt>.
*/
virtual void
add(const Number a, const VectorSpaceVector<Number> &V) override;
void
add(const Number a, const Vector<Number> &V);

/**
* Multiple additions of scaled vectors, i.e. <tt>*this += a*V+b*W</tt>.
*/
virtual void
add(const Number a,
const VectorSpaceVector<Number> &V,
const Number b,
const VectorSpaceVector<Number> &W) override;
void
add(const Number a,
const Vector<Number> &V,
const Number b,
const Vector<Number> &W);

/**
* Scaling and simple addition of a multiple of a vector, i.e. <tt>*this
* = s*(*this)+a*V</tt>
*/
virtual void
sadd(const Number s,
const Number a,
const VectorSpaceVector<Number> &V) override;
void
sadd(const Number s, const Number a, const Vector<Number> &V);

/**
* Scale each element of this vector by the corresponding element in the
* argument. This function is mostly meant to simulate multiplication
* (and immediate re-assignment) by a diagonal scaling matrix.
*/
virtual void
scale(const VectorSpaceVector<Number> &scaling_factors) override;
void
scale(const Vector<Number> &scaling_factors);

/**
* Assignment <tt>*this = a*V</tt>.
*/
virtual void
equ(const Number a, const VectorSpaceVector<Number> &V) override;
void
equ(const Number a, const Vector<Number> &V);

/**
* Return whether the vector contains only elements with value zero.
Expand Down Expand Up @@ -298,10 +294,10 @@ namespace LinearAlgebra
* For complex-valued vectors, the scalar product in the second step is
* implemented as $\left<v,w\right>=\sum_i v_i \bar{w_i}$.
*/
virtual Number
add_and_dot(const Number a,
const VectorSpaceVector<Number> &V,
const VectorSpaceVector<Number> &W) override;
Number
add_and_dot(const Number a,
const Vector<Number> &V,
const Vector<Number> &W);

/**
* Return the pointer to the underlying array. Ownership still resides
Expand Down

0 comments on commit 78d062c

Please sign in to comment.