Skip to content

Commit

Permalink
Merge pull request #334 from mir-group/mpifix
Browse files Browse the repository at this point in the history
Add broadcast of kernel string length
  • Loading branch information
anjohan authored Dec 19, 2022
2 parents dd7e835 + 32457c3 commit 960757e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/flare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ jobs:
matrix:
omp: [OFF, ON]
lapack: [OFF, ON]
name: "(OpenMP, Lapack) ="
python-version: ["3.7", "3.8"]
name: "(OpenMP, Lapack, Python) ="

# The type of runner that the job will run on
runs-on: ubuntu-latest
Expand All @@ -30,6 +31,10 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Sphinx and Breathe
run: |
Expand Down Expand Up @@ -90,7 +95,7 @@ jobs:
- name: Install LAMMPS
run: |
git clone --depth 1 https://github.com/lammps/lammps.git lammps
cd lammps/src
cp pair_hybrid.* pair_lj_cut.* ..
rm pair_*.cpp pair_*.h
Expand All @@ -103,7 +108,7 @@ jobs:
rm KOKKOS/pair_*.*
mv pair_kokkos.* KOKKOS/
cd ../..
cd lammps_plugins
./install.sh $(pwd)/../lammps
cd ..
Expand Down
2 changes: 2 additions & 0 deletions lammps_plugins/compute_flare_std_atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ void ComputeFlareStdAtom::read_file(char *filename) {
MPI_Bcast(&cutoff, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&radial_string_length, 1, MPI_INT, 0, world);
MPI_Bcast(&cutoff_string_length, 1, MPI_INT, 0, world);
MPI_Bcast(&kernel_string_length, 1, MPI_INT, 0, world);
MPI_Bcast(radial_string, radial_string_length + 1, MPI_CHAR, 0, world);
MPI_Bcast(cutoff_string, cutoff_string_length + 1, MPI_CHAR, 0, world);
MPI_Bcast(kernel_string, kernel_string_length + 1, MPI_CHAR, 0, world);
Expand Down Expand Up @@ -530,6 +531,7 @@ void ComputeFlareStdAtom::read_L_inverse(char *filename) {
MPI_Bcast(&l_max, 1, MPI_INT, 0, world);
MPI_Bcast(&n_kernels, 1, MPI_INT, 0, world);
MPI_Bcast(&cutoff, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&kernel_string_length, 1, MPI_INT, 0, world);
MPI_Bcast(&radial_string_length, 1, MPI_INT, 0, world);
MPI_Bcast(&cutoff_string_length, 1, MPI_INT, 0, world);
MPI_Bcast(radial_string, radial_string_length + 1, MPI_CHAR, 0, world);
Expand Down
8 changes: 7 additions & 1 deletion lammps_plugins/kokkos/pair_flare_kokkos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,12 @@ void PairFLAREKokkos<DeviceType>::coeff(int narg, char **arg)
{
PairFLARE::coeff(narg,arg);

if(!normalized)
error->all(FLERR, "for now, pair flare/kk only supports the normalized kernel");
if(power != 2)
error->all(FLERR, "for now, pair flare/kk only supports the power-2 kernel");
//TODO check chebyshev and quadratic

n_harmonics = (l_max+1)*(l_max+1);
n_radial = n_species * n_max;
n_bond = n_radial * n_harmonics;
Expand Down Expand Up @@ -777,7 +783,7 @@ void PairFLAREKokkos<DeviceType>::init_style()
if (memstr != NULL) {
maxmem = std::atof(memstr) * 1.0e9;
}
printf("FLARE will use up to %.2f GB of device memory, controlled by MAXMEM environment variable\n", maxmem/1.0e9);
if(comm->me==0 || comm->me==comm->nprocs-1) printf("FLARE will use up to %.2f GB of device memory, controlled by MAXMEM environment variable\n", maxmem/1.0e9);
}


Expand Down
9 changes: 7 additions & 2 deletions lammps_plugins/pair_flare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ void PairFLARE::read_file(char *filename) {
MPI_Bcast(&cutoff, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&radial_string_length, 1, MPI_INT, 0, world);
MPI_Bcast(&cutoff_string_length, 1, MPI_INT, 0, world);
MPI_Bcast(&kernel_string_length, 1, MPI_INT, 0, world);
MPI_Bcast(radial_string, radial_string_length + 1, MPI_CHAR, 0, world);
MPI_Bcast(cutoff_string, cutoff_string_length + 1, MPI_CHAR, 0, world);
MPI_Bcast(kernel_string, kernel_string_length + 1, MPI_CHAR, 0, world);
Expand Down Expand Up @@ -357,11 +358,15 @@ void PairFLARE::read_file(char *filename) {
cutoff_function = cos_cutoff;

// Set the kernel
if (!strcmp(kernel_string, "NormalizedDotProduct")) {
if (strcmp(kernel_string, "NormalizedDotProduct") == 0) {
normalized = true;
} else {
}
else if (strcmp(kernel_string, "DotProduct") == 0){
normalized = false;
}
else {
error->all(FLERR, "Kernel string not recognized, expected <power> <kernel string>");
}

// Parse the beta vectors.
memory->create(beta, beta_size * n_species, "pair:beta");
Expand Down
4 changes: 2 additions & 2 deletions tests/test_lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_lammps_uncertainty(
if n_species > n_types:
pytest.skip()

if (power == 1) and ("kokkos" in os.environ.get("lmp")):
if (power == 1 or kernel_type=="DotProduct") and ("kokkos" in os.environ.get("lmp")):
pytest.skip()

os.chdir(rootdir)
Expand Down Expand Up @@ -211,7 +211,7 @@ def test_lammps_uncertainty(
### run
fix fix_nve all nve
compute unc all flare/std/atom {coeff_str}
dump dump_all all custom 1 traj.lammps id type x y z vx vy vz fx fy fz c_unc
dump dump_all all custom 1 traj.lammps id type x y z vx vy vz fx fy fz c_unc
dump_modify dump_all sort id
thermo_style custom step temp press cpu pxx pyy pzz pxy pxz pyz ke pe etotal vol lx ly lz atoms
thermo_modify flush yes format float %23.16g
Expand Down

0 comments on commit 960757e

Please sign in to comment.