escript
Revision_
|
00001 00002 /***************************************************************************** 00003 * 00004 * Copyright (c) 2003-2014 by University of Queensland 00005 * http://www.uq.edu.au 00006 * 00007 * Primary Business: Queensland, Australia 00008 * Licensed under the Open Software License version 3.0 00009 * http://www.opensource.org/licenses/osl-3.0.php 00010 * 00011 * Development until 2012 by Earth Systems Science Computational Center (ESSCC) 00012 * Development 2012-2013 by School of Earth Sciences 00013 * Development from 2014 by Centre for Geoscience Computing (GeoComp) 00014 * 00015 *****************************************************************************/ 00016 00017 00018 /****************************************************************************/ 00019 00020 /* Paso: shared components */ 00021 00022 /****************************************************************************/ 00023 00024 /* Author: Lutz Gross, l.gross@uq.edu.au */ 00025 00026 /****************************************************************************/ 00027 00028 #ifndef __PASO_SHAREDCOMPONENTS_H__ 00029 #define __PASO_SHAREDCOMPONENTS_H__ 00030 00031 #include "Paso.h" 00032 00033 namespace paso { 00034 00035 struct SharedComponents; 00036 typedef boost::shared_ptr<SharedComponents> SharedComponents_ptr; 00037 typedef boost::shared_ptr<const SharedComponents> const_SharedComponents_ptr; 00038 00039 PASO_DLL_API 00040 struct SharedComponents 00041 { 00042 SharedComponents(dim_t localLength, dim_t nNeighbours, 00043 const Esys_MPI_rank* neighbours, const index_t* sharedArray, 00044 const index_t* offset, index_t m, index_t b, Esys_MPIInfo *mpiInfo) 00045 : local_length(localLength*m), 00046 numNeighbors(nNeighbours) 00047 { 00048 mpi_info = Esys_MPIInfo_getReference(mpiInfo); 00049 neighbor = new Esys_MPI_rank[numNeighbors]; 00050 if (!offset) { 00051 numSharedComponents = 0; 00052 } else { 00053 numSharedComponents = offset[nNeighbours] * m; 00054 } 00055 shared = new index_t[numSharedComponents]; 00056 offsetInShared = new index_t[numNeighbors+1]; 00057 if (numNeighbors > 0 && offset != NULL) { 00058 #pragma omp parallel 00059 { 00060 #pragma omp for 00061 for (dim_t i=0; i < numNeighbors; i++) { 00062 neighbor[i] = neighbours[i]; 00063 offsetInShared[i] = offset[i] * m; 00064 } 00065 offsetInShared[numNeighbors] = offset[nNeighbours] * m; 00066 #pragma omp for 00067 for (dim_t i=0; i<offset[nNeighbours]; i++) { 00068 const index_t itmp=m*sharedArray[i]+b; 00069 for (dim_t j=0; j < m; ++j) 00070 shared[m*i+j]=itmp+j; 00071 } 00072 } 00073 } else { 00074 offsetInShared[numNeighbors]=0; 00075 } 00076 } 00077 00078 ~SharedComponents() 00079 { 00080 delete[] neighbor; 00081 delete[] shared; 00082 delete[] offsetInShared; 00083 Esys_MPIInfo_free(mpi_info); 00084 } 00085 00087 dim_t local_length; 00088 00090 dim_t numNeighbors; 00091 00094 index_t* offsetInShared; 00095 00097 Esys_MPI_rank* neighbor; 00098 00101 index_t* shared; 00102 00104 dim_t numSharedComponents; 00105 00106 Esys_MPIInfo *mpi_info; 00107 }; 00108 00109 } // namespace paso 00110 00111 #endif // __PASO_SHAREDCOMPONENTS_H__ 00112