24#ifndef MORPHEUS_DENSEMATRIX_OPENMP_CONVERT_IMPL_HPP
25#define MORPHEUS_DENSEMATRIX_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_dense_matrix_format_container_v<SourceType> &&
44 Morpheus::is_dense_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 MORPHEUS_ASSERT((dst.nrows() >= src.nrows()) && (dst.ncols() >= src.ncols()),
52 "Destination matrix must have equal or larger shape to the "
55#pragma omp parallel for collapse(2)
56 for (size_type i = 0; i < src.nrows(); i++) {
57 for (size_type j = 0; j < src.ncols(); j++) {
58 dst(i, j) = src(i, j);
63template <
typename ExecSpace,
typename SourceType,
typename DestinationType>
65 const SourceType& src, DestinationType& dst,
66 typename std::enable_if<
67 Morpheus::is_dense_matrix_format_container_v<SourceType> &&
68 Morpheus::is_dense_vector_format_container_v<DestinationType> &&
69 Morpheus::has_custom_backend_v<ExecSpace> &&
70 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
71 Morpheus::has_access_v<ExecSpace, SourceType, DestinationType>>::type* =
73 using size_type =
typename SourceType::size_type;
75 dst.resize(src.nrows() * src.ncols());
77#pragma omp parallel for collapse(2)
78 for (size_type i = 0; i < src.nrows(); i++) {
79 for (size_type j = 0; j < src.ncols(); j++) {
80 size_type idx = i * src.ncols() + j;
86template <
typename ExecSpace,
typename SourceType,
typename DestinationType>
88 const SourceType&, DestinationType&,
89 typename std::enable_if<
90 Morpheus::is_dense_matrix_format_container_v<SourceType> &&
91 Morpheus::is_coo_matrix_format_container_v<DestinationType> &&
92 Morpheus::has_custom_backend_v<ExecSpace> &&
93 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
94 Morpheus::has_access_v<ExecSpace, SourceType, DestinationType>>::type* =
99template <
typename ExecSpace,
typename SourceType,
typename DestinationType>
101 const SourceType& src, DestinationType& dst,
102 typename std::enable_if<
103 Morpheus::is_coo_matrix_format_container_v<SourceType> &&
104 Morpheus::is_dense_matrix_format_container_v<DestinationType> &&
105 Morpheus::has_custom_backend_v<ExecSpace> &&
106 Morpheus::has_openmp_execution_space_v<ExecSpace> &&
107 Morpheus::has_access_v<ExecSpace, SourceType, DestinationType>>::type* =
109 using size_type =
typename SourceType::size_type;
111 dst.resize(src.nrows(), src.ncols());
113#pragma omp parallel for
114 for (size_type n = 0; n < src.nnnz(); n++) {
115 size_type i = src.crow_indices(n);
116 size_type j = src.ccolumn_indices(n);
117 dst(i, j) = src.cvalues(n);
Definition: Morpheus_Exceptions.hpp:43
Generic Morpheus interfaces.
Definition: dummy.cpp:24