Add DeviceBuffer as a typedef for cl_mem/device ponter
authorAleksei Iupinov <a.yupinov@gmail.com>
Thu, 8 Feb 2018 18:03:19 +0000 (19:03 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Wed, 14 Feb 2018 12:04:04 +0000 (13:04 +0100)
It is applied to unify the pairlist structure.

Change-Id: I81f78dca2a356ffc7b7638047d29ea29e20c689e

src/gromacs/gpu_utils/gputraits.cuh
src/gromacs/gpu_utils/gputraits_ocl.h
src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_types.h
src/gromacs/mdlib/nbnxn_gpu_types_common.h
src/gromacs/mdlib/nbnxn_ocl/nbnxn_ocl_data_mgmt.cpp
src/gromacs/mdlib/nbnxn_ocl/nbnxn_ocl_types.h

index 8ec95a29b9d9caa75c69f81ee9a822c0d7f32ad0..9e96830a202949635af0eeac6aefc70d060386d7 100644 (file)
@@ -46,5 +46,8 @@
 using CommandStream = cudaStream_t;
 //! \brief Single GPU call timing event - meaningless in CUDA
 using CommandEvent  = void;
+//! \brief A device-side buffer of ValueTypes
+template<typename ValueType>
+using DeviceBuffer  = ValueType *;
 
 #endif
index bc16239497c4446461cd5d424a16286d4d906580..9d8575788d77cfe9c93d557f0b14a3f54cb638c9 100644 (file)
@@ -48,5 +48,8 @@
 using CommandStream = cl_command_queue;
 //! \brief Single GPU call timing event
 using CommandEvent  = cl_event;
+//! \brief A device-side buffer of ValueTypes
+template<typename ValueType>
+using DeviceBuffer  = cl_mem;
 
 #endif
index 06a2dba7a23857da824d81bb9393ce23edab4d12..c155d5bdba6bc02ec97f6cd9ebb5219868f54994 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2012, The GROMACS development team.
- * Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -113,7 +113,6 @@ enum evdwCu {
 /* All structs prefixed with "cu_" hold data used in GPU calculations and
  * are passed to the kernels, except cu_timers_t. */
 /*! \cond */
-typedef struct cu_plist     cu_plist_t;
 typedef struct cu_atomdata  cu_atomdata_t;
 typedef struct cu_nbparam   cu_nbparam_t;
 typedef struct nb_staging   nb_staging_t;
@@ -202,30 +201,7 @@ struct cu_nbparam
 /** \internal
  * \brief Pair list data.
  */
-struct cu_plist
-{
-    int              na_c;         /**< number of atoms per cluster                  */
-
-    int              nsci;         /**< size of sci, # of i clusters in the list     */
-    int              sci_nalloc;   /**< allocation size of sci                       */
-    nbnxn_sci_t     *sci;          /**< list of i-cluster ("super-clusters")         */
-
-    int              ncj4;         /**< total # of 4*j clusters                      */
-    int              cj4_nalloc;   /**< allocation size of cj4                       */
-    nbnxn_cj4_t     *cj4;          /**< 4*j cluster list, contains j cluster number
-                                        and index into the i cluster list            */
-    int              nimask;       /**< # of 4*j clusters * # of warps               */
-    int              imask_nalloc; /**< allocation size of imask                     */
-    unsigned int    *imask;        /**< imask for 2 warps for each 4*j cluster group */
-    nbnxn_excl_t    *excl;         /**< atom interaction bits                        */
-    int              nexcl;        /**< count for excl                               */
-    int              excl_nalloc;  /**< allocation size of excl                      */
-
-    /* parameter+variables for normal and rolling pruning */
-    bool             haveFreshList;          /**< true after search, indictes that initial pruning with outer prunning is needed */
-    int              rollingPruningNumParts; /**< the number of parts/steps over which one cyle of roling pruning takes places */
-    int              rollingPruningPart;     /**< the next part to which the roling pruning needs to be applied */
-};
+using cu_plist_t = gpu_plist;
 
 /** \internal
  * \brief Typedef of actual timer type.
index e4d86421cdfb69867319f3bb8efb8c18444e58d0..ab836f843797e223d2fcf530f655408347869646 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -44,6 +44,8 @@
 
 #include "config.h"
 
+#include "gromacs/mdlib/nbnxn_pairlist.h"
+
 #if GMX_GPU == GMX_GPU_OPENCL
 #include "gromacs/gpu_utils/gpuregiontimer_ocl.h"
 #endif
@@ -72,4 +74,29 @@ struct nbnxn_gpu_timers_t
     bool           didRollingPrune[2]; /**< true when we timed rolling pruning (at the previous step) and the timings need to be accounted for */
 };
 
+struct gpu_plist
+{
+    int                        na_c;         /**< number of atoms per cluster                  */
+
+    int                        nsci;         /**< size of sci, # of i clusters in the list     */
+    int                        sci_nalloc;   /**< allocation size of sci                       */
+    DeviceBuffer<nbnxn_sci_t>  sci;          /**< list of i-cluster ("super-clusters")         */
+
+    int                        ncj4;         /**< total # of 4*j clusters                      */
+    int                        cj4_nalloc;   /**< allocation size of cj4                       */
+    DeviceBuffer<nbnxn_cj4_t>  cj4;          /**< 4*j cluster list, contains j cluster number
+                                                and index into the i cluster list            */
+    int                        nimask;       /**< # of 4*j clusters * # of warps               */
+    int                        imask_nalloc; /**< allocation size of imask                     */
+    DeviceBuffer<unsigned int> imask;        /**< imask for 2 warps for each 4*j cluster group */
+    DeviceBuffer<nbnxn_excl_t> excl;         /**< atom interaction bits                        */
+    int                        nexcl;        /**< count for excl                               */
+    int                        excl_nalloc;  /**< allocation size of excl                      */
+
+    /* parameter+variables for normal and rolling pruning */
+    bool             haveFreshList;          /**< true after search, indictes that initial pruning with outer prunning is needed */
+    int              rollingPruningNumParts; /**< the number of parts/steps over which one cyle of roling pruning takes places */
+    int              rollingPruningPart;     /**< the next part to which the roling pruning needs to be applied */
+};
+
 #endif
index 559fcfd461595c555d6b5c7eca7993ac30f56987..e65160374f680152d246561ebd528bdba1b81db8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
index ac55b49ba902d751e7cc2a4685805618bb679250..a3e02bf73c201b5183ab1b97270b0cff68842287 100644 (file)
@@ -262,34 +262,7 @@ typedef struct cl_nbparam_params
 /*! \internal
  * \brief Pair list data.
  */
-typedef struct cl_plist
-{
-    int              na_c;         /**< number of atoms per cluster                  */
-
-    int              nsci;         /**< size of sci, # of i clusters in the list     */
-    int              sci_nalloc;   /**< allocation size of sci                       */
-    cl_mem           sci;          /**< list of i-cluster ("super-clusters").
-                                        It contains elements of type nbnxn_sci_t     */
-
-    int              ncj4;         /**< total # of 4*j clusters                      */
-    int              cj4_nalloc;   /**< allocation size of cj4                       */
-    cl_mem           cj4;          /**< 4*j cluster list, contains j cluster number and
-                                        index into the i cluster list.
-                                        It contains elements of type nbnxn_cj4_t     */
-    int              nimask;       /**< # of 4*j clusters * # of warps               */
-    int              imask_nalloc; /**< allocation size of imask                     */
-    cl_mem           imask;        /**< imask for 2 warps for each 4*j cluster group */
-    cl_mem           excl;         /**< atom interaction bits
-                                        It contains elements of type nbnxn_excl_t    */
-    int              nexcl;        /**< count for excl                               */
-    int              excl_nalloc;  /**< allocation size of excl                      */
-
-    /* parameter+variables for normal and rolling pruning */
-    bool             haveFreshList;          /**< true after search, indictes that initial pruning with outer prunning is needed */
-    int              rollingPruningNumParts; /**< the number of parts/steps over which one cyle of roling pruning takes places */
-    int              rollingPruningPart;     /**< the next part to which the roling pruning needs to be applied */
-}cl_plist_t;
-
+using cl_plist_t = gpu_plist;
 
 /** \internal
  * \brief Typedef of actual timer type.