Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
DenseVector/Kernels/Morpheus_WAXPBY_Impl.hpp
1
24#ifndef MORPHEUS_DENSEVECTOR_KERNELS_WAXPBY_IMPL_HPP
25#define MORPHEUS_DENSEVECTOR_KERNELS_WAXPBY_IMPL_HPP
26
27#if defined(MORPHEUS_ENABLE_HIP)
28#include <impl/Morpheus_HIPUtils.hpp>
29#elif defined(MORPHEUS_ENABLE_CUDA)
30#include <impl/Morpheus_CudaUtils.hpp>
31#endif
32
33namespace Morpheus {
34namespace Impl {
35namespace Kernels {
36
37template <typename SizeType, typename ValueType1, typename ValueType2,
38 typename ValueType3>
39__global__ void waxpby_kernel(SizeType n, ValueType1 alpha, const ValueType1* x,
40 ValueType2 beta, const ValueType2* y,
41 ValueType3* w) {
42 const SizeType tid = blockDim.x * blockIdx.x + threadIdx.x;
43 if (tid > n) return;
44
45 if (alpha == 1.0) {
46 w[tid] = x[tid] + beta * y[tid];
47 } else if (beta == 1.0) {
48 w[tid] = alpha * x[tid] + y[tid];
49 } else {
50 w[tid] = alpha * x[tid] + beta * y[tid];
51 }
52}
53} // namespace Kernels
54} // namespace Impl
55} // namespace Morpheus
56
57#endif // MORPHEUS_DENSEVECTOR_KERNELS_WAXPBY_IMPL_HPP
Generic Morpheus interfaces.
Definition: dummy.cpp:24