Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dgridSoA #41

Closed
wants to merge 29 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
aacf68e
Adding exception for arrayOfStructure option for bGrid.
massimim Jun 9, 2023
18f2d72
Some documentation to bGrid.
massimim Jun 15, 2023
b81c423
bGrid: API documentation and refactoring of the template API.
massimim Jun 15, 2023
d82e985
Cleaning up naming for the BlockViewGrid
massimim Jun 15, 2023
9e29f8e
bGrid - introducing the concept of BlockView and refactoring the bitm…
massimim Jun 15, 2023
cdcdc0d
bGrid - fixing multi-GPU
massimim Jun 16, 2023
54b508d
Merge branch 'bGrid' into bGrid-newTemaplateAPI
massimim Jun 16, 2023
ea82dfc
Adding scripts
massimim Jun 16, 2023
cc536e8
Merge branch 'bGrid-newTemaplateAPI' into bGrid
massimim Jun 16, 2023
55af708
Benchmarks and scripts
massimim Jun 19, 2023
90a4ba9
Code documentation
massimim Jun 19, 2023
019db4d
Fixing grid spacing in bGrid.
massimim Jun 19, 2023
1790087
Merge remote-tracking branch 'origin/develop' into bGrid
massimim Jun 22, 2023
588b746
WIP
massimim Jun 22, 2023
9a87088
Fixing report filename for benchmarks scripts
massimim Jun 22, 2023
1168cc2
Adding halo option.
massimim Jun 23, 2023
0bdce94
Adding halo option.
massimim Jun 23, 2023
3dc808e
WIP
massimim Jun 23, 2023
ceab2a6
domain_neighbour_globalIdx for dGridSoA
massimim Jun 26, 2023
8197006
Merge branch 'lattice-benchmark-lbm' into dGridSOA
massimim Jun 26, 2023
13377a4
Testing block sizes on bGrid
massimim Jun 27, 2023
3a36f0c
Adding dGridSoA to the stencil tests
massimim Jun 28, 2023
a49b27a
WIP
massimim Jun 29, 2023
fde014d
Extending unit test for stencil to dGridSoA
massimim Jun 29, 2023
b0e74e6
WIP
massimim Jun 29, 2023
1dd5abc
WIP
massimim Jun 30, 2023
81b3526
WIP
massimim Jun 30, 2023
2a2caf7
WIP
massimim Jun 30, 2023
b63b90b
WIP
massimim Jun 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixing grid spacing in bGrid.
massimim committed Jun 19, 2023
commit 019db4d6a03e771b8309d3d2291ccb151e071e98
10 changes: 1 addition & 9 deletions libNeonDomain/include/Neon/domain/details/bGrid/bField.h
Original file line number Diff line number Diff line change
@@ -84,13 +84,6 @@ class bField : public Neon::domain::interface::FieldBaseTemplate<T,
auto initHaloUpdateTable() -> void;


//
// enum PartitionBackend
// {
// cpu = 0,
// gpu = 1,
// };

struct Data
{
Data() = default;
@@ -112,8 +105,7 @@ class bField : public Neon::domain::interface::FieldBaseTemplate<T,

std::shared_ptr<Grid> grid;
BlockViewField<T, 0> memoryField;

int mCardinality;
int cardinality;

// Neon::domain::tool::HaloTable1DPartitioning latticeHaloUpdateTable;
Neon::domain::tool::HaloTable1DPartitioning soaHaloUpdateTable;
21 changes: 16 additions & 5 deletions libNeonDomain/include/Neon/domain/details/bGrid/bField_imp.h
Original file line number Diff line number Diff line change
@@ -79,11 +79,22 @@ template <typename T, int C, typename SBlock>
auto bField<T, C, SBlock>::getReference(const Neon::index_3d& cartesianIdx,
const int& cardinality) -> T&
{
auto& grid = this->getGrid();
auto [setIdx, bIdx] = grid.helpGetSetIdxAndGridIdx(cartesianIdx);
auto& partition = getPartition(Neon::Execution::host, setIdx, Neon::DataView::STANDARD);
auto& result = partition(bIdx, cardinality);
return result;
if constexpr (SBlock::isMultiResMode) {
auto& grid = this->getGrid();
auto uniformCartesianIdx = cartesianIdx / grid.helpGetMultiResFactor();
auto uniformCartesianIdxTruncation = cartesianIdx % grid.helpGetMultiResFactor();
static_assert(uniformCartesianIdxTruncation == 0);
auto [setIdx, bIdx] = grid.helpGetSetIdxAndGridIdx(uniformCartesianIdx);
auto& partition = getPartition(Neon::Execution::host, setIdx, Neon::DataView::STANDARD);
auto& result = partition(bIdx, cardinality);
return result;
} else {
auto& grid = this->getGrid();
auto [setIdx, bIdx] = grid.helpGetSetIdxAndGridIdx(cartesianIdx);
auto& partition = getPartition(Neon::Execution::host, setIdx, Neon::DataView::STANDARD);
auto& result = partition(bIdx, cardinality);
return result;
}
}

template <typename T, int C, typename SBlock>
15 changes: 12 additions & 3 deletions libNeonDomain/include/Neon/domain/details/bGrid/bGrid.h
Original file line number Diff line number Diff line change
@@ -72,9 +72,10 @@ class bGrid : public Neon::domain::interface::GridBaseTemplate<bGrid<SBlock>,
const ActiveCellLambda activeCellLambda /**< Function that identify the user domain inside the boxed Cartesian discretization */,
const Neon::domain::Stencil& stencil /**< union of tall the stencil that will be used in the computation */,
const int multiResDiscreteIdxSpacing /**< Parameter for the multi-resolution. Index i and index (i+1) may be remapped as i*voxelSpacing and (i+1)* voxelSpacing.
* For a uniform bGrid, i.e outside the context of multi-resolution this parameter is always 1*/,
const double_3d& spacingData = double_3d(1, 1, 1) /** Physical spacing between two consecutive data points in the Cartesian domain */,
const double_3d& origin = double_3d(0, 0, 0) /** Physical location in space of the origin of the Cartesian discretization */);
* For a uniform bGrid, i.e outside the context of multi-resolution this parameter is always 1 */
,
const double_3d& spacingData /** Physical spacing between two consecutive data points in the Cartesian domain */,
const double_3d& origin /** Physical location in space of the origin of the Cartesian discretization */);

/**
* Returns some properties for a given cartesian in the Cartesian domain.
@@ -159,12 +160,20 @@ class bGrid : public Neon::domain::interface::GridBaseTemplate<bGrid<SBlock>,
*/
auto getBlockViewGrid() const -> BlockView::Grid&;


/**
* Retrieve the block vew grid internally used.
* This grid can be leverage to allocate data at the block level.
*/
auto getActiveBitMask() const -> BlockView::Field<typename SBlock::BitMask, 1>&;

/**
* Helper function to retrieve the discrete index spacing used for the multi-resolution
*/
template <int dummy = SBlock::isMultiResMode>
auto helGetMultiResDiscreteIdxSpacing() const -> std::enable_if_t<dummy == 1, int>;


/**
* Help function to retrieve the block connectivity as a BlockViewGrid field
*/
19 changes: 15 additions & 4 deletions libNeonDomain/include/Neon/domain/details/bGrid/bGrid_imp.h
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ bGrid<SBlock>::bGrid(const Neon::Backend& backend,
SBlock::memBlockSize3D.template newType<int32_t>(),
domainSize,
Neon::domain::Stencil::s27_t(false),
1);
multiResDiscreteIdxSpacing);

mData->mDataBlockOriginField = mData->partitioner1D.getGlobalMapping();
mData->mStencil3dTo1dOffset = mData->partitioner1D.getStencil3dTo1dOffset();
@@ -95,7 +95,7 @@ bGrid<SBlock>::bGrid(const Neon::Backend& backend,
.getGrid()
.template newContainer<Neon::Execution::host>(
"activeBitMaskInit",
[&](Neon::set::Loader& loader) {
[&, this](Neon::set::Loader& loader) {
auto bitMaskPartition = loader.load(mData->activeBitField);
return [&, bitMaskPartition](const auto& bitMaskIdx) mutable {
auto prtIdx = bitMaskPartition.prtID();
@@ -107,9 +107,9 @@ bGrid<SBlock>::bGrid(const Neon::Backend& backend,
for (int k = 0; k < SBlock::memBlockSize3D.template newType<int32_t>().z; k++) {
for (int j = 0; j < SBlock::memBlockSize3D.template newType<int32_t>().y; j++) {
for (int i = 0; i < SBlock::memBlockSize3D.template newType<int32_t>().x; i++) {
auto globalPosition = blockOrigin + Neon::int32_3d(i, j, k);
auto globalPosition = blockOrigin + Neon::int32_3d(i, j, k);
bool const isInDomain = globalPosition < domainSize;
bool const isActive = activeCellLambda(globalPosition);
bool const isActive = activeCellLambda(globalPosition * mData->mMultiResDiscreteIdxSpacing);
if (isActive && isInDomain) {
countActive++;
bitMask.setActive(i, j, k);
@@ -319,6 +319,17 @@ auto bGrid<SBlock>::
return mData->activeBitField;
}

/**
* Helper function to retrieve the discrete index spacing used for the multi-resolution
*/
template <typename SBlock>
template <int dummy>
auto bGrid<SBlock>::helGetMultiResDiscreteIdxSpacing() const
-> std::enable_if_t<dummy == 1, int>
{
return mData->mMultiResDiscreteIdxSpacing;
}

template <typename SBlock>
auto bGrid<SBlock>::
helpGetBlockConnectivity()
Original file line number Diff line number Diff line change
@@ -141,6 +141,7 @@ class bPartition
typename SBlock::BitMask const* NEON_RESTRICT mMask;
Neon::int32_3d const* NEON_RESTRICT mOrigin;
int mSetIdx;
int mMultiResDiscreteIdxSpacing = 1;
};

} // namespace Neon::domain::details::bGrid
Original file line number Diff line number Diff line change
@@ -45,7 +45,10 @@ NEON_CUDA_HOST_DEVICE inline auto bPartition<T, C, SBlock>::
location.x += gidx.mInDataBlockIdx.x;
location.y += gidx.mInDataBlockIdx.y;
location.z += gidx.mInDataBlockIdx.z;
return location;
if constexpr (SBlock::isMultiResMode){
return location * mMultiResDiscreteIdxSpacing;
}
return location ;
}

template <typename T, int C, typename SBlock>
6 changes: 3 additions & 3 deletions libNeonDomain/include/Neon/domain/tools/Partitioner1D.h
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ class Partitioner1D
NEON_DIVIDE_UP(domainSize.y, dataBlockSize.y),
NEON_DIVIDE_UP(domainSize.z, dataBlockSize.z));

std::vector<int> nBlockProjectedToZ(block3DSpan.z);
std::vector<int> nBlockProjectedToZ(mData->block3DSpan.z);

auto block3dIdxToBlockOrigin = [&](Neon::int32_3d const& block3dIdx) {
Neon::int32_3d blockOrigin(block3dIdx.x * dataBlockSize.x * multiResDiscreteIdxSpacing,
@@ -148,7 +148,7 @@ class Partitioner1D
activeIndexLambda,
block3dIdxToBlockOrigin,
getVoxelAbsolute3DIdx,
block3DSpan,
mData->block3DSpan,
dataBlockSize,
domainSize,
multiResDiscreteIdxSpacing);
@@ -159,7 +159,7 @@ class Partitioner1D
bcLambda,
block3dIdxToBlockOrigin,
getVoxelAbsolute3DIdx,
block3DSpan,
mData->block3DSpan,
dataBlockSize,
domainSize,
stencil,