40 #include <ginkgo/ginkgo.hpp> 42 #include <collective_common.hpp> 47 template <
typename ValueType,
typename IndexType>
48 extern void scatter_add_values(
const IndexType num_elems,
49 const IndexType *indices,
50 const ValueType *from_array,
51 ValueType *into_array);
53 template <
typename ValueType,
typename IndexType>
54 extern void scatter_diff_values(
const IndexType num_elems,
55 const IndexType *indices,
56 const ValueType *from_array,
57 ValueType *into_array);
59 template <
typename ValueType,
typename IndexType>
60 extern void scatter_avg_values(
const IndexType num_elems,
61 const IndexType *indices,
62 const ValueType *from_array,
63 ValueType *into_array);
65 template <
typename ValueType,
typename IndexType>
66 extern void scatter_values(
const IndexType num_elems,
const IndexType *indices,
67 const ValueType *from_array, ValueType *into_array);
70 template <
typename ValueType,
typename IndexType>
72 Scatter(
const IndexType num_elems,
const IndexType *indices,
73 const ValueType *from_array, ValueType *into_array,
75 : num_elems{num_elems},
77 from_array{from_array},
78 into_array{into_array},
82 void run(std::shared_ptr<const gko::OmpExecutor>)
const override 86 #pragma omp parallel for 87 for (
auto i = 0; i < num_elems; ++i) {
88 into_array[indices[i]] = from_array[i];
92 #pragma omp parallel for 93 for (
auto i = 0; i < num_elems; ++i) {
94 into_array[indices[i]] = from_array[i] + into_array[indices[i]];
98 #pragma omp parallel for 99 for (
auto i = 0; i < num_elems; ++i) {
100 into_array[indices[i]] = from_array[i] - into_array[indices[i]];
104 #pragma omp parallel for 105 for (
auto i = 0; i < num_elems; ++i) {
106 into_array[indices[i]] =
107 (from_array[i] + into_array[indices[i]]) / 2;
111 std::cout <<
"Undefined gather operation" << std::endl;
117 void run(std::shared_ptr<const gko::CudaExecutor>)
const override 121 scatter_values(num_elems, indices, from_array, into_array);
124 scatter_add_values(num_elems, indices, from_array, into_array);
127 scatter_diff_values(num_elems, indices, from_array, into_array);
130 scatter_avg_values(num_elems, indices, from_array, into_array);
133 std::cout <<
"Undefined gather operation" << std::endl;
138 const IndexType num_elems;
139 const IndexType *indices;
140 const ValueType *from_array;
141 ValueType *into_array;
142 OperationType optype;
145 #define INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(_macro) \ 146 template _macro(float, gko::int32); \ 147 template _macro(double, gko::int32); \ 148 template _macro(float, gko::int64); \ 149 template _macro(double, gko::int64); 151 #define DECLARE_SCATTER(ValueType, IndexType) \ 152 struct Scatter<ValueType, IndexType> 153 INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(DECLARE_SCATTER);
154 #undef DECLARE_SCATTER 159 #endif // gather_scatter.hpp Definition: scatter.hpp:71
The Schwarz wrappers namespace.
Definition: comm_helpers.hpp:49