Skip to content

Commit

Permalink
Add GPU Gems layout to alpaka n-body
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber committed Nov 14, 2023
1 parent 8b711eb commit dc6897b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion examples/alpaka/nbody/nbody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ enum Mapping
AoS,
SoA_SB,
SoA_MB,
AoSoA
AoSoA,
SplitGpuGems
};

template<typename Acc, typename ParticleRefI, typename ParticleRefJ>
Expand Down Expand Up @@ -229,6 +230,8 @@ void run(std::ostream& plotFile)
return "SoA MB";
if(m == 3)
return "AoSoA" + std::to_string(aosoaLanes);
if(m == 4)
return "SplitGpuGems";
std::abort();
};
const auto title = "GM " + mappingName(MappingGM) + " SM " + mappingName(MappingSM);
Expand All @@ -252,6 +255,18 @@ void run(std::ostream& plotFile)
return llama::mapping::SoA<ArrayExtents, Particle, llama::mapping::Blobs::OnePerField>{extents};
if constexpr(MappingGM == AoSoA)
return llama::mapping::AoSoA<ArrayExtents, Particle, aosoaLanes>{extents};
using boost::mp11::mp_list;
if constexpr(MappingGM == SplitGpuGems)
return llama::mapping::Split<
ArrayExtents,
Particle,
mp_list<
mp_list<tag::Pos, tag::X>,
mp_list<tag::Pos, tag::Y>,
mp_list<tag::Pos, tag::Z>,
mp_list<tag::Mass>>,
llama::mapping::BindAoS<>::fn,
llama::mapping::BindAoS<>::fn>{extents};
}();

Stopwatch watch;
Expand Down Expand Up @@ -351,6 +366,7 @@ set y2tics auto
run<alpaka::ExampleDefaultAcc, AoSoA, AoS>(plotFile);
run<alpaka::ExampleDefaultAcc, AoSoA, SoA_SB>(plotFile);
run<alpaka::ExampleDefaultAcc, AoSoA, AoSoA>(plotFile);
run<alpaka::ExampleDefaultAcc, SplitGpuGems, AoS>(plotFile);

plotFile << R"(EOD
plot $data using 2:xtic(1) ti col axis x1y1, "" using 3 ti col axis x1y2
Expand Down

0 comments on commit dc6897b

Please sign in to comment.