Skip to content

[WIP] Rebase load balancing #274

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

Open
wants to merge 170 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
b58a1e6
add Morton & Hilbert class to compute SFC
Feb 15, 2024
d514054
add simple timers
Feb 15, 2024
262ba26
add timers on advection 2d demos
Feb 15, 2024
7027643
add load balancing demos (without MPI first)
Feb 15, 2024
8a560f8
fix: wrong folder for sfc.hpp
Feb 15, 2024
70f017b
fix: correct folder for sfc.hpp
Feb 15, 2024
abc7b56
add some missing tests for samurai::cell
Feb 15, 2024
88d0e8a
add tests for MRmesh
Feb 18, 2024
bd4c869
fix SFC computation for hilbert + interface
Mar 6, 2024
05dc1bb
add unit test for sfc key computation
Mar 6, 2024
2c9f36d
add unit tests
Mar 9, 2024
0ca6744
add mesh remove test
Mar 11, 2024
702fd44
update statistisque module
Mar 21, 2024
e9f6ab5
add load balancing base class + some usefull functions
Mar 21, 2024
2a012ad
add load balancing derived class for SFC
Mar 21, 2024
a5d13ba
add mrmesh constructeur for ca_type
Mar 21, 2024
1fdb5a1
remove load balancing from mesh class + add merge & remove functions
Mar 21, 2024
a184e83
add gravity base load balancing for cells
Mar 21, 2024
2c4a867
add graph based with interface propagation load balancing class
Mar 21, 2024
ad3cbfa
add load balancing demo
Mar 21, 2024
d36577c
add some unit test for load balancing function
Mar 21, 2024
f195e64
add script parse stats file
Mar 22, 2024
e08af7c
add load balancing demos
Mar 22, 2024
086b868
add unit test files
Apr 2, 2024
0ad4dab
remove cout
Apr 2, 2024
8ef2f37
fix unused warning
Apr 2, 2024
d0d76c6
update load balancing demo
Apr 2, 2024
6857303
add void load balancing class for demo
Apr 4, 2024
2aa4f33
add getName() funcitons
Apr 4, 2024
875800f
clean demo code for load balancing
Apr 4, 2024
fab9958
remove useless class SFC_LoadBalancer_cells
Apr 4, 2024
9312f9e
fix warnings
Apr 10, 2024
2a8baf4
remove define
Apr 10, 2024
55fc071
fix warning and remove old function
Apr 10, 2024
020b530
fix warnings
Apr 10, 2024
b319761
fix warnings
Apr 10, 2024
ee3b1d0
fxi read stats scripts
Apr 10, 2024
d80d6ad
fix load balancing sfc transfer rate
Apr 10, 2024
b9d80eb
fix warning
Apr 10, 2024
8136420
fix warnings
Apr 12, 2024
f82cce5
fix warnings
Apr 12, 2024
fbf90ae
fix partition mesh with 1 mpi
Apr 17, 2024
a49af14
fix libdeps error in cmake
Apr 17, 2024
76b2047
add load balancing in advection 2D demo + fix new interface bc
Apr 17, 2024
81c2170
fix bc and conv interface
Apr 17, 2024
df98cb2
extract merge / remove CA from Mesh from mesh file to load balance file
Apr 17, 2024
625c4cf
fix SFC load balance
Apr 17, 2024
74f7b62
add mesh constructor with mpi neighbourhood
Apr 17, 2024
e705e25
return new mesh from load balancing with sfc
Apr 17, 2024
9fc92a9
fix update neighbour in constructor
Apr 18, 2024
a5b3764
update load balancing SFC with data exchange
Apr 18, 2024
7af599b
clang format
Apr 18, 2024
86c8089
update advection with dynamic load balancing
Apr 18, 2024
f9a7953
clang format
Apr 23, 2024
f9a4dca
fix mpi for unit tests
Apr 23, 2024
0d231e3
clang format
Apr 23, 2024
a2ee1a7
fix bug template parameter to keep number of ghosts in config
Apr 25, 2024
ceb78eb
update unit test mrmesh
Apr 25, 2024
bc8438b
fix: MPI (#199)
gouarin May 2, 2024
6e65799
remove load balancing from mesh class + add merge & remove functions
Mar 21, 2024
317c212
fix warnings
Apr 10, 2024
b791f24
fix update neighbour in constructor
Apr 18, 2024
30eac01
remove check nan
May 2, 2024
b2da43a
remove useless argument
May 2, 2024
c676532
add mrmesh tests
May 2, 2024
b1d5805
fix example with load balancing
May 2, 2024
6170114
fix load balance diffusion gravity
May 3, 2024
acf313e
update load balance sfc
May 3, 2024
0816dff
fix return value for interface propagation
May 6, 2024
bcf3194
fix interval propagation
May 6, 2024
df23304
fix: discover neighbour after field update
May 6, 2024
e8e2164
remove discover for SFC
May 6, 2024
54dad07
undo partition_mesh all processes as neighbours
May 7, 2024
13894db
fix gravity based to take load evolution into account
May 7, 2024
7e712c8
add new LB algorithm based on field
May 7, 2024
7a3faf4
fix +1 in logical coord
May 7, 2024
ea54538
test new version LB
May 7, 2024
23f8cd8
fix unit test load balancing
May 7, 2024
9d03b68
fix load balancing dim parameter + weight for bayrcenter
May 7, 2024
15681f5
update new load balancing strategy
May 7, 2024
5d75d93
add new strategy for test in demo
May 7, 2024
8949be5
ifx missing libdeps in cmake
May 7, 2024
576e0ec
fix assert
May 14, 2024
2d5ea88
load balacing interface propagation with local field
May 14, 2024
9ebb472
fix diffusion load balancing with field by removing diagonal exchanges
May 14, 2024
9b5998d
load balancing thresold + cmptInterfaceUniform
May 16, 2024
29c8501
update interface prop strategy
May 16, 2024
4919941
fix global min/max for interface uniform
May 16, 2024
87b3dae
fix load balancing base interface
May 17, 2024
4abe998
fix laod blancing diffusion
May 17, 2024
89e7133
update advection 2d test
May 17, 2024
f01d2ca
fix load balancing crash
May 21, 2024
a50eb0e
FIX bug max level for archive in serizalize
May 22, 2024
0e100d0
remove fix crash
May 22, 2024
c10b546
remove useless constructor
May 29, 2024
7d3458f
update load balancer with reordering + update field using all to all …
May 29, 2024
40a3207
try fix interface prop lb
May 29, 2024
2735358
update SFC load balancing
May 29, 2024
02300cc
fix load balancing with SFC
May 30, 2024
cfd11ca
add ordering function to others lb strategy
May 30, 2024
5dab244
fix MPI comm in SFC
Jun 3, 2024
697101d
Add functions to compute the number of intervals in CellArray
gouarin May 31, 2024
0f00164
Add get_interval_location function in CellArray which return the inde…
gouarin May 31, 2024
be51e15
Refactor Mesh_base class to include MPI neighborhood information as c…
gouarin May 31, 2024
cdce539
start adding metis and scotch for load balancing
gouarin May 31, 2024
15b056e
fix warnings
Jun 3, 2024
38d5d68
fix warnings
Jun 3, 2024
173aee3
fix missings refs
Jun 3, 2024
ac604c1
updarte demo adv
Jun 3, 2024
85d842a
fix warnings
Jun 3, 2024
0abf0e7
fix warnings
Jun 3, 2024
8747a0f
fix init advection for 3D tests
Jun 3, 2024
dc1414b
add update mesh & change return object for LB to be a field with rank
Jun 5, 2024
30909e9
clean code and fix wrning
Jun 5, 2024
ff2f5d4
update reordoring to use update_mesh
Jun 6, 2024
024256d
update reordering
Jun 6, 2024
94cc599
clean code - use of update_mesh in reordering
Jun 7, 2024
247fcbc
remove useless
Jun 7, 2024
7eb6a0c
update timer, add ncalls
Jun 7, 2024
6d8a13d
remove petsc from linear conveciton - unused
Jun 10, 2024
5f36c9f
update linear convection with load balancing
Jun 10, 2024
158db8f
fix field type in linear conv + return val for lb cell
Jun 10, 2024
3b697fe
add timers to samurai init
Jun 11, 2024
f7de172
const + fix comment
Jun 11, 2024
f657530
fix warnings
Jun 11, 2024
0342ac2
try fix LB cells
Jun 11, 2024
f0b02d8
fix interface prop to use flags field
Jun 11, 2024
6706f96
fix linear conv to use times in samurai init
Jun 11, 2024
15d03d1
fix dim type + set access to derived class to logs
Jun 11, 2024
7f7f09a
fix dim type
Jun 11, 2024
bfe3217
getStencilToNeighbour as function to allow multiple stencil instead o…
Jun 11, 2024
06d2128
fix dim type
Jun 11, 2024
98a2cb7
fix dim
Jun 11, 2024
41e64e1
fix warning
Jun 11, 2024
557a5ae
fix warning
Jun 11, 2024
4fe5efc
fix warning
Jun 11, 2024
c33a5a4
add timer for init
Jun 11, 2024
16ebe25
fix warning
Jun 11, 2024
158b9df
fix diffusion by splitting dirs
Jun 11, 2024
cb910a7
add timers
Jun 11, 2024
70b2ff9
try fix loadbalancing strategy based on geo dist
Jun 12, 2024
f91c07f
fix missing include for tests + add celLExists + add unit test
Jun 13, 2024
ca03f84
fix compile error
Jun 13, 2024
af040e1
add new load balancing strategy squelette
Jun 13, 2024
93a8c4c
fix MPI lock with update_mesh
Jun 14, 2024
f9af480
add empty() to cellList
Jun 14, 2024
ced6f23
update LBM demo
Jun 14, 2024
e43083b
fix missing link libraries for lbm
Jun 14, 2024
77f5892
uncomment lbm in cmake
Jun 14, 2024
c7bddb2
add more load balancing strategy in LBM demo
Jun 14, 2024
42a0eeb
update timer in lbm demo
Jun 14, 2024
678a4e2
add weigh for SFC load balancing
Jul 9, 2024
e7c6e60
fix assert
Jul 9, 2024
2cc2123
add unbalance boolean criteria to trigger load balancing
Jul 10, 2024
868b25d
update sfc w require_loadbalancing
Jul 11, 2024
5d663b9
fix const compite error
Jul 12, 2024
855daec
update diff LB
Jul 12, 2024
04bb980
update intro + config
Jul 22, 2024
0de0541
test different cell weights
Jul 22, 2024
96fe005
fix: add missing func to update new lb auto trigger
Jul 22, 2024
d750d4c
fix void load balancer
Jul 24, 2024
22e3603
add test with ponio
Jul 24, 2024
c4b5d20
fix warning
Jul 25, 2024
42c5216
fix warning
Jul 25, 2024
be71678
impl new approach
Jul 25, 2024
7c935dc
fix new name for LB
Jul 25, 2024
b4ebc2b
fix: Rebase working in single
sbstndb Feb 25, 2025
653109b
Remove useless MPI stuff
sbstndb Feb 26, 2025
a43b6ed
Undo unwanted commit
sbstndb Feb 26, 2025
d328e2b
Remove Stuff
sbstndb Feb 26, 2025
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
3 changes: 2 additions & 1 deletion demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ find_package(CLI11)

add_subdirectory(from_obj)
add_subdirectory(FiniteVolume)
add_subdirectory(loadbalancing)
# add_subdirectory(MPI)
# add_subdirectory(LBM)
add_subdirectory(LBM)
add_subdirectory(p4est)
add_subdirectory(pablo)
add_subdirectory(tutorial)
Expand Down
6 changes: 4 additions & 2 deletions demos/FiniteVolume/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ if(PETSC_FOUND)
target_link_libraries(manual_block_matrix_assembly samurai CLI11::CLI11 ${PETSC_LINK_LIBRARIES} ${MPI_LIBRARIES})
endif()

add_executable(finite-volume-linear-convection linear_convection.cpp)
target_link_libraries(finite-volume-linear-convection samurai CLI11::CLI11 ${MPI_LIBRARIES})


add_executable(finite-volume-amr-burgers-hat AMR_Burgers_Hat.cpp)
target_link_libraries(finite-volume-amr-burgers-hat samurai CLI11::CLI11)

Expand All @@ -53,8 +57,6 @@ target_link_libraries(finite-volume-advection-2d-user-bc samurai CLI11::CLI11)
add_executable(finite-volume-scalar-burgers-2d scalar_burgers_2d.cpp)
target_link_libraries(finite-volume-scalar-burgers-2d samurai CLI11::CLI11)

add_executable(finite-volume-linear-convection linear_convection.cpp)
target_link_libraries(finite-volume-linear-convection samurai CLI11::CLI11)

add_executable(finite-volume-burgers burgers.cpp)
target_link_libraries(finite-volume-burgers samurai CLI11::CLI11)
Expand Down
75 changes: 70 additions & 5 deletions demos/FiniteVolume/advection_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
#include <samurai/stencil_field.hpp>
#include <samurai/subset/subset_op.hpp>

#include <samurai/load_balancing.hpp>
#include <samurai/load_balancing_sfc.hpp>
#include <samurai/load_balancing_sfc_w.hpp>
#include <samurai/load_balancing_diffusion.hpp>
#include <samurai/load_balancing_force.hpp>
#include <samurai/load_balancing_diffusion_interval.hpp>
#include <samurai/load_balancing_void.hpp>

#include <samurai/timers.hpp>

#include <filesystem>
namespace fs = std::filesystem;

Expand All @@ -23,11 +33,13 @@ auto init(Mesh& mesh)
{
auto u = samurai::make_field<double, 1>("u", mesh);

u.fill( 0. );

samurai::for_each_cell(
mesh,
[&](auto& cell)
{
auto center = cell.center();
auto center = cell.center();
const double radius = .2;
const double x_center = 0.3;
const double y_center = 0.3;
Expand All @@ -38,7 +50,7 @@ auto init(Mesh& mesh)
else
{
u[cell] = 0;
}
}
});

return u;
Expand Down Expand Up @@ -146,21 +158,26 @@ void flux_correction(double dt, const std::array<double, 2>& a, const Field& u,
template <class Field>
void save(const fs::path& path, const std::string& filename, const Field& u, const std::string& suffix = "")
{
auto mesh = u.mesh();
auto level_ = samurai::make_field<std::size_t, 1>("level", mesh);
auto mesh = u.mesh();
auto level_ = samurai::make_field<std::size_t, 1>("level", mesh);
auto domain_ = samurai::make_field<int, 1>("domain", mesh);

if (!fs::exists(path))
{
fs::create_directory(path);
}

int mrank = 0;

samurai::for_each_cell(mesh,
[&](const auto& cell)
{
level_[cell] = cell.level;
level_[cell] = cell.level;
domain_[cell] = mrank;
});
#ifdef SAMURAI_WITH_MPI
mpi::communicator world;
mrank = world.rank();
samurai::save(path, fmt::format("{}_size_{}{}", filename, world.size(), suffix), mesh, u, level_);
#else
samurai::save(path, fmt::format("{}{}", filename, suffix), mesh, u, level_);
Expand All @@ -175,6 +192,7 @@ int main(int argc, char* argv[])
using Config = samurai::MRConfig<dim>;

// Simulation parameters
double radius = 0.2, x_center = 0.3, y_center = 0.3;
xt::xtensor_fixed<double, xt::xshape<dim>> min_corner = {0., 0.};
xt::xtensor_fixed<double, xt::xshape<dim>> max_corner = {1., 1.};
std::array<double, dim> a{
Expand All @@ -194,6 +212,7 @@ int main(int argc, char* argv[])
fs::path path = fs::current_path();
std::string filename = "FV_advection_2d";
std::size_t nfiles = 1;
std::size_t nt_loadbalance = 1; // nombre d'iteration entre les equilibrages

app.add_option("--min-corner", min_corner, "The min corner of the box")->capture_default_str()->group("Simulation parameters");
app.add_option("--max-corner", max_corner, "The max corner of the box")->capture_default_str()->group("Simulation parameters");
Expand All @@ -202,6 +221,7 @@ int main(int argc, char* argv[])
app.add_option("--Tf", Tf, "Final time")->capture_default_str()->group("Simulation parameters");
app.add_option("--min-level", min_level, "Minimum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--max-level", max_level, "Maximum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--nt-loadbalance", nt_loadbalance, "Maximum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--mr-eps", mr_epsilon, "The epsilon used by the multiresolution to adapt the mesh")
->capture_default_str()
->group("Multiresolution");
Expand All @@ -227,19 +247,57 @@ int main(int argc, char* argv[])
double t = 0.;

auto u = init(mesh);


samurai::make_bc<samurai::Dirichlet<1>>(u, 0.);
auto unp1 = samurai::make_field<double, 1>("unp1", mesh);

auto MRadaptation = samurai::make_MRAdapt(u);

samurai::times::timers.start("MRadaptation");
MRadaptation(mr_epsilon, mr_regularity);
samurai::times::timers.stop("MRadaptation");

save(path, filename, u, "_init");

std::size_t nsave = 1;
std::size_t nt = 0;


// For now, void_balancer is verified and works properly
// Diffusion_LoadBalancer_cell not exist ???
// Load_balancing::Diffusion donne de très mauvais resultats, peut-etre des parametres internes ?

SFC_LoadBalancer_interval<dim, Morton> balancer;
// Void_LoadBalancer<dim> balancer;
// Diffusion_LoadBalancer_cell<dim> balancer;
// Diffusion_LoadBalancer_interval<dim> balancer;
// Load_balancing::Diffusion balancer;
// Load_balancing::SFCw<dim, Morton> balancer;

std::ofstream logs;
#ifdef SAMURAI_WITH_MPI
boost::mpi::communicator world;
logs.open( fmt::format("log_{}.dat", world.rank()), std::ofstream::app );
#endif
while (t != Tf)
{
bool reqBalance = balancer.require_balance( mesh );

if( reqBalance ) std::cerr << "\t> Load Balancing required !!! " << std::endl;

// if ( ( nt % nt_loadbalance == 0 || reqBalance ) && nt > 1 )
if ( ( nt % nt_loadbalance == 0 ) && nt > 1 )
// if ( reqBalance && nt > 1 )
{
samurai::times::timers.start("load-balancing");
balancer.load_balance(mesh, u);
samurai::times::timers.stop("load-balancing");
}

samurai::times::timers.start("MRadaptation");
MRadaptation(mr_epsilon, mr_regularity);
samurai::times::timers.stop("MRadaptation");

t += dt;
if (t > Tf)
Expand All @@ -251,8 +309,13 @@ int main(int argc, char* argv[])
std::cout << fmt::format("iteration {}: t = {}, dt = {}", nt++, t, dt) << std::endl;

samurai::update_ghost_mr(u);

unp1.resize();

samurai::times::timers.start("upwind");
unp1 = u - dt * samurai::upwind(a, u);
samurai::times::timers.stop("upwind");

if (correction)
{
flux_correction(dt, a, u, unp1);
Expand All @@ -265,7 +328,9 @@ int main(int argc, char* argv[])
const std::string suffix = (nfiles != 1) ? fmt::format("_ite_{}", nsave++) : "";
save(path, filename, u, suffix);
}

}

samurai::finalize();
return 0;
}
Loading
Loading