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

[on hold] Update alpaka nbody to C++20 #821

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion examples/alpaka/nbody/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (NOT TARGET llama::llama)
endif()
find_package(alpaka 1.0 REQUIRED)
alpaka_add_executable(${PROJECT_NAME} nbody.cpp ../../common/Stopwatch.hpp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
target_link_libraries(${PROJECT_NAME} PRIVATE llama::llama fmt::fmt alpaka::alpaka xsimd)

if (MSVC)
Expand Down
23 changes: 8 additions & 15 deletions examples/alpaka/nbody/nbody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,7 @@ LLAMA_FN_HOST_ACC_INLINE void pPInteraction(const Acc& acc, ParticleRefI& pis, P
template<int ThreadsPerBlock, int SharedElementsPerBlock, int ElementsPerThread, typename QuotedSMMapping>
struct UpdateKernel
{
// TODO(bgruber): make this an IILE in C++20
template<typename Mapping, typename Acc, std::size_t... Is>
ALPAKA_FN_HOST_ACC auto makeSharedViewHelper(const Acc& acc, std::index_sequence<Is...>) const
{
return llama::View{
Mapping{},
llama::Array<std::byte*, sizeof...(Is)>{
alpaka::declareSharedVar<std::byte[Mapping{}.blobSize(Is)], Is>(acc)...}};
}

template<typename Acc, typename View>
ALPAKA_FN_HOST_ACC void operator()(const Acc& acc, View particles) const
ALPAKA_FN_HOST_ACC void operator()(const auto& acc, auto particles) const
{
auto sharedView = [&]
{
Expand All @@ -191,7 +180,12 @@ struct UpdateKernel
{
using Mapping = typename QuotedSMMapping::
template fn<llama::ArrayExtents<int, SharedElementsPerBlock>, SharedMemoryParticle>;
return makeSharedViewHelper<Mapping>(acc, std::make_index_sequence<Mapping::blobCount>{});
return [&]<std::size_t... Is>(std::index_sequence<Is...>)
{
return llama::View{
Mapping{},
llama::Array{alpaka::declareSharedVar<std::byte[Mapping{}.blobSize(Is)], Is>(acc)...}};
}(std::make_index_sequence<Mapping::blobCount>{});
}
}();

Expand All @@ -217,8 +211,7 @@ struct UpdateKernel
template<int ElementsPerThread>
struct MoveKernel
{
template<typename Acc, typename View>
ALPAKA_FN_HOST_ACC void operator()(const Acc& acc, View particles) const
ALPAKA_FN_HOST_ACC void operator()(const auto& acc, auto particles) const
{
const auto ti = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0];
const auto i = ti * ElementsPerThread;
Expand Down
Loading