RTOp Package Browser (Single Doxygen Collection)  Version of the Day
RTOpPack_SPMD_apply_op_def.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // RTOp: Interfaces and Support Software for Vector Reduction Transformation
5 // Operations
6 // Copyright (2006) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 
43 #ifndef RTOPPACK_SPMD_APPLY_OP_DEF_HPP
44 #define RTOPPACK_SPMD_APPLY_OP_DEF_HPP
45 
47 #include "Teuchos_Workspace.hpp"
48 #include "Teuchos_CommHelpers.hpp"
49 
50 #ifdef RTOPPACK_ENABLE_SHOW_DUMP
51 # include "Teuchos_VerboseObject.hpp"
52 #endif // RTOPPACK_ENABLE_SHOW_DUMP
53 
54 
55 namespace RTOpPack {
56 
57 
58 #ifdef RTOPPACK_ENABLE_SHOW_DUMP
59 
60 
61 template<class Scalar>
62 void print( const ConstSubVectorView<Scalar> &v, Teuchos::FancyOStream &out_arg )
63 {
64  Teuchos::RCP<Teuchos::FancyOStream> out = Teuchos::rcp(&out_arg,false);
65  Teuchos::OSTab tab(out);
66  *out << "globalOffset="<<v.globalOffset()<<"\n";
67  *out << "subDim="<<v.subDim()<<"\n";
68  *out << "values:\n";
69  tab.incrTab();
70  for( int i = 0; i < v.subDim(); ++i )
71  *out << " " << v(i) << ":" << (v.globalOffset()+i);
72  *out << "\n";
73 }
74 
75 # include "Teuchos_VerboseObject.hpp"
76 
77 
78 #endif // RTOPPACK_ENABLE_SHOW_DUMP
79 
80 
81 } // namespace RTOpPack
82 
83 
84 // ///////////////////////////
85 // Template implementations
86 
87 
88 //
89 // Misc Helper functions
90 //
91 
92 
93 template<class PrimitiveScalar>
95  int num_values,
96  int num_indexes,
97  int num_chars
98  )
99 {
100  return 3 * sizeof(index_type)
101  + num_values * sizeof(PrimitiveScalar)
102  + num_indexes * sizeof(index_type)
103  + num_chars * sizeof(char_type);
104 }
105 
106 
107 template<class Scalar>
109  const RTOpT<Scalar> &op,
110  Ordinal num_values,
111  Ordinal num_indexes,
112  Ordinal num_chars,
113  const ReductTarget &reduct_obj,
114  char reduct_obj_ext[]
115  )
116 {
117  using Teuchos::arrayView;
118  typedef typename RTOpT<Scalar>::primitive_value_type primitive_value_type;
119  typedef Teuchos::SerializationTraits<Ordinal, primitive_value_type> PVTST;
120  typedef Teuchos::SerializationTraits<Ordinal, index_type> ITST;
121  typedef Teuchos::SerializationTraits<Ordinal, char_type> CTST;
122  const Ordinal
123  prim_value_type_size = PVTST::fromCountToDirectBytes(1),
124  index_type_size = ITST::fromCountToDirectBytes(1);
125  //char_type_size = CTST::fromCountToDirectBytes(1);
126  const Ordinal
127  num_values_off = 0,
128  num_indexes_off = num_values_off + index_type_size,
129  num_chars_off = num_indexes_off + index_type_size,
130  values_off = num_chars_off + index_type_size,
131  indexes_off = values_off + num_values * prim_value_type_size,
132  chars_off = indexes_off + num_indexes * index_type_size;
133  ITST::serialize(1, &num_values, index_type_size, &reduct_obj_ext[num_values_off]);
134  ITST::serialize(1, &num_indexes, index_type_size, &reduct_obj_ext[num_indexes_off]);
135  ITST::serialize(1, &num_chars, index_type_size, &reduct_obj_ext[num_chars_off]);
137  reduct_obj,
138  arrayView(PVTST::convertFromCharPtr(&reduct_obj_ext[values_off]), num_values),
139  arrayView(ITST::convertFromCharPtr(&reduct_obj_ext[indexes_off]), num_indexes),
140  arrayView(CTST::convertFromCharPtr(&reduct_obj_ext[chars_off]), num_chars)
141  );
142  // ToDo: Change above implementation to only require indirect serialization!
143 }
144 
145 
146 template<class Scalar>
148  const RTOpT<Scalar> &op,
149  int num_values_in,
150  int num_indexes_in,
151  int num_chars_in,
152  const char reduct_obj_ext[],
153  ReductTarget *reduct_obj
154  )
155 {
156  using Teuchos::arrayView;
157  typedef typename RTOpT<Scalar>::primitive_value_type primitive_value_type;
158  typedef Teuchos::SerializationTraits<int,primitive_value_type> PVTST;
159  typedef Teuchos::SerializationTraits<int,index_type> ITST;
160  typedef Teuchos::SerializationTraits<int,char_type> CTST;
161  const Ordinal
162  prim_value_type_size = PVTST::fromCountToDirectBytes(1),
163  index_type_size = ITST::fromCountToDirectBytes(1);
164  //char_type_size = CTST::fromCountToDirectBytes(1);
165  const Ordinal
166  num_values_off = 0,
167  num_indexes_off = num_values_off + index_type_size,
168  num_chars_off = num_indexes_off + index_type_size,
169  values_off = num_chars_off + index_type_size,
170  indexes_off = values_off + num_values_in * prim_value_type_size,
171  chars_off = indexes_off + num_indexes_in * index_type_size;
172 #ifdef RTOP_DEBUG
173  Ordinal num_values = -1, num_indexes = -1, num_chars = -1;
174  ITST::deserialize(index_type_size, &reduct_obj_ext[num_values_off], 1, &num_values);
175  ITST::deserialize(index_type_size, &reduct_obj_ext[num_indexes_off], 1, &num_indexes);
176  ITST::deserialize(index_type_size, &reduct_obj_ext[num_chars_off], 1, &num_chars);
177  TEUCHOS_TEST_FOR_EXCEPT(
178  !(
179  num_values==num_values_in && num_indexes==num_indexes_in
180  && num_chars==num_chars_in )
181  );
182 #endif
184  arrayView(PVTST::convertFromCharPtr(&reduct_obj_ext[values_off]), num_values_in),
185  arrayView(ITST::convertFromCharPtr(&reduct_obj_ext[indexes_off]), num_indexes_in),
186  arrayView(CTST::convertFromCharPtr(&reduct_obj_ext[chars_off]), num_chars_in),
187  Teuchos::ptr(reduct_obj)
188  );
189  // ToDo: Change above implementation to only require indirect serialization!
190 }
191 
192 
193 namespace RTOpPack {
194 
195 
196 //
197 // ReductTargetSerializer
198 //
199 
200 
201 template<class Scalar>
203  const Teuchos::RCP<const RTOpT<Scalar> > &op
204  )
205  :op_(op.assert_not_null())
206 {
207  using Teuchos::outArg;
208  typedef typename RTOpT<Scalar>::primitive_value_type PrimitiveScalar;
209  op_->get_reduct_type_num_entries(
210  outArg(num_values_), outArg(num_indexes_), outArg(num_chars_) );
212  serializedSize<PrimitiveScalar>(num_values_,num_indexes_,num_chars_);
213 }
214 
215 
216 template<class Scalar>
219 {
220  return reduct_obj_ext_size_ * count;
221 }
222 
223 
224 template<class Scalar>
226  const index_type count
227  ,const ReductTarget * const reduct_objs[]
228  ,const index_type bytes
229  ,char charBuffer[]
230  ) const
231 {
232 #ifdef RTOP_DEBUG
233  TEUCHOS_TEST_FOR_EXCEPT( !(count > 0) );
234  TEUCHOS_TEST_FOR_EXCEPT( !reduct_objs );
235  TEUCHOS_TEST_FOR_EXCEPT( !(bytes==this->getBufferSize(count)) );
236  TEUCHOS_TEST_FOR_EXCEPT( !charBuffer );
237 #endif
238  Ordinal offset = 0;
239  for( Ordinal i = 0; i < count; ++i, offset += reduct_obj_ext_size_ ) {
242  ,*reduct_objs[i],&charBuffer[offset]
243  );
244  }
245 }
246 
247 
248 template<class Scalar>
249 Teuchos::RCP<ReductTarget>
251 {
252  return op_->reduct_obj_create();
253 }
254 
255 template<class Scalar>
257  const index_type bytes
258  ,const char charBuffer[]
259  ,const index_type count
260  ,ReductTarget * const reduct_objs[]
261  ) const
262 {
263 #ifdef RTOP_DEBUG
264  TEUCHOS_TEST_FOR_EXCEPT( !(bytes > 0) );
265  TEUCHOS_TEST_FOR_EXCEPT( !charBuffer );
266  TEUCHOS_TEST_FOR_EXCEPT( !(bytes==getBufferSize(count)) );
267  TEUCHOS_TEST_FOR_EXCEPT( !reduct_objs );
268 #endif
269  Ordinal offset = 0;
270  for( Ordinal i = 0; i < count; ++i, offset += reduct_obj_ext_size_ ) {
273  ,&charBuffer[offset],reduct_objs[i]
274  );
275  }
276 }
277 
278 
279 //
280 // ReductTargetReductionOp
281 //
282 
283 
284 template<class Scalar>
286  const Teuchos::RCP<const RTOpT<Scalar> > &op
287  )
288  :op_(op)
289 {}
290 
291 
292 template<class Scalar>
294  const Ordinal count,
295  const ReductTarget*const inBuffer[],
296  ReductTarget*const inoutBuffer[]
297  ) const
298 {
299  for( Ordinal i = 0; i < count; ++i )
300  op_->reduce_reduct_objs( *inBuffer[i], Teuchos::ptr(inoutBuffer[i]) );
301 }
302 
303 
304 } // namespace RTOpPack
305 
306 
307 template<class Scalar>
309  const Teuchos::Comm<index_type> *comm,
310  const RTOpT<Scalar> &op,
311  const int num_cols,
312  const ReductTarget*const i_reduct_objs[],
313  ReductTarget*const reduct_objs[]
314  )
315 {
316  using Teuchos::Workspace;
317  using Teuchos::reduceAll;
318  Teuchos::WorkspaceStore* wss = Teuchos::get_default_workspace_store().get();
319  Workspace<Teuchos::RCP<ReductTarget> >
320  i_i_reduct_objs( wss, num_cols );
321  Workspace<ReductTarget*>
322  _i_i_reduct_objs( wss, num_cols );
323  for( int kc = 0; kc < num_cols; ++kc ) {
324  i_i_reduct_objs[kc] = op.reduct_obj_create();
325  _i_i_reduct_objs[kc] = &*i_i_reduct_objs[kc];
326  }
328  serializer(Teuchos::rcpFromRef(op));
330  reductOp(Teuchos::rcpFromRef(op));
331  reduceAll<Ordinal>(
332  *comm, serializer, reductOp,
333  num_cols, &i_reduct_objs[0], &_i_i_reduct_objs[0]);
334  for( int kc = 0; kc < num_cols; ++kc ) {
335  op.reduce_reduct_objs(*_i_i_reduct_objs[kc], Teuchos::ptr(reduct_objs[kc]));
336  }
337 }
338 
339 
340 template<class Scalar>
342  const Teuchos::Comm<index_type> *comm,
343  const RTOpT<Scalar> &op,
344  const int num_vecs,
345  const RTOpPack::ConstSubVectorView<Scalar> sub_vecs[],
346  const int num_targ_vecs,
347  const RTOpPack::SubVectorView<Scalar> targ_sub_vecs[],
348  ReductTarget *reduct_obj
349  )
350 {
351  ReductTarget* reduct_objs[] = { reduct_obj };
353  comm,op,1,num_vecs,sub_vecs,num_targ_vecs,targ_sub_vecs
354  ,reduct_obj ? reduct_objs : NULL
355  );
356 }
357 
358 
360 template<class Scalar>
362  const Teuchos::Comm<index_type> *comm,
363  const RTOpT<Scalar> &op,
364  const int num_cols,
365  const int num_multi_vecs,
366  const RTOpPack::ConstSubMultiVectorView<Scalar> sub_multi_vecs[],
367  const int num_targ_multi_vecs,
368  const RTOpPack::SubMultiVectorView<Scalar> targ_sub_multi_vecs[],
369  RTOpPack::ReductTarget*const reduct_objs[]
370  )
371 {
372  using Teuchos::arcp;
373  using Teuchos::Workspace;
374  Teuchos::WorkspaceStore* wss = Teuchos::get_default_workspace_store().get();
375  int k, j, off;
376  Workspace<ConstSubVectorView<Scalar> > c_sub_vecs(wss,num_multi_vecs*num_cols);
377  if(sub_multi_vecs) {
378  for( off = 0, j = 0; j < num_cols; ++j ) {
379  for( k = 0; k < num_multi_vecs; ++k ) {
380  const ConstSubMultiVectorView<Scalar> &mv = sub_multi_vecs[k];
381  c_sub_vecs[off++].initialize(mv.globalOffset(), mv.subDim(),
382  arcp(&mv(0,j), 0, mv.subDim(), false), 1);
383  }
384  }
385  }
386  Workspace<SubVectorView<Scalar> > c_targ_sub_vecs(wss,num_targ_multi_vecs*num_cols);
387  if(targ_sub_multi_vecs) {
388  for( off = 0, j = 0; j < num_cols; ++j ) {
389  for( k = 0; k < num_targ_multi_vecs; ++k ) {
390  const SubMultiVectorView<Scalar> &mv = targ_sub_multi_vecs[k];
391  c_targ_sub_vecs[off++].initialize(mv.globalOffset(), mv.subDim(),
392  arcp(&mv(0,j), 0, mv.subDim(), false), 1);
393  }
394  }
395  }
397  comm,op,num_cols
398  ,num_multi_vecs, num_multi_vecs && sub_multi_vecs ? &c_sub_vecs[0] : NULL
399  ,num_targ_multi_vecs, num_targ_multi_vecs && targ_sub_multi_vecs ? &c_targ_sub_vecs[0] : NULL
400  ,reduct_objs
401  );
402 }
403 
404 
405 template<class Scalar>
407  const Teuchos::Comm<index_type> *comm,
408  const RTOpT<Scalar> &op,
409  const int num_cols,
410  const int num_vecs,
411  const ConstSubVectorView<Scalar> sub_vecs[],
412  const int num_targ_vecs,
413  const SubVectorView<Scalar> sub_targ_vecs[],
414  ReductTarget*const reduct_objs[]
415  )
416 {
417  using Teuchos::arrayView;
418 #ifdef RTOPPACK_ENABLE_SHOW_DUMP
419  Teuchos::RCP<Teuchos::FancyOStream>
420  out = Teuchos::VerboseObjectBase::getDefaultOStream();
421  Teuchos::OSTab tab(out);
423  *out << "\nEntering RTOpPack::SPMD_apply_op(...) ...\n";
424  *out
425  << "\ncomm = " << (comm?comm->description():"NULL")
426  << "\nop = " << op.description()
427  << "\nnum_cols = " << num_cols
428  << "\nnum_vecs = " << num_vecs
429  << "\nnum_targ_vecs = " << num_targ_vecs
430  << "\n";
431  if( num_vecs && sub_vecs ) {
432  *out << "\nInput vectors:\n";
433  Teuchos::OSTab tab2(out);
434  for( int kc = 0; kc < num_cols; ++kc ) {
435  for( int k = 0; k < num_vecs; ++k ) {
436  *out << "\nvecs["<<kc<<","<<k<<"] =\n";
437  print(sub_vecs[kc*num_vecs+k],*out);
438  }
439  }
440  }
441  if( num_targ_vecs && sub_targ_vecs ) {
442  *out << "\nInput/output vectors *before* transforamtion:\n";
443  Teuchos::OSTab tab2(out);
444  for( int kc = 0; kc < num_cols; ++kc ) {
445  for( int k = 0; k < num_targ_vecs; ++k ) {
446  *out << "\nvecs["<<kc<<","<<k<<"] =\n";
447  print(sub_targ_vecs[kc*num_targ_vecs+k],*out);
448  }
449  }
450  }
451  if(reduct_objs) {
452  *out << "\nInput/output reduction objects *before* reduction:\n";
453  Teuchos::OSTab tab2(out);
454  for( int kc = 0; kc < num_cols; ++kc ) {
455  *out
456  << "\nreduct_objs["<<kc<<"] =\n"
457  << describe(*reduct_objs[kc],Teuchos::VERB_EXTREME);
458  }
459  }
460  }
461 #endif // RTOPPACK_ENABLE_SHOW_DUMP
462  using Teuchos::Workspace;
463  Teuchos::WorkspaceStore* wss = Teuchos::get_default_workspace_store().get();
464  if( reduct_objs == NULL && sub_vecs == NULL && sub_targ_vecs == NULL ) {
465  // This is a transformation operation with no data on this processor.
466  // Therefore, we can just exist!
467  }
468  else {
469  const int localSubDim =
470  ( num_vecs
471  ? ( sub_vecs ? sub_vecs[0].subDim() : 0 )
472  : ( sub_targ_vecs ? sub_targ_vecs[0].subDim() : 0 )
473  );
474  // See if we need to do any global communication at all?
475  if( comm==NULL || reduct_objs == NULL ) {
476  if( ( sub_vecs || sub_targ_vecs ) && localSubDim ) {
477  for( int kc = 0; kc < num_cols; ++kc ) {
478  op.apply_op(
479  arrayView(sub_vecs+kc*num_vecs, num_vecs),
480  arrayView(sub_targ_vecs+kc*num_targ_vecs, num_targ_vecs),
481  reduct_objs ? Teuchos::ptr(reduct_objs[kc]) : Teuchos::null
482  );
483  }
484  }
485  }
486  else {
487  // Check the preconditions for excluding empty target vectors.
488  TEUCHOS_TEST_FOR_EXCEPTION(
489  ( ( num_vecs && !sub_vecs) || ( num_targ_vecs && !sub_targ_vecs) ) && !( !sub_vecs && !sub_targ_vecs )
490  ,std::logic_error
491  ,"SPMD_apply_op(...): Error, invalid arguments num_vecs = " << num_vecs
492  << ", sub_vecs = " << sub_vecs << ", num_targ_vecs = " << num_targ_vecs
493  << ", sub_targ_vecs = " << sub_targ_vecs
494  );
495  //
496  // There is a non-null reduction target object and we are using
497  // SPMD so we need to reduce it across processors
498  //
499  // Allocate the intermediate target object and perform the
500  // reduction for the vector elements on this processor.
501  //
502  Workspace<Teuchos::RCP<ReductTarget> >
503  i_reduct_objs( wss, num_cols );
504  for( int kc = 0; kc < num_cols; ++kc ) {
505  i_reduct_objs[kc] = op.reduct_obj_create();
506  if( ( sub_vecs || sub_targ_vecs ) && localSubDim ) {
507  op.apply_op(
508  arrayView(sub_vecs+kc*num_vecs, num_vecs),
509  arrayView(sub_targ_vecs+kc*num_targ_vecs, num_targ_vecs),
510  i_reduct_objs[kc].ptr()
511  );
512  }
513  }
514 #ifdef RTOPPACK_ENABLE_SHOW_DUMP
516  if(reduct_objs) {
517  *out << "\nIntermediate reduction objects in this process before global reduction:\n";
518  Teuchos::OSTab tab2(out);
519  for( int kc = 0; kc < num_cols; ++kc ) {
520  *out
521  << "\ni_reduct_objs["<<kc<<"] =\n"
522  << describe(*i_reduct_objs[kc],Teuchos::VERB_EXTREME);
523  }
524  }
525  }
526 #endif // RTOPPACK_ENABLE_SHOW_DUMP
527  //
528  // Reduce the local intermediate reduction objects into the global reduction objects
529  //
530  Workspace<const ReductTarget*>
531  _i_reduct_objs( wss, num_cols );
532  for( int kc = 0; kc < num_cols; ++kc ) {
533  _i_reduct_objs[kc] = &*i_reduct_objs[kc];
534  }
535 #ifdef RTOPPACK_ENABLE_SHOW_DUMP
537  if(reduct_objs) {
538  *out << "\nPerforming global reduction ...\n";
539  }
540  }
541 #endif // RTOPPACK_ENABLE_SHOW_DUMP
542  SPMD_all_reduce(comm,op,num_cols,&_i_reduct_objs[0],reduct_objs);
543  }
544  }
545 #ifdef RTOPPACK_ENABLE_SHOW_DUMP
547  if( num_targ_vecs && sub_targ_vecs ) {
548  *out << "\nInput/output vectors *after* transforamtion:\n";
549  Teuchos::OSTab tab2(out);
550  for( int kc = 0; kc < num_cols; ++kc ) {
551  for( int k = 0; k < num_targ_vecs; ++k ) {
552  *out << "\nvecs["<<kc<<","<<k<<"] =\n";
553  print(sub_targ_vecs[kc*num_targ_vecs+k],*out);
554  }
555  }
556  }
557  if(reduct_objs) {
558  *out << "\nInput/output reduction objects *after* reduction:\n";
559  Teuchos::OSTab tab2(out);
560  for( int kc = 0; kc < num_cols; ++kc ) {
561  *out
562  << "\nreduct_objs["<<kc<<"] =\n"
563  << describe(*reduct_objs[kc],Teuchos::VERB_EXTREME);
564  }
565  }
566  *out << "\nLeaving RTOpPack::SPMD_apply_op(...) ...\n";
567  }
568 #endif // RTOPPACK_ENABLE_SHOW_DUMP
569 }
570 
571 
572 //
573 // Explicit Template Instaniation Macros
574 //
575 
576 
577 #define RTOPPACK_SPMD_APPLY_OP_INSTANT_SCALAR(SCALAR) \
578  \
579  template int serializedSize<SCALAR >( \
580  int num_values, \
581  int num_indexes, \
582  int num_chars \
583  ); \
584  \
585  template void serialize<SCALAR >( \
586  const RTOpT<SCALAR > &op, \
587  Ordinal num_values, \
588  Ordinal num_indexes, \
589  Ordinal num_chars, \
590  const ReductTarget &reduct_obj, \
591  char reduct_obj_ext[] \
592  ); \
593  \
594  template void deserialize<SCALAR >( \
595  const RTOpT<SCALAR > &op, \
596  int num_values_in, \
597  int num_indexes_in, \
598  int num_chars_in, \
599  const char reduct_obj_ext[], \
600  ReductTarget *reduct_obj \
601  ); \
602  \
603  template class ReductTargetSerializer<SCALAR >; \
604  \
605  template class ReductTargetReductionOp<SCALAR >; \
606  \
607  template void SPMD_all_reduce<SCALAR >( \
608  const Teuchos::Comm<index_type> *comm, \
609  const RTOpT<SCALAR > &op, \
610  const int num_cols, \
611  const ReductTarget*const i_reduct_objs[], \
612  ReductTarget*const reduct_objs[] \
613  ); \
614  \
615  template void SPMD_apply_op<SCALAR >( \
616  const Teuchos::Comm<index_type> *comm, \
617  const RTOpT<SCALAR > &op, \
618  const int num_vecs, \
619  const RTOpPack::ConstSubVectorView<SCALAR > sub_vecs[], \
620  const int num_targ_vecs, \
621  const RTOpPack::SubVectorView<SCALAR > targ_sub_vecs[], \
622  ReductTarget *reduct_obj \
623  ); \
624  \
625  template void SPMD_apply_op<SCALAR >( \
626  const Teuchos::Comm<index_type> *comm, \
627  const RTOpT<SCALAR > &op, \
628  const int num_cols, \
629  const int num_multi_vecs, \
630  const RTOpPack::ConstSubMultiVectorView<SCALAR > sub_multi_vecs[], \
631  const int num_targ_multi_vecs, \
632  const RTOpPack::SubMultiVectorView<SCALAR > targ_sub_multi_vecs[], \
633  RTOpPack::ReductTarget*const reduct_objs[] \
634  ); \
635  \
636  template void SPMD_apply_op<SCALAR >( \
637  const Teuchos::Comm<index_type> *comm, \
638  const RTOpT<SCALAR > &op, \
639  const int num_cols, \
640  const int num_vecs, \
641  const ConstSubVectorView<SCALAR > sub_vecs[], \
642  const int num_targ_vecs, \
643  const SubVectorView<SCALAR > sub_targ_vecs[], \
644  ReductTarget*const reduct_objs[] \
645  );
646 
647 
648 #endif // RTOPPACK_SPMD_APPLY_OP_DEF_HPP
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.
void serialize(const index_type count, const ReductTarget *const reduct_objs[], const index_type bytes, char charBuffer[]) const
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
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 initialize(Ordinal globalOffset_in, Ordinal subDim_in, Ordinal colOffset_in, Ordinal numSubCols_in, const ArrayRCP< Scalar > &values_in, Ordinal leadingDim_in)
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.
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.
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
Teuchos::RCP< const RTOpT< Scalar > > op_
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.
void reduce(const Ordinal count, const ReductTarget *const inBuffer[], ReductTarget *const inoutBuffer[]) const