@@ -130,8 +130,7 @@ void PairMATGLKokkos<DeviceType>::compute(int eflag, int vflag)
130130 atomKK->sync (execution_space, datamask_read);
131131 atomKK->modified (execution_space, datamask_modify);
132132
133- using AT_ = typename AT ::t_x_array; // (nall, 3) double on the device
134- AT_ x = atomKK->k_x .template view <DeviceType>();
133+ auto x = atomKK->k_x .template view <DeviceType>();
135134 auto f = atomKK->k_f .template view <DeviceType>();
136135 auto type = atomKK->k_type .template view <DeviceType>();
137136
@@ -173,13 +172,15 @@ void PairMATGLKokkos<DeviceType>::compute(int eflag, int vflag)
173172
174173 // Fill Z + mask from atom type.
175174 const auto type_to_z = d_type_to_z_;
175+ const auto d_atomic_numbers = d_atomic_numbers_;
176+ const auto d_local_or_ghost = d_local_or_ghost_;
176177 Kokkos::parallel_for (
177178 " matgl_kk:fill_atoms" ,
178179 Kokkos::RangePolicy<DeviceType>(0 , nall),
179180 KOKKOS_LAMBDA (const int i) {
180181 const int t = type (i);
181- d_atomic_numbers_ (i) = type_to_z (t);
182- d_local_or_ghost_ (i) = (i < nlocal);
182+ d_atomic_numbers (i) = type_to_z (t);
183+ d_local_or_ghost (i) = (i < nlocal);
183184 });
184185
185186 // local_row_of_(j) = the owned row representing the same physical atom as
@@ -205,6 +206,7 @@ void PairMATGLKokkos<DeviceType>::compute(int eflag, int vflag)
205206 // so initialize numneigh_short_ for ghost atoms to zero).
206207 Kokkos::deep_copy (d_numneigh_short_, 0 );
207208 const double r_max_sq = r_max_squared_;
209+ const auto d_numneigh_short = d_numneigh_short_;
208210
209211 Kokkos::parallel_for (
210212 " matgl_kk:count_neigh" ,
@@ -224,16 +226,17 @@ void PairMATGLKokkos<DeviceType>::compute(int eflag, int vflag)
224226 const double rsq = dx * dx + dy * dy + dz * dz;
225227 if (rsq <= r_max_sq) ++nshort;
226228 }
227- d_numneigh_short_ (i) = nshort;
229+ d_numneigh_short (i) = nshort;
228230 });
229231
230232 // 3) Exclusive prefix-sum into d_first_edge_ (length nall+1).
233+ const auto d_first_edge = d_first_edge_;
231234 Kokkos::parallel_scan (
232235 " matgl_kk:scan_edges" ,
233236 Kokkos::RangePolicy<DeviceType>(0 , nall + 1 ),
234237 KOKKOS_LAMBDA (const int i, int &update, const bool final ) {
235- const int v = (i < nall) ? d_numneigh_short_ (i) : 0 ;
236- if (final ) d_first_edge_ (i) = update;
238+ const int v = (i < nall) ? d_numneigh_short (i) : 0 ;
239+ if (final ) d_first_edge (i) = update;
237240 update += v;
238241 });
239242
@@ -256,6 +259,8 @@ void PairMATGLKokkos<DeviceType>::compute(int eflag, int vflag)
256259 // need one consistent row per physical atom (periodicity goes through
257260 // unit_shifts, not through ghost-row duplication; see pair_matgl.cpp).
258261 const auto d_local_row_of = d_local_row_of_;
262+ const auto d_edge_index = d_edge_index_;
263+ const auto d_unit_shifts = d_unit_shifts_;
259264 const double *const h_inv_host = domain->h_inv ;
260265 const double hinv0 = h_inv_host[0 ], hinv1 = h_inv_host[1 ], hinv2 = h_inv_host[2 ];
261266 const double hinv3 = h_inv_host[3 ], hinv4 = h_inv_host[4 ], hinv5 = h_inv_host[5 ];
@@ -268,7 +273,7 @@ void PairMATGLKokkos<DeviceType>::compute(int eflag, int vflag)
268273 const double yi = x (i, 1 );
269274 const double zi = x (i, 2 );
270275 const int jnum = d_numneigh (i);
271- int e = d_first_edge_ (i);
276+ int e = d_first_edge (i);
272277 for (int jj = 0 ; jj < jnum; ++jj) {
273278 const int j = d_neighbors (i, jj) & NEIGHMASK ;
274279 const double dx = x (j, 0 ) - xi;
@@ -289,11 +294,11 @@ void PairMATGLKokkos<DeviceType>::compute(int eflag, int vflag)
289294 const double ly = hinv1 * ddy + hinv3 * ddz;
290295 const double lx = hinv0 * ddx + hinv5 * ddy + hinv4 * ddz;
291296
292- d_edge_index_ (0 , e) = i;
293- d_edge_index_ (1 , e) = j_local;
294- d_unit_shifts_ (e, 0 ) = static_cast <int64_t >(Kokkos::round (lx));
295- d_unit_shifts_ (e, 1 ) = static_cast <int64_t >(Kokkos::round (ly));
296- d_unit_shifts_ (e, 2 ) = static_cast <int64_t >(Kokkos::round (lz));
297+ d_edge_index (0 , e) = i;
298+ d_edge_index (1 , e) = j_local;
299+ d_unit_shifts (e, 0 ) = static_cast <int64_t >(Kokkos::round (lx));
300+ d_unit_shifts (e, 1 ) = static_cast <int64_t >(Kokkos::round (ly));
301+ d_unit_shifts (e, 2 ) = static_cast <int64_t >(Kokkos::round (lz));
297302 ++e;
298303 }
299304 });
0 commit comments