24#ifndef MORPHEUS_CSR_OPENMP_CONVERT_IMPL_HPP
25#define MORPHEUS_CSR_OPENMP_CONVERT_IMPL_HPP
27#include <Morpheus_Macros.hpp>
28#if defined(MORPHEUS_ENABLE_OPENMP)
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>
39template <
typename ExecSpace,
typename SourceType,
typename DestinationType>
41 const SourceType& src, DestinationType& dst,
42 typename std::enable_if<
43 Morpheus::is_csr_matrix_format_container_v<SourceType> &&
44 Morpheus::is_csr_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* =
49 using size_type =
typename SourceType::size_type;
51 dst.resize(src.nrows(), src.ncols(), src.nnnz());
54#pragma omp parallel for
55 for (size_type n = 0; n < src.nrows() + 1; n++) {
56 dst.row_offsets(n) = src.crow_offsets(n);
59#pragma omp parallel for
60 for (size_type n = 0; n < src.nnnz(); n++) {
61 dst.column_indices(n) = src.ccolumn_indices(n);
64#pragma omp parallel for
65 for (size_type n = 0; n < src.nnnz(); n++) {
66 dst.values(n) = src.cvalues(n);
70template <
typename ExecSpace,
typename SourceType,
typename DestinationType>
72 const SourceType& src, DestinationType& dst,
73 typename std::enable_if<
74 Morpheus::is_csr_matrix_format_container_v<SourceType> &&
75 Morpheus::is_coo_matrix_format_container_v<DestinationType> &&
76 Morpheus::has_custom_backend_v<ExecSpace> &&
77 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
78 Morpheus::has_access_v<ExecSpace, SourceType, DestinationType>>::type* =
80 using size_type =
typename SourceType::size_type;
81 using index_type =
typename SourceType::index_type;
83 dst.resize(src.nrows(), src.ncols(), src.nnnz());
86#pragma omp parallel for
87 for (size_type i = 0; i < src.nrows(); i++) {
88 for (index_type jj = src.crow_offsets(i); jj < src.crow_offsets(i + 1);
90 dst.row_indices(jj) = i;
94#pragma omp parallel for
95 for (size_type n = 0; n < src.nnnz(); n++) {
96 dst.column_indices(n) = src.ccolumn_indices(n);
99#pragma omp parallel for
100 for (size_type n = 0; n < src.nnnz(); n++) {
101 dst.values(n) = src.cvalues(n);
105template <
typename ExecSpace,
typename SourceType,
typename DestinationType>
107 const SourceType&, DestinationType&,
108 typename std::enable_if<
109 Morpheus::is_coo_matrix_format_container_v<SourceType> &&
110 Morpheus::is_csr_matrix_format_container_v<DestinationType> &&
111 Morpheus::has_custom_backend_v<ExecSpace> &&
112 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
113 Morpheus::has_access_v<ExecSpace, SourceType, DestinationType>>::type* =
Definition: Morpheus_Exceptions.hpp:43
Generic Morpheus interfaces.
Definition: dummy.cpp:24