Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Dia/OpenMP/Morpheus_Convert_Impl.hpp
1
24#ifndef MORPHEUS_DIA_OPENMP_CONVERT_IMPL_HPP
25#define MORPHEUS_DIA_OPENMP_CONVERT_IMPL_HPP
26
27#include <Morpheus_Macros.hpp>
28#if defined(MORPHEUS_ENABLE_OPENMP)
29
30#include <Morpheus_Exceptions.hpp>
31#include <Morpheus_SpaceTraits.hpp>
32#include <Morpheus_FormatTraits.hpp>
33#include <Morpheus_FormatTags.hpp>
34#include <Morpheus_Spaces.hpp>
35
36namespace Morpheus {
37namespace Impl {
38
39template <typename ExecSpace, typename SourceType, typename DestinationType>
40void convert(
41 const SourceType& src, DestinationType& dst,
42 typename std::enable_if<
43 Morpheus::is_dia_matrix_format_container_v<SourceType> &&
44 Morpheus::is_dia_matrix_format_container_v<DestinationType> &&
45 Morpheus::has_custom_backend_v<ExecSpace> &&
46 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
47 Morpheus::has_access_v<ExecSpace, SourceType, DestinationType>>::type* =
48 nullptr) {
49 using size_type = typename SourceType::size_type;
50
51 dst.resize(src.nrows(), src.ncols(), src.nnnz(),
52 src.cdiagonal_offsets().size());
53
54// element-wise copy of indices and values
55#pragma omp parallel for
56 for (size_type n = 0; n < (size_type)src.cdiagonal_offsets().size(); n++) {
57 dst.diagonal_offsets(n) = src.cdiagonal_offsets(n);
58 }
59
60#pragma omp parallel for
61 for (size_type j = 0; j < src.cvalues().ncols(); j++) {
62 for (size_type i = 0; i < src.cvalues().nrows(); i++) {
63 dst.values(i, j) = src.cvalues(i, j);
64 }
65 }
66}
67
68template <typename ExecSpace, typename SourceType, typename DestinationType>
69void convert(
70 const SourceType&, DestinationType&,
71 typename std::enable_if<
72 Morpheus::is_dia_matrix_format_container_v<SourceType> &&
73 Morpheus::is_coo_matrix_format_container_v<DestinationType> &&
74 Morpheus::has_custom_backend_v<ExecSpace> &&
75 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
76 Morpheus::has_access_v<ExecSpace, SourceType, DestinationType>>::type* =
77 nullptr) {
78 throw Morpheus::NotImplementedException("convert<Kokkos::OpenMP>");
79}
80
81template <typename ExecSpace, typename SourceType, typename DestinationType>
82void convert(
83 const SourceType&, DestinationType&,
84 typename std::enable_if<
85 Morpheus::is_coo_matrix_format_container_v<SourceType> &&
86 Morpheus::is_dia_matrix_format_container_v<DestinationType> &&
87 Morpheus::has_custom_backend_v<ExecSpace> &&
88 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
89 Morpheus::has_access_v<ExecSpace, SourceType, DestinationType>>::type* =
90 nullptr) {
91 throw Morpheus::NotImplementedException("convert<Kokkos::OpenMP>");
92}
93
94} // namespace Impl
95} // namespace Morpheus
96
97#endif // MORPHEUS_ENABLE_OPENMP
98#endif // MORPHEUS_DIA_OPENMP_CONVERT_IMPL_HPP
Definition: Morpheus_Exceptions.hpp:43
Generic Morpheus interfaces.
Definition: dummy.cpp:24