Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Coo/OpenMP/Morpheus_Convert_Impl.hpp
1
24#ifndef MORPHEUS_COO_OPENMP_CONVERT_IMPL_HPP
25#define MORPHEUS_COO_OPENMP_CONVERT_IMPL_HPP
26
27#include <Morpheus_Macros.hpp>
28#if defined(MORPHEUS_ENABLE_OPENMP)
29
30#include <Morpheus_SpaceTraits.hpp>
31#include <Morpheus_FormatTraits.hpp>
32#include <Morpheus_FormatTags.hpp>
33#include <Morpheus_Spaces.hpp>
34
35namespace Morpheus {
36namespace Impl {
37
38template <typename ExecSpace, typename SourceType, typename DestinationType>
39void convert(
40 const SourceType& src, DestinationType& dst,
41 typename std::enable_if<
42 Morpheus::is_coo_matrix_format_container_v<SourceType> &&
43 Morpheus::is_coo_matrix_format_container_v<DestinationType> &&
44 Morpheus::has_custom_backend_v<ExecSpace> &&
45 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
46 Morpheus::has_access_v<ExecSpace, SourceType, DestinationType>>::type* =
47 nullptr) {
48 using size_type = typename SourceType::size_type;
49
50 dst.resize(src.nrows(), src.ncols(), src.nnnz());
51
52// element-wise copy of indices and values
53#pragma omp parallel for
54 for (size_type n = 0; n < src.nnnz(); n++) {
55 dst.row_indices(n) = src.crow_indices(n);
56 }
57
58#pragma omp parallel for
59 for (size_type n = 0; n < src.nnnz(); n++) {
60 dst.column_indices(n) = src.ccolumn_indices(n);
61 }
62
63#pragma omp parallel for
64 for (size_type n = 0; n < src.nnnz(); n++) {
65 dst.values(n) = src.cvalues(n);
66 }
67}
68
69} // namespace Impl
70} // namespace Morpheus
71
72#endif // MORPHEUS_ENABLE_OPENMP
73#endif // MORPHEUS_COO_OPENMP_CONVERT_IMPL_HPP
Generic Morpheus interfaces.
Definition: dummy.cpp:24