Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
massimim committed Jun 30, 2023
1 parent 81b3526 commit 2a2caf7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
1 change: 1 addition & 0 deletions libNeonCore/include/Neon/core/tools/metaprogramming.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
#include "Neon/core/tools/metaprogramming/debugHelp.h"
#include "Neon/core/tools/metaprogramming/extractTupleVecType.h"
#include "Neon/core/tools/metaprogramming/tupleVecTable.h"
#include "Neon/core/tools/metaprogramming/ConstexprFor.h"
14 changes: 14 additions & 0 deletions libNeonCore/include/Neon/core/tools/metaprogramming/ConstexprFor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

namespace Neon {

template <auto Start, auto End, auto Inc, class F>
constexpr void ConstexprFor(F&& f)
{
if constexpr (Start < End) {
f(std::integral_constant<decltype(Start), Start>());
ConstexprFor<Start + Inc, End, Inc>(f);
}
}

} // namespace Neon
29 changes: 10 additions & 19 deletions libNeonDomain/tests/domain-stencil/src/stencil.cu
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ NEON_CUDA_HOST_DEVICE inline auto viaTemplate(const IDX& idx, int i, const Parti
};


template <auto Start, auto End, auto Inc, class F>
constexpr void constexpr_for(F&& f)
{
if constexpr (Start < End) {
f(std::integral_constant<decltype(Start), Start>());
constexpr_for<Start + Inc, End, Inc>(f);
}
}
//template <auto Start, auto End, auto Inc, class F>
//constexpr void constexpr_for(F&& f)
//{
// if constexpr (Start < End) {
// f(std::integral_constant<decltype(Start), Start>());
// constexpr_for<Start + Inc, End, Inc>(f);
// }
//}

template <typename Field>
auto laplaceTemplate(const Field& filedA,
Expand All @@ -107,7 +107,7 @@ auto laplaceTemplate(const Field& filedA,
int count = 0;
using Ngh3DIdx = Neon::int8_3d;

constexpr_for<0, 6, 1>([&](auto sIdx) {
Neon::ConstexprFor<0, 6, 1>([&](auto sIdx) {
a.template getNghData<stencil[sIdx].x,
stencil[sIdx].y,
stencil[sIdx].z>(idx, i,
Expand All @@ -116,16 +116,7 @@ auto laplaceTemplate(const Field& filedA,
count++;
});
});


// viaTemplate<0>(idx, i, a, partial, count);
// viaTemplate<1>(idx, i, a, partial, count);
// viaTemplate<2>(idx, i, a, partial, count);
// viaTemplate<3>(idx, i, a, partial, count);
// viaTemplate<4>(idx, i, a, partial, count);
// viaTemplate<5>(idx, i, a, partial, count);



b(idx, i) = a(idx, i) - count * partial;
}
};
Expand Down

0 comments on commit 2a2caf7

Please sign in to comment.