Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Dia/Kernels/Morpheus_MatrixOperations_Impl.hpp
1
24#ifndef MORPHEUS_DIA_KERNELS_MATRIXOPERATIONS_IMPL_HPP
25#define MORPHEUS_DIA_KERNELS_MATRIXOPERATIONS_IMPL_HPP
26
27#include <Morpheus_Macros.hpp>
28#if defined(MORPHEUS_ENABLE_CUDA) || defined(MORPHEUS_ENABLE_HIP)
29
30namespace Morpheus {
31namespace Impl {
32
33namespace Kernels {
34template <typename ValueType, typename IndexType, typename SizeType>
35__global__ void update_dia_diagonal_kernel(const SizeType num_rows,
36 const SizeType num_cols,
37 const SizeType num_diagonals,
38 const SizeType pitch,
39 const IndexType* diagonal_offsets,
40 ValueType* values,
41 const ValueType* diagonal) {
42 const SizeType thread_id = blockDim.x * blockIdx.x + threadIdx.x;
43 const SizeType grid_size = gridDim.x * blockDim.x;
44
45 for (SizeType row = thread_id; row < num_rows; row += grid_size) {
46 for (SizeType n = 0; n < num_diagonals; n++) {
47 const IndexType col = row + diagonal_offsets[n];
48 const SizeType idx = row + pitch * n;
49
50 if ((col >= 0 && col < (IndexType)num_cols) && (col == (IndexType)row)) {
51 values[idx] = (values[idx] == ValueType(0)) ? 0 : diagonal[col];
52 }
53 }
54 }
55}
56
57} // namespace Kernels
58} // namespace Impl
59} // namespace Morpheus
60
61#endif // MORPHEUS_ENABLE_CUDA || MORPHEUS_ENABLE_HIP
62#endif // MORPHEUS_DIA_KERNELS_MATRIXOPERATIONS_IMPL_HPP
Generic Morpheus interfaces.
Definition: dummy.cpp:24