Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Csr/Kernels/Morpheus_MatrixOperations_Impl.hpp
1
24#ifndef MORPHEUS_CSR_KERNELS_MATRIXOPERATIONS_IMPL_HPP
25#define MORPHEUS_CSR_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_csr_diagonal_kernel(const SizeType nrows,
36 const IndexType* Ap,
37 const IndexType* Aj, ValueType* Ax,
38 const ValueType* diagonal) {
39 const SizeType thread_id = blockDim.x * blockIdx.x + threadIdx.x;
40 const SizeType grid_size = gridDim.x * blockDim.x;
41
42 for (SizeType row = thread_id; row < nrows; row += grid_size) {
43 const IndexType row_start = Ap[row];
44 const IndexType row_end = Ap[row + 1];
45
46 for (IndexType jj = row_start; jj < row_end; jj++) {
47 if (Aj[jj] == row) {
48 Ax[jj] = diagonal[row];
49 break;
50 }
51 }
52 }
53}
54
55} // namespace Kernels
56} // namespace Impl
57} // namespace Morpheus
58
59#endif // MORPHEUS_ENABLE_CUDA || MORPHEUS_ENABLE_HIP
60#endif // MORPHEUS_CSR_KERNELS_MATRIXOPERATIONS_IMPL_HPP
Generic Morpheus interfaces.
Definition: dummy.cpp:24