FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
diagonal_csr.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
10#include <kernel/backend.hpp>
11#include <kernel/util/memory_arbiter.hpp>
12
13namespace FEAT::LAFEM::Arch
14{
17 {
18 template <typename DT_, typename IT_>
19 static void exec_generic_impl(DT_ * diag, const DT_ * const val, const IT_ * const col_idx, const IT_ * const row_ptr, const Index rows);
20
21 template <typename DT_, typename IT_>
22 static void exec_cuda_impl(DT_ * diag, const DT_ * const val, const IT_ * const col_idx, const IT_ * const row_ptr, const Index rows);
23
24 template <typename DT_, typename IT_>
25 static void exec_generic(Memory::Arbiter& diag, const Memory::Arbiter& val, const Memory::Arbiter& col_idx, const Memory::Arbiter& row_ptr, const Index rows)
26 {
31 exec_generic_impl(d_view.get_w(), a_view.get_r(), ci_view.get_r(), rp_view.get_r(), rows);
32 }
33
34 template <typename DT_, typename IT_>
35 static void exec_cuda(Memory::Arbiter& diag, const Memory::Arbiter& val, const Memory::Arbiter& col_idx, const Memory::Arbiter& row_ptr, const Index rows)
36 {
41 exec_cuda_impl(d_view.get_w(), a_view.get_r(), ci_view.get_r(), rp_view.get_r(), rows);
42 }
43
44 template <typename DT_, typename IT_>
45 static void exec(Memory::Arbiter& diag, const Memory::Arbiter& val, const Memory::Arbiter& col_idx, const Memory::Arbiter& row_ptr, const Index rows)
46 {
48 {
50 exec_generic<DT_, IT_>(diag, val, col_idx, row_ptr, rows);
51 break;
52
54#ifdef FEAT_HAVE_MKL
55 Backend::warn_missing("LAFEM::Arch::DiagonalCSR::exec");
56 exec_generic<DT_, IT_>(diag, val, col_idx, row_ptr, rows);
57#else
58 XABORTM("LAFEM::Arch::DiagonalCSR::exec: MKL backend not available!");
59#endif
60 break;
61
63#ifdef FEAT_HAVE_CUDA
64 exec_cuda<DT_, IT_>(diag, val, col_idx, row_ptr, rows);
65#else
66 XABORTM("LAFEM::Arch::DiagonalCSR::exec: CUDA backend not available!");
67#endif
68 break;
69
70 default:
71 XABORTM("LAFEM::Arch::DiagonalCSR::exec: unknown backend!");
72 break;
73 }
74 }
75 };
76
77#ifdef FEAT_EICKT
78 extern template void DiagonalCSR::exec_generic_impl(float *, const float * const, const std::uint32_t * const, const std::uint32_t * const, const Index);
79 extern template void DiagonalCSR::exec_generic_impl(float *, const float * const, const std::uint64_t * const, const std::uint64_t * const, const Index);
80 extern template void DiagonalCSR::exec_generic_impl(double *, const double * const, const std::uint32_t * const, const std::uint32_t * const, const Index);
81 extern template void DiagonalCSR::exec_generic_impl(double *, const double * const, const std::uint64_t * const, const std::uint64_t * const, const Index);
82#endif
83
84} // namespace FEAT::LAFEM::Arch
85
86#ifndef __CUDACC__
87#define KERNEL_LAFEM_ARCH_DIAGONAL_CSR_HPP 1
88#include <kernel/lafem/arch/diagonal_csr_generic.hpp>
89#endif
#define XABORTM(msg)
Abortion macro definition with custom message.
Definition: assertion.hpp:192
FEAT Kernel base header.
static PreferredBackend get_preferred_backend()
get current preferred backend
Definition: backend.cpp:32
static void warn_missing(const char *operation, PreferredBackend preferred_backend, PreferredBackend fallback_backend=PreferredBackend::generic)
issues a warning about unsupported backend usage
Definition: backend.cpp:77
Memory arbiter class.
Typed memory view class.
const T_ * get_r() const
Returns a const typed pointer to the array that grants read access.
T_ * get_w()
Returns a typed pointer to the array that grants write (and read) access.
@ read
read-only access
@ write
write-only access (see attention note above)
std::uint64_t Index
Index data type.
for 0 <= i < n: diag[i] <- A[i][i]