Skip to content
Open
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
5d07c43
cleanup
tdavidcl Mar 15, 2026
de797a6
cleanup
tdavidcl Mar 15, 2026
b161128
better ?
tdavidcl Mar 15, 2026
58b4695
better reporting ?
tdavidcl Mar 15, 2026
ff5a902
better reporting ?
tdavidcl Mar 15, 2026
e0cd91d
streamline that shit
tdavidcl Mar 15, 2026
6bc2845
whoopsi
tdavidcl Mar 15, 2026
ee3632a
correct max mem usage
tdavidcl Mar 16, 2026
f815d5f
try to permute time mesure and power mesure
tdavidcl Mar 16, 2026
cdca66a
attempt
tdavidcl Mar 16, 2026
d811e5f
attempt
tdavidcl Mar 16, 2026
775d26a
add duration
tdavidcl Mar 16, 2026
3944ef1
Merge branch 'main' into aurora-test4
tdavidcl Mar 16, 2026
1d53302
add support for linked geopm
tdavidcl Mar 17, 2026
9011b2a
enable geopm on aurora
tdavidcl Mar 17, 2026
9dc904d
shut up warnings
tdavidcl Mar 17, 2026
bd98637
Merge branch 'main' into aurora-test4
tdavidcl Mar 17, 2026
9534a22
Merge branch 'main' into aurora-test4
tdavidcl Mar 19, 2026
dcd76b0
better ?
tdavidcl Mar 19, 2026
2ebb27a
more debug infos
tdavidcl Mar 19, 2026
8f7087b
dammit
tdavidcl Mar 19, 2026
36b2516
dammit
tdavidcl Mar 19, 2026
5e2d837
more steps
tdavidcl Mar 20, 2026
8d69537
Merge branch 'main' into aurora-test4
tdavidcl Mar 21, 2026
0f0d14c
Merge branch 'main' into aurora-test4
tdavidcl Mar 21, 2026
c4217cd
Merge branch 'main' into aurora-test4
tdavidcl Mar 21, 2026
e698051
better ?
tdavidcl Mar 22, 2026
9079339
more omp
tdavidcl Mar 22, 2026
05bf4f7
print
tdavidcl Mar 24, 2026
b6228ea
print
tdavidcl Mar 24, 2026
e0a117d
print
tdavidcl Mar 24, 2026
6ec6ec7
print
tdavidcl Mar 24, 2026
2b28ecd
lb weight
tdavidcl Mar 24, 2026
2ab4df4
fix buildbot if invoked outside of repo
tdavidcl Mar 25, 2026
1bed2de
add way of fetching MPI timers
tdavidcl Mar 25, 2026
35941e4
add mpi timers
tdavidcl Mar 25, 2026
5687d48
add timestep callback
tdavidcl Mar 25, 2026
06eee3e
add callback to script
tdavidcl Mar 25, 2026
98b1e99
cleaner
tdavidcl Mar 25, 2026
d2ddf42
faster
tdavidcl Mar 26, 2026
9774603
faster
tdavidcl Mar 26, 2026
f376a07
Merge branch 'main' into aurora-test4
tdavidcl Apr 1, 2026
91848f5
Merge branch 'main' into aurora-test4
tdavidcl Apr 2, 2026
afe16b0
Merge branch 'main' into aurora-test4
tdavidcl Apr 3, 2026
5ce8eae
Merge branch 'main' into aurora-test4
tdavidcl Apr 3, 2026
2634fc2
max check on scans
tdavidcl Apr 13, 2026
098ef5e
max check on scans
tdavidcl Apr 13, 2026
40347bb
other values
tdavidcl Apr 13, 2026
bc83f81
max check on scans
tdavidcl Apr 13, 2026
e78096e
max check on scans
tdavidcl Apr 13, 2026
e8977bf
some checksum
tdavidcl Apr 14, 2026
38b4785
some checksum
tdavidcl Apr 14, 2026
90486c3
even more checks
tdavidcl Apr 14, 2026
46632aa
better checks
tdavidcl Apr 14, 2026
7f0079e
expand kernel
tdavidcl Apr 14, 2026
46ed9b7
oob check
tdavidcl Apr 15, 2026
ece0151
other tree fields
tdavidcl Apr 15, 2026
0ba522b
add prefix to checksums
tdavidcl Apr 15, 2026
f1b4ecb
restore normal kernel
tdavidcl Apr 16, 2026
28a757e
Merge branch 'main' into aurora-test5
tdavidcl May 15, 2026
cbd3e14
kernel replay
tdavidcl Jun 1, 2026
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
53 changes: 46 additions & 7 deletions examples/benchmarks/sph_weak_scale_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
)
cfg.set_boundary_periodic()
cfg.set_eos_adiabatic(gamma)
cfg.set_max_neigh_cache_size(int(100e9))
cfg.print_status()
model.set_solver_config(cfg)
model.init_scheduler(scheduler_split_val, scheduler_merge_val)
Expand Down Expand Up @@ -102,7 +101,7 @@

model.set_value_in_a_box("uint", "f64", 0, bmin, bmax)

rinj = 8 * dr
rinj = 16 * dr
u_inj = 1
model.add_kernel_value("uint", "f64", u_inj, (0, 0, 0), rinj)

Expand All @@ -116,9 +115,6 @@
model.set_cfl_cour(0.1)
model.set_cfl_force(0.1)

model.set_cfl_multipler(1e-4)
model.set_cfl_mult_stiffness(1e6)

shamrock.backends.reset_mem_info_max()

# converge smoothing length and compute initial dt
Expand All @@ -128,11 +124,42 @@
res_rates = []
res_cnts = []
res_system_metrics = []
res_mpi_timers = []

"""
Here we insert callbacks to measure solver MPI usage by fetching the timers twice at the begining and end of the step
"""
before_mpi_timers, after_mpi_timers = None, None

def callback_before_mpi_timer():
global before_mpi_timers
# print(shamrock.sys.world_rank(), "register before_mpi_timers")
before_mpi_timers = shamrock.comm.get_timers()

def callback_after_mpi_timer():
global after_mpi_timers
# print(shamrock.sys.world_rank(), "register after_mpi_timers")
after_mpi_timers = shamrock.comm.get_timers()

model.add_timestep_callback(
step_begin=callback_before_mpi_timer, step_end=callback_after_mpi_timer
)

continue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The continue statement here will cause the benchmark loop to be skipped entirely. This appears to be leftover debug code that should be removed to allow the benchmark to run.


for i in range(10):
if shamrock.sys.world_rank() == 0:
print("running step ", i + 1, "/", 10, " ...")

for i in range(5):
shamrock.sys.mpi_barrier()

# To replay the same step
model.set_next_dt(0.0)
model.timestep()

if shamrock.sys.world_rank() == 0:
print("collecting results ...")

tmp_res_rate, tmp_res_cnt, tmp_system_metrics = (
model.solver_logs_last_rate(),
model.solver_logs_last_obj_count(),
Expand All @@ -141,14 +168,25 @@
res_rates.append(tmp_res_rate)
res_cnts.append(tmp_res_cnt)
res_system_metrics.append(tmp_system_metrics)
res_mpi_timers.append(shamrock.comm.mpi_timers_delta(before_mpi_timers, after_mpi_timers))

if shamrock.sys.world_rank() == 0:
print("sleeping 1 second ...")

import time

time.sleep(1)

if shamrock.sys.world_rank() == 0:
print("done sleeping 1 second ...")

# result is the best rate of the 5 steps
res_rate, res_cnt = max(res_rates), res_cnts[0]

# index of the max rate
max_rate_index = res_rates.index(max(res_rates))
max_rate_system_metrics = res_system_metrics[max_rate_index]

max_mpi_timers = res_mpi_timers[max_rate_index]
step_time = res_cnt / res_rate

if shamrock.sys.world_rank() == 0:
Expand All @@ -168,6 +206,7 @@
"rate": res_rate,
"cnt": res_cnt,
"step_time": step_time,
"mpi_timers": max_mpi_timers,
}

# print the system metrics
Expand Down
35 changes: 35 additions & 0 deletions src/shamalgs/include/shamalgs/buf_checksum.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// -------------------------------------------------------//
//
// SHAMROCK code for hydrodynamics
// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
//
// -------------------------------------------------------//

#pragma once

/**
* @file buf_checksum.hpp
* @author Timothée David--Cléris (tim.shamrock@proton.me)
* @brief
*
*/

#include "shambase/checksum.hpp"
#include "shamalgs/primitives/flatten.hpp"
#include "shambackends/DeviceBuffer.hpp"

namespace shamalgs {

template<class T>
inline u64 buf_checksum(const sham::DeviceBuffer<T> &buf) {
auto flattened_buf = primitives::flatten_buffer(buf);

using Tscal = typename shambase::VectorProperties<T>::component_type;
std::vector<Tscal> data = flattened_buf.copy_to_stdvec();
return shambase::fnv1a_hash(
reinterpret_cast<const char *>(data.data()), data.size() * sizeof(Tscal));
}

} // namespace shamalgs
3 changes: 3 additions & 0 deletions src/shamalgs/src/collective/sparse_exchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace shamalgs::collective {
/// fetch u64_2 from global message data
std::vector<u64_2> fetch_global_message_data(
const std::vector<CommMessageInfo> &messages_send) {
__shamrock_stack_entry();

std::vector<u64_2> local_data = std::vector<u64_2>(messages_send.size());

Expand Down Expand Up @@ -84,6 +85,7 @@ namespace shamalgs::collective {

/// decode message to get message
std::vector<CommMessageInfo> decode_all_message(const std::vector<u64_2> &global_data) {
__shamrock_stack_entry();
std::vector<CommMessageInfo> message_all(global_data.size());
for (u64 i = 0; i < global_data.size(); i++) {
message_all[i] = unpack(global_data[i]);
Expand All @@ -94,6 +96,7 @@ namespace shamalgs::collective {

/// compute message tags
void compute_tags(std::vector<CommMessageInfo> &message_all) {
__shamrock_stack_entry();

std::vector<i32> tag_map(shamcomm::world_size(), 0);

Expand Down
43 changes: 43 additions & 0 deletions src/shambase/include/shambase/checksum.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// -------------------------------------------------------//
//
// SHAMROCK code for hydrodynamics
// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
//
// -------------------------------------------------------//

#pragma once

/**
* @file checksum.hpp
* @author Timothée David--Cléris (tim.shamrock@proton.me)
* @brief
*
*/

#include "shambase/aliases_int.hpp"
#include <cstddef>

namespace shambase {

/**
* @brief Compute the FNV-1a hash of a given data
*
* @param data
* @param size
* @return u64
*/
inline u64 fnv1a_hash(const char *data, size_t size) {
constexpr u64 fnv_offset_basis = 14695981039346656037ULL;
constexpr u64 fnv_prime = 1099511628211ULL;

u64 hash = fnv_offset_basis;
for (size_t i = 0; i < size; ++i) {
hash ^= static_cast<u64>(static_cast<unsigned char>(data[i]));
hash *= fnv_prime;
}
return hash;
}

} // namespace shambase
4 changes: 2 additions & 2 deletions src/shammodels/gsph/src/modules/GSPHGhostHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,13 @@ auto GSPHGhostHandler<vec>::gen_id_table_interfaces(GeneratorMap &&gen)

for (auto &[k, v] : send_count_stats) {
if (v > 0.2) {
warn_log += shambase::format("\n patch {} high interf/patch volume: {}", k, v);
// warn_log += shambase::format("\n patch {} high interf/patch volume: {}", k, v);
has_warn = true;
}
}

if (has_warn && shamcomm::world_rank() == 0) {
warn_log = "\n This can lead to high mpi "
warn_log = "\n High interf/patch volume. This can lead to high mpi "
"overhead, try to increase the patch split crit"
+ warn_log;
}
Expand Down
7 changes: 7 additions & 0 deletions src/shammodels/sph/include/shammodels/sph/SPHUtilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ namespace shammodels::sph {
PatchField<flt> interactR_patch = sched.map_owned_to_patch_field_simple<flt>(
[&](const Patch p, PatchDataLayer &pdat) -> flt {
if (!pdat.is_empty()) {
#if false
auto tmp = pdat.get_field<flt>(ihpart).compute_max() * h_evol_max * Rkern;
shamcomm::logs::raw_ln(
shambase::format("patch {}, Rghost = {}", p.id_patch, tmp));
return tmp;
#else
return pdat.get_field<flt>(ihpart).compute_max() * h_evol_max * Rkern;
#endif
} else {
return shambase::VectorProperties<flt>::get_min();
}
Expand Down
9 changes: 9 additions & 0 deletions src/shammodels/sph/include/shammodels/sph/Solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
#include "shamrock/scheduler/ShamrockCtx.hpp"
#include "shamsys/legacy/log.hpp"
#include "shamtree/TreeTraversalCache.hpp"
#include <functional>
#include <memory>
#include <optional>
#include <stdexcept>
#include <variant>
#include <vector>
namespace shammodels::sph {

struct TimestepLog {
Expand Down Expand Up @@ -75,6 +78,12 @@ namespace shammodels::sph {
Config solver_config;
SolverLog solve_logs;

struct SolverStepCallback {
std::optional<std::function<void(void)>> step_begin_callback;
std::optional<std::function<void(void)>> step_end_callback;
};
std::vector<SolverStepCallback> timestep_callbacks{};

inline void init_required_fields() { solver_config.set_layout(context.get_pdl_write()); }

// serial patch tree control
Expand Down
4 changes: 2 additions & 2 deletions src/shammodels/sph/src/BasicSPHGhosts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,13 @@ auto BasicSPHGhostHandler<vec>::gen_id_table_interfaces(GeneratorMap &&gen)

for (auto &[k, v] : send_count_stats) {
if (v > 0.2) {
warn_log += shambase::format("\n patch {} high interf/patch volume: {}", k, v);
// warn_log += shambase::format("\n patch {} high interf/patch volume: {}", k, v);
has_warn = true;
}
}

if (has_warn && shamcomm::world_rank() == 0) {
warn_log = "\n This can lead to high mpi "
warn_log = "\n High interf/patch volume. This can lead to high mpi "
"overhead, try to increase the patch split crit"
+ warn_log;
}
Expand Down
12 changes: 12 additions & 0 deletions src/shammodels/sph/src/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,12 @@ shammodels::sph::TimestepLog shammodels::sph::Solver<Tvec, Kern>::evolve_once()
sham::MemPerfInfos mem_perf_infos_start = sham::details::get_mem_perf_info();
f64 mpi_timer_start = shamcomm::mpi::get_timer("total");

for (auto &callbacks : timestep_callbacks) {
if (callbacks.step_begin_callback) {
shambase::get_check_ref(callbacks.step_begin_callback)();
}
}

Tscal t_current = solver_config.get_time();
Tscal dt = solver_config.get_dt_sph();

Expand Down Expand Up @@ -2643,6 +2649,12 @@ shammodels::sph::TimestepLog shammodels::sph::Solver<Tvec, Kern>::evolve_once()

tstep.end();

for (auto it = timestep_callbacks.rbegin(); it != timestep_callbacks.rend(); ++it) {
if (it->step_begin_callback) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The condition checks step_begin_callback but the following line attempts to call step_end_callback. This will lead to a crash if step_end_callback is not provided while step_begin_callback is, or it will skip the call if only step_end_callback is provided. It should check it->step_end_callback instead.

Suggested change
if (it->step_begin_callback) {
if (it->step_end_callback) {

shambase::get_check_ref(it->step_end_callback)();
}
}

f64 delta_mpi_timer = shamcomm::mpi::get_timer("total") - mpi_timer_start;
sham::MemPerfInfos mem_perf_infos_end = sham::details::get_mem_perf_info();

Expand Down
Loading
Loading