Destruct sna/grid/local/kk properly and use local arrays
This commit is contained in:
@ -240,6 +240,11 @@ class ComputeSNAGridLocalKokkos : public ComputeSNAGridLocal {
|
|||||||
|
|
||||||
typename AT::t_x_array_randomread x;
|
typename AT::t_x_array_randomread x;
|
||||||
typename AT::t_int_1d_randomread type;
|
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_grid;
|
||||||
DAT::tdual_float_2d k_gridall;
|
DAT::tdual_float_2d k_gridall;
|
||||||
typename AT::t_float_2d d_grid;
|
typename AT::t_float_2d d_grid;
|
||||||
@ -247,6 +252,7 @@ class ComputeSNAGridLocalKokkos : public ComputeSNAGridLocal {
|
|||||||
|
|
||||||
DAT::tdual_float_4d k_gridlocal;
|
DAT::tdual_float_4d k_gridlocal;
|
||||||
typename AT::t_float_4d d_gridlocal;
|
typename AT::t_float_4d d_gridlocal;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Utility routine which wraps computing per-team scratch size requirements for
|
// Utility routine which wraps computing per-team scratch size requirements for
|
||||||
|
|||||||
@ -135,11 +135,12 @@ ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::ComputeSNAGridL
|
|||||||
template<class DeviceType, typename real_type, int vector_length>
|
template<class DeviceType, typename real_type, int vector_length>
|
||||||
ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::~ComputeSNAGridLocalKokkos()
|
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;
|
if (copymode) return;
|
||||||
//printf(">>> After copymode\n");
|
//printf(">>> After copymode\n");
|
||||||
|
|
||||||
memoryKK->destroy_kokkos(k_cutsq,cutsq);
|
memoryKK->destroy_kokkos(k_cutsq,cutsq);
|
||||||
|
memoryKK->destroy_kokkos(k_alocal,alocal);
|
||||||
//memoryKK->destroy_kokkos(k_grid,grid);
|
//memoryKK->destroy_kokkos(k_grid,grid);
|
||||||
//memoryKK->destroy_kokkos(k_gridall, gridall);
|
//memoryKK->destroy_kokkos(k_gridall, gridall);
|
||||||
//memoryKK->destroy_kokkos(k_gridlocal, gridlocal);
|
//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_global();
|
||||||
//ComputeGrid::set_grid_local();
|
//ComputeGrid::set_grid_local();
|
||||||
//ComputeSNAGridLocal::setup();
|
//ComputeSNAGridLocal::setup();
|
||||||
|
ComputeGridLocal::setup();
|
||||||
|
|
||||||
// allocate arrays
|
// allocate arrays
|
||||||
//memoryKK->create_kokkos(k_gridall, gridall, size_array_rows, size_array_cols, "grid:gridall");
|
//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
|
// do not use or allocate gridlocal for now
|
||||||
|
|
||||||
gridlocal_allocated = 0;
|
//gridlocal_allocated = 0;
|
||||||
//array = gridall;
|
//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_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
|
// Compute
|
||||||
@ -192,6 +198,8 @@ void ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::compute_lo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf(">>> ComputeSNAGridLocalKokkos::compute_local begin\n");
|
||||||
|
|
||||||
copymode = 1;
|
copymode = 1;
|
||||||
|
|
||||||
zlen = nzhi-nzlo+1;
|
zlen = nzhi-nzlo+1;
|
||||||
@ -212,6 +220,7 @@ void ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::compute_lo
|
|||||||
|
|
||||||
ntotal = atomKK->nlocal + atomKK->nghost;
|
ntotal = atomKK->nlocal + atomKK->nghost;
|
||||||
// Allocate view for number of neighbors per grid point
|
// 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);
|
MemKK::realloc_kokkos(d_ninside,"ComputeSNAGridLocalKokkos:ninside",total_range);
|
||||||
|
|
||||||
// "chunksize" variable is default 32768 in compute_sna_grid.cpp, and set by user
|
// "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
|
} // end while
|
||||||
|
|
||||||
k_gridlocal.template modify<DeviceType>();
|
copymode = 0;
|
||||||
k_gridlocal.template sync<LMPHostType>();
|
|
||||||
|
|
||||||
//k_grid.template modify<DeviceType>();
|
k_alocal.template modify<DeviceType>();
|
||||||
//k_grid.template sync<LMPHostType>();
|
k_alocal.template sync<LMPHostType>();
|
||||||
|
|
||||||
k_gridall.template modify<DeviceType>();
|
|
||||||
k_gridall.template sync<LMPHostType>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -830,9 +835,9 @@ void ComputeSNAGridLocalKokkos<DeviceType, real_type, vector_length>::operator()
|
|||||||
const F_FLOAT xtmp = xgrid[0];
|
const F_FLOAT xtmp = xgrid[0];
|
||||||
const F_FLOAT ytmp = xgrid[1];
|
const F_FLOAT ytmp = xgrid[1];
|
||||||
const F_FLOAT ztmp = xgrid[2];
|
const F_FLOAT ztmp = xgrid[2];
|
||||||
d_gridall(igrid,0) = xtmp;
|
//d_gridall(igrid,0) = xtmp;
|
||||||
d_gridall(igrid,1) = ytmp;
|
//d_gridall(igrid,1) = ytmp;
|
||||||
d_gridall(igrid,2) = ztmp;
|
//d_gridall(igrid,2) = ztmp;
|
||||||
|
|
||||||
const auto idxb_max = snaKK.idxb_max;
|
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++) {
|
for (int icoeff = 0; icoeff < ncoeff; icoeff++) {
|
||||||
const auto idxb = icoeff % idxb_max;
|
const auto idxb = icoeff % idxb_max;
|
||||||
const auto idx_chem = 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,21 +61,21 @@ ComputeGridLocal::ComputeGridLocal(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
ComputeGridLocal::~ComputeGridLocal()
|
ComputeGridLocal::~ComputeGridLocal()
|
||||||
{
|
{
|
||||||
//printf(">>> ComputeGridLocal begin destruct\n");
|
printf(">>> ComputeGridLocal begin destruct\n");
|
||||||
deallocate();
|
deallocate();
|
||||||
//printf(">>> ComputeGridLocal end destruct\n");
|
printf(">>> ComputeGridLocal end destruct\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ComputeGridLocal::setup()
|
void ComputeGridLocal::setup()
|
||||||
{
|
{
|
||||||
//printf(">>> ComputeGridLocal setup\n");
|
|
||||||
deallocate();
|
deallocate();
|
||||||
set_grid_global();
|
set_grid_global();
|
||||||
set_grid_local();
|
set_grid_local();
|
||||||
allocate();
|
allocate();
|
||||||
assign_coords();
|
assign_coords();
|
||||||
|
printf(">>> ComputeGridLocal setup nx ny nz %d %d %d %d %d %d\n", nxlo, nxhi, nylo, nyhi, nzlo, nzhi);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
@ -182,6 +182,7 @@ ComputeSNAGridLocal::ComputeSNAGridLocal(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
ComputeSNAGridLocal::~ComputeSNAGridLocal()
|
ComputeSNAGridLocal::~ComputeSNAGridLocal()
|
||||||
{
|
{
|
||||||
|
if (copymode) return;
|
||||||
memory->destroy(radelem);
|
memory->destroy(radelem);
|
||||||
memory->destroy(wjelem);
|
memory->destroy(wjelem);
|
||||||
memory->destroy(cutsq);
|
memory->destroy(cutsq);
|
||||||
|
|||||||
Reference in New Issue
Block a user