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
34namespace paso {
35
36struct SharedComponents;
37typedef boost::shared_ptr<SharedComponents> SharedComponents_ptr;
38typedef boost::shared_ptr<const SharedComponents> const_SharedComponents_ptr;
39
41{
42 SharedComponents(dim_t localLength, const std::vector<int>& neighbours,
43 const index_t* sharedArray,
44 const std::vector<index_t>& offset,
45 index_t m = 1, index_t b = 0)
46 : local_length(localLength*m),
47 neighbour(neighbours),
48 offsetInShared(offset)
49 {
50 if (offset.empty()) {
51 numSharedComponents = 0;
52 } else {
53 numSharedComponents = offset[neighbours.size()] * m;
54 }
55 shared = new index_t[numSharedComponents];
56 if (!neighbours.empty() && !offset.empty()) {
57 if (m != 1) {
58 for (int i = 0; i < offsetInShared.size(); i++) {
59 offsetInShared[i] *= m;
60 }
61 }
62#pragma omp parallel for
63 for (dim_t i = 0; i < offset[neighbours.size()]; i++) {
64 const index_t itmp = m * sharedArray[i] + b;
65 for (dim_t j = 0; j < m; ++j)
66 shared[m*i+j] = itmp+j;
67 }
68 } else {
69 offsetInShared[neighbours.size()] = 0;
70 }
71 }
72
74 {
75 delete[] shared;
76 }
77
80
82 std::vector<int> neighbour;
83
86 std::vector<index_t> offsetInShared;
87
90 index_t* shared;
91
94};
95
96} // namespace paso
97
98#endif // __PASO_SHAREDCOMPONENTS_H__
99
Definition BiCGStab.cpp:25
boost::shared_ptr< const SharedComponents > const_SharedComponents_ptr
Definition SharedComponents.h:38
boost::shared_ptr< SharedComponents > SharedComponents_ptr
Definition SharedComponents.h:37
#define PASO_DLL_API
Definition paso/src/system_dep.h:29
Definition SharedComponents.h:41
std::vector< index_t > offsetInShared
Definition SharedComponents.h:86
index_t * shared
Definition SharedComponents.h:90
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:42
dim_t local_length
local array length shared
Definition SharedComponents.h:79
~SharedComponents()
Definition SharedComponents.h:73
dim_t numSharedComponents
= offsetInShared[numNeighbours]
Definition SharedComponents.h:93
std::vector< int > neighbour
list of the processors sharing values with this processor
Definition SharedComponents.h:82