escript  Revision_
SharedComponents.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2020 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17 
18 
19 /****************************************************************************/
20 
21 /* Paso: shared components */
22 
23 /****************************************************************************/
24 
25 /* Author: Lutz Gross, l.gross@uq.edu.au */
26 
27 /****************************************************************************/
28 
29 #ifndef __PASO_SHAREDCOMPONENTS_H__
30 #define __PASO_SHAREDCOMPONENTS_H__
31 
32 #include "Paso.h"
33 
34 namespace paso {
35 
36 struct SharedComponents;
37 typedef boost::shared_ptr<SharedComponents> SharedComponents_ptr;
38 typedef boost::shared_ptr<const SharedComponents> const_SharedComponents_ptr;
39 
41 struct SharedComponents
42 {
43  SharedComponents(dim_t localLength, const std::vector<int>& neighbours,
44  const index_t* sharedArray,
45  const std::vector<index_t>& offset,
46  index_t m = 1, index_t b = 0)
47  : local_length(localLength*m),
48  neighbour(neighbours),
49  offsetInShared(offset)
50  {
51  if (offset.empty()) {
53  } else {
54  numSharedComponents = offset[neighbours.size()] * m;
55  }
57  if (!neighbours.empty() && !offset.empty()) {
58  if (m != 1) {
59  for (int i = 0; i < offsetInShared.size(); i++) {
60  offsetInShared[i] *= m;
61  }
62  }
63 #pragma omp parallel for
64  for (dim_t i = 0; i < offset[neighbours.size()]; i++) {
65  const index_t itmp = m * sharedArray[i] + b;
66  for (dim_t j = 0; j < m; ++j)
67  shared[m*i+j] = itmp+j;
68  }
69  } else {
70  offsetInShared[neighbours.size()] = 0;
71  }
72  }
73 
75  {
76  delete[] shared;
77  }
78 
81 
83  std::vector<int> neighbour;
84 
87  std::vector<index_t> offsetInShared;
88 
91  index_t* shared;
92 
95 };
96 
97 } // namespace paso
98 
99 #endif // __PASO_SHAREDCOMPONENTS_H__
100 
paso::SharedComponents::local_length
dim_t local_length
local array length shared
Definition: SharedComponents.h:94
paso::SharedComponents::SharedComponents
SharedComponents(dim_t localLength, const std::vector< int > &neighbours, const index_t *sharedArray, const std::vector< index_t > &offset, index_t m=1, index_t b=0)
Definition: SharedComponents.h:57
paso::SharedComponents::~SharedComponents
~SharedComponents()
Definition: SharedComponents.h:88
paso::SharedComponents::numSharedComponents
dim_t numSharedComponents
= offsetInShared[numNeighbours]
Definition: SharedComponents.h:108
Paso.h
paso::SharedComponents::neighbour
std::vector< int > neighbour
list of the processors sharing values with this processor
Definition: SharedComponents.h:97
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:93
paso::SharedComponents_ptr
boost::shared_ptr< SharedComponents > SharedComponents_ptr
Definition: SharedComponents.h:50
paso::SharedComponents::shared
index_t * shared
Definition: SharedComponents.h:105
paso::const_SharedComponents_ptr
boost::shared_ptr< const SharedComponents > const_SharedComponents_ptr
Definition: SharedComponents.h:52
escript::DataTypes::index_t
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:88
paso::SharedComponents::offsetInShared
std::vector< index_t > offsetInShared
Definition: SharedComponents.h:101
PASO_DLL_API
#define PASO_DLL_API
Definition: Paso.h:60
paso
Definition: BiCGStab.cpp:26