escript  Revision_4925
SharedComponents.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
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 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16 
17 
18 /****************************************************************************/
19 
20 /* Paso: shared components */
21 
22 /****************************************************************************/
23 
24 /* Author: Lutz Gross, l.gross@uq.edu.au */
25 
26 /****************************************************************************/
27 
28 #ifndef __PASO_SHAREDCOMPONENTS_H__
29 #define __PASO_SHAREDCOMPONENTS_H__
30 
31 #include "Paso.h"
32 
33 namespace paso {
34 
36 typedef boost::shared_ptr<SharedComponents> SharedComponents_ptr;
37 typedef boost::shared_ptr<const SharedComponents> const_SharedComponents_ptr;
38 
41 {
42  SharedComponents(dim_t localLength, dim_t nNeighbours,
43  const Esys_MPI_rank* neighbours, const index_t* sharedArray,
44  const index_t* offset, index_t m, index_t b, Esys_MPIInfo *mpiInfo)
45  : local_length(localLength*m),
46  numNeighbors(nNeighbours)
47  {
50  if (!offset) {
52  } else {
53  numSharedComponents = offset[nNeighbours] * m;
54  }
57  if (numNeighbors > 0 && offset != NULL) {
58 #pragma omp parallel
59  {
60 #pragma omp for
61  for (dim_t i=0; i < numNeighbors; i++) {
62  neighbor[i] = neighbours[i];
63  offsetInShared[i] = offset[i] * m;
64  }
65  offsetInShared[numNeighbors] = offset[nNeighbours] * m;
66 #pragma omp for
67  for (dim_t i=0; i<offset[nNeighbours]; i++) {
68  const index_t itmp=m*sharedArray[i]+b;
69  for (dim_t j=0; j < m; ++j)
70  shared[m*i+j]=itmp+j;
71  }
72  }
73  } else {
75  }
76  }
77 
79  {
80  delete[] neighbor;
81  delete[] shared;
82  delete[] offsetInShared;
84  }
85 
88 
91 
95 
98 
102 
105 
107 };
108 
109 } // namespace paso
110 
111 #endif // __PASO_SHAREDCOMPONENTS_H__
112 
#define PASO_DLL_API
Definition: Paso.h:41
dim_t numNeighbors
number of processors sharing values with this processor
Definition: SharedComponents.h:90
~SharedComponents()
Definition: SharedComponents.h:78
void Esys_MPIInfo_free(Esys_MPIInfo *in)
Definition: Esys_MPI.cpp:60
boost::shared_ptr< const SharedComponents > const_SharedComponents_ptr
Definition: SharedComponents.h:37
boost::shared_ptr< SharedComponents > SharedComponents_ptr
Definition: SharedComponents.h:35
Struct that holds MPI communicator, rank, size and a tag counter.
Definition: Esys_MPI.h:48
dim_t local_length
local array length shared
Definition: SharedComponents.h:87
index_t * offsetInShared
Definition: SharedComponents.h:94
dim_t numSharedComponents
= offsetInShared[numNeighbors]
Definition: SharedComponents.h:104
Esys_MPIInfo * Esys_MPIInfo_getReference(Esys_MPIInfo *in)
Definition: Esys_MPI.cpp:67
int index_t
Definition: types.h:25
int Esys_MPI_rank
Definition: Esys_MPI.h:37
Definition: SharedComponents.h:40
Esys_MPIInfo * mpi_info
Definition: SharedComponents.h:106
SharedComponents(dim_t localLength, dim_t nNeighbours, const Esys_MPI_rank *neighbours, const index_t *sharedArray, const index_t *offset, index_t m, index_t b, Esys_MPIInfo *mpiInfo)
Definition: SharedComponents.h:42
Esys_MPI_rank * neighbor
list of the processors sharing values with this processor
Definition: SharedComponents.h:97
int dim_t
Definition: types.h:24
index_t * shared
Definition: SharedComponents.h:101