Skip to content
Snippets Groups Projects
Commit 7f880430 authored by Helen Schottenhamml's avatar Helen Schottenhamml Committed by Christoph Rettinger
Browse files

Clean CUDA communication module

parent 7df70d4f
Branches
Tags
No related merge requests found
......@@ -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 )
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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_;
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment