Skip to content

Commit

Permalink
WIP - fixing issue with alpha and beta containers.
Browse files Browse the repository at this point in the history
  • Loading branch information
massimim committed Dec 6, 2023
1 parent 2b81ae7 commit 4760cf5
Show file tree
Hide file tree
Showing 5 changed files with 477 additions and 463 deletions.
282 changes: 142 additions & 140 deletions libNeonDomain/include/Neon/domain/details/bGridDisg/bPartition.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,182 +9,184 @@

namespace Neon::domain::details::disaggregated::bGrid {

template <typename SBlock>
class bSpan;

template <typename T, int C, typename SBlock>
class bPartition
{
public:
using Span = bSpan<SBlock>;
using Idx = bIndex<SBlock>;
using NghIdx = typename Idx::NghIdx;
using Type = T;
using NghData = Neon::domain::NghData<T>;

using BlockViewGrid = Neon::domain::tool::GridTransformer<details::GridTransformation>::Grid;
using BlockViewGridIdx = BlockViewGrid::Idx;

public:
bPartition();

~bPartition() = default;

explicit bPartition(int setIdx,
int mCardinality,
T* mMem,
typename Idx::DataBlockIdx* mBlockConnectivity,
typename SBlock::BitMask const* NEON_RESTRICT mMask,
Neon::int32_3d* mOrigin,
NghIdx* mStencilNghIndex,
Neon::int32_3d mDomainSize);

/**
* Retrieve the cardinality of the field.
*/
inline NEON_CUDA_HOST_DEVICE auto
cardinality()
template<typename SBlock>
class bSpan;

template<typename T, int C, typename SBlock>
class bPartition {
public:
using Span = bSpan<SBlock>;
using Idx = bIndex<SBlock>;
using NghIdx = typename Idx::NghIdx;
using Type = T;
using NghData = Neon::domain::NghData<T>;

using BlockViewGrid = Neon::domain::tool::GridTransformer<details::GridTransformation>::Grid;
using BlockViewGridIdx = BlockViewGrid::Idx;

public:
bPartition();

~bPartition() = default;

explicit bPartition(int setIdx,
int mCardinality,
T *mMem,
typename Idx::DataBlockIdx *mBlockConnectivity,
typename SBlock::BitMask const *NEON_RESTRICT mMask,
Neon::int32_3d *mOrigin,
NghIdx *mStencilNghIndex,
Neon::int32_3d mDomainSize);

/**
* Retrieve the cardinality of the field.
*/
inline NEON_CUDA_HOST_DEVICE auto
cardinality()
const -> int;

/**
* Gets the field metadata at a cartesian point.
*/
inline NEON_CUDA_HOST_DEVICE auto
operator()(const Idx& cell,
int card)
-> T&;

/**
* Gets the field metadata at a cartesian point.
*/
inline NEON_CUDA_HOST_DEVICE auto
operator()(const Idx& cell,
int card)
const -> const T&;

/**
* Gets the field metadata at a neighbour cartesian point.
*/
NEON_CUDA_HOST_DEVICE inline auto
getNghData(const Idx& cell,
const NghIdx& offset,
const int card)
/**
* Gets the field metadata at a cartesian point.
*/
inline NEON_CUDA_HOST_DEVICE auto
operator()(const Idx &cell,
int card)
-> T &;

/**
* Gets the field metadata at a cartesian point.
*/
inline NEON_CUDA_HOST_DEVICE auto
operator()(const Idx &cell,
int card)
const -> const T &;

/**
* Gets the field metadata at a neighbour cartesian point.
*/
NEON_CUDA_HOST_DEVICE inline auto
getNghData(const Idx &cell,
const NghIdx &offset,
const int card)
const -> NghData;

/**
* Gets the field metadata at a neighbour cartesian point.
*/
NEON_CUDA_HOST_DEVICE inline auto
getNghData(const Idx& eId,
uint8_t nghID,
int card)
/**
* Gets the field metadata at a neighbour cartesian point.
*/
NEON_CUDA_HOST_DEVICE inline auto
getNghData(const Idx &eId,
uint8_t nghID,
int card)
const -> NghData;

/**
* Gets the field metadata at a neighbour cartesian point.
*/
template <int xOff, int yOff, int zOff>
NEON_CUDA_HOST_DEVICE inline auto
getNghData(const Idx& eId,
int card)
/**
* Gets the field metadata at a neighbour cartesian point.
*/
template<int xOff, int yOff, int zOff>
NEON_CUDA_HOST_DEVICE inline auto
getNghData(const Idx &eId,
int card)
const -> NghData;

/**
* Gets the field metadata at a neighbour cartesian point.
*/
template <int xOff, int yOff, int zOff>
NEON_CUDA_HOST_DEVICE inline auto
getNghData(const Idx& eId,
int card,
T defaultValue)
/**
* Gets the field metadata at a neighbour cartesian point.
*/
template<int xOff, int yOff, int zOff>
NEON_CUDA_HOST_DEVICE inline auto
getNghData(const Idx &eId,
int card,
T defaultValue)
const -> NghData;

template <int xOff,
int yOff,
int zOff,
typename LambdaVALID,
typename LambdaNOTValid = void*>
NEON_CUDA_HOST_DEVICE inline auto
getNghData(const Idx& gidx,
int card,
LambdaVALID funIfValid,
LambdaNOTValid funIfNOTValid = nullptr)
const -> std::enable_if_t<std::is_invocable_v<LambdaVALID, T> && (std::is_invocable_v<LambdaNOTValid, T> || std::is_same_v<LambdaNOTValid, void*>), void>;

template <int xOff,
int yOff,
int zOff>
NEON_CUDA_HOST_DEVICE inline auto
writeNghData(const Idx& gidx,
int card,
T value)
template<int xOff,
int yOff,
int zOff,
typename LambdaVALID,
typename LambdaNOTValid = void *>
NEON_CUDA_HOST_DEVICE inline auto
getNghData(const Idx &gidx,
int card,
LambdaVALID funIfValid,
LambdaNOTValid funIfNOTValid = nullptr)
const -> std::enable_if_t<std::is_invocable_v<LambdaVALID, T> && (std::is_invocable_v<LambdaNOTValid, T> ||
std::is_same_v<LambdaNOTValid, void *>), void>;

template<int xOff,
int yOff,
int zOff>
NEON_CUDA_HOST_DEVICE inline auto
writeNghData(const Idx &gidx,
int card,
T value)
-> bool;

/**
* Gets the global coordinates of the cartesian point.
*/
NEON_CUDA_HOST_DEVICE inline auto
getGlobalIndex(const Idx& cell)
/**
* Gets the global coordinates of the cartesian point.
*/
NEON_CUDA_HOST_DEVICE inline auto
getGlobalIndex(const Idx &cell)
const -> Neon::index_3d;

NEON_CUDA_HOST_DEVICE inline auto
isActive(const Idx& cell,
const typename SBlock::BitMask* mask = nullptr) const -> bool;
NEON_CUDA_HOST_DEVICE inline auto
isActive(const Idx &cell,
const typename SBlock::BitMask *mask = nullptr) const -> bool;


NEON_CUDA_HOST_DEVICE inline auto
getDomainSize()
NEON_CUDA_HOST_DEVICE inline auto
getDomainSize()
const -> Neon::index_3d;

/**
* Gets the Idx for in the block view space.
*/
NEON_CUDA_HOST_DEVICE inline auto
getBlockViewIdx(const Idx& cell)
auto mem() const -> T const *;

/**
* Gets the Idx for in the block view space.
*/
NEON_CUDA_HOST_DEVICE inline auto
getBlockViewIdx(const Idx &cell)
const -> BlockViewGridIdx;


NEON_CUDA_HOST_DEVICE inline auto
helpGetPitch(const Idx& cell, int card)
NEON_CUDA_HOST_DEVICE inline auto
helpGetPitch(const Idx &cell, int card)
const -> uint32_t;

NEON_CUDA_HOST_DEVICE inline auto
helpGetValidIdxPitchExplicit(const Idx& idx, int card)
NEON_CUDA_HOST_DEVICE inline auto
helpGetValidIdxPitchExplicit(const Idx &idx, int card)
const -> uint32_t;

NEON_CUDA_HOST_DEVICE inline auto
helpNghPitch(const Idx& nghIdx, int card)
NEON_CUDA_HOST_DEVICE inline auto
helpNghPitch(const Idx &nghIdx, int card)
const -> std::tuple<bool, uint32_t>;

NEON_CUDA_HOST_DEVICE inline auto
helpGetNghIdx(const Idx& idx, const NghIdx& offset)
NEON_CUDA_HOST_DEVICE inline auto
helpGetNghIdx(const Idx &idx, const NghIdx &offset)
const -> Idx;

template <int xOff, int yOff, int zOff>
NEON_CUDA_HOST_DEVICE inline auto
helpGetNghIdx(const Idx& idx)
template<int xOff, int yOff, int zOff>
NEON_CUDA_HOST_DEVICE inline auto
helpGetNghIdx(const Idx &idx)
const -> Idx;

NEON_CUDA_HOST_DEVICE inline auto
helpGetNghIdx(const Idx& idx, const NghIdx& offset, const typename Idx::DataBlockIdx* blockConnectivity)
NEON_CUDA_HOST_DEVICE inline auto
helpGetNghIdx(const Idx &idx, const NghIdx &offset, const typename Idx::DataBlockIdx *blockConnectivity)
const -> Idx;

template <int xOff, int yOff, int zOff>
NEON_CUDA_HOST_DEVICE inline auto
helpGetNghIdx(const Idx& idx, const typename Idx::DataBlockIdx* blockConnectivity)
template<int xOff, int yOff, int zOff>
NEON_CUDA_HOST_DEVICE inline auto
helpGetNghIdx(const Idx &idx, const typename Idx::DataBlockIdx *blockConnectivity)
const -> Idx;


int mCardinality;
T* mMem;
NghIdx const* NEON_RESTRICT mStencilNghIndex;
typename Idx::DataBlockIdx const* NEON_RESTRICT mBlockConnectivity;
typename SBlock::BitMask const* NEON_RESTRICT mMask;
Neon::int32_3d const* NEON_RESTRICT mOrigin;
int mSetIdx;
int mMultiResDiscreteIdxSpacing = 1;
Neon::int32_3d mDomainSize;
};
int mCardinality;
T *mMem;
NghIdx const *NEON_RESTRICT mStencilNghIndex;
typename Idx::DataBlockIdx const *NEON_RESTRICT mBlockConnectivity;
typename SBlock::BitMask const *NEON_RESTRICT mMask;
Neon::int32_3d const *NEON_RESTRICT mOrigin;
int mSetIdx;
int mMultiResDiscreteIdxSpacing = 1;
Neon::int32_3d mDomainSize;
};

} // namespace Neon::domain::details::disaggregated::bGrid

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ NEON_CUDA_HOST_DEVICE inline auto bPartition<T, C, SBlock>::
return mDomainSize;
}

template <typename T, int C, typename SBlock>
NEON_CUDA_HOST_DEVICE inline auto bPartition<T, C, SBlock>::
mem() const -> T const *{
return mMem;
}


template <typename T, int C, typename SBlock>
NEON_CUDA_HOST_DEVICE inline auto bPartition<T, C, SBlock>::
getBlockViewIdx(const Idx& gidx)
Expand Down
Loading

0 comments on commit 4760cf5

Please sign in to comment.