From 6914071dad8a7bbee95c283747841ed9d321fee7 Mon Sep 17 00:00:00 2001 From: denghuilu Date: Fri, 13 Aug 2021 15:55:50 +0800 Subject: [PATCH 1/3] add code comment for InputNlist struct --- source/lib/include/neighbor_list.h | 33 +++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/source/lib/include/neighbor_list.h b/source/lib/include/neighbor_list.h index e0901c26d0..0bda061bd0 100644 --- a/source/lib/include/neighbor_list.h +++ b/source/lib/include/neighbor_list.h @@ -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; @@ -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 > & 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 ); @@ -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); From 2a042e48d79bf81da3d952733801162e4f33cfa1 Mon Sep 17 00:00:00 2001 From: denghuilu Date: Fri, 13 Aug 2021 17:29:42 +0800 Subject: [PATCH 2/3] use doxygen style for comments --- source/lib/include/neighbor_list.h | 68 ++++++++++++++++-------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/source/lib/include/neighbor_list.h b/source/lib/include/neighbor_list.h index 0bda061bd0..8333e86d98 100644 --- a/source/lib/include/neighbor_list.h +++ b/source/lib/include/neighbor_list.h @@ -11,19 +11,20 @@ namespace deepmd{ -// 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. +/** + * @brief Construct InputNlist with the input LAMMPS nbor list info. + * + * @struct InputNlist +*/ struct InputNlist { + /// Number of core region atoms int inum; + /// Array stores the core region atom's index int * ilist; + /// Array stores the core region atom's neighbor atom number int * numneigh; + /// Array stores the core region atom's neighbor index int ** firstneigh; InputNlist () : inum(0), ilist(NULL), numneigh(NULL), firstneigh(NULL) @@ -39,23 +40,25 @@ 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. +/** + *@brief Construct the InputNlist with a two-dimensional vector. + * + *@param to_nlist: InputNlist struct which stores the neighbor information of the core region atoms. + *@param from_nlist: Vector which stores the neighbor information of the core region atoms. + */ void convert_nlist( InputNlist & to_nlist, std::vector > & 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 +/** + *@brief Compute the max number of neighbors within the core region atoms + * + *@param to_nlist: InputNlist struct which stores the neighbor information of the core region atoms. + * + *@return integer + *@retval max number of neighbors + */ int max_numneigh( const InputNlist & to_nlist ); @@ -83,24 +86,25 @@ 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. +/** + *@brief Convert the a host memory InputNlist to a device memory InputNlist + * + *@param cpu_nlist: Host memory InputNlist struct which stores the neighbor information of the core region atoms + *@param gpu_nlist: Device memory InputNlist struct which stores the neighbor information of the core region atoms + *@param gpu_memory: Device array which stores the elements of gpu_nlist + *@param max_nbor_size + */ 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. +/** + *@brief Reclaim the allocated device memory of struct InputNlist + * + *@param gpu_nlist: Device memory InputNlist struct which stores the neighbor information of the core region atoms + */ void free_nlist_gpu_device( InputNlist & gpu_nlist); From b549925be793a75894e9036acc6e1779ca4e6316 Mon Sep 17 00:00:00 2001 From: denghuilu Date: Fri, 13 Aug 2021 17:31:44 +0800 Subject: [PATCH 3/3] fix line changes --- source/lib/include/neighbor_list.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/lib/include/neighbor_list.h b/source/lib/include/neighbor_list.h index 8333e86d98..53e6d83d2c 100644 --- a/source/lib/include/neighbor_list.h +++ b/source/lib/include/neighbor_list.h @@ -43,8 +43,8 @@ struct InputNlist /** *@brief Construct the InputNlist with a two-dimensional vector. * - *@param to_nlist: InputNlist struct which stores the neighbor information of the core region atoms. - *@param from_nlist: Vector which stores the neighbor information of the core region atoms. + *@param to_nlist: InputNlist struct which stores the neighbor information of the core region atoms. + *@param from_nlist: Vector which stores the neighbor information of the core region atoms. */ void convert_nlist( InputNlist & to_nlist, @@ -54,7 +54,7 @@ void convert_nlist( /** *@brief Compute the max number of neighbors within the core region atoms * - *@param to_nlist: InputNlist struct which stores the neighbor information of the core region atoms. + *@param to_nlist: InputNlist struct which stores the neighbor information of the core region atoms. * *@return integer *@retval max number of neighbors @@ -89,10 +89,10 @@ build_nlist_cpu( /** *@brief Convert the a host memory InputNlist to a device memory InputNlist * - *@param cpu_nlist: Host memory InputNlist struct which stores the neighbor information of the core region atoms - *@param gpu_nlist: Device memory InputNlist struct which stores the neighbor information of the core region atoms - *@param gpu_memory: Device array which stores the elements of gpu_nlist - *@param max_nbor_size + *@param cpu_nlist: Host memory InputNlist struct which stores the neighbor information of the core region atoms + *@param gpu_nlist: Device memory InputNlist struct which stores the neighbor information of the core region atoms + *@param gpu_memory: Device array which stores the elements of gpu_nlist + *@param max_nbor_size */ void convert_nlist_gpu_device( InputNlist & gpu_nlist, @@ -103,7 +103,7 @@ void convert_nlist_gpu_device( /** *@brief Reclaim the allocated device memory of struct InputNlist * - *@param gpu_nlist: Device memory InputNlist struct which stores the neighbor information of the core region atoms + *@param gpu_nlist: Device memory InputNlist struct which stores the neighbor information of the core region atoms */ void free_nlist_gpu_device( InputNlist & gpu_nlist);