diff --git a/src/cuda/communication/CustomMemoryBuffer.h b/src/cuda/communication/CustomMemoryBuffer.h index d0e8bdff930757010db67d5aa96c90ff35c34c9c..2caab2a41b13f5fb88c6e3052312e742778db408 100644 --- a/src/cuda/communication/CustomMemoryBuffer.h +++ b/src/cuda/communication/CustomMemoryBuffer.h @@ -100,13 +100,13 @@ namespace communication { static void *allocate( size_t size ) { void *p; - WALBERLA_CUDA_CHECK( cudaMallocHost( &p, size )); + WALBERLA_CUDA_CHECK( cudaMallocHost( &p, size )) return p; } static void deallocate( void *ptr ) { - WALBERLA_CUDA_CHECK( cudaFreeHost( ptr )); + WALBERLA_CUDA_CHECK( cudaFreeHost( ptr )) } static void memcpy( void *dst, void *src, size_t count ) @@ -120,13 +120,13 @@ namespace communication { static void *allocate( size_t size ) { void *p; - WALBERLA_CUDA_CHECK( cudaMalloc( &p, size )); + WALBERLA_CUDA_CHECK( cudaMalloc( &p, size )) return p; } static void deallocate( void *ptr ) { - WALBERLA_CUDA_CHECK( cudaFree( ptr )); + WALBERLA_CUDA_CHECK( cudaFree( ptr )) } static void memcpy( void *dst, void *src, size_t count ) diff --git a/src/cuda/communication/CustomMemoryBuffer.impl.h b/src/cuda/communication/CustomMemoryBuffer.impl.h index 3d7715f89f3776e712011365491e96473ec1418a..21d70e4ccceac05de50c8ceea67e09b780e9fa38 100644 --- a/src/cuda/communication/CustomMemoryBuffer.impl.h +++ b/src/cuda/communication/CustomMemoryBuffer.impl.h @@ -26,14 +26,10 @@ namespace communication { template<typename Allocator> - CustomMemoryBuffer<Allocator>::CustomMemoryBuffer() - : begin_( nullptr ), cur_( nullptr ), end_( nullptr ) - { - } + CustomMemoryBuffer<Allocator>::CustomMemoryBuffer() = default; template<typename Allocator> CustomMemoryBuffer<Allocator>::CustomMemoryBuffer( std::size_t initSize ) - : begin_( nullptr ), cur_( nullptr ), end_( nullptr ) { if( initSize > 0 ) { @@ -45,7 +41,6 @@ namespace communication { template<typename Allocator> CustomMemoryBuffer<Allocator>::CustomMemoryBuffer( const CustomMemoryBuffer &pb ) - : begin_( nullptr ), cur_( nullptr ), end_( nullptr ) { if( pb.begin_ != nullptr ) { @@ -59,7 +54,10 @@ namespace communication { template<typename Allocator> CustomMemoryBuffer<Allocator> &CustomMemoryBuffer<Allocator>::operator=( const CustomMemoryBuffer<Allocator> &pb ) { - auto copy( pb ); + if( this == &pb ) + return *this; + + CustomMemoryBuffer<Allocator> copy( pb ); std::swap( cur_, copy.cur_ ); std::swap( begin_, copy.begin_ ); std::swap( end_, copy.end_ ); @@ -105,7 +103,7 @@ namespace communication { resize( size() + bytes ); auto result = cur_; cur_ += bytes; - WALBERLA_ASSERT_LESS_EQUAL( cur_, end_ ); + WALBERLA_ASSERT_LESS_EQUAL( cur_, end_ ) return result; } diff --git a/src/cuda/communication/MemcpyPackInfo.h b/src/cuda/communication/MemcpyPackInfo.h index 8d85b7f1a7faefe8f3d824a2a13b24ff31bc8f11..20637b51a36385b21e49cd257a4a41bdaf1ea0a8 100644 --- a/src/cuda/communication/MemcpyPackInfo.h +++ b/src/cuda/communication/MemcpyPackInfo.h @@ -19,11 +19,11 @@ public: MemcpyPackInfo( BlockDataID pdfsID_ ) : pdfsID(pdfsID_), numberOfGhostLayers_(0), communicateAllGhostLayers_(true) {}; - virtual ~MemcpyPackInfo() {}; + virtual ~MemcpyPackInfo() = default; - virtual void pack (stencil::Direction dir, unsigned char * buffer, IBlock * block, cudaStream_t stream); - virtual void unpack(stencil::Direction dir, unsigned char * buffer, IBlock * block, cudaStream_t stream); - virtual uint_t size(stencil::Direction dir, IBlock * block); + void pack (stencil::Direction dir, unsigned char * buffer, IBlock * block, cudaStream_t stream) override; + void unpack(stencil::Direction dir, unsigned char * buffer, IBlock * block, cudaStream_t stream) override; + uint_t size(stencil::Direction dir, IBlock * block) override; private: BlockDataID pdfsID; diff --git a/src/cuda/communication/MemcpyPackInfo.impl.h b/src/cuda/communication/MemcpyPackInfo.impl.h index 166a7611225a643f095e40863d529ffbdac377e5..b75587c5bcdcef1ce38e06f58db53339095ce7f8 100644 --- a/src/cuda/communication/MemcpyPackInfo.impl.h +++ b/src/cuda/communication/MemcpyPackInfo.impl.h @@ -20,7 +20,7 @@ void MemcpyPackInfo< GPUFieldType >::pack(stencil::Direction dir, unsigned char { // Extract field data pointer from the block const GPUFieldType * fieldPtr = block->getData< GPUFieldType >( pdfsID ); - WALBERLA_ASSERT_NOT_NULLPTR( fieldPtr ); + WALBERLA_ASSERT_NOT_NULLPTR( fieldPtr ) // cell_idx_t nrOfGhostLayers = cell_idx_c( numberOfGhostLayersToCommunicate( fieldPtr ) ); CellInterval fieldCi = field::getGhostRegion( *fieldPtr, dir, nrOfGhostLayers, false ); @@ -70,7 +70,7 @@ void MemcpyPackInfo< GPUFieldType >::unpack(stencil::Direction dir, unsigned cha IBlock * block, cudaStream_t stream) { GPUFieldType * fieldPtr = block->getData< GPUFieldType >( pdfsID ); - WALBERLA_ASSERT_NOT_NULLPTR(fieldPtr); + WALBERLA_ASSERT_NOT_NULLPTR(fieldPtr) cell_idx_t nrOfGhostLayers = cell_idx_c( numberOfGhostLayersToCommunicate( fieldPtr ) ); @@ -221,7 +221,7 @@ uint_t MemcpyPackInfo< GPUFieldType >::numberOfGhostLayersToCommunicate( const G } else { - WALBERLA_ASSERT_LESS_EQUAL( numberOfGhostLayers_, field->nrOfGhostLayers() ); + WALBERLA_ASSERT_LESS_EQUAL( numberOfGhostLayers_, field->nrOfGhostLayers() ) return numberOfGhostLayers_; } }