10 #ifndef IFPACK2_DETAILS_MULTIVECTORLOCALGATHERSCATTER_HPP
11 #define IFPACK2_DETAILS_MULTIVECTORLOCALGATHERSCATTER_HPP
17 #include "Tpetra_MultiVector.hpp"
18 #include "Tpetra_Map.hpp"
51 template<
class MV_in,
class MV_out>
54 typedef typename MV_in::scalar_type InScalar;
55 typedef typename MV_out::scalar_type OutScalar;
56 typedef typename MV_in::local_ordinal_type LO;
57 typedef typename MV_in::global_ordinal_type GO;
58 typedef typename MV_in::node_type NO;
64 gather (MV_out& X_out,
69 const size_t numRows = X_out.getLocalLength ();
70 const size_t numVecs = X_in.getNumVectors ();
72 for (
size_t j = 0; j < numVecs; ++j) {
73 ArrayRCP<const InScalar> X_in_j = X_in.getData(j);
74 ArrayRCP<OutScalar> X_out_j = X_out.getDataNonConst(j);
75 for (
size_t i = 0; i < numRows; ++i) {
76 const size_t i_perm = perm[i];
77 X_out_j[i] = X_in_j[i_perm];
94 const size_t numBlocks = X_out.getLocalLength() / blockSize;
95 const size_t numVecs = X_in.getNumVectors ();
97 for (
size_t j = 0; j < numVecs; ++j) {
98 ArrayRCP<const InScalar> X_in_j = X_in.getData(j);
99 ArrayRCP<OutScalar> X_out_j = X_out.getDataNonConst(j);
100 for (
size_t i = 0; i < numBlocks; ++i) {
101 const size_t i_perm = perm[i];
102 for (LO k = 0; k < blockSize; k++) {
103 X_out_j[i * blockSize + k] = X_in_j[i_perm * blockSize + k];
111 scatter (MV_in& X_in,
116 const size_t numRows = X_out.getLocalLength();
117 const size_t numVecs = X_in.getNumVectors();
119 for (
size_t j = 0; j < numVecs; ++j) {
120 ArrayRCP<InScalar> X_in_j = X_in.getDataNonConst(j);
121 ArrayRCP<const OutScalar> X_out_j = X_out.getData(j);
122 for (
size_t i = 0; i < numRows; ++i) {
123 const size_t i_perm = perm[i];
124 X_in_j[i_perm] = X_out_j[i];
138 const size_t numBlocks = X_out.getLocalLength() / blockSize;
139 const size_t numVecs = X_in.getNumVectors ();
141 for (
size_t j = 0; j < numVecs; ++j) {
142 ArrayRCP<const InScalar> X_in_j = X_in.getData(j);
143 ArrayRCP<OutScalar> X_out_j = X_out.getDataNonConst(j);
144 for (
size_t i = 0; i < numBlocks; ++i) {
145 const size_t i_perm = perm[i];
146 for (LO k = 0; k < blockSize; k++) {
147 X_in_j[i_perm * blockSize + k] = X_out_j[i * blockSize + k];
157 template<
typename InView,
typename OutView>
158 void gatherViewToView(OutView X_out,
164 for(
size_t j = 0; j < X_out.extent(1); ++j) {
165 for(
size_t i = 0; i < X_out.extent(0); ++i) {
166 const LO i_perm = perm[i];
167 X_out(i, j) = X_in(i_perm, j);
172 template<
typename InView,
typename OutView>
173 void scatterViewToView(InView X_in,
178 for(
size_t j = 0; j < X_out.extent(1); ++j) {
179 for(
size_t i = 0; i < X_out.extent(0); ++i) {
180 const LO i_perm = perm[i];
181 X_in(i_perm, j) = X_out(i, j);
186 template<
typename InView,
typename OutView>
187 void gatherViewToViewBlock(OutView X_out,
194 size_t numBlocks = X_out.extent(0) / blockSize;
195 for(
size_t j = 0; j < X_out.extent(1); ++j) {
196 for(
size_t i = 0; i < numBlocks; ++i) {
197 const LO i_perm = perm[i];
198 for(LO k = 0; k < blockSize; k++) {
199 X_out(i * blockSize + k, j) = X_in(i_perm * blockSize + k, j);
205 template<
typename InView,
typename OutView>
206 void scatterViewToViewBlock(InView X_in,
213 size_t numBlocks = X_out.extent(0) / blockSize;
214 for(
size_t j = 0; j < X_out.extent(1); ++j) {
215 for(
size_t i = 0; i < numBlocks; ++i) {
216 const LO i_perm = perm[i];
217 for(LO k = 0; k < blockSize; k++) {
218 X_in(i_perm * blockSize + k, j) = X_out(i * blockSize + k, j);
227 template<
typename InView>
228 void gatherMVtoView(MV_out X_out,
234 size_t numRows = X_out.getLocalLength();
235 for(
size_t j = 0; j < X_out.getNumVectors(); ++j) {
237 for(
size_t i = 0; i < numRows; ++i) {
238 const LO i_perm = perm[i];
239 X_out_j[i] = X_in(i_perm, j);
244 template<
typename InView>
245 void scatterMVtoView(InView X_in,
249 size_t numRows = X_out.getLocalLength();
251 for(
size_t j = 0; j < X_in.extent(1); ++j) {
253 for(
size_t i = 0; i < numRows; ++i) {
254 const LO i_perm = perm[i];
255 X_in(i_perm, j) = X_out_j[i];
260 template<
typename InView>
261 void gatherMVtoViewBlock(MV_out X_out,
267 size_t numBlocks = X_out.getLocalLength() / blockSize;
269 for(
size_t j = 0; j < X_out.getNumVectors(); ++j) {
271 for(
size_t i = 0; i < numBlocks; ++i) {
272 const LO i_perm = perm[i];
273 for(LO k = 0; k < blockSize; k++) {
274 X_out_j[i * blockSize + k] = X_in(i_perm * blockSize + k, j);
280 template<
typename InView>
281 void scatterMVtoViewBlock(InView X_in,
286 size_t numBlocks = X_out.getLocalLength() / blockSize;
288 for(
size_t j = 0; j < X_in.extent(1); ++j) {
290 for(
size_t i = 0; i < numBlocks; ++i) {
291 const LO i_perm = perm[i];
292 for(LO k = 0; k < blockSize; k++) {
293 X_in(i_perm * blockSize + k, j) = X_out_j[i * blockSize + k];
303 #endif // IFPACK2_DETAILS_MULTIVECTORLOCALGATHERSCATTER_HPP
Implementation detail of Ifpack2::Container subclasses.
Definition: Ifpack2_Details_MultiVectorLocalGatherScatter.hpp:52