Destruct sna/grid/local/kk properly and use local arrays

This commit is contained in:
rohskopf
2023-07-09 10:20:45 -06:00
parent 3f9cc8f0fd
commit b5dc7d58a8
4 changed files with 30 additions and 18 deletions

View File

@ -240,6 +240,11 @@ class ComputeSNAGridLocalKokkos : public ComputeSNAGridLocal {
typename AT::t_x_array_randomread x;
typename AT::t_int_1d_randomread type;
DAT::tdual_float_2d k_alocal;
typename AT::t_float_2d d_alocal;
/*
DAT::tdual_float_2d k_grid;
DAT::tdual_float_2d k_gridall;
typename AT::t_float_2d d_grid;
@ -247,6 +252,7 @@ class ComputeSNAGridLocalKokkos : public ComputeSNAGridLocal {
DAT::tdual_float_4d k_gridlocal;
typename AT::t_float_4d d_gridlocal;
*/
// Utility routine which wraps computing per-team scratch size requirements for

View File

@ -135,11 +135,12 @@ ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::ComputeSNAGridL
template<class DeviceType, typename real_type, int vector_length>
ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::~ComputeSNAGridLocalKokkos()
{
//printf(">>> ComputeSNAGridLocalKokkos destruct begin copymode %d\n", copymode);
printf(">>> ComputeSNAGridLocalKokkos destruct begin copymode %d\n", copymode);
if (copymode) return;
//printf(">>> After copymode\n");
memoryKK->destroy_kokkos(k_cutsq,cutsq);
memoryKK->destroy_kokkos(k_alocal,alocal);
//memoryKK->destroy_kokkos(k_grid,grid);
//memoryKK->destroy_kokkos(k_gridall, gridall);
//memoryKK->destroy_kokkos(k_gridlocal, gridlocal);
@ -169,18 +170,23 @@ void ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::setup()
//ComputeGrid::set_grid_global();
//ComputeGrid::set_grid_local();
//ComputeSNAGridLocal::setup();
ComputeGridLocal::setup();
// allocate arrays
//memoryKK->create_kokkos(k_gridall, gridall, size_array_rows, size_array_cols, "grid:gridall");
memoryKK->create_kokkos(k_alocal, alocal, size_local_rows, size_local_cols, "grid:alocal");
// do not use or allocate gridlocal for now
gridlocal_allocated = 0;
//gridlocal_allocated = 0;
//array = gridall;
d_gridlocal = k_gridlocal.template view<DeviceType>();
array_local = alocal;
//d_gridlocal = k_gridlocal.template view<DeviceType>();
//d_grid = k_grid.template view<DeviceType>();
d_gridall = k_gridall.template view<DeviceType>();
//d_gridall = k_gridall.template view<DeviceType>();
d_alocal = k_alocal.template view<DeviceType>();
}
// Compute
@ -192,6 +198,8 @@ void ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::compute_lo
return;
}
printf(">>> ComputeSNAGridLocalKokkos::compute_local begin\n");
copymode = 1;
zlen = nzhi-nzlo+1;
@ -212,6 +220,7 @@ void ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::compute_lo
ntotal = atomKK->nlocal + atomKK->nghost;
// Allocate view for number of neighbors per grid point
printf(">>> total_range: %d\n", total_range);
MemKK::realloc_kokkos(d_ninside,"ComputeSNAGridLocalKokkos:ninside",total_range);
// "chunksize" variable is default 32768 in compute_sna_grid.cpp, and set by user
@ -351,14 +360,10 @@ void ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::compute_lo
} // end while
k_gridlocal.template modify<DeviceType>();
k_gridlocal.template sync<LMPHostType>();
copymode = 0;
//k_grid.template modify<DeviceType>();
//k_grid.template sync<LMPHostType>();
k_gridall.template modify<DeviceType>();
k_gridall.template sync<LMPHostType>();
k_alocal.template modify<DeviceType>();
k_alocal.template sync<LMPHostType>();
}
/* ----------------------------------------------------------------------
@ -830,9 +835,9 @@ void ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::operator()
const F_FLOAT xtmp = xgrid[0];
const F_FLOAT ytmp = xgrid[1];
const F_FLOAT ztmp = xgrid[2];
d_gridall(igrid,0) = xtmp;
d_gridall(igrid,1) = ytmp;
d_gridall(igrid,2) = ztmp;
//d_gridall(igrid,0) = xtmp;
//d_gridall(igrid,1) = ytmp;
//d_gridall(igrid,2) = ztmp;
const auto idxb_max = snaKK.idxb_max;
@ -841,7 +846,7 @@ void ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::operator()
for (int icoeff = 0; icoeff < ncoeff; icoeff++) {
const auto idxb = icoeff % idxb_max;
const auto idx_chem = icoeff / idxb_max;
d_gridall(igrid,icoeff+3) = my_sna.blist(ii,idx_chem,idxb);
//d_gridall(igrid,icoeff+3) = my_sna.blist(ii,idx_chem,idxb);
}
}

View File

@ -61,21 +61,21 @@ ComputeGridLocal::ComputeGridLocal(LAMMPS *lmp, int narg, char **arg) :
ComputeGridLocal::~ComputeGridLocal()
{
//printf(">>> ComputeGridLocal begin destruct\n");
printf(">>> ComputeGridLocal begin destruct\n");
deallocate();
//printf(">>> ComputeGridLocal end destruct\n");
printf(">>> ComputeGridLocal end destruct\n");
}
/* ---------------------------------------------------------------------- */
void ComputeGridLocal::setup()
{
//printf(">>> ComputeGridLocal setup\n");
deallocate();
set_grid_global();
set_grid_local();
allocate();
assign_coords();
printf(">>> ComputeGridLocal setup nx ny nz %d %d %d %d %d %d\n", nxlo, nxhi, nylo, nyhi, nzlo, nzhi);
}
/* ----------------------------------------------------------------------

View File

@ -182,6 +182,7 @@ ComputeSNAGridLocal::ComputeSNAGridLocal(LAMMPS *lmp, int narg, char **arg) :
ComputeSNAGridLocal::~ComputeSNAGridLocal()
{
if (copymode) return;
memory->destroy(radelem);
memory->destroy(wjelem);
memory->destroy(cutsq);