From aa1a87687bbaec39252f26afe77dc54931857b04 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 8 Oct 2020 07:32:36 -0600 Subject: [PATCH 1/3] Fix minor issues --- src/KOKKOS/atom_vec_spin_kokkos.cpp | 15 +++++++++------ src/KOKKOS/atom_vec_spin_kokkos.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/KOKKOS/atom_vec_spin_kokkos.cpp b/src/KOKKOS/atom_vec_spin_kokkos.cpp index c5c2ffb5be..188748d655 100644 --- a/src/KOKKOS/atom_vec_spin_kokkos.cpp +++ b/src/KOKKOS/atom_vec_spin_kokkos.cpp @@ -97,6 +97,9 @@ void AtomVecSpinKokkos::grow(int n) memoryKK->grow_kokkos(atomKK->k_fm,atomKK->fm,nmax,"atom:fm"); memoryKK->grow_kokkos(atomKK->k_fm_long,atomKK->fm_long,nmax,"atom:fm_long"); + grow_pointers(); + atomKK->sync(Host,ALL_MASK); + if (atom->nextra_grow) for (int iextra = 0; iextra < atom->nextra_grow; iextra++) modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); @@ -106,7 +109,7 @@ void AtomVecSpinKokkos::grow(int n) reset local array ptrs ------------------------------------------------------------------------- */ -void AtomVecSpinKokkos::grow_reset() +void AtomVecSpinKokkos::grow_pointers() { tag = atomKK->tag; d_tag = atomKK->k_tag.d_view; @@ -121,7 +124,7 @@ void AtomVecSpinKokkos::grow_reset() image = atomKK->image; d_image = atomKK->k_image.d_view; h_image = atomKK->k_image.h_view; - + x = atomKK->x; d_x = atomKK->k_x.d_view; h_x = atomKK->k_x.h_view; @@ -389,7 +392,7 @@ int AtomVecSpinKokkos::pack_border(int n, int *list, double *buf, buf[m++] = h_sp(j,3); } } - + if (atom->nextra_border) for (int iextra = 0; iextra < atom->nextra_border; iextra++) m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); @@ -478,7 +481,7 @@ int AtomVecSpinKokkos::pack_border_vel(int n, int *list, double *buf, } } } - + if (atom->nextra_border) for (int iextra = 0; iextra < atom->nextra_border; iextra++) m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); @@ -1026,8 +1029,8 @@ void AtomVecSpinKokkos::create_atom(int itype, double *coord) atomKK->sync(Host,ALL_MASK); atomKK->modified(Host,ALL_MASK); - tag[nlocal] = 0; - type[nlocal] = itype; + h_tag[nlocal] = 0; + h_type[nlocal] = itype; h_x(nlocal,0) = coord[0]; h_x(nlocal,1) = coord[1]; h_x(nlocal,2) = coord[2]; diff --git a/src/KOKKOS/atom_vec_spin_kokkos.h b/src/KOKKOS/atom_vec_spin_kokkos.h index a9f7077a24..5dca7b4e13 100644 --- a/src/KOKKOS/atom_vec_spin_kokkos.h +++ b/src/KOKKOS/atom_vec_spin_kokkos.h @@ -56,7 +56,7 @@ class AtomVecSpinKokkos : public AtomVecKokkos { void force_clear(int, size_t); - void grow_reset(); + void grow_pointers(); // input lists to be checked int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, From e8ebce1b5281ca0d4e8651918c64f24d940d7ec0 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 8 Oct 2020 08:21:55 -0600 Subject: [PATCH 2/3] Fix GPU compile error --- src/KOKKOS/kokkos_type.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index b6992602d0..041a6d4771 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -1028,8 +1028,8 @@ typedef tdual_virial_array::t_host_const_randomread t_virial_array_randomread; // Spin types -//2d X_FLOAT array n*3 -typedef Kokkos::DualView tdual_sp_array; +//2d X_FLOAT array n*4 +typedef Kokkos::DualView tdual_sp_array; typedef tdual_sp_array::t_host t_sp_array; typedef tdual_sp_array::t_host_const t_sp_array_const; typedef tdual_sp_array::t_host_um t_sp_array_um; From c85498e98baf752c05ec5f2a8ea7ecaaba9535eb Mon Sep 17 00:00:00 2001 From: julient31 Date: Fri, 9 Oct 2020 09:47:47 -0600 Subject: [PATCH 3/3] started to add spin/kk to the doc modified validaion tests for kokkos compatibility --- doc/src/atom_style.rst | 2 +- .../llg_exchange.py | 2 +- .../run-test-exchange.sh | 5 +++-- .../test-spin-precession.in | 12 ++++++++-- .../validation_damped_exchange/two_spins.data | 22 ------------------- .../validation_nve/in.spin.iron-nve | 7 +++++- .../validation_nve/run-test-nve.sh | 5 +++-- 7 files changed, 24 insertions(+), 31 deletions(-) delete mode 100644 examples/SPIN/test_problems/validation_damped_exchange/two_spins.data diff --git a/doc/src/atom_style.rst b/doc/src/atom_style.rst index 4957901676..a59f8d31e0 100644 --- a/doc/src/atom_style.rst +++ b/doc/src/atom_style.rst @@ -27,7 +27,7 @@ Syntax template-ID = ID of molecule template specified in a separate :doc:`molecule ` command *hybrid* args = list of one or more sub-styles, each with their args -* accelerated styles (with same args) = *angle/kk* or *atomic/kk* or *bond/kk* or *charge/kk* or *full/kk* or *molecular/kk* +* accelerated styles (with same args) = *angle/kk* or *atomic/kk* or *bond/kk* or *charge/kk* or *full/kk* or *molecular/kk* or *spin/kk* Examples """""""" diff --git a/examples/SPIN/test_problems/validation_damped_exchange/llg_exchange.py b/examples/SPIN/test_problems/validation_damped_exchange/llg_exchange.py index 49eecb5b44..dd1c543bb3 100755 --- a/examples/SPIN/test_problems/validation_damped_exchange/llg_exchange.py +++ b/examples/SPIN/test_problems/validation_damped_exchange/llg_exchange.py @@ -65,6 +65,6 @@ for t in range (0,N): # calc. average magnetization Sm = (S1+S2)*0.5 # calc. energy - en = -2.0*J0*(np.dot(S1,S2)) + en = -J0*(np.dot(S1,S2)) # print res. in ps for comparison with LAMMPS print(t*dt/1000.0,Sm[0],Sm[1],Sm[2],en) diff --git a/examples/SPIN/test_problems/validation_damped_exchange/run-test-exchange.sh b/examples/SPIN/test_problems/validation_damped_exchange/run-test-exchange.sh index 599730fe7b..ce8a6c3dbf 100755 --- a/examples/SPIN/test_problems/validation_damped_exchange/run-test-exchange.sh +++ b/examples/SPIN/test_problems/validation_damped_exchange/run-test-exchange.sh @@ -4,8 +4,9 @@ rm res_*.dat # compute Lammps -./../../../../src/lmp_serial \ - -in test-spin-precession.in +../../../../src/lmp_serial -in test-spin-precession.in +# mpirun -np 1 ../../../../src/lmp_kokkos_mpi_only \ +# -k on -sf kk -in test-spin-precession.in in="$(grep -n Step log.lammps | awk -F ':' '{print $1}')" en="$(grep -n Loop log.lammps | awk -F ':' '{print $1}')" in="$(echo "$in+1" | bc -l)" diff --git a/examples/SPIN/test_problems/validation_damped_exchange/test-spin-precession.in b/examples/SPIN/test_problems/validation_damped_exchange/test-spin-precession.in index 0ca49364d2..6eea93224e 100644 --- a/examples/SPIN/test_problems/validation_damped_exchange/test-spin-precession.in +++ b/examples/SPIN/test_problems/validation_damped_exchange/test-spin-precession.in @@ -2,10 +2,18 @@ units metal atom_style spin -atom_modify map array +# atom_style spin/kk boundary f f f -read_data two_spins.data +atom_modify map array +lattice sc 3.0 +region box block 0 2 0 1 0 1 +create_box 1 box +create_atoms 1 box + +mass 1 55.845 +set atom 1 spin 2.0 1.0 0.0 0.0 +set atom 2 spin 2.0 0.0 1.0 0.0 pair_style spin/exchange 3.1 pair_coeff * * exchange 3.1 11.254 0.0 1.0 diff --git a/examples/SPIN/test_problems/validation_damped_exchange/two_spins.data b/examples/SPIN/test_problems/validation_damped_exchange/two_spins.data deleted file mode 100644 index 013f813751..0000000000 --- a/examples/SPIN/test_problems/validation_damped_exchange/two_spins.data +++ /dev/null @@ -1,22 +0,0 @@ -LAMMPS data file via write_data, version 19 Sep 2019, timestep = 0 - -2 atoms -1 atom types - -0.0 6.0 xlo xhi -0.0 3.0 ylo yhi -0.0 3.0 zlo zhi - -Masses - -1 1 - -Atoms # spin - -1 1 2.0 0.0 0.0 0.0 1.0 0.0 0.0 0 0 0 -2 1 2.0 3.0 0.0 0.0 0.0 1.0 0.0 0 0 0 - -Velocities - -1 0.0 0.0 0.0 -2 0.0 0.0 0.0 diff --git a/examples/SPIN/test_problems/validation_nve/in.spin.iron-nve b/examples/SPIN/test_problems/validation_nve/in.spin.iron-nve index f00fb1ec12..a29d0158cf 100644 --- a/examples/SPIN/test_problems/validation_nve/in.spin.iron-nve +++ b/examples/SPIN/test_problems/validation_nve/in.spin.iron-nve @@ -3,6 +3,7 @@ clear units metal atom_style spin +# atom_style spin/kk dimension 3 boundary p p p @@ -46,4 +47,8 @@ variable tmag equal c_out_mag[6] thermo_style custom step time v_tmag temp v_emag ke pe etotal thermo 200 -run 100000 +compute outsp all property/atom spx spy spz sp fmx fmy fmz +dump 1 all custom 10 dump_iron.lammpstrj type x y z c_outsp[1] c_outsp[2] c_outsp[3] + +# run 100000 +run 10000 diff --git a/examples/SPIN/test_problems/validation_nve/run-test-nve.sh b/examples/SPIN/test_problems/validation_nve/run-test-nve.sh index 441e7cf46d..a8eb179b7f 100755 --- a/examples/SPIN/test_problems/validation_nve/run-test-nve.sh +++ b/examples/SPIN/test_problems/validation_nve/run-test-nve.sh @@ -4,8 +4,9 @@ rm res_*.dat # compute Lammps -./../../../../src/lmp_serial \ - -in in.spin.iron-nve +# mpirun -np 1 ../../../../src/lmp_kokkos_mpi_only \ +# -k on -sf kk -in in.spin.iron-nve +../../../../src/lmp_serial -in in.spin.iron-nve in="$(grep -n Step log.lammps | awk -F ':' '{print $1}')" en="$(grep -n Loop log.lammps | awk -F ':' '{print $1}')" in="$(echo "$in+1" | bc -l)"