Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (1)
......@@ -7,5 +7,6 @@ target_sources( cuda
GPUPackInfo.h
CustomMemoryBuffer.h
UniformGPUScheme.h
GeneratedGPUPackInfo.h
GeneratedGPUPackInfo.h
CombinedInPlaceGpuPackInfo.h
)
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file CombinedInPlaceGpuPackInfo.h
//! \ingroup cuda
//! \author Markus Holzer<markus.holzer@fau.de>
//
//======================================================================================================================
#pragma once
#include "stencil/Directions.h"
#include "domain_decomposition/IBlock.h"
#include "lbm/inplace_streaming/TimestepTracker.h"
#include <cuda_runtime.h>
#define IS_EVEN(x) (((x) &1) ^ 1)
namespace walberla {
namespace cuda {
template<typename EvenPackInfo, typename OddPackInfo>
class CombinedInPlaceGpuPackInfo: public ::walberla::cuda::GeneratedGPUPackInfo {
public:
template<typename... Args>
explicit CombinedInPlaceGpuPackInfo(std::shared_ptr<lbm::TimestepTracker> &tracker, Args &&... args)
: tracker_(tracker), evenPackInfo_(std::forward<Args>(args)...),
oddPackInfo_(std::forward<Args>(args)...) {}
~CombinedInPlaceGpuPackInfo() override = default;
void pack(stencil::Direction dir, unsigned char *buffer, IBlock *block, cudaStream_t stream) override {
if (IS_EVEN(tracker_->getCounter())) {
return evenPackInfo_.pack(dir, buffer, block, stream);
} else {
return oddPackInfo_.pack(dir, buffer, block, stream);
}
}
void unpack(stencil::Direction dir, unsigned char *buffer, IBlock *block, cudaStream_t stream) override {
if (IS_EVEN(tracker_->getCounter())) {
return evenPackInfo_.unpack(dir, buffer, block, stream);
} else {
return oddPackInfo_.unpack(dir, buffer, block, stream);
}
}
uint_t size(stencil::Direction dir, IBlock *block) override {
if (IS_EVEN(tracker_->getCounter())) {
return evenPackInfo_.size(dir, block);
} else {
return oddPackInfo_.size(dir, block);
}
}
private:
const std::shared_ptr<lbm::TimestepTracker> &tracker_;
EvenPackInfo evenPackInfo_;
OddPackInfo oddPackInfo_;
};
} //namespace cuda
} //namespace walberla
\ No newline at end of file
......@@ -33,6 +33,7 @@ namespace cuda {
class GeneratedGPUPackInfo
{
public:
virtual ~GeneratedGPUPackInfo() = default;
virtual void pack ( stencil::Direction dir, unsigned char *buffer, IBlock *block, cudaStream_t stream ) = 0;
virtual void unpack( stencil::Direction dir, unsigned char *buffer, IBlock *block, cudaStream_t stream ) = 0;
virtual uint_t size( stencil::Direction dir, IBlock *block ) = 0;
......
......@@ -34,7 +34,7 @@ class CombinedInPlaceCpuPackInfo : public ::walberla::communication::UniformPack
{
public:
template< typename... Args >
CombinedInPlaceCpuPackInfo(std::shared_ptr< lbm::TimestepTracker >& tracker, Args&&... args)
explicit CombinedInPlaceCpuPackInfo(std::shared_ptr< lbm::TimestepTracker >& tracker, Args&&... args)
: tracker_(tracker), evenPackInfo_(std::forward< Args >(args)...), oddPackInfo_(std::forward< Args >(args)...)
{}
......