BLAS1 – KokkosKernels blas1 interfaces

abs

template<class execution_space, class RMV, class XMV>
void KokkosBlas::abs(const execution_space &space, const RMV &R, const XMV &X)

R(i,j) = abs(X(i,j))

Non-blocking function to replace each entry in R with the absolute value (magnitude) of the corresponding entry in X.

Template Parameters:
  • execution_space – a Kokkos execution space to run the kernels on.

  • RMV – 1-D or 2-D Kokkos::View specialization.

  • XMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as RMV, and its entries must be assignable to those of RMV.

Parameters:
  • space – [in] an execution_space instance where the kernel will run.

  • R – [out] view of type RMV that contains the absolute value X on output.

  • X – [in] view of type XMV.

template<class RMV, class XMV>
void KokkosBlas::abs(const RMV &R, const XMV &X)

R(i,j) = abs(X(i,j))

Non-blocking function to replace each entry in R with the absolute value (magnitude) of the corresponding entry in X. The kernel is executed in the default stream/queue associated with the execution space of RMV.

Template Parameters:
  • RMV – 1-D or 2-D Kokkos::View specialization.

  • XMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as RMV, and its entries must be assignable to those of RMV.

Parameters:
  • R – [out] view of type RMV that contains the absolute value X on output.

  • X – [in] view of type XMV.

axpby

template<class execution_space, class AV, class XMV, class BV, class YMV>
void KokkosBlas::axpby(const execution_space &exec_space, const AV &a, const XMV &X, const BV &b, const YMV &Y)

Computes Y := a*X + b*Y.

This function is non-blocking and thread-safe.

Template Parameters:
  • execution_space – The type of execution space where the kernel will run.

  • AV – Scalar or 0-D or 1-D Kokkos::View.

  • XMV – 1-D Kokkos::View or 2-D Kokkos::View. It must have the same rank as YMV.

  • BV – Scalar or 0-D or 1-D Kokkos::View.

  • YMV – 1-D or 2-D Kokkos::View.

Parameters:
  • exec_space – [in] The execution space instance on which the kernel will run.

  • a – [in] Input of type AV:

    • scaling parameter for 1-D or 2-D X,

    • scaling parameters for 2-D X.

  • X – [in] View of type XMV. It must have the same extent(s) as Y.

  • b – [in] input of type BV:

    • scaling parameter for 1-D or 2-D Y,

    • scaling parameters for 2-D Y.

  • Y – [in/out] View of type YMV in which the results will be stored.

template<class AV, class XMV, class BV, class YMV>
void KokkosBlas::axpby(const AV &a, const XMV &X, const BV &b, const YMV &Y)

Computes Y := a*X + b*Y.

This function is non-blocking and thread-safe. The kernel is executed in the default stream/queue associated with the execution space of XMV.

Template Parameters:
  • AV – Scalar or 0-D Kokkos::View or 1-D Kokkos::View.

  • XMV – 1-D Kokkos::View or 2-D Kokkos::View. It must have the same rank as YMV.

  • BV – Scalar or 0-D Kokkos::View or 1-D Kokkos::View.

  • YMV – 1-D Kokkos::View or 2-D Kokkos::View.

Parameters:
  • a – [in] Input of type AV:

    • scaling parameter for 1-D or 2-D X,

    • scaling parameters for 2-D X.

  • X – [in] View of type XMV. It must have the same extent(s) as Y.

  • b – [in] input of type BV:

    • scaling parameter for 1-D or 2-D Y,

    • scaling parameters for 2-D Y.

  • Y – [in/out] View of type YMV in which the results will be stored.

dot

template<class RV, class XMV, class YMV>
void KokkosBlas::dot(const RV &R, const XMV &X, const YMV &Y, typename std::enable_if<Kokkos::is_view<RV>::value, int>::type = 0)

Compute the column-wise dot products of two multivectors.

This function is non-blocking and thread-safe. The kernel is executed in the default stream/queue associated with the execution space of XVM.

This function implements a few different use cases:

  • If X and Y are both 1-D, then this is a single dot product. R must be 0-D (a View of a single value).

  • If X and Y are both 2-D, then this function computes their dot products columnwise. R must be 1-D.

  • If X is 2-D and Y is 1-D, then this function computes the dot product of each column of X, with Y, in turn. R must be 1-D.

  • If X is 1-D and Y is 2-D, then this function computes the dot product X with each column of Y, in turn. R must be 1-D.

Note

To implementers: We use enable_if here so that the compiler doesn’t confuse this version of dot() with the three-argument version of dot() in Kokkos_Blas1.hpp.

Template Parameters:
  • RV – 0-D resp. 1-D output View

  • XMV – 1-D resp. 2-D input View

  • YMV – 1-D resp. 2-D input View

Parameters:
  • R – [out] Output 1-D or 0-D View to which to write results.

  • X – [in] Input 2-D or 1-D View.

  • Y – [in] Input 2-D or 1-D View.

template<class XVector, class YVector>
Kokkos::Details::InnerProductSpaceTraits<typename XVector::non_const_value_type>::dot_type KokkosBlas::dot(const XVector &x, const YVector &y)

Return the dot product of the two vectors x and y.

The kernel is executed in the default stream/queue associated with the execution space of XVector.

Template Parameters:
  • XVector – Type of the first vector x; a 1-D Kokkos::View.

  • YVector – Type of the second vector y; a 1-D Kokkos::View.

Parameters:
  • x – [in] Input 1-D View.

  • y – [in] Input 1-D View.

Returns:

The dot product result; a single value.

fill

template<class execution_space, class XMV>
void KokkosBlas::fill(const execution_space &space, const XMV &X, const typename XMV::non_const_value_type &val)

Fill the multivector or single vector X with the given value.

This function is non-blocking and thread-safe

Template Parameters:
  • execution_space – a Kokkos execution space

  • XMV – 1-D or 2-D output View

Parameters:
  • space – [in] A Kokkos instance of execution_space on which the kernel will run.

  • X – [out] Output View (1-D or 2-D).

  • val – [in] Value with which to fill the entries of X.

template<class XMV>
void KokkosBlas::fill(const XMV &X, const typename XMV::non_const_value_type &val)

Fill the multivector or single vector X with the given value.

This function is non-blocking and thread-safe The kernel is executed in the default stream/queue associated with the execution space of XMV.

Template Parameters:

XMV – 1-D or 2-D output View

Parameters:
  • X – [out] Output View (1-D or 2-D).

  • val – [in] Value with which to fill the entries of X.

mult

template<class execution_space, class YMV, class AV, class XMV>
void KokkosBlas::mult(const execution_space &space, typename YMV::const_value_type &gamma, const YMV &Y, typename AV::const_value_type &alpha, const AV &A, const XMV &X)

Element wise multiplication of two vectors: Y[i] = gamma * Y[i] + alpha * A[i] * X[i].

This function is non-blocking and thread-safe

Template Parameters:
  • execution_type – a Kokkos execution space type.

  • YMV – Type of the first vector Y; a 1-D or 2-D Kokkos::View.

  • AV – Type of the second vector A; a 1-D Kokkos::View.

  • XMV – Type of the third vector X; a 1-D or 2-D Kokkos::View.

Parameters:
  • space – [in] An instance of execution_space on which the kernel will run (it may specify an execution stream/queue).

  • gamma – [in] The scalar to apply to Y.

  • Y – [in/out] The Y vector.

  • alpha – [in] The scalar to apply to A.

  • A – [in] The vector to apply to X.

  • X – [in] The X vector.

template<class YMV, class AV, class XMV>
void KokkosBlas::mult(typename YMV::const_value_type &gamma, const YMV &Y, typename AV::const_value_type &alpha, const AV &A, const XMV &X)

Element wise multiplication of two vectors: Y[i] = gamma * Y[i] + alpha * A[i] * X[i].

This function is non-blocking and thread-safe The kernel is executed in the default stream/queue associated with the execution space of YMV.

Template Parameters:
  • YMV – Type of the first vector Y; a 1-D or 2-D Kokkos::View.

  • AV – Type of the second vector A; a 1-D Kokkos::View.

  • XMV – Type of the third vector X; a 1-D or 2-D Kokkos::View.

Parameters:
  • gamma – [in] The scalar to apply to Y.

  • Y – [in/out] The Y vector.

  • alpha – [in] The scalar to apply to A.

  • A – [in] The vector to apply to X.

  • X – [in] The X vector.

nrm1

template<class RV, class XMV>
void KokkosBlas::nrm1(const RV &R, const XMV &X, typename std::enable_if<Kokkos::is_view<RV>::value, int>::type = 0)

R(j) = nrm1(X(i,j))

Replace each entry in R with the nrm1olute value (magnitude) of the corresponding entry in X. This function is non-blocking and thread-safe. The kernel is executed in the default stream/queue associated with the execution space of XMV.

Template Parameters:
  • RMV – 1-D or 2-D Kokkos::View specialization.

  • XMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as RMV, and its entries must be assignable to those of RMV.

Parameters:
  • R – [out] Output 1-D View containing the result

  • X – [in] Input 1-D View.

template<class XVector>
Kokkos::Details::InnerProductSpaceTraits<typename XVector::non_const_value_type>::mag_type KokkosBlas::nrm1(const XVector &x)

Return the nrm1 of the vector x.

Template Parameters:

XVector – Type of the first vector x; a 1-D Kokkos::View.

Parameters:

x – [in] Input 1-D View.

Returns:

The nrm1 product result; a single value.

nrm2

template<class RV, class XMV>
void KokkosBlas::nrm2(const RV &R, const XMV &X, typename std::enable_if<Kokkos::is_view<RV>::value, int>::type = 0)

R(i,j) = nrm2(X(i,j))

Replace each entry in R with the nrm2olute value (magnitude) of the corresponding entry in X. This function is non-blocking and thread-safe The kernel is executed in the default stream/queue associated with the execution space of XMV.

where the kernel will be executed.

Template Parameters:
  • RMV – 1-D or 2-D Kokkos::View specialization.

  • XMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as RMV, and its entries must be assignable to those of RMV.

Parameters:
  • R – [out] Output View containing results (rank 0 or 1).

  • X – [in] Input View (rank 1 or 2).

template<class XVector>
Kokkos::Details::InnerProductSpaceTraits<typename XVector::non_const_value_type>::mag_type KokkosBlas::nrm2(const XVector &x)

Return the nrm2 of the vector x.

The kernel is executed in the default stream/queue associated with the execution space of XVector.

Template Parameters:

XVector – Type of the first vector x; a 1-D Kokkos::View.

Parameters:

x – [in] Input 1-D View.

Returns:

The nrm2 product result; a single value.

nrm2w

template<class RV, class XMV>
void KokkosBlas::nrm2w(const RV &R, const XMV &X, const XMV &W, typename std::enable_if<Kokkos::is_view<RV>::value, int>::type = 0)

R(i,j) = nrm2w(X(i,j))

Replace each entry in R with the nrm2w, absolute value (magnitude), of the corresponding entry in X. This function is non-blocking and thread-safe The kernel is executed in the default stream/queue associated with the execution space of XVM.

Template Parameters:
  • execution_space – a Kokkos execution space where the kernel will run.

  • RMV – 1-D or 2-D Kokkos::View specialization.

  • XMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as RMV, and its entries must be assignable to those of RMV.

Parameters:
  • R – [out] Output View containing results (rank 0 or 1).

  • X – [in] Input View (rank 1 or 2).

  • W – [in] Input View (rank 1 or 2).

template<class XVector>
Kokkos::Details::InnerProductSpaceTraits<typename XVector::non_const_value_type>::mag_type KokkosBlas::nrm2w(const XVector &x, const XVector &w)

Return the nrm2w of the vector x.

The kernel is executed in the default stream/queue associated with the execution space of XVector.

Template Parameters:

XVector – Type of the first vector x; a 1-D Kokkos::View.

Parameters:
  • x – [in] Input 1-D View.

  • w – [in]

Returns:

The nrm2w product result; a single value.

nrminf

template<class RV, class XMV>
void KokkosBlas::nrminf(const RV &R, const XMV &X, typename std::enable_if<Kokkos::is_view<RV>::value, int>::type = 0)

R(j) = nrminf(X(i,j))

Replace each entry in R with the nrminfolute value (magnitude) of the corresponding entry in X.

Template Parameters:
  • RMV – 1-D or 2-D Kokkos::View specialization.

  • XMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as RMV, and its entries must be assignable to those of RMV.

template<class XVector>
Kokkos::Details::InnerProductSpaceTraits<typename XVector::non_const_value_type>::mag_type KokkosBlas::nrminf(const XVector &x)

Return the nrminf of the vector x.

Template Parameters:

XVector – Type of the first vector x; a 1-D Kokkos::View.

Parameters:

x – [in] Input 1-D View.

Returns:

The nrminf product result; a single value.

reciprocal

template<class execution_space, class RMV, class XMV>
void KokkosBlas::reciprocal(const execution_space &space, const RMV &R, const XMV &X)

R(i,j) = reciprocal(X(i,j))

Replace each entry in R with the absolute value (magnitude), of the reciprocal of the corresponding entry in X. This function is non-blocking and thread-safe

Template Parameters:
  • execution_space – a Kokkos execution space

  • RMV – 1-D or 2-D Kokkos::View specialization.

  • XMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as RMV, and its entries must be assignable to those of RMV.

Parameters:
  • space – [in] an instance of execution space where the kernel will run

  • R – [out] a view of type RMV that contains the inverse of the values in X.

  • X – [in] a view of type XMV that contains the values to invert.

template<class RMV, class XMV>
void KokkosBlas::reciprocal(const RMV &R, const XMV &X)

R(i,j) = reciprocal(X(i,j))

Replace each entry in R with the absolute value (magnitude), of the reciprocal of the corresponding entry in X. This function is non-blocking and thread-safe The kernel is executed in the default stream/queue associated with the execution space of RMV.

Template Parameters:
  • RMV – 1-D or 2-D Kokkos::View specialization.

  • XMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as RMV, and its entries must be assignable to those of RMV.

scal

template<class execution_space, class RMV, class AV, class XMV>
void KokkosBlas::scal(const execution_space &space, const RMV &R, const AV &a, const XMV &X)

Computes R := alpha*X.

This function is non-blocking and thread-safe

Template Parameters:
  • execution_space – a Kokkos execution space where the kernel will run.

  • RMV – 1-D or 2-D Kokkos::View specialization.

  • XMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as RMV.

  • AV – 1-D or 2-D Kokkos::View specialization.

Parameters:
  • space – [in] the execution space instance on which the kernel will run.

  • R – [in/out] view of type RMV in which the results will be stored.

  • a – [in] view of type AV, scaling parameter for X.

  • X – [in] input view of type XMV.

template<class RMV, class AV, class XMV>
void KokkosBlas::scal(const RMV &R, const AV &a, const XMV &X)

Computes R := alpha*X.

This function is non-blocking and thread-safe The kernel is executed in the default stream/queue associated with the execution space of YMV.

Template Parameters:
  • RMV – 1-D or 2-D Kokkos::View specialization.

  • XMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as RMV.

  • AV – 1-D or 2-D Kokkos::View specialization.

Parameters:
  • R – [in/out] view of type RMV in which the results will be stored.

  • a – [in] view of type AV, scaling parameter for X.

  • X – [in] input view of type XMV.

sum

template<class RV, class XMV>
void KokkosBlas::sum(const RV &R, const XMV &X, typename std::enable_if<Kokkos::is_view<RV>::value, int>::type = 0)

R(j) = sum(X(i,j))

Replace each entry in R with the sumolute value (magnitude) of the corresponding entry in X. This function is non-blocking and thread-safe. The kernel is executed in the default stream/queue associated with the execution space of XVM.

Template Parameters:
  • RMV – 1-D or 2-D Kokkos::View specialization.

  • XMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as RMV, and its entries must be assignable to those of RMV.

Parameters:
  • R – [out] Output View (rank 0 or 1) containing the results.

  • X – [in] Input View (rank 1 or 2).

swap

template<class execution_space, class XVector, class YVector>
void KokkosBlas::swap(execution_space const &space, XVector const &x, YVector const &y)

Swaps the entries of vectors x and y.

Swaps x and y. Note that this is akin to performing a deep_copy, swapping pointers inside view can only be performed if no aliasing, subviews, etc… exist, which cannot be asserted by this function.

This function is non-blocking unless the underlying TPL requested at compile time is itself blocking

Template Parameters:
  • execution_space – an execution space to perform parallel work

  • XVector – Type of the first vector x; a rank 1 Kokkos::View.

  • YVector – Type of the first vector y; a rank 1 Kokkos::View.

Parameters:
  • space – [in] execution space passed to execution policies

  • x – [in/out] rank 1 View.

  • y – [in/out] rank 1 View.

template<class XVector, class YVector>
void KokkosBlas::swap(const XVector &x, const YVector &y)

Swaps the entries of vectors x and y.

This function is non-blocking unless the underlying TPL requested at compile time is itself blocking. Note that the kernel will be executed on the default stream of the execution_space associted with x.

Template Parameters:
  • XVector – Type of the first vector x; a rank 1 Kokkos::View.

  • YVector – Type of the first vector y; a rank 1 Kokkos::View.

Parameters:
  • x – [in/out] rank 1 View.

  • y – [in/out] rank 1 View.

update

template<class execution_space, class XMV, class YMV, class ZMV>
void KokkosBlas::update(const execution_space &space, const typename XMV::non_const_value_type &alpha, const XMV &X, const typename YMV::non_const_value_type &beta, const YMV &Y, const typename ZMV::non_const_value_type &gamma, const ZMV &Z)

Compute Z := alpha*X + beta*Y + gamma*Z.

This function is non-blocking and thread-safe

Template Parameters:
  • execution_space – a Kokkos execution space where the kernel will run.

  • XMV – 1-D or 2-D Kokkos::View specialization.

  • YMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as XMV.

  • ZMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as XMV and YMV, and it must make sense to add up the entries of XMV and YMV and assign them to the entries of ZMV.

Parameters:
  • space – [in] the execution space instance on which the kernel will run.

  • alpha – [in] scaling parameter for X

  • X – [in] input view of type XMV

  • beta – [in] scaling parameter for Y

  • Y – [in] input view of type YMV

  • gamma – [in] scaling parameter for Z

  • Z – [in/out] view of type ZMV in which the results will be stored.

template<class XMV, class YMV, class ZMV>
void KokkosBlas::update(const typename XMV::non_const_value_type &alpha, const XMV &X, const typename YMV::non_const_value_type &beta, const YMV &Y, const typename ZMV::non_const_value_type &gamma, const ZMV &Z)

Compute Z := alpha*X + beta*Y + gamma*Z.

This function is non-blocking and thread-safe The kernel is executed in the default stream/queue associated with the execution space of ZMV.

Template Parameters:
  • XMV – 1-D or 2-D Kokkos::View specialization.

  • YMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as XMV.

  • ZMV – 1-D or 2-D Kokkos::View specialization. It must have the same rank as XMV and YMV, and it must make sense to add up the entries of XMV and YMV and assign them to the entries of ZMV.

Parameters:
  • alpha – [in] scaling parameter for X

  • X – [in] input view of type XMV

  • beta – [in] scaling parameter for Y

  • Y – [in] input view of type YMV

  • gamma – [in] scaling parameter for Z

  • Z – [in/out] view of type ZMV in which the results will be stored.