Skip to content

Commit 523b9cc

Browse files
committed
perf(kernels): split move_kernel with precomputed randon numbers
Use of 2D random number buffer for each particle (layout left) Total time move kernel (move+random for new ) | |OMP | MPI | CUDA | | --| -- | --- |-- | old | 137.069686 | 119.201964 | 136.673589 | new | 103.405564+14.312186 | 98.172346 +13.936711 | 52.763011+4|
1 parent e4eb0a7 commit 523b9cc

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

apps/libs/mc/public/mc/alias.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <Kokkos_Core_fwd.hpp>
55
#include <Kokkos_ScatterView.hpp>
66
#include <common/traits.hpp>
7+
#include <traits/Kokkos_IterationPatternTrait.hpp>
78

89
// static_assert(FloatingPointType<Kokkos::Experimental::half_t>,
910
// "Kokkos half_t ok");
@@ -65,7 +66,7 @@ namespace MC
6566
using ParticleAges = ParticleAgesBase<ComputeSpace>;
6667

6768
using ParticleSamples = Kokkos::
68-
View<Kokkos::Experimental::half_t**, Kokkos::LayoutLeft, ComputeSpace>;
69+
View<Kokkos::Experimental::half_t**, Kokkos::LayoutRight, ComputeSpace>;
6970

7071
template <typename MemorySpace>
7172
using ParticlePropertyViewType =

apps/libs/simulation/public/simulation/kernels/kernels.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ namespace Simulation::KernelInline
2222
using cycle_kernel_type = CycleFunctor<Model>;
2323
using move_kernel_type = MoveFunctor;
2424

25+
ComputeSpace move_space{};
26+
2527
cycle_reducer_view_type<Space> cycle_reducer;
2628
move_reducer_view_type<Space> move_reducer;
2729
cycle_kernel_type cycle_kernel;
@@ -50,7 +52,8 @@ namespace Simulation::KernelInline
5052
cycle_kernel.update(d_t, container);
5153

5254
// TODO: Why need to update all views (where did we lost the refcount ? )
53-
move_kernel.update(d_t,
55+
move_kernel.update(move_space,
56+
d_t,
5457
container.n_particles(),
5558
std::move(new_move),
5659
container.position,

apps/libs/simulation/public/simulation/kernels/move_kernel.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define __SIMULATION_MOVE_KERNEL_HPP__
33

44
#include "Kokkos_Macros.hpp"
5+
#include "common/common.hpp"
56
#include <Kokkos_Assert.hpp>
67
#include <Kokkos_Core.hpp>
78
#include <Kokkos_Printf.hpp>
@@ -67,8 +68,7 @@ namespace Simulation::KernelInline
6768
const std::size_t i_compartment,
6869
const double random_number)
6970
{
70-
const int mask_do_serch =
71-
static_cast<int>(do_serch); // Image this is from another calculation
71+
const int mask_do_serch = static_cast<int>(do_serch);
7272

7373
const int max_neighbor = static_cast<int>(neighbors.extent(1));
7474

@@ -172,7 +172,8 @@ namespace Simulation::KernelInline
172172
random(std::move(_random)), enable_move(b_move),
173173
enable_leave(b_leave) {};
174174

175-
void update(double _d_t,
175+
void update(const ComputeSpace& ex,
176+
double _d_t,
176177
std::size_t n_p,
177178
MoveInfo<ComputeSpace>&& move_i,
178179
MC::ParticlePositions _positions,
@@ -194,7 +195,7 @@ namespace Simulation::KernelInline
194195
this->status = std::move(_status);
195196
this->ages = std::move(_ages);
196197

197-
Kokkos::fill_random(random, random_pool, 0., 1.);
198+
Kokkos::fill_random(ex, random, random_pool, 0., 1.);
198199
}
199200

200201
KOKKOS_INLINE_FUNCTION void operator()(

apps/libs/simulation/public/simulation/simulation.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,16 @@ namespace Simulation
213213
{
214214
return;
215215
}
216+
217+
pre_cycle(container, d_t, cycle_functors);
218+
216219
if (f_reaction)
217220
{
218221
this->contribs_scatter.reset();
219222
cycle_functors.launch_model(n_particle);
220223
}
221-
pre_cycle(container, d_t, cycle_functors);
222224

225+
cycle_functors.move_space.fence();
223226
if (cycle_functors.move_kernel.need_launch())
224227
{
225228

tools/cases.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<number_particle>5000</number_particle>
1111
<delta_time>0.001</delta_time>
1212
<results_file_name>debug</results_file_name>
13-
<number_exported_result>10</number_exported_result>
14-
<model_name>monod</model_name>
13+
<number_exported_result>0</number_exported_result>
14+
<model_name>none</model_name>
1515
<!--<initialiser_path>./cma_data/0d_4s_init.h5</initialiser_path> -->
1616
<!-- <initialiser_path>./cma_data/n14_init.h5</initialiser_path> -->
1717
<initialiser_path>./cma_data/sanofi_init.h5</initialiser_path>

tools/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get_executable(instal: str, mpi: bool = True):
4141
if instal:
4242
return f"/opt/biomc/{appname}"
4343
else:
44-
return f"{ROOT}/builddir/host/apps/cli/{appname}"
44+
return f"{ROOT}/builddir/gpu/apps/cli/{appname}"
4545

4646

4747
def mk_parser():

0 commit comments

Comments
 (0)