RTOp Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RTOpPack_SPMD_apply_op_def.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // RTOp: Interfaces and Support Software for Vector Reduction Transformation
4 // Operations
5 //
6 // Copyright 2006 NTESS and the RTOp contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef RTOPPACK_SPMD_APPLY_OP_DEF_HPP
12 #define RTOPPACK_SPMD_APPLY_OP_DEF_HPP
13 
15 #include "Teuchos_Workspace.hpp"
16 #include "Teuchos_CommHelpers.hpp"
17 
18 
19 //
20 // Implementation-only utlities!
21 //
22 
23 
24 namespace RTOpPack {
25 
26 
27 RCP<FancyOStream>& spmdApplyOpDumpOut();
28 
29 
30 template<class Scalar>
32 {
34  Teuchos::OSTab tab(out);
35  *out << "globalOffset="<<v.globalOffset()<<"\n";
36  *out << "subDim="<<v.subDim()<<"\n";
37  *out << "values:\n";
38  tab.incrTab();
39  for( int i = 0; i < v.subDim(); ++i )
40  *out << " " << v(i) << ":" << (v.globalOffset()+i);
41  *out << "\n";
42 }
43 
44 
45 } // namespace RTOpPack
46 
47 
48 // ///////////////////////////
49 // Template implementations
50 
51 
52 //
53 // Misc Helper functions
54 //
55 
56 
57 template<class PrimitiveScalar>
59  int num_values,
60  int num_indexes,
61  int num_chars
62  )
63 {
64  return 3 * sizeof(index_type)
65  + num_values * sizeof(PrimitiveScalar)
66  + num_indexes * sizeof(index_type)
67  + num_chars * sizeof(char_type);
68 }
69 
70 
71 template<class Scalar>
73  const RTOpT<Scalar> &op,
74  Ordinal num_values,
75  Ordinal num_indexes,
76  Ordinal num_chars,
77  const ReductTarget &reduct_obj,
78  char reduct_obj_ext[]
79  )
80 {
81  using Teuchos::arrayView;
82  typedef typename RTOpT<Scalar>::primitive_value_type primitive_value_type;
86  const Ordinal
87  prim_value_type_size = PVTST::fromCountToDirectBytes(1),
88  index_type_size = ITST::fromCountToDirectBytes(1);
89  //char_type_size = CTST::fromCountToDirectBytes(1);
90  const Ordinal
91  num_values_off = 0,
92  num_indexes_off = num_values_off + index_type_size,
93  num_chars_off = num_indexes_off + index_type_size,
94  values_off = num_chars_off + index_type_size,
95  indexes_off = values_off + num_values * prim_value_type_size,
96  chars_off = indexes_off + num_indexes * index_type_size;
97  ITST::serialize(1, &num_values, index_type_size, &reduct_obj_ext[num_values_off]);
98  ITST::serialize(1, &num_indexes, index_type_size, &reduct_obj_ext[num_indexes_off]);
99  ITST::serialize(1, &num_chars, index_type_size, &reduct_obj_ext[num_chars_off]);
101  reduct_obj,
102  arrayView(PVTST::convertFromCharPtr(&reduct_obj_ext[values_off]), num_values),
103  arrayView(ITST::convertFromCharPtr(&reduct_obj_ext[indexes_off]), num_indexes),
104  arrayView(CTST::convertFromCharPtr(&reduct_obj_ext[chars_off]), num_chars)
105  );
106  // ToDo: Change above implementation to only require indirect serialization!
107 }
108 
109 
110 template<class Scalar>
112  const RTOpT<Scalar> &op,
113  int num_values_in,
114  int num_indexes_in,
115  int num_chars_in,
116  const char reduct_obj_ext[],
117  ReductTarget *reduct_obj
118  )
119 {
120  using Teuchos::arrayView;
121  typedef typename RTOpT<Scalar>::primitive_value_type primitive_value_type;
125  const Ordinal
126  prim_value_type_size = PVTST::fromCountToDirectBytes(1),
127  index_type_size = ITST::fromCountToDirectBytes(1);
128  //char_type_size = CTST::fromCountToDirectBytes(1);
129  const Ordinal
130  num_values_off = 0,
131  num_indexes_off = num_values_off + index_type_size,
132  num_chars_off = num_indexes_off + index_type_size,
133  values_off = num_chars_off + index_type_size,
134  indexes_off = values_off + num_values_in * prim_value_type_size,
135  chars_off = indexes_off + num_indexes_in * index_type_size;
136 #ifdef RTOP_DEBUG
137  Ordinal num_values = -1, num_indexes = -1, num_chars = -1;
138  ITST::deserialize(index_type_size, &reduct_obj_ext[num_values_off], 1, &num_values);
139  ITST::deserialize(index_type_size, &reduct_obj_ext[num_indexes_off], 1, &num_indexes);
140  ITST::deserialize(index_type_size, &reduct_obj_ext[num_chars_off], 1, &num_chars);
142  !(
143  num_values==num_values_in && num_indexes==num_indexes_in
144  && num_chars==num_chars_in ),
145  std::logic_error,
146  "Error: RTOp="<<op.op_name()
147  << ", num_values="<<num_values<<", num_values_in="<<num_values_in
148  << ", num_indexes="<<num_indexes<<", num_indexes_in="<<num_indexes_in
149  << ", num_chars="<<num_chars<<", num_chars_in="<<num_chars_in
150  );
151 #endif
153  arrayView(PVTST::convertFromCharPtr(&reduct_obj_ext[values_off]), num_values_in),
154  arrayView(ITST::convertFromCharPtr(&reduct_obj_ext[indexes_off]), num_indexes_in),
155  arrayView(CTST::convertFromCharPtr(&reduct_obj_ext[chars_off]), num_chars_in),
156  Teuchos::ptr(reduct_obj)
157  );
158  // ToDo: Change above implementation to only require indirect serialization!
159 }
160 
161 
162 namespace RTOpPack {
163 
164 
165 //
166 // ReductTargetSerializer
167 //
168 
169 
170 template<class Scalar>
172  const Teuchos::RCP<const RTOpT<Scalar> > &op
173  )
174  :op_(op.assert_not_null())
175 {
176  using Teuchos::outArg;
177  typedef typename RTOpT<Scalar>::primitive_value_type PrimitiveScalar;
178  op_->get_reduct_type_num_entries(
179  outArg(num_values_), outArg(num_indexes_), outArg(num_chars_) );
181  serializedSize<PrimitiveScalar>(num_values_,num_indexes_,num_chars_);
182 }
183 
184 
185 template<class Scalar>
188 {
189  return reduct_obj_ext_size_ * count;
190 }
191 
192 
193 template<class Scalar>
195  const index_type count
196  ,const ReductTarget * const reduct_objs[]
197  ,const index_type bytes
198  ,char charBuffer[]
199  ) const
200 {
201 #ifdef RTOP_DEBUG
202  TEUCHOS_TEST_FOR_EXCEPT( !(count > 0) );
203  TEUCHOS_TEST_FOR_EXCEPT( !reduct_objs );
204  TEUCHOS_TEST_FOR_EXCEPT( !(bytes==this->getBufferSize(count)) );
205  TEUCHOS_TEST_FOR_EXCEPT( !charBuffer );
206 #else
207  (void)bytes;
208 #endif
209  Ordinal offset = 0;
210  for( Ordinal i = 0; i < count; ++i, offset += reduct_obj_ext_size_ ) {
212  *op_,num_values_,num_indexes_,num_chars_
213  ,*reduct_objs[i],&charBuffer[offset]
214  );
215  }
216 }
217 
218 
219 template<class Scalar>
222 {
223  return op_->reduct_obj_create();
224 }
225 
226 template<class Scalar>
228  const index_type bytes
229  ,const char charBuffer[]
230  ,const index_type count
231  ,ReductTarget * const reduct_objs[]
232  ) const
233 {
234 #ifdef RTOP_DEBUG
235  TEUCHOS_TEST_FOR_EXCEPT( !(bytes > 0) );
236  TEUCHOS_TEST_FOR_EXCEPT( !charBuffer );
237  TEUCHOS_TEST_FOR_EXCEPT( !(bytes==getBufferSize(count)) );
238  TEUCHOS_TEST_FOR_EXCEPT( !reduct_objs );
239 #else
240  (void)bytes;
241 #endif
242  Ordinal offset = 0;
243  for( Ordinal i = 0; i < count; ++i, offset += reduct_obj_ext_size_ ) {
245  *op_,num_values_,num_indexes_,num_chars_
246  ,&charBuffer[offset],reduct_objs[i]
247  );
248  }
249 }
250 
251 
252 //
253 // ReductTargetReductionOp
254 //
255 
256 
257 template<class Scalar>
259  const Teuchos::RCP<const RTOpT<Scalar> > &op
260  )
261  :op_(op)
262 {}
263 
264 
265 template<class Scalar>
267  const Ordinal count,
268  const ReductTarget*const inBuffer[],
269  ReductTarget*const inoutBuffer[]
270  ) const
271 {
272  for( Ordinal i = 0; i < count; ++i )
273  op_->reduce_reduct_objs( *inBuffer[i], Teuchos::ptr(inoutBuffer[i]) );
274 }
275 
276 
277 } // namespace RTOpPack
278 
279 
280 template<class Scalar>
282  const Teuchos::Comm<index_type> *comm,
283  const RTOpT<Scalar> &op,
284  const int num_cols,
285  const ReductTarget*const i_reduct_objs[],
286  ReductTarget*const reduct_objs[]
287  )
288 {
289  using Teuchos::Workspace;
290  using Teuchos::reduceAll;
292  Workspace<Teuchos::RCP<ReductTarget> >
293  i_i_reduct_objs( wss, num_cols );
294  Workspace<ReductTarget*>
295  _i_i_reduct_objs( wss, num_cols );
296  for( int kc = 0; kc < num_cols; ++kc ) {
297  i_i_reduct_objs[kc] = op.reduct_obj_create();
298  _i_i_reduct_objs[kc] = &*i_i_reduct_objs[kc];
299  }
301  serializer(Teuchos::rcpFromRef(op));
303  reductOp(Teuchos::rcpFromRef(op));
304  reduceAll<Ordinal>(
305  *comm, serializer, reductOp,
306  num_cols, &i_reduct_objs[0], &_i_i_reduct_objs[0]);
307  for( int kc = 0; kc < num_cols; ++kc ) {
308  op.reduce_reduct_objs(*_i_i_reduct_objs[kc], Teuchos::ptr(reduct_objs[kc]));
309  }
310 }
311 
312 
313 template<class Scalar>
315  const Teuchos::Comm<index_type> *comm,
316  const RTOpT<Scalar> &op,
317  const int num_vecs,
318  const RTOpPack::ConstSubVectorView<Scalar> sub_vecs[],
319  const int num_targ_vecs,
320  const RTOpPack::SubVectorView<Scalar> targ_sub_vecs[],
321  ReductTarget *reduct_obj
322  )
323 {
324  ReductTarget* reduct_objs[] = { reduct_obj };
326  comm,op,1,num_vecs,sub_vecs,num_targ_vecs,targ_sub_vecs
327  ,reduct_obj ? reduct_objs : NULL
328  );
329 }
330 
331 
333 template<class Scalar>
335  const Teuchos::Comm<index_type> *comm,
336  const RTOpT<Scalar> &op,
337  const int num_cols,
338  const int num_multi_vecs,
339  const RTOpPack::ConstSubMultiVectorView<Scalar> sub_multi_vecs[],
340  const int num_targ_multi_vecs,
341  const RTOpPack::SubMultiVectorView<Scalar> targ_sub_multi_vecs[],
342  RTOpPack::ReductTarget*const reduct_objs[]
343  )
344 {
345  using Teuchos::arcp;
346  using Teuchos::Workspace;
348  int k, j, off;
349  Workspace<ConstSubVectorView<Scalar> > c_sub_vecs(wss,num_multi_vecs*num_cols);
350  if(sub_multi_vecs) {
351  for( off = 0, j = 0; j < num_cols; ++j ) {
352  for( k = 0; k < num_multi_vecs; ++k ) {
353  const ConstSubMultiVectorView<Scalar> &mv = sub_multi_vecs[k];
354  if (mv.subDim()) {
355  c_sub_vecs[off++].initialize(mv.globalOffset(), mv.subDim(),
356  arcp(&mv(0,j), 0, mv.subDim(), false), 1);
357  }
358  else {
359  c_sub_vecs[off++].initialize(mv.globalOffset(), mv.subDim(),
360  Teuchos::null, 1);
361  }
362  }
363  }
364  }
365  Workspace<SubVectorView<Scalar> > c_targ_sub_vecs(wss,num_targ_multi_vecs*num_cols);
366  if(targ_sub_multi_vecs) {
367  for( off = 0, j = 0; j < num_cols; ++j ) {
368  for( k = 0; k < num_targ_multi_vecs; ++k ) {
369  const SubMultiVectorView<Scalar> &mv = targ_sub_multi_vecs[k];
371  if (mv.subDim()) { mv_j = arcp(&mv(0,j), 0, mv.subDim(), false); }
372  c_targ_sub_vecs[off++].initialize(mv.globalOffset(), mv.subDim(), mv_j, 1);
373  }
374  }
375  }
377  comm,op,num_cols
378  ,num_multi_vecs, num_multi_vecs && sub_multi_vecs ? &c_sub_vecs[0] : NULL
379  ,num_targ_multi_vecs, num_targ_multi_vecs && targ_sub_multi_vecs ? &c_targ_sub_vecs[0] : NULL
380  ,reduct_objs
381  );
382 }
383 
384 
385 template<class Scalar>
387  const Teuchos::Comm<index_type> *comm,
388  const RTOpT<Scalar> &op,
389  const int num_cols,
390  const int num_vecs,
391  const ConstSubVectorView<Scalar> sub_vecs[],
392  const int num_targ_vecs,
393  const SubVectorView<Scalar> sub_targ_vecs[],
394  ReductTarget*const reduct_objs[]
395  )
396 {
397  using Teuchos::arrayView;
399  Teuchos::OSTab tab(out);
400  if (nonnull(out)) {
401  *out << "\nEntering RTOpPack::SPMD_apply_op(...) ...\n";
402  *out
403  << "\ncomm = " << (comm?comm->description():"NULL")
404  << "\nop = " << op.description()
405  << "\nnum_cols = " << num_cols
406  << "\nnum_vecs = " << num_vecs
407  << "\nnum_targ_vecs = " << num_targ_vecs
408  << "\n";
409  if( num_vecs && sub_vecs ) {
410  *out << "\nInput vectors:\n";
411  Teuchos::OSTab tab2(out);
412  for( int kc = 0; kc < num_cols; ++kc ) {
413  for( int k = 0; k < num_vecs; ++k ) {
414  *out << "\nvecs["<<kc<<","<<k<<"] =\n";
415  print(sub_vecs[kc*num_vecs+k],*out);
416  }
417  }
418  }
419  if( num_targ_vecs && sub_targ_vecs ) {
420  *out << "\nInput/output vectors *before* transforamtion:\n";
421  Teuchos::OSTab tab2(out);
422  for( int kc = 0; kc < num_cols; ++kc ) {
423  for( int k = 0; k < num_targ_vecs; ++k ) {
424  *out << "\nvecs["<<kc<<","<<k<<"] =\n";
425  print(sub_targ_vecs[kc*num_targ_vecs+k],*out);
426  }
427  }
428  }
429  if(reduct_objs) {
430  *out << "\nInput/output reduction objects *before* reduction:\n";
431  Teuchos::OSTab tab2(out);
432  for( int kc = 0; kc < num_cols; ++kc ) {
433  *out
434  << "\nreduct_objs["<<kc<<"] =\n"
435  << describe(*reduct_objs[kc],Teuchos::VERB_EXTREME);
436  }
437  }
438  }
439  using Teuchos::Workspace;
441  if( reduct_objs == NULL && sub_vecs == NULL && sub_targ_vecs == NULL ) {
442  // This is a transformation operation with no data on this processor.
443  // Therefore, we can just exist!
444  }
445  else {
446  const int localSubDim =
447  ( num_vecs
448  ? ( sub_vecs ? sub_vecs[0].subDim() : 0 )
449  : ( sub_targ_vecs ? sub_targ_vecs[0].subDim() : 0 )
450  );
451  // See if we need to do any global communication at all?
452  if( comm==NULL || reduct_objs == NULL ) {
453  if( ( sub_vecs || sub_targ_vecs ) && localSubDim ) {
454  for( int kc = 0; kc < num_cols; ++kc ) {
455  op.apply_op(
456  arrayView(sub_vecs+kc*num_vecs, num_vecs),
457  arrayView(sub_targ_vecs+kc*num_targ_vecs, num_targ_vecs),
458  reduct_objs ? Teuchos::ptr(reduct_objs[kc]) : Teuchos::null
459  );
460  }
461  }
462  }
463  else {
464  // Check the preconditions for excluding empty target vectors.
466  ( ( num_vecs && !sub_vecs) || ( num_targ_vecs && !sub_targ_vecs) ) && !( !sub_vecs && !sub_targ_vecs )
467  ,std::logic_error
468  ,"SPMD_apply_op(...): Error, invalid arguments num_vecs = " << num_vecs
469  << ", sub_vecs = " << sub_vecs << ", num_targ_vecs = " << num_targ_vecs
470  << ", sub_targ_vecs = " << sub_targ_vecs
471  );
472  //
473  // There is a non-null reduction target object and we are using
474  // SPMD so we need to reduce it across processors
475  //
476  // Allocate the intermediate target object and perform the
477  // reduction for the vector elements on this processor.
478  //
479  Workspace<Teuchos::RCP<ReductTarget> >
480  i_reduct_objs( wss, num_cols );
481  for( int kc = 0; kc < num_cols; ++kc ) {
482  i_reduct_objs[kc] = op.reduct_obj_create();
483  if( ( sub_vecs || sub_targ_vecs ) && localSubDim ) {
484  op.apply_op(
485  arrayView(sub_vecs+kc*num_vecs, num_vecs),
486  arrayView(sub_targ_vecs+kc*num_targ_vecs, num_targ_vecs),
487  i_reduct_objs[kc].ptr()
488  );
489  }
490  }
491  if(nonnull(out)) {
492  if(reduct_objs) {
493  *out << "\nIntermediate reduction objects in this process before global reduction:\n";
494  Teuchos::OSTab tab2(out);
495  for( int kc = 0; kc < num_cols; ++kc ) {
496  *out
497  << "\ni_reduct_objs["<<kc<<"] =\n"
498  << describe(*i_reduct_objs[kc],Teuchos::VERB_EXTREME);
499  }
500  }
501  }
502  //
503  // Reduce the local intermediate reduction objects into the global reduction objects
504  //
505  Workspace<const ReductTarget*>
506  _i_reduct_objs( wss, num_cols );
507  for( int kc = 0; kc < num_cols; ++kc ) {
508  _i_reduct_objs[kc] = &*i_reduct_objs[kc];
509  }
510  if(nonnull(out)) {
511  if(reduct_objs) {
512  *out << "\nPerforming global reduction ...\n";
513  }
514  }
515  SPMD_all_reduce(comm,op,num_cols,&_i_reduct_objs[0],reduct_objs);
516  }
517  }
518  if(nonnull(out)) {
519  if( num_targ_vecs && sub_targ_vecs ) {
520  *out << "\nInput/output vectors *after* transforamtion:\n";
521  Teuchos::OSTab tab2(out);
522  for( int kc = 0; kc < num_cols; ++kc ) {
523  for( int k = 0; k < num_targ_vecs; ++k ) {
524  *out << "\nvecs["<<kc<<","<<k<<"] =\n";
525  print(sub_targ_vecs[kc*num_targ_vecs+k],*out);
526  }
527  }
528  }
529  if(reduct_objs) {
530  *out << "\nInput/output reduction objects *after* reduction:\n";
531  Teuchos::OSTab tab2(out);
532  for( int kc = 0; kc < num_cols; ++kc ) {
533  *out
534  << "\nreduct_objs["<<kc<<"] =\n"
535  << describe(*reduct_objs[kc],Teuchos::VERB_EXTREME);
536  }
537  }
538  *out << "\nLeaving RTOpPack::SPMD_apply_op(...) ...\n";
539  *out << std::flush;
540  }
541 }
542 
543 
544 //
545 // Explicit Template Instaniation Macros
546 //
547 
548 
549 #define RTOPPACK_SPMD_APPLY_OP_INSTANT_SCALAR(SCALAR) \
550  \
551  template int serializedSize<SCALAR >( \
552  int num_values, \
553  int num_indexes, \
554  int num_chars \
555  ); \
556  \
557  template void serialize<SCALAR >( \
558  const RTOpT<SCALAR > &op, \
559  Ordinal num_values, \
560  Ordinal num_indexes, \
561  Ordinal num_chars, \
562  const ReductTarget &reduct_obj, \
563  char reduct_obj_ext[] \
564  ); \
565  \
566  template void deserialize<SCALAR >( \
567  const RTOpT<SCALAR > &op, \
568  int num_values_in, \
569  int num_indexes_in, \
570  int num_chars_in, \
571  const char reduct_obj_ext[], \
572  ReductTarget *reduct_obj \
573  ); \
574  \
575  template class ReductTargetSerializer<SCALAR >; \
576  \
577  template class ReductTargetReductionOp<SCALAR >; \
578  \
579  template void SPMD_all_reduce<SCALAR >( \
580  const Teuchos::Comm<index_type> *comm, \
581  const RTOpT<SCALAR > &op, \
582  const int num_cols, \
583  const ReductTarget*const i_reduct_objs[], \
584  ReductTarget*const reduct_objs[] \
585  ); \
586  \
587  template void SPMD_apply_op<SCALAR >( \
588  const Teuchos::Comm<index_type> *comm, \
589  const RTOpT<SCALAR > &op, \
590  const int num_vecs, \
591  const RTOpPack::ConstSubVectorView<SCALAR > sub_vecs[], \
592  const int num_targ_vecs, \
593  const RTOpPack::SubVectorView<SCALAR > targ_sub_vecs[], \
594  ReductTarget *reduct_obj \
595  ); \
596  \
597  template void SPMD_apply_op<SCALAR >( \
598  const Teuchos::Comm<index_type> *comm, \
599  const RTOpT<SCALAR > &op, \
600  const int num_cols, \
601  const int num_multi_vecs, \
602  const RTOpPack::ConstSubMultiVectorView<SCALAR > sub_multi_vecs[], \
603  const int num_targ_multi_vecs, \
604  const RTOpPack::SubMultiVectorView<SCALAR > targ_sub_multi_vecs[], \
605  RTOpPack::ReductTarget*const reduct_objs[] \
606  ); \
607  \
608  template void SPMD_apply_op<SCALAR >( \
609  const Teuchos::Comm<index_type> *comm, \
610  const RTOpT<SCALAR > &op, \
611  const int num_cols, \
612  const int num_vecs, \
613  const ConstSubVectorView<SCALAR > sub_vecs[], \
614  const int num_targ_vecs, \
615  const SubVectorView<SCALAR > sub_targ_vecs[], \
616  ReductTarget*const reduct_objs[] \
617  );
618 
619 
620 #endif // RTOPPACK_SPMD_APPLY_OP_DEF_HPP
std::string op_name() const
Return the name (as a null-terminated C-style string) of the operator.
int serializedSize(int num_values, int num_indexes, int num_chars)
Return the size in bytes of an external representation of a ReductTarget object.
void SPMD_all_reduce(const Teuchos::Comm< index_type > *comm, const RTOpT< Scalar > &op, const int num_cols, const ReductTarget *const i_reduct_objs[], ReductTarget *const reduct_objs[])
Reduce a set of reduction objects.
Teuchos::RCP< ReductTarget > createObj() const
Class for a changeable sub-vector.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void serialize(const index_type count, const ReductTarget *const reduct_objs[], const index_type bytes, char charBuffer[]) const
basic_OSTab< CharT, Traits > & incrTab(const int tabs=1)
Teuchos_Ordinal index_type
ReductionOp subclass for ReductTarget objects.
void serialize(const RTOpT< Scalar > &op, Ordinal num_values, Ordinal num_indexes, Ordinal num_chars, const ReductTarget &reduct_obj, char reduct_obj_ext[])
Serialize a ReductTarget object.
Class for a non-changeable sub-vector.
void deserialize(const RTOpT< Scalar > &op, int num_values, int num_indexes, int num_chars, const char reduct_obj_ext[], ReductTarget *reduct_obj)
Deserialize a ReductTarget object.
Serializer subclass for ReductTarget objects.
Templated interface to vector reduction/transformation operators {abstract}.
index_type getBufferSize(const index_type count) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class for a changeable sub-vector.
void extract_reduct_obj_state(const ReductTarget &reduct_obj, const ArrayView< primitive_value_type > &value_data, const ArrayView< index_type > &index_data, const ArrayView< char_type > &char_data) const
Extract the state of an already created reduction object.
void deserialize(const index_type bytes, const char charBuffer[], const index_type count, ReductTarget *const reduct_objs[]) const
void load_reduct_obj_state(const ArrayView< const primitive_value_type > &value_data, const ArrayView< const index_type > &index_data, const ArrayView< const char_type > &char_data, const Ptr< ReductTarget > &reduct_obj) const
Load the state of an already created reduction object given arrays of primitive objects.
virtual std::string description() const
PrimitiveTypeTraits< Scalar, Scalar >::primitiveType primitive_value_type
Abstract base class for all reduction objects.
void print(const ConstSubVectorView< Scalar > &v, Teuchos::FancyOStream &out_arg)
void reduce_reduct_objs(const ReductTarget &in_reduct_obj, const Ptr< ReductTarget > &inout_reduct_obj) const
Reduce intermediate reduction target objects.
Teuchos::RCP< ReductTarget > reduct_obj_create() const
Creates a new reduction target object initialized and ready to be used in a reduction.
bool nonnull(const boost::shared_ptr< T > &p)
Class for a non-changeable sub-multi-vector (submatrix).
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, Ordinal colOffset_in, Ordinal numSubCols_in, const ArrayRCP< const Scalar > &values_in, Ordinal leadingDim_in)
Teuchos::RCP< const RTOpT< Scalar > > op_
void apply_op(const ArrayView< const ConstSubVectorView< Scalar > > &sub_vecs, const ArrayView< const SubVectorView< Scalar > > &targ_sub_vecs, const Ptr< ReductTarget > &reduct_obj) const
Apply the reduction/transformation operator to a set of sub-vectors.
Teuchos_Ordinal Ordinal
void SPMD_apply_op(const Teuchos::Comm< index_type > *comm, const RTOpT< Scalar > &op, const int num_vecs, const ConstSubVectorView< Scalar > sub_vecs[], const int num_targ_vecs, const SubVectorView< Scalar > targ_sub_vecs[], ReductTarget *reduct_obj)
Apply an RTOp in SMPD mode to a set of vectors with contiguous storage per process.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
TEUCHOSCORE_LIB_DLL_EXPORT Teuchos::RCP< WorkspaceStore > get_default_workspace_store()
void reduce(const Ordinal count, const ReductTarget *const inBuffer[], ReductTarget *const inoutBuffer[]) const
RCP< FancyOStream > & spmdApplyOpDumpOut()