Skip to content

Commit

Permalink
add code comment for InputNlist struct
Browse files Browse the repository at this point in the history
  • Loading branch information
denghuilu committed Aug 13, 2021
1 parent ee0f6e6 commit 6914071
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion source/lib/include/neighbor_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@

namespace deepmd{

// format of the input neighbor list
// construct InputNlist with the input LAMMPS nbor list info.
//
// members
// inum, numneigh, firstneigh are provided by LAMMPS.
// inum is the number of core region atoms.
// ilist is the atoms index array within the core region.
// numneigh is the array which indicates each core region atom's neighbor atom number.
// firstneigh is two-dimensional array which store each core region atom's neighbor index.
struct InputNlist
{
int inum;
Expand All @@ -32,11 +39,23 @@ struct InputNlist
~InputNlist(){};
};

// construct the InputNlist with a two-dimensional vector.
// inputs
// from_nlist
// from_nlist is a two-dimensional vector which stores the neighbor information of the core region atoms.
// outputs
// to_nlist
// to_nlist is the InputNlist struct which stores the neighbor information of the core region atoms.
void convert_nlist(
InputNlist & to_nlist,
std::vector<std::vector<int> > & from_nlist
);

// compute the max number of neighbors within the core region atoms
// outputs
// to_nlist is the InputNlist struct which stores the neighbor information of the core region atoms.
// returns
// integer: max number of neighbors
int max_numneigh(
const InputNlist & to_nlist
);
Expand Down Expand Up @@ -64,12 +83,24 @@ build_nlist_cpu(
const float & rcut);

#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
// convert the a host memory InputNlist to a device memory InputNlist.
// inputs
// cpu_nlist, gpu_memory, max_nbor_size
// cpu_nlist is the host memory InputNlist struct which stores the neighbor information of the core region atoms.
// gpu_memory is the device array which stores the elements of gpu_nlist.
// max_nbor_size is the max neighbor size.
// outputs
// gpu_nlist
// gpu_nlist is the device memory InputNlist struct which stores the neighbor information of the core region atoms.
void convert_nlist_gpu_device(
InputNlist & gpu_nlist,
InputNlist & cpu_nlist,
int* & gpu_memory,
const int & max_nbor_size);

// Reclaim the allocated device memory of struct InputNlist
// inputs
// gpu_nlist is the device memory InputNlist struct which stores the neighbor information of the core region atoms.
void free_nlist_gpu_device(
InputNlist & gpu_nlist);

Expand Down

0 comments on commit 6914071

Please sign in to comment.