Loading src/TNL/Meshes/DistributedMeshes/Directions.h +22 −54 Original line number Diff line number Diff line Loading @@ -110,20 +110,19 @@ public: return result-1; }*/ static int add(int direction) static constexpr int add(int direction) { if(direction==0) return 0; if(direction>0) return 2*pow3(direction-1); //positive direction has higer index return 2*i3pow(direction-1); //positive direction has higer index else return pow3(-direction-1); return i3pow(-direction-1); } static int pow3(int exp) // return 3^exp static constexpr int i3pow(int exp) { int ret=1; for(int i=0;i<exp;i++) Loading @@ -132,37 +131,6 @@ public: } }; //for c++11 -- in c++14 simply 3^dim-1 template<int dim> class DirectionCount { public: static constexpr int get(){return 0;} }; template <> class DirectionCount<1> { public: static constexpr int get(){return 2;} }; template <> class DirectionCount<2> { public: static constexpr int get(){return 8;} }; template <> class DirectionCount<3> { public: static constexpr int get(){return 26;} }; } // namespace DistributedMeshes } // namespace Meshes } // namespace TNL src/TNL/Meshes/DistributedMeshes/DistributedGrid.h +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ class DistributedMesh< Grid< Dimension, Real, Device, Index > > static constexpr int getMeshDimension() { return Dimension; }; static constexpr int getNeighborsCount() { return DirectionCount<Dimension>::get(); } //c++14 may use Directions::pow3(Dimension)-1 static constexpr int getNeighborsCount() { return Directions::i3pow(Dimension)-1; } DistributedMesh(); Loading src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer.h +15 −17 Original line number Diff line number Diff line Loading @@ -30,14 +30,14 @@ template< int MeshDimension, class DistributedMeshSynchronizer< DistributedMesh< Grid< MeshDimension, GridReal, Device, Index > >, MeshDimension > { public: static constexpr int getMeshDimension() { return MeshDimension; }; static constexpr int getNeighborCount() {return DirectionCount<MeshDimension>::get();}; typedef typename Grid< MeshDimension, GridReal, Device, Index >::Cell Cell; typedef typename Grid< MeshDimension, GridReal, Device, Index >::DistributedMeshType DistributedGridType; typedef typename DistributedGridType::CoordinatesType CoordinatesType; using SubdomainOverlapsType = typename DistributedGridType::SubdomainOverlapsType; static constexpr int getMeshDimension() { return DistributedGridType::getMeshDimension(); }; static constexpr int getNeighborsCount() { return DistributedGridType::getNeighborsCount(); }; enum PeriodicBoundariesCopyDirection { BoundaryToOverlap, Loading Loading @@ -74,7 +74,7 @@ class DistributedMeshSynchronizer< DistributedMesh< Grid< MeshDimension, GridRea const int *neighbors = distributedGrid->getNeighbors(); for( int i=0; i<this->getNeighborCount(); i++ ) for( int i=0; i<this->getNeighborsCount(); i++ ) { Index sendSize=1;//send and receive areas have the same size Loading Loading @@ -126,7 +126,7 @@ class DistributedMeshSynchronizer< DistributedMesh< Grid< MeshDimension, GridRea if( !distributedGrid->isDistributed() ) return; // allocate buffers (setSize does nothing if the array size is already correct) for( int i=0; i<this->getNeighborCount(); i++ ) { for( int i=0; i<this->getNeighborsCount(); i++ ) { sendBuffers[ i ].setSize( sendSizes[ i ] * sizeof(RealType) ); recieveBuffers[ i ].setSize( sendSizes[ i ] * sizeof(RealType)); } Loading @@ -143,12 +143,12 @@ class DistributedMeshSynchronizer< DistributedMesh< Grid< MeshDimension, GridRea PeriodicBoundariesMaskPointer( nullptr ) ); // the mask is used only when receiving data ); //async send and receive MPI_Request requests[2*this->getNeighborCount()]; MPI_Request requests[2*this->getNeighborsCount()]; MPI_Comm group = distributedGrid->getCommunicationGroup(); int requestsCount( 0 ); //send everything, recieve everything for( int i=0; i<this->getNeighborCount(); i++ ) for( int i=0; i<this->getNeighborsCount(); i++ ) { /*TNL_MPI_PRINT( "Sending data... " << i << " sizes -> " << sendSizes[ i ] << "sendDimensions -> " << sendDimensions[ i ] Loading Loading @@ -199,7 +199,7 @@ class DistributedMeshSynchronizer< DistributedMesh< Grid< MeshDimension, GridRea using RealType = typename MeshFunctionType::RealType; using Helper = BufferEntitiesHelper< MeshFunctionType, PeriodicBoundariesMaskPointer, getMeshDimension(), RealType, Device >; for(int i=0;i<this->getNeighborCount();i++) for(int i=0;i<this->getNeighborsCount();i++) { bool isBoundary=( neighbor[ i ] == -1 ); if( ! isBoundary || periodicBoundaries ) Loading @@ -211,24 +211,22 @@ class DistributedMeshSynchronizer< DistributedMesh< Grid< MeshDimension, GridRea private: Containers::StaticArray< getNeighborCount(), int > sendSizes; Containers::Array< std::uint8_t, Device, Index > sendBuffers[getNeighborCount()]; Containers::Array< std::uint8_t, Device, Index > recieveBuffers[getNeighborCount()]; Containers::StaticArray< getNeighborsCount(), int > sendSizes; Containers::Array< std::uint8_t, Device, Index > sendBuffers[getNeighborsCount()]; Containers::Array< std::uint8_t, Device, Index > recieveBuffers[getNeighborsCount()]; PeriodicBoundariesCopyDirection periodicBoundariesCopyDirection = BoundaryToOverlap; CoordinatesType sendDimensions[getNeighborCount()]; CoordinatesType recieveDimensions[getNeighborCount()]; CoordinatesType sendBegin[getNeighborCount()]; CoordinatesType recieveBegin[getNeighborCount()]; CoordinatesType sendDimensions[getNeighborsCount()]; CoordinatesType recieveDimensions[getNeighborsCount()]; CoordinatesType sendBegin[getNeighborsCount()]; CoordinatesType recieveBegin[getNeighborsCount()]; DistributedGridType *distributedGrid; bool isSet; }; } // namespace DistributedMeshes } // namespace Meshes } // namespace TNL Loading
src/TNL/Meshes/DistributedMeshes/Directions.h +22 −54 Original line number Diff line number Diff line Loading @@ -110,20 +110,19 @@ public: return result-1; }*/ static int add(int direction) static constexpr int add(int direction) { if(direction==0) return 0; if(direction>0) return 2*pow3(direction-1); //positive direction has higer index return 2*i3pow(direction-1); //positive direction has higer index else return pow3(-direction-1); return i3pow(-direction-1); } static int pow3(int exp) // return 3^exp static constexpr int i3pow(int exp) { int ret=1; for(int i=0;i<exp;i++) Loading @@ -132,37 +131,6 @@ public: } }; //for c++11 -- in c++14 simply 3^dim-1 template<int dim> class DirectionCount { public: static constexpr int get(){return 0;} }; template <> class DirectionCount<1> { public: static constexpr int get(){return 2;} }; template <> class DirectionCount<2> { public: static constexpr int get(){return 8;} }; template <> class DirectionCount<3> { public: static constexpr int get(){return 26;} }; } // namespace DistributedMeshes } // namespace Meshes } // namespace TNL
src/TNL/Meshes/DistributedMeshes/DistributedGrid.h +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ class DistributedMesh< Grid< Dimension, Real, Device, Index > > static constexpr int getMeshDimension() { return Dimension; }; static constexpr int getNeighborsCount() { return DirectionCount<Dimension>::get(); } //c++14 may use Directions::pow3(Dimension)-1 static constexpr int getNeighborsCount() { return Directions::i3pow(Dimension)-1; } DistributedMesh(); Loading
src/TNL/Meshes/DistributedMeshes/DistributedGridSynchronizer.h +15 −17 Original line number Diff line number Diff line Loading @@ -30,14 +30,14 @@ template< int MeshDimension, class DistributedMeshSynchronizer< DistributedMesh< Grid< MeshDimension, GridReal, Device, Index > >, MeshDimension > { public: static constexpr int getMeshDimension() { return MeshDimension; }; static constexpr int getNeighborCount() {return DirectionCount<MeshDimension>::get();}; typedef typename Grid< MeshDimension, GridReal, Device, Index >::Cell Cell; typedef typename Grid< MeshDimension, GridReal, Device, Index >::DistributedMeshType DistributedGridType; typedef typename DistributedGridType::CoordinatesType CoordinatesType; using SubdomainOverlapsType = typename DistributedGridType::SubdomainOverlapsType; static constexpr int getMeshDimension() { return DistributedGridType::getMeshDimension(); }; static constexpr int getNeighborsCount() { return DistributedGridType::getNeighborsCount(); }; enum PeriodicBoundariesCopyDirection { BoundaryToOverlap, Loading Loading @@ -74,7 +74,7 @@ class DistributedMeshSynchronizer< DistributedMesh< Grid< MeshDimension, GridRea const int *neighbors = distributedGrid->getNeighbors(); for( int i=0; i<this->getNeighborCount(); i++ ) for( int i=0; i<this->getNeighborsCount(); i++ ) { Index sendSize=1;//send and receive areas have the same size Loading Loading @@ -126,7 +126,7 @@ class DistributedMeshSynchronizer< DistributedMesh< Grid< MeshDimension, GridRea if( !distributedGrid->isDistributed() ) return; // allocate buffers (setSize does nothing if the array size is already correct) for( int i=0; i<this->getNeighborCount(); i++ ) { for( int i=0; i<this->getNeighborsCount(); i++ ) { sendBuffers[ i ].setSize( sendSizes[ i ] * sizeof(RealType) ); recieveBuffers[ i ].setSize( sendSizes[ i ] * sizeof(RealType)); } Loading @@ -143,12 +143,12 @@ class DistributedMeshSynchronizer< DistributedMesh< Grid< MeshDimension, GridRea PeriodicBoundariesMaskPointer( nullptr ) ); // the mask is used only when receiving data ); //async send and receive MPI_Request requests[2*this->getNeighborCount()]; MPI_Request requests[2*this->getNeighborsCount()]; MPI_Comm group = distributedGrid->getCommunicationGroup(); int requestsCount( 0 ); //send everything, recieve everything for( int i=0; i<this->getNeighborCount(); i++ ) for( int i=0; i<this->getNeighborsCount(); i++ ) { /*TNL_MPI_PRINT( "Sending data... " << i << " sizes -> " << sendSizes[ i ] << "sendDimensions -> " << sendDimensions[ i ] Loading Loading @@ -199,7 +199,7 @@ class DistributedMeshSynchronizer< DistributedMesh< Grid< MeshDimension, GridRea using RealType = typename MeshFunctionType::RealType; using Helper = BufferEntitiesHelper< MeshFunctionType, PeriodicBoundariesMaskPointer, getMeshDimension(), RealType, Device >; for(int i=0;i<this->getNeighborCount();i++) for(int i=0;i<this->getNeighborsCount();i++) { bool isBoundary=( neighbor[ i ] == -1 ); if( ! isBoundary || periodicBoundaries ) Loading @@ -211,24 +211,22 @@ class DistributedMeshSynchronizer< DistributedMesh< Grid< MeshDimension, GridRea private: Containers::StaticArray< getNeighborCount(), int > sendSizes; Containers::Array< std::uint8_t, Device, Index > sendBuffers[getNeighborCount()]; Containers::Array< std::uint8_t, Device, Index > recieveBuffers[getNeighborCount()]; Containers::StaticArray< getNeighborsCount(), int > sendSizes; Containers::Array< std::uint8_t, Device, Index > sendBuffers[getNeighborsCount()]; Containers::Array< std::uint8_t, Device, Index > recieveBuffers[getNeighborsCount()]; PeriodicBoundariesCopyDirection periodicBoundariesCopyDirection = BoundaryToOverlap; CoordinatesType sendDimensions[getNeighborCount()]; CoordinatesType recieveDimensions[getNeighborCount()]; CoordinatesType sendBegin[getNeighborCount()]; CoordinatesType recieveBegin[getNeighborCount()]; CoordinatesType sendDimensions[getNeighborsCount()]; CoordinatesType recieveDimensions[getNeighborsCount()]; CoordinatesType sendBegin[getNeighborsCount()]; CoordinatesType recieveBegin[getNeighborsCount()]; DistributedGridType *distributedGrid; bool isSet; }; } // namespace DistributedMeshes } // namespace Meshes } // namespace TNL