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

[updated] Incorporate Cajita / Cabana::Grid load balancer #2

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6093894
ci: upgrade Kokkos version
cz4rs Sep 9, 2024
bf9fd60
remove unused variables
cz4rs Sep 9, 2024
e97bfac
avoid redundant initialization
cz4rs Aug 8, 2024
4d673de
Merge pull request #114 from cz4rs/misc-fixes
streeve Sep 9, 2024
4ab9d09
add vim temporary files to gitignore
aetx Jul 28, 2021
f67680e
add ALL to CMakeLists.txt
aetx Jul 28, 2021
638fa07
first integration of ALL
aetx Jul 28, 2021
038ecc9
format and move balance operation into neighbour update
aetx Aug 2, 2021
7ee7633
debug printfs and pseudo unbalanced work
aetx Aug 2, 2021
30bf78a
REVERT BEFORE MERGING increase minimum cmake version
aetx Aug 2, 2021
f062793
update comment regarding minimum domain size
aetx Aug 2, 2021
a5188e7
add explicit halo width via input file
aetx Aug 2, 2021
9d93c26
add vtk particles output via 'dump * * vtk n filname*%' command
aetx Aug 3, 2021
88958ad
fix some warnings and potential bugs
aetx Aug 4, 2021
c2671bd
fix resizing of pack_ranks_migrate_all
aetx Aug 5, 2021
f5d76c1
update atom initialization to not assume fully filled system
aetx Aug 5, 2021
957a3fb
update format
aetx Aug 5, 2021
6cdec01
use actual number of particles for balancing
aetx Aug 5, 2021
831d011
REVERT BEFORE MERGING increase system box by *2
aetx Aug 5, 2021
ff820d1
a little bit of cleanup
aetx Aug 5, 2021
6b4dcea
rename VTKDomainWriter to VTKWriter
aetx Aug 5, 2021
e2f50ff
rename vtk_domain_writer.h to vtk_writer.h
aetx Aug 5, 2021
3309e85
also output local work in domain output
aetx Aug 5, 2021
0d1eadf
output current, not last work
aetx Aug 5, 2021
a0b3f58
remove remaining debug output
aetx Aug 5, 2021
bf97931
add ALL to ci
aetx Aug 5, 2021
b768bfc
create additional create_domain that estimates ghost_cutoff
aetx Aug 5, 2021
a85d8a1
if reading a data file, use default ghost_offset
aetx Aug 5, 2021
6c98cb4
use CabanaMD_ENABLE_ALL to enable load balancing
aetx Aug 13, 2021
87585ec
change ALL library detection to Cabana like automatism
aetx Aug 26, 2021
4310c85
use Cajita grid to balance
aetx Aug 9, 2021
c8f7a8d
use CabanaMD_ENABLE_ALL to enable load balancing
aetx Aug 13, 2021
c07ffa0
update load balancer to use cajita lb
aetx Aug 26, 2021
03e56ea
update CI
aetx Aug 26, 2021
7c7700f
remove old explicit dependency
aetx Aug 26, 2021
4475bf6
use CabanaMD_ENABLE_LB to enable load balancing
aetx Aug 29, 2021
7151057
force LB on in CI
aetx Aug 29, 2021
8085e2d
use fixed number of subdivisions per rank for global mesh
aetx Aug 30, 2021
89f539b
use cmake_dependent_option for CabanaMD_ENABLE_LB
aetx Sep 2, 2021
dd0f07b
output lb quality as well
aetx Sep 23, 2021
0de3bde
missing space in output
aetx Sep 23, 2021
451439f
rename getQuality->getImbalance
aetx Oct 7, 2021
71a6478
move LoadBalancer into Experimental namespace
aetx Oct 21, 2021
ed12492
fix vacuum initialisation of particles. now corresponds to bulk system
aetx Nov 12, 2021
45ba761
Fix deprecated code and remaining warnings
cz4rs Jun 19, 2024
087baee
Apply clang-format
cz4rs Jun 20, 2024
8504ea2
Add a CLI flag for creating an unbalanced system
cz4rs Jun 25, 2024
ed3bcd8
Remove unused file
cz4rs Aug 9, 2024
e7eb3da
Use upstream Cabana repository
cz4rs Sep 10, 2024
2980a48
Revert unnecessary changes
cz4rs Sep 10, 2024
7192941
Change file naming scheme
cz4rs Jun 26, 2024
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
21 changes: 15 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
cxx: ['g++', 'clang++']
backend: ['SERIAL', 'OPENMP']
cmake_build_type: ['Debug', 'Release']
kokkos_ver: ['3.7.02']
kokkos_ver: ['4.3.01']
arborx: ['ArborX', 'NoArborX']
nnp: ['ON', 'OFF']
layout: ['1']
Expand All @@ -27,7 +27,7 @@ jobs:
cxx: 'g++'
openmp: 'ON'
cmake_build_type: 'Release'
kokkos_ver: '3.7.02'
kokkos_ver: '4.3.01'
arborx: 'NoArborX'
nnp: 'OFF'
layout: '2'
Expand All @@ -38,7 +38,7 @@ jobs:
cxx: 'g++'
openmp: 'ON'
cmake_build_type: 'Release'
kokkos_ver: '3.7.02'
kokkos_ver: '4.3.01'
arborx: 'NoArborX'
nnp: 'ON'
layout: '6'
Expand All @@ -49,7 +49,7 @@ jobs:
cxx: 'g++'
openmp: 'ON'
cmake_build_type: 'Release'
kokkos_ver: '3.7.02'
kokkos_ver: '4.3.01'
arborx: 'NoArborX'
nnp: 'OFF'
layout: '6'
Expand Down Expand Up @@ -94,6 +94,15 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }}
cmake --build build --parallel 2
cmake --install build
- name: Checkout ALL
run: |
git clone --depth 1 --branch master https://gitlab.jsc.fz-juelich.de/SLMS/loadbalancing ALL
- name: Build ALL
working-directory: ALL
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/ALL
cmake --build build --parallel 2
cmake --install build
- name: Checkout Cabana
uses: actions/checkout@v3
with:
Expand All @@ -106,9 +115,8 @@ jobs:
cmake -B build \
-DCMAKE_INSTALL_PREFIX=$HOME/Cabana \
-DMPIEXEC_MAX_NUMPROCS=2 -DMPIEXEC_PREFLAGS="--oversubscribe" \
-DCMAKE_PREFIX_PATH="$HOME/kokkos;$HOME/arborx" \
-DCMAKE_PREFIX_PATH="$HOME/kokkos;$HOME/arborx;$HOME/ALL" \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
-DCabana_DISABLE_CAJITA_DEPRECATION_WARNINGS=ON \
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }}
cmake --build build --parallel 2
cmake --install build
Expand Down Expand Up @@ -140,6 +148,7 @@ jobs:
-DCabanaMD_LAYOUT=${{ matrix.layout }} \
-DCabanaMD_VECTORLENGTH=${{ matrix.vector }} \
-DCabanaMD_ENABLE_NNP=${{ matrix.nnp }} \
-DCabanaMD_ENABLE_LB=ON \
-DN2P2_DIR=$HOME/n2p2 \
-DCabanaMD_LAYOUT_NNP=${{ matrix.layout_nnp }} \
-DCabanaMD_VECTORLENGTH_NNP=${{ matrix.vector_nnp }}
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.14)
project(CabanaMD LANGUAGES CXX VERSION 0.1.0)

set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -18,6 +18,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
##---------------------------------------------------------------------------##
find_package(Cabana REQUIRED)

option(CabanaMD_ENABLE_LB "Utilize Cabana load balancer" OFF)

##---------------------------------------------------------------------------##
# Set up optional libraries
##---------------------------------------------------------------------------##
Expand Down
3 changes: 3 additions & 0 deletions input/in.lj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ pair_coeff 1 1 1.0 1.0 2.5

neighbor 0.3 bin
neigh_modify every 20 one 50
comm_modify cutoff * 20
fix 1 all nve
thermo 10

dump dmpvtk all vtk 10 dump%_*.vtu

run 100
1 change: 1 addition & 0 deletions src/CabanaMD_config.hpp.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define CabanaMD_GIT_COMMIT_HASH "@CabanaMD_GIT_COMMIT_HASH@"

#cmakedefine CabanaMD_ENABLE_NNP
#cmakedefine CabanaMD_ENABLE_LB

#cmakedefine CabanaMD_LAYOUT @CabanaMD_LAYOUT@
#cmakedefine CabanaMD_VECTORLENGTH "@CabanaMD_VECTORLENGTH@"
Expand Down
9 changes: 9 additions & 0 deletions src/cabanamd.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
#include <integrator_nve.h>
#include <types.h>

#ifdef CabanaMD_ENABLE_LB
#include <Cabana_Grid_LoadBalancer.hpp>
#include <Cabana_Grid_Types.hpp>
#endif

class CabanaMD
{
public:
Expand All @@ -81,6 +86,10 @@ class CbnMD : public CabanaMD
Comm<t_System> *comm;
Binning<t_System> *binning;
InputFile<t_System> *input;
#ifdef CabanaMD_ENABLE_LB
Cabana::Grid::Experimental::LoadBalancer<Cabana::Grid::UniformMesh<double>>
*lb;
#endif

void init( InputCL cl ) override;
void run() override;
Expand Down
72 changes: 65 additions & 7 deletions src/cabanamd_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,19 @@
#include <Cabana_Core.hpp>
#include <Kokkos_Core.hpp>

#include <mpi.h>

#include <output.h>
#include <property_kine.h>
#include <property_pote.h>
#include <property_temperature.h>
#include <read_data.h>
#include <vtk_writer.h>

#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>

#define MAXPATHLEN 1024

Expand Down Expand Up @@ -224,6 +228,12 @@ void CbnMD<t_System, t_Neighbor>::init( InputCL commandline )
comm->update_force();
}

#ifdef CabanaMD_ENABLE_LB
lb = new Cabana::Grid::Experimental::LoadBalancer<
Cabana::Grid::UniformMesh<double>>( MPI_COMM_WORLD,
system->global_grid );
#endif

// Initial output
int step = 0;
if ( input->thermo_rate > 0 )
Expand All @@ -236,10 +246,19 @@ void CbnMD<t_System, t_Neighbor>::init( InputCL commandline )
auto KE = kine.compute( system ) / system->N;
if ( !_print_lammps )
{
#ifdef CabanaMD_ENABLE_LB
log( out, "\n", std::fixed, std::setprecision( 6 ),
"#Timestep Temperature PotE ETot Time Atomsteps/s "
"LBImbalance\n",
step, " ", T, " ", PE, " ", PE + KE, " ",
std::setprecision( 2 ), 0.0, " ", std::scientific, 0.0, " ",
std::setprecision( 2 ), 0.0 );
#else
log( out, "\n", std::fixed, std::setprecision( 6 ),
"#Timestep Temperature PotE ETot Time Atomsteps/s\n", step,
" ", T, " ", PE, " ", PE + KE, " ", std::setprecision( 2 ),
0.0, " ", std::scientific, 0.0 );
#endif
}
else
{
Expand All @@ -264,6 +283,7 @@ template <class t_System, class t_Neighbor>
void CbnMD<t_System, t_Neighbor>::run()
{
std::ofstream out( input->output_file, std::ofstream::app );
std::ofstream err( input->error_file, std::ofstream::app );

auto neigh_cutoff = input->force_cutoff + input->neighbor_skin;
bool half_neigh = input->force_iteration_type == FORCE_ITER_NEIGH_HALF;
Expand All @@ -272,15 +292,19 @@ void CbnMD<t_System, t_Neighbor>::run()
PotE<t_System, t_Neighbor> pote( comm );
KinE<t_System> kine( comm );

std::string vtk_actual_domain_basename( "domain_act" );
std::string vtk_lb_domain_basename( "domain_lb" );

double force_time = 0;
double comm_time = 0;
double neigh_time = 0;
double integrate_time = 0;
double lb_time = 0;
double other_time = 0;

double last_time = 0;
Kokkos::Timer timer, force_timer, comm_timer, neigh_timer, integrate_timer,
other_timer;
lb_timer, other_timer;

// Main timestep loop
for ( int step = 1; step <= nsteps; step++ )
Expand All @@ -292,6 +316,16 @@ void CbnMD<t_System, t_Neighbor>::run()

if ( step % input->comm_exchange_rate == 0 && step > 0 )
{
// Update domain decomposition
lb_timer.reset();
#ifdef CabanaMD_ENABLE_LB
double work = system->N_local + system->N_ghost;
auto new_global_grid = lb->createBalancedGlobalGrid(
system->global_mesh, *system->partitioner, work );
system->update_global_grid( new_global_grid );
#endif
lb_time += lb_timer.seconds();

// Exchange atoms across MPI ranks
comm_timer.reset();
comm->exchange();
Expand Down Expand Up @@ -361,9 +395,16 @@ void CbnMD<t_System, t_Neighbor>::run()
double time = timer.seconds();
double rate =
1.0 * system->N * input->thermo_rate / ( time - last_time );
#ifdef CabanaMD_ENABLE_LB
log( out, std::fixed, std::setprecision( 6 ), step, " ", T, " ",
PE, " ", PE + KE, " ", std::setprecision( 2 ), time, " ",
std::scientific, rate, " ", std::setprecision( 2 ),
lb->getImbalance() );
#else
log( out, std::fixed, std::setprecision( 6 ), step, " ", T, " ",
PE, " ", PE + KE, " ", std::setprecision( 2 ), time, " ",
std::scientific, rate );
#endif
last_time = time;
}
else
Expand All @@ -373,8 +414,22 @@ void CbnMD<t_System, t_Neighbor>::run()
" ", T, " ", PE, " ", PE + KE, " ", time );
last_time = time;
}
#ifdef CabanaMD_ENABLE_LB
double work = system->N_local + system->N_ghost;
std::array<double, 6> vertices;
vertices = lb->getVertices();
VTKWriter::writeDomain( MPI_COMM_WORLD, step, vertices, work,
vtk_actual_domain_basename );
vertices = lb->getInternalVertices();
VTKWriter::writeDomain( MPI_COMM_WORLD, step, vertices, work,
vtk_lb_domain_basename );
#endif
}

if ( step % input->vtk_rate == 0 )
VTKWriter::writeParticles( MPI_COMM_WORLD, step, system,
input->vtk_file, err );

if ( input->dumpbinaryflag )
dump_binary( step );

Expand All @@ -391,16 +446,18 @@ void CbnMD<t_System, t_Neighbor>::run()
{
double steps_per_sec = 1.0 * nsteps / time;
double atom_steps_per_sec = system->N * steps_per_sec;
// todo(sschulz): Properly remove lb timing if not enabled.
log( out, std::fixed, std::setprecision( 2 ),
"\n#Procs Atoms | Time T_Force T_Neigh T_Comm T_Int ",
"\n#Procs Atoms | Time T_Force T_Neigh T_Comm T_Int T_lb ",
"T_Other |\n", comm->num_processes(), " ", system->N, " | ", time,
" ", force_time, " ", neigh_time, " ", comm_time, " ",
integrate_time, " ", other_time, " | PERFORMANCE\n", std::fixed,
comm->num_processes(), " ", system->N, " | ", 1.0, " ",
integrate_time, " ", lb_time, " ", other_time, " | PERFORMANCE\n",
std::fixed, comm->num_processes(), " ", system->N, " | ", 1.0, " ",
force_time / time, " ", neigh_time / time, " ", comm_time / time,
" ", integrate_time / time, " ", other_time / time,
" | FRACTION\n\n", "#Steps/s Atomsteps/s Atomsteps/(proc*s)\n",
std::scientific, steps_per_sec, " ", atom_steps_per_sec, " ",
" ", integrate_time / time, " ", lb_time / time, " ",
other_time / time, " | FRACTION\n\n",
"#Steps/s Atomsteps/s Atomsteps/(proc*s)\n", std::scientific,
steps_per_sec, " ", atom_steps_per_sec, " ",
atom_steps_per_sec / comm->num_processes() );
}
else
Expand All @@ -409,6 +466,7 @@ void CbnMD<t_System, t_Neighbor>::run()
" procs for ", nsteps, " steps with ", system->N, " atoms" );
}
out.close();
err.close();

if ( input->write_data_flag )
write_data( system, input->output_data_file );
Expand Down
2 changes: 1 addition & 1 deletion src/comm_mpi_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void Comm<t_System>::exchange()
// resized as well
if ( pack_ranks_migrate_all.extent( 0 ) < x.size() )
{
max_local *= 1.1;
max_local = x.size() * 1.1;
Kokkos::realloc( pack_ranks_migrate_all, max_local );
}
pack_ranks_migrate =
Expand Down
7 changes: 7 additions & 0 deletions src/inputCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ void InputCL::read_args( int argc, char *argv[] )
" (N = positive integer)\n",
" (PATH = location of ",
"directory)\n" );
log( std::cout, " --sparse : "
"create a vacuum for an unbalanced system\n" );
}

// Read Lammps input deck
Expand Down Expand Up @@ -233,6 +235,11 @@ void InputCL::read_args( int argc, char *argv[] )
i += 3;
}

else if ( ( strcmp( argv[i], "--sparse" ) == 0 ) )
{
sparse = true;
}

else if ( ( strstr( argv[i], "--kokkos-" ) == NULL ) )
{
log_err( std::cout, "Unknown command line argument: ", argv[i] );
Expand Down
1 change: 1 addition & 0 deletions src/inputCL.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class InputCL
int layout_type;
int nnp_layout_type;
int device_type;
bool sparse = false;

int dumpbinary_rate, correctness_rate;
bool dumpbinaryflag, correctnessflag;
Expand Down
Loading
Loading