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

extended LAMMPS commands support #3

Merged
merged 26 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8a406e6
Update clang format to match Cabana
streeve Sep 25, 2024
eafa26a
apply new format
streeve Sep 25, 2024
f6279ff
Merge pull request #117 from streeve/update_format
streeve Oct 4, 2024
3a7c1e1
Print number of particles sent and received
cz4rs Jun 28, 2024
d1be7d1
Add basic support for `group` command
cz4rs Aug 7, 2024
766fad7
Update .gitignore
cz4rs Aug 8, 2024
3792555
Use a struct for storing region coordinates
cz4rs Aug 8, 2024
ce06bbe
Add ParaView script for automated data processing
cz4rs Aug 9, 2024
a64f6c4
Allow boxes with non-zero offset
cz4rs Aug 9, 2024
4be9ba4
Use two atom types
cz4rs Aug 14, 2024
4e542df
Use different velocities depending on atom type
cz4rs Aug 14, 2024
fa3739a
Support multiple regions
cz4rs Aug 16, 2024
43c314c
Decide atom type based on region
cz4rs Aug 16, 2024
8f4360d
Add customized input deck
cz4rs Aug 27, 2024
a884201
Fix formatting
cz4rs Aug 28, 2024
b253d73
Use 4 digits in data files by default
cz4rs Aug 28, 2024
0d274d9
Fix compatibility with original decks
cz4rs Aug 28, 2024
94e06f3
Add missing default
cz4rs Sep 18, 2024
af5cd5e
Allow empty regions
cz4rs Sep 25, 2024
7f58084
Rename load balancing deck
cz4rs Sep 25, 2024
65bb0bc
Move ParaView script to `utils`
cz4rs Sep 25, 2024
091690c
Drop redundant comments
cz4rs Sep 25, 2024
a2d0f1c
Fix formatting
cz4rs Oct 7, 2024
9e8a5aa
Extract summary printing into a method
cz4rs Oct 7, 2024
7334d3b
Make communication statistics consistent with other output
cz4rs Oct 8, 2024
89f2b06
Apply suggestions from code review
cz4rs Oct 9, 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
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ BinPackParameters: true
IndentWidth: 4
SpacesInParentheses: true
BreakConstructorInitializersBeforeComma: true
PointerAlignment: Right
AlwaysBreakAfterReturnType: None
KeepEmptyLinesAtTheStartOfBlocks: false
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ jobs:
- name: Run clang-format style check
uses: jidicula/[email protected]
with:
clang-format-version: '10'
clang-format-version: '14'
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
build
.cproject
.project
*.jpg
*.pvtu
*.vtu

cabanaMD.err
cabanaMD.out
1 change: 0 additions & 1 deletion bin/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
// This main file is simply a driver
int main( int argc, char *argv[] )
{

MPI_Init( &argc, &argv );

{
Expand Down
16 changes: 3 additions & 13 deletions cmake/FindCLANG_FORMAT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,7 @@

find_program(CLANG_FORMAT_EXECUTABLE
NAMES clang-format
clang-format-7
clang-format-6.0
clang-format-5.0
clang-format-4.0
clang-format-3.9
clang-format-3.8
clang-format-3.7
clang-format-3.6
clang-format-3.5
clang-format-3.4
clang-format-3.3
clang-format-14
DOC "clang-format executable")
mark_as_advanced(CLANG_FORMAT_EXECUTABLE)

Expand All @@ -38,11 +28,11 @@ if(CLANG_FORMAT_EXECUTABLE)
OUTPUT_VARIABLE clang_format_version
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)

if(clang_format_version MATCHES "^clang-format version .*")
if(clang_format_version MATCHES "^.*clang-format version .*")
# clang_format_version sample: "clang-format version 3.9.1-4ubuntu3~16.04.1
# (tags/RELEASE_391/rc2)"
string(REGEX
REPLACE "clang-format version ([.0-9]+).*"
REPLACE "^.*clang-format version ([.0-9]+).*"
"\\1"
CLANG_FORMAT_VERSION
"${clang_format_version}")
Expand Down
41 changes: 41 additions & 0 deletions input/in.lb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Example for exercising load balancing (not intended to be physical)

units lj
atom_style atomic

newton off

lattice fcc 0.8442
region lo-box block 0 10 0 10 0 10
region mid-box block 5 10 5 10 5 10
region hi-box block 0 5 15 20 15 20
region hj-box block 15 20 15 20 0 5
create_box 4 box

mass 1 2.0
mass 2 8.0
mass 3 9.0
mass 4 1.0

create_atoms 1 region lo-box
create_atoms 2 region mid-box
create_atoms 3 region hi-box
create_atoms 4 region hj-box

velocity 1 create 10.4 87287 loop geom
velocity 2 create 41.6 87287 loop geom
velocity 3 create 20.8 87287 loop geom
velocity 4 create 10.4 87287 loop geom

pair_style lj/cut 2.5
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
5 changes: 5 additions & 0 deletions src/cabanamd.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ class CbnMD : public CabanaMD

void dump_binary( int ) override;
void check_correctness( int ) override;

private:
void print_summary( std::ofstream &out, int step, T_V_FLOAT T, T_F_FLOAT PE,
T_V_FLOAT KE, double time, double rate,
T_INT exchanged = -1 );
};

#include <cabanamd_impl.h>
Expand Down
91 changes: 45 additions & 46 deletions src/cabanamd_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,27 +244,8 @@ void CbnMD<t_System, t_Neighbor>::init( InputCL commandline )
auto T = temp.compute( system );
auto PE = pote.compute( system, force, neighbor ) / system->N;
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
{
log( out, "\nStep Temp E_pair TotEng CPU\n", step, " ", T, " ", PE,
" ", PE + KE, " ", 0.0 );
}

print_summary( out, step, T, PE, KE, 0.0, 0.0 );
}

if ( input->dumpbinaryflag )
Expand Down Expand Up @@ -313,6 +294,7 @@ void CbnMD<t_System, t_Neighbor>::run()
integrate_timer.reset();
integrator->initial_integrate( system );
integrate_time += integrate_timer.seconds();
T_INT exchanged = -1;

if ( step % input->comm_exchange_rate == 0 && step > 0 )
{
Expand All @@ -328,7 +310,7 @@ void CbnMD<t_System, t_Neighbor>::run()

// Exchange atoms across MPI ranks
comm_timer.reset();
comm->exchange();
exchanged = comm->exchange();
comm_time += comm_timer.seconds();

// Sort atoms
Expand Down Expand Up @@ -389,31 +371,14 @@ void CbnMD<t_System, t_Neighbor>::run()
auto T = temp.compute( system );
auto PE = pote.compute( system, force, neighbor ) / system->N;
auto KE = kine.compute( system ) / system->N;
double time = timer.seconds();
double rate =
1.0 * system->N * input->thermo_rate / ( time - last_time );

print_summary( out, step, T, PE, KE, time, rate, exchanged );

last_time = time;

if ( !_print_lammps )
{
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
{
double time = timer.seconds();
log( out, std::fixed, std::setprecision( 6 ), " ", step,
" ", 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;
Expand Down Expand Up @@ -681,3 +646,37 @@ void CbnMD<t_System, t_Neighbor>::check_correctness( int step )
}
err.close();
}

template <class t_System, class t_Neighbor>
void CbnMD<t_System, t_Neighbor>::print_summary( std::ofstream &out, int step,
T_V_FLOAT T, T_F_FLOAT PE,
T_V_FLOAT KE, double time,
double rate, T_INT exchanged )
{
if ( !_print_lammps )
{
if ( step == 0 )
{
log( out, "\n#Timestep Temperature PotE ETot Time Atomsteps/s "
#ifdef CabanaMD_ENABLE_LB
"LB-Imbalance MPI-Exchanged"
#endif
);
}

log( out, step, "\t", std::fixed, std::setprecision( 6 ), T, "\t", PE,
"\t", PE + KE, "\t", std::setprecision( 2 ), time, "\t",
std::scientific, rate
#ifdef CabanaMD_ENABLE_LB
,
"\t", std::setprecision( 2 ), lb->getImbalance(), "\t",
( exchanged != -1 ) ? std::to_string( exchanged ) : "-"
#endif
);
}
else
{
log( out, "\nStep Temp E_pair TotEng CPU\n", step, " ", T, " ", PE, " ",
PE + KE, " ", time );
}
}
3 changes: 1 addition & 2 deletions src/comm_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class Comm
Comm( t_System *s, T_X_FLOAT comm_depth_ );
void init();
void create_domain_decomposition();
void exchange();
T_INT exchange();
void exchange_halo();
void update_halo();
void update_force();
Expand Down Expand Up @@ -323,7 +323,6 @@ class Comm
KOKKOS_INLINE_FUNCTION
void operator()( const TagHaloPBC, const T_INT &i ) const
{

switch ( phase )
{
case 0:
Expand Down
12 changes: 6 additions & 6 deletions src/comm_mpi_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

#include <mpi.h>

#include <algorithm>
#include <output.h>

template <class t_System>
Comm<t_System>::Comm( t_System *s, T_X_FLOAT comm_depth_ )
Expand Down Expand Up @@ -189,9 +189,8 @@ void Comm<t_System>::reduce_min_float( T_FLOAT *vals, T_INT count )
}

template <class t_System>
void Comm<t_System>::exchange()
T_INT Comm<t_System>::exchange()
{

Kokkos::Profiling::pushRegion( "Comm::exchange" );

N_local = system->N_local;
Expand Down Expand Up @@ -271,13 +270,16 @@ void Comm<t_System>::exchange()
system->N_local = N_local;
system->N_ghost = 0;

T_INT global_send = N_total_send;
reduce_int( &global_send, 1 );

Kokkos::Profiling::popRegion();
return global_send;
}

template <class t_System>
void Comm<t_System>::exchange_halo()
{

Kokkos::Profiling::pushRegion( "Comm::exchange_halo" );

N_local = system->N_local;
Expand Down Expand Up @@ -367,7 +369,6 @@ void Comm<t_System>::exchange_halo()
template <class t_System>
void Comm<t_System>::update_halo()
{

Kokkos::Profiling::pushRegion( "Comm::update_halo" );

N_local = system->N_local;
Expand Down Expand Up @@ -409,7 +410,6 @@ void Comm<t_System>::update_halo()
template <class t_System>
void Comm<t_System>::update_force()
{

Kokkos::Profiling::pushRegion( "Comm::update_force" );

N_local = system->N_local;
Expand Down
Loading
Loading