ug4
parallel_vector_impl.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3  * Author: Andreas Vogel
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef __H__LIB_ALGEBRA__PARALLELIZATION__PARALLEL_VECTOR_IMPL__
34 #define __H__LIB_ALGEBRA__PARALLELIZATION__PARALLEL_VECTOR_IMPL__
35 
36 #include <cmath>
37 #include "parallel_vector.h"
38 #include "common/common.h" // for UGError
39 // additions for profiling (14042011ih)
41 #define PROFILE_PARALLEL_VECTOR
42 #ifdef PROFILE_PARALLEL_VECTOR
43 #define PARVEC_PROFILE_FUNC() PROFILE_FUNC()
44 #define PARVEC_PROFILE_BEGIN(name) PROFILE_BEGIN(name)
45 #define PARVEC_PROFILE_END() PROFILE_END()
46 #else
47 #define PARVEC_PROFILE_FUNC()
48 #define PARVEC_PROFILE_BEGIN(name)
49 #define PARVEC_PROFILE_END()
50 #endif
51 // additions for profiling - end
52 
53 namespace ug
54 {
55 
56 template <typename TVector>
59 {
60  // forward to sequential vectors
61  TVector::operator=(*dynamic_cast<const TVector*>(&v));
62 
63  // copy storage type and layouts
64  this->set_storage_type(v.get_storage_mask());
65  this->set_layouts(v.layouts());
66 
67  // we're done
68  return *this;
69 }
70 
71 template <typename TVector>
74 {
75  // compute storage mask
76  uint mask = get_storage_mask() & v.get_storage_mask();
77 
78  // check mask
79  if(mask == 0)
80  UG_THROW("ParallelVector::operator-=: Incompatible storage type: "<<
81  get_storage_mask()<<" and "<<v.get_storage_mask());
82 
83  // set this vector to mask
84  m_type = mask;
85 
86  // forward
87  TVector::operator-=(*dynamic_cast<const TVector*>(&v));
88 
89  // we're done
90  return *this;
91 }
92 
93 template <typename TVector>
96 {
97  // compute parallel storage mask
98  uint mask = get_storage_mask() & v.get_storage_mask();
99 
100  // check mask
101  if(mask == 0)
102  UG_THROW("ParallelVector::operator+=: Incompatible storage type: "<<
103  get_storage_mask()<<" and "<<v.get_storage_mask());
104 
105  // set to new mask
106  m_type = mask;
107 
108  // forward to sequential vector
109  TVector::operator+=(*dynamic_cast<const TVector*>(&v));
110 
111  // we're done
112  return *this;
113 }
114 
115 template <typename TVector>
116 bool
119 {
120  PROFILE_FUNC_GROUP("algebra parallelization");
121 
122  // can only change if current state is defined
123  if(has_storage_type(PST_UNDEFINED))
124  UG_THROW("ParallelVector::change_storage_type: Trying to change"
125  " storage type of a vector that has type PST_UNDEFINED.");
126 
127  // if already in that type
128  if(has_storage_type(type)) return true;
129 
130  // check layouts
131  if(layouts().invalid())
132  UG_THROW("ParallelVector::change_storage_type: No "
133  "layouts given but trying to change type.")
134 
135  // else switch to that type
136  switch(type)
137  {
138  case PST_CONSISTENT:
139  if(has_storage_type(PST_UNIQUE)){
140  PARVEC_PROFILE_BEGIN(ParVec_CSTUnique2Consistent);
141  UniqueToConsistent(this, layouts()->master(), layouts()->slave(),
142  &layouts()->comm());
143  set_storage_type(PST_CONSISTENT);
144  PARVEC_PROFILE_END(); //ParVec_CSTUnique2Consistent
145  }
146  else if(has_storage_type(PST_ADDITIVE)){
147  PARVEC_PROFILE_BEGIN(ParVec_CSTAdditive2Consistent);
148  AdditiveToConsistent(this, layouts()->master(), layouts()->slave(),
149  &layouts()->comm());
150  set_storage_type(PST_CONSISTENT);
151  PARVEC_PROFILE_END(); //ParVec_CSTAdditive2Consistent
152  }
153  else return false;
154 
155  if(layouts()->overlap_enabled()){
156  PARVEC_PROFILE_BEGIN(ParVec_CSTAdditive2Consistent_CopyOverlap);
157  CopyValues(this, layouts()->slave_overlap(),
158  layouts()->master_overlap(), &layouts()->comm());
159  }
160 
161  break;
162 
163  case PST_ADDITIVE:
164  if(has_storage_type(PST_UNIQUE)){
165  PARVEC_PROFILE_BEGIN(ParVec_CSTUnique2Additive);
166  add_storage_type(PST_ADDITIVE);
167  PARVEC_PROFILE_END(); //ParVec_CSTUnique2Additive
168  }
169  else if(has_storage_type(PST_CONSISTENT)){
170  PARVEC_PROFILE_BEGIN(ParVec_CSTConsistent2Additive);
171  ConsistentToUnique(this, layouts()->slave());
172  if(layouts()->overlap_enabled())
173  SetLayoutValues(this, layouts()->master_overlap(), 0);
174  set_storage_type(PST_ADDITIVE);
175  add_storage_type(PST_UNIQUE);
176  PARVEC_PROFILE_END(); //ParVec_CSTConsistent2Additive
177  }
178  else return false;
179  break;
180 
181  case PST_UNIQUE:
182  if(has_storage_type(PST_ADDITIVE)){
183  PARVEC_PROFILE_BEGIN(ParVec_CSTAdditive2Unique);
184  if(layouts()->overlap_enabled()){
185  AdditiveToConsistent(this, layouts()->master(), layouts()->slave(),
186  &layouts()->comm());
187  CopyValues(this, layouts()->slave_overlap(),
188  layouts()->master_overlap(), &layouts()->comm());
189  ConsistentToUnique(this, layouts()->slave());
190  }
191  else{
192  AdditiveToUnique(this, layouts()->master(), layouts()->slave(),
193  &layouts()->comm());
194  }
195  add_storage_type(PST_UNIQUE);
196  PARVEC_PROFILE_END(); //ParVec_CSTAdditive2Unique
197  }
198  else if(has_storage_type(PST_CONSISTENT)){
199  PARVEC_PROFILE_BEGIN(ParVec_CSTConsistent2Unique);
200  if(layouts()->overlap_enabled()){
201  CopyValues(this, layouts()->slave_overlap(),
202  layouts()->master_overlap(), &layouts()->comm());
203  }
204  ConsistentToUnique(this, layouts()->slave());
205  set_storage_type(PST_ADDITIVE);
206  add_storage_type(PST_UNIQUE);
207  PARVEC_PROFILE_END(); //ParVec_CSTConsistent2Unique
208  }
209  else return false;
210 
211  if(layouts()->overlap_enabled()){
212  SetLayoutValues(this, layouts()->slave_overlap(), 0);
213  }
214  break;
215  default: return false;
216  }
217  return true;
218 }
219 
220 template <typename TVector>
221 void
224 {
225  PROFILE_FUNC_GROUP("algebra");
226  if(type == PST_UNDEFINED) return;
227 
228  // set all local vector to value. Therefore parallel vector is consistent
229  TVector::set(w);
230  set_storage_type(PST_CONSISTENT);
231 
232  // if w == 0.0, we have all types
233  if(w == 0.0){
234  add_storage_type(PST_ADDITIVE);
235  add_storage_type(PST_UNIQUE);
236  return;
237  }
238 
239  // consistent required
240  if(type & PST_CONSISTENT) return;
241 
242  // additive or additive unique
243  change_storage_type(PST_UNIQUE);
244 }
245 
246 template <typename TVector>
247 number
250 {
251  this->set(d);
252  return d;
253 }
254 
255 template <typename TVector>
256 void
259 {
260  PROFILE_FUNC_GROUP("algebra");
261  // set all local vector to value. Therefore parallel vector is consistent
262  TVector::set_random(from, to);
263  set_storage_type(PST_ADDITIVE);
264 
265  // additive or additive unique
266  change_storage_type(type);
267 }
268 
269 template <typename TVector>
270 inline
272 {
273  PROFILE_FUNC_GROUP("algebra parallelization");
274  // step 1: make vector d additive unique
275  if(!const_cast<ParallelVector<TVector>*>(this)->change_storage_type(PST_UNIQUE))
276  UG_THROW("ParallelVector::norm(): Cannot change"
277  " ParallelStorageType to unique.");
278 
279  // step 2: compute process-local defect norm, square them
280  double tNormLocal = (double)TVector::norm();
281  tNormLocal *= tNormLocal;
282 
283  // step 3: sum squared local norms
284  PARVEC_PROFILE_BEGIN(ParVec_norm_allreduce);
285  double tNormGlobal;
286  if(layouts()->proc_comm().empty())
287  tNormGlobal = tNormLocal;
288  else
289  tNormGlobal = layouts()->proc_comm().allreduce(tNormLocal, PCL_RO_SUM);
291 
292  // step 4: return global norm ( = square root of summed squared local norms)
293  return sqrt((number)tNormGlobal);
294 }
295 
296 template <typename TVector>
297 inline
299 {
300  PROFILE_FUNC_GROUP("algebra parallelization");
301 
302  if(this->has_storage_type(PST_ADDITIVE))
303  if(!const_cast<ParallelVector<TVector>*>(this)->change_storage_type(PST_UNIQUE))
304  UG_THROW("ParallelVector::norm(): Cannot change"
305  " ParallelStorageType to unique.");
306 
307  // step 2: compute process-local defect norm, square them
308  double tNormLocal = (double)TVector::maxnorm();
309 
310  // step 3: sum squared local norms
311  PARVEC_PROFILE_BEGIN(ParVec_norm_allreduce);
312  double tNormGlobal;
313  if(layouts()->proc_comm().empty())
314  tNormGlobal = tNormLocal;
315  else
316  tNormGlobal = layouts()->proc_comm().allreduce(tNormLocal, PCL_RO_MAX);
318 
319  // step 4: return global norm ( = square root of summed squared local norms)
320  return (number)tNormGlobal;
321 }
322 
323 template <typename TVector>
324 inline
326 {
327  PROFILE_FUNC_GROUP("algebra parallelization");
328  // step 0: check that storage type is given
329  if(this->has_storage_type(PST_UNDEFINED) || v.has_storage_type(PST_UNDEFINED))
330  {
331  UG_LOG("ERROR in 'ParallelVector::dotprod': "
332  "Parallel storage type of vector not given.\n");
333  UG_THROW("ERROR in ParallelVector::dotprod(): No parallel "
334  "Storage type given.");
335  }
336 
337  // step 1: Check if good storage type are given (no communication needed)
338  // - additive (unique) <-> consistent is ok
339  // - unique <-> unique is ok
340  bool check = false;
341  if(this->has_storage_type(PST_ADDITIVE)
342  && v.has_storage_type(PST_CONSISTENT)) check = true;
343  if(this->has_storage_type(PST_CONSISTENT)
344  && v.has_storage_type(PST_ADDITIVE)) check = true;
345  if(this->has_storage_type(PST_UNIQUE)
346  && v.has_storage_type(PST_UNIQUE)) check = true;
347 
348  // step 2: fall back
349  // if storage type not as in the upper cases, communicate to
350  // correct solution a user of this function should ideally avoid
351  // such a change and do it outside of this function
352  if(!check)
353  {
354  // unique <-> additive => consistent <-> additive
355  if(this->has_storage_type(PST_UNIQUE)
357  {this->change_storage_type(PST_CONSISTENT);}
358  // additive <-> unique => unique <-> unique
359  else if(this->has_storage_type(PST_ADDITIVE)
361  {this->change_storage_type(PST_UNIQUE);}
362  // consistent <-> consistent => unique <-> consistent
363  else {this->change_storage_type(PST_UNIQUE);}
364  }
365 
366  // step 3: compute local dot product
367  double tSumLocal = (double)TVector::dotprod(v);
368  double tSumGlobal;
369 
370  // step 4: sum global contributions
371  if(layouts()->proc_comm().empty())
372  tSumGlobal = tSumLocal;
373  else
374  layouts()->proc_comm().allreduce(&tSumLocal, &tSumGlobal, 1,
376 
377  // step 5: return result
378  return tSumGlobal;
379 }
380 
381 template <typename TVector>
383 {
384 
385 // a) for unique: all slaves must be zero
386  if(this->has_storage_type(PST_UNIQUE)){
387  // get slave layout
388  const IndexLayout& layout = layouts()->slave();
389 
390  // interface iterators
391  typename IndexLayout::const_iterator iter = layout.begin();
392  typename IndexLayout::const_iterator end = layout.end();
393 
394  // iterate over interfaces
395  for(; iter != end; ++iter)
396  {
397  // get interface
398  const typename IndexLayout::Interface& interface = layout.interface(iter);
399 
400  // loop over indices
401  for(typename IndexLayout::Interface::const_iterator iter = interface.begin();
402  iter != interface.end(); ++iter)
403  {
404  // get index
405  const size_t index = interface.get_element(iter);
406 
407  // set value of vector to zero
408  if(BlockNorm2((*this)[index]) != 0.0){
409  UG_LOG_ALL_PROCS("Unique vector at slave index "<<index<<
410  " has block norm: "<<BlockNorm2((*this)[index])<<"\n");
411  }
412  }
413  }
414  }
415 
416 // c) for consistent: slave values must be equal to master values
417  if(this->has_storage_type(PST_CONSISTENT)){
418  // create a new communicator if required.
420 
421  // step 1: copy master values to slaves
422  // create the required communication policies
423  ComPol_CheckConsistency<TVector> cpVecCheckConsistency(this);
424 
425  // perform communication
426  com.send_data(layouts()->slave(), cpVecCheckConsistency);
427  com.receive_data(layouts()->master(), cpVecCheckConsistency);
428  com.communicate();
429  }
430 }
431 
432 template <typename TVector>
434 {
435  // try to change to unique
436  if(this->has_storage_type(PST_ADDITIVE)){
437  this->change_storage_type(PST_UNIQUE);
438  }
439 
440  // if not unique -> make it unique
441  // at this point one may change the vector
442  if(!this->has_storage_type(PST_UNIQUE)){
443  SetLayoutValues(this, layouts()->slave(), 0.0);
444  this->set_storage_type(PST_UNIQUE);
445  }
446 
447  // change to consistent
448  this->change_storage_type(PST_CONSISTENT);
449 }
450 
451 // for template expressions
452 // d = alpha*v1
453 template<typename T>
455  double alpha1, const ParallelVector<T> &v1)
456 {
457  PROFILE_FUNC_GROUP("algebra");
459  VecScaleAssign(*dynamic_cast<T*>(&dest), alpha1, *dynamic_cast<const T*>(&v1));
460 }
461 
462 // for template expressions
463 // d = v1
464 template<typename T>
465 inline void VecAssign(ParallelVector<T> &dest,
466  const ParallelVector<T> &v1)
467 {
468  PROFILE_FUNC_GROUP("algebra");
470  VecAssign(*dynamic_cast<T*>(&dest), *dynamic_cast<const T*>(&v1));
471 }
472 
473 
474 // dest = alpha1*v1 + alpha2*v2
475 template<typename T>
476 inline void VecScaleAdd(ParallelVector<T> &dest,
477  double alpha1, const ParallelVector<T> &v1,
478  double alpha2, const ParallelVector<T> &v2)
479 {
480  PROFILE_FUNC_GROUP("algebra");
481  uint mask = v1.get_storage_mask() & v2.get_storage_mask();
482  UG_COND_THROW(mask == 0, "VecScaleAdd: cannot add vectors v1 and v2 because their storage masks are incompatible");
483  dest.set_storage_type(mask);
484 
485  VecScaleAdd(*dynamic_cast<T*>(&dest), alpha1, *dynamic_cast<const T*>(&v1),
486  alpha2, *dynamic_cast<const T*>(&v2));
487 }
488 
489 // dest = alpha1*v1 + alpha2*v2 + alpha3*v3
490 template<typename T>
491 inline void VecScaleAdd(ParallelVector<T> &dest,
492  double alpha1, const ParallelVector<T> &v1,
493  double alpha2, const ParallelVector<T> &v2,
494  double alpha3, const ParallelVector<T> &v3)
495 {
496  PROFILE_FUNC_GROUP("algebra");
497  uint mask = v1.get_storage_mask() &
498  v2.get_storage_mask() &
499  v3.get_storage_mask();
500  UG_COND_THROW(mask == 0, "VecScaleAdd: cannot add vectors v1 and v2 because their storage masks are incompatible");
501  dest.set_storage_type(mask);
502 
503  VecScaleAdd((T&)dest, alpha1, (const T&)v1, alpha2, (const T&)v2, alpha3, (const T&)v3);
504 }
505 
506 // returns scal<a, b>
507 template<typename T>
508 inline double VecProd(const ParallelVector<T> &a, const ParallelVector<T> &b)
509 {
510  return const_cast<ParallelVector<T>* >(&a)->dotprod(b);
511 }
512 
513 // Elementwise (Hadamard) product of two vectors
514 template<typename T>
516 {
517  uint mask = v1.get_storage_mask() & v2.get_storage_mask();
518  UG_COND_THROW(mask == 0, "VecHadamardProd: cannot multiply vectors v1 and v2 because their storage masks are incompatible");
519  dest.set_storage_type(mask);
520 
521  VecHadamardProd(*dynamic_cast<T*>(&dest), *dynamic_cast<const T*>(&v1), *dynamic_cast<const T*>(&v2));
522 }
523 
524 // Elementwise exp of a vector
525 template<typename T>
526 inline void VecExp(ParallelVector<T> &dest, const ParallelVector<T> &v)
527 {
528  VecExp(*dynamic_cast<T*>(&dest), *dynamic_cast<const T*>(&v));
529 }
530 
531 // Elementwise log (natural logarithm) of a vector
532 template<typename T>
533 inline void VecLog(ParallelVector<T> &dest, const ParallelVector<T> &v)
534 {
535  VecLog(*dynamic_cast<T*>(&dest), *dynamic_cast<const T*>(&v));
536 }
537 
539 
540 template<typename TVector>
542 {
543  CloneVector((TVector&)dest, (TVector&)src);
545  dest.set_layouts(src.layouts());
546  return true;
547 }
548 
549 template<typename TVector>
551 {
553  *pVec = *this;
554  return pVec;
555 }
556 
557 template<typename TVector>
559 {
560  return SmartPtr<ParallelVector<TVector> >(this->virtual_clone());
561 }
562 
563 template<typename TVector>
565 {
566  ParallelVector<TVector>* pVec = new ParallelVector<TVector>(this->size());
567 // pVec->set_storage_type(this->get_storage_mask()); --> undefined is correct
568  pVec->set_layouts(this->layouts());
569  return pVec;
570 }
571 
572 template<typename TVector>
574 {
575  return SmartPtr<ParallelVector<TVector> >(this->virtual_clone_without_values());
576 }
577 
578 
579 
580 } // end namespace ug
581 
582 #endif /* __H__LIB_ALGEBRA__PARALLELIZATION__PARALLEL_VECTOR_IMPL__ */
Definition: smart_pointer.h:108
Performs communication between interfaces on different processes.
Definition: pcl_interface_communicator.h:68
bool communicate(int tag=749345)
sends and receives the collected data.
Definition: pcl_interface_communicator_impl.hpp:409
void send_data(int targetProc, const Interface &interface, ICommunicationPolicy< TLayout > &commPol)
collects data that will be send during communicate.
Definition: pcl_interface_communicator_impl.hpp:80
void receive_data(int srcProc, const Interface &interface, ICommunicationPolicy< TLayout > &commPol)
registers a communication-policy to receive data on communicate.
Definition: pcl_interface_communicator_impl.hpp:188
You may add elements to this interface and iterate over them.
Definition: pcl_communication_structs.h:207
Element & get_element(iterator iter)
Definition: pcl_communication_structs.h:298
iterator end(size_t level=0)
returns the iterator to the last interface of the layout.
Definition: pcl_communication_structs.h:492
iterator begin(size_t level=0)
returns the iterator to the first interface of the layout.
Definition: pcl_communication_structs.h:486
InterfaceMap::const_iterator const_iterator
Definition: pcl_communication_structs.h:477
Communication Policy to check consistency of a vector.
Definition: communication_policies.h:783
Definition: parallel_vector.h:60
number dotprod(const this_type &v)
dotprod (overwrites TVector::dotprod())
Definition: parallel_vector_impl.h:325
virtual this_type * virtual_clone() const
virtual clone using covariant return type
Definition: parallel_vector_impl.h:550
void check_storage_type() const
checks correctness of storage type
Definition: parallel_vector_impl.h:382
void set_random(number from, number to, ParallelStorageType type)
set all entries to a random number (overwrites TVector::set_random(number from, number to))
Definition: parallel_vector_impl.h:258
bool has_storage_type(uint type) const
returns if the current storage type has a given representation
Definition: parallel_vector.h:119
this_type & operator=(T t)
catch all other assignments so we don't use copy constructor here
ConstSmartPtr< AlgebraLayouts > layouts() const
returns the algebra layouts
Definition: parallel_vector.h:97
virtual this_type * virtual_clone_without_values() const
virtual clone using covariant return type excluding values
Definition: parallel_vector_impl.h:564
uint get_storage_mask() const
returns storage type mask
Definition: parallel_vector.h:123
void set(number w, ParallelStorageType type)
set all entries to value and the storage type
Definition: parallel_vector_impl.h:223
this_type & operator-=(const this_type &v)
subtract a vector
Definition: parallel_vector_impl.h:73
SmartPtr< this_type > clone() const
clones the vector (deep-copy) including values
Definition: parallel_vector_impl.h:558
bool change_storage_type(ParallelStorageType type)
changes to the requested storage type if possible
Definition: parallel_vector_impl.h:118
void set_storage_type(uint type)
sets the storage type
Definition: parallel_vector.h:104
number maxnorm() const
max norm (overwrites TVector::maxnorm())
Definition: parallel_vector_impl.h:298
number norm() const
two norm (overwrites TVector::norm())
Definition: parallel_vector_impl.h:271
ParallelVector< TVector > this_type
own type
Definition: parallel_vector.h:66
this_type & operator+=(const this_type &v)
add a vector
Definition: parallel_vector_impl.h:95
void set_layouts(ConstSmartPtr< AlgebraLayouts > layouts)
sets the algebra layouts
Definition: parallel_vector.h:100
SmartPtr< this_type > clone_without_values() const
clones the vector (deep-copy) excluding values
Definition: parallel_vector_impl.h:573
void enforce_consistent_type()
sets storage type to consistent
Definition: parallel_vector_impl.h:433
void ConsistentToUnique(TVector *pVec, const IndexLayout &slaveLayout)
changes parallel storage type from consistent to unique
Definition: parallelization_util.h:388
void SetLayoutValues(TVector *pVec, const IndexLayout &layout, typename TVector::value_type val)
sets the values of a vector to a given number only on the layout indices
Definition: parallelization_util.h:315
void UniqueToConsistent(TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
changes parallel storage type from unique to consistent
Definition: parallelization_util.h:204
void AdditiveToUnique(TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
changes parallel storage type from additive to unique
Definition: parallelization_util.h:261
void CopyValues(TVector *pVec, const IndexLayout &sourceLayout, const IndexLayout &targetLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
Copies values from the source to the target layout.
Definition: parallelization_util.h:228
void AdditiveToConsistent(TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
changes parallel storage type from additive to consistent
Definition: parallelization_util.h:160
ParallelStorageType
Definition: parallel_storage_type.h:66
@ PST_UNDEFINED
Definition: parallel_storage_type.h:67
@ PST_CONSISTENT
Definition: parallel_storage_type.h:68
@ PST_UNIQUE
Definition: parallel_storage_type.h:70
@ PST_ADDITIVE
Definition: parallel_storage_type.h:69
#define PCL_RO_SUM
Definition: pcl_methods.h:63
#define PCL_DT_DOUBLE
Definition: pcl_datatype.h:57
#define PCL_RO_MAX
Definition: pcl_methods.h:61
#define UG_LOG_ALL_PROCS(msg)
Definition: log.h:371
#define UG_THROW(msg)
Definition: error.h:57
#define UG_LOG(msg)
Definition: log.h:367
unsigned int uint
Definition: types.h:114
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
double number
Definition: types.h:124
void VecScaleAdd(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1, typename vector_t::value_type s2, const vector_t &v2)
Scales two Vectors, adds them and returns the sum in a third vector.
Definition: math_vector_functions_common_impl.hpp:265
the ug namespace
void VecAssign(vector_t &dest, const vector_t &v1)
sets dest = v1 entrywise
Definition: operations_vec.h:154
void VecExp(double &dest, const double &v)
calculates elementwise exp
Definition: operations_vec.h:122
void CloneVector(Vector< TValueType > &dest, const Vector< TValueType > &src)
Definition: vector_impl.h:341
double VecProd(const double &a, const double &b)
returns scal<a, b>
Definition: operations_vec.h:84
void VecLog(double &dest, const double &v)
calculates elementwise log (natural logarithm)
Definition: operations_vec.h:128
double BlockNorm2(const TYPE &v)
Definition: blocks.h:51
void VecHadamardProd(double &dest, const double &v1, const double &v2)
calculates s = a * b (the Hadamard product)
Definition: operations_vec.h:114
void VecScaleAssign(double &dest, double alpha1, const double &v1)
calculates dest = alpha1*v1. for doubles
Definition: operations_vec.h:49
#define PARVEC_PROFILE_END()
Definition: parallel_vector_impl.h:45
#define PARVEC_PROFILE_BEGIN(name)
Definition: parallel_vector_impl.h:44
switch(yytype)
Definition: parser.cpp:1299
#define PROFILE_FUNC_GROUP(groups)
Definition: profiler.h:258