Use default constructor for the device buffers that can be uninitialized
authorArtem Zhmurov <zhmurov@gmail.com>
Tue, 30 Mar 2021 14:44:12 +0000 (17:44 +0300)
committerArtem Zhmurov <zhmurov@gmail.com>
Tue, 30 Mar 2021 14:44:12 +0000 (17:44 +0300)
Some buffers in NBNXM are initialized conditionally, which posseses
a problem for the OpenCL kernel jit compilation, where these buffers
are used as arguments.

Refs #2608

src/gromacs/nbnxm/gpu_types_common.h
src/gromacs/nbnxm/nbnxm_gpu_data_mgmt.cpp

index ee6357e3f637dbe5b6c4c524290bbd6501fe1f14..8fa52b7f9eb29a5aa1b797c2c1a5c84261ca852d 100644 (file)
@@ -176,11 +176,11 @@ struct NBParamGpu
 
     /* LJ non-bonded parameters - accessed through texture memory */
     //! nonbonded parameter table with 6*C6/12*C12 pairs per atom type-pair, ntype^2 elements
-    DeviceBuffer<Float2> nbfp;
+    DeviceBuffer<Float2> nbfp{};
     //! texture object bound to nbfp
     DeviceTexture nbfp_texobj;
     //! nonbonded parameter table per atom type, ntype elements
-    DeviceBuffer<Float2> nbfp_comb;
+    DeviceBuffer<Float2> nbfp_comb{};
     //! texture object bound to nbfp_comb
     DeviceTexture nbfp_comb_texobj;
 
@@ -188,7 +188,7 @@ struct NBParamGpu
     //! table scale/spacing
     float coulomb_tab_scale;
     //! pointer to the table in the device memory
-    DeviceBuffer<float> coulomb_tab;
+    DeviceBuffer<float> coulomb_tab{};
     //! texture object bound to coulomb_tab
     DeviceTexture coulomb_tab_texobj;
 };
index c545a10fddd86f982e3792ab2f17939ecd1a686d..afd969ee7f8d7c34cd1c52211993cd7ce3bb5106 100644 (file)
@@ -319,11 +319,6 @@ static void initNbparam(NBParamGpu*                     nbp,
         GMX_RELEASE_ASSERT(ic.coulombEwaldTables, "Need valid Coulomb Ewald correction tables");
         init_ewald_coulomb_force_table(*ic.coulombEwaldTables, nbp, deviceContext);
     }
-    else
-    {
-        // Need to initialize for OpenCL, since it is unconditionally used as a kernel argument.
-        allocateDeviceBuffer(&nbp->coulomb_tab, 1, deviceContext);
-    }
 
     /* set up LJ parameter lookup table */
     if (!useLjCombRule(nbp->vdwType))
@@ -336,11 +331,6 @@ static void initNbparam(NBParamGpu*                     nbp,
                              numTypes * numTypes,
                              deviceContext);
     }
-    else
-    {
-        // Need to initialize for OpenCL, since it is unconditionally used as a kernel argument.
-        allocateDeviceBuffer(&nbp->nbfp, 1, deviceContext);
-    }
 
     /* set up LJ-PME parameter lookup table */
     if (ic.vdwtype == VanDerWaalsType::Pme)
@@ -354,11 +344,6 @@ static void initNbparam(NBParamGpu*                     nbp,
                              numTypes,
                              deviceContext);
     }
-    else
-    {
-        // Need to initialize for OpenCL, since it is unconditionally used as a kernel argument.
-        allocateDeviceBuffer(&nbp->nbfp_comb, 1, deviceContext);
-    }
 }
 
 NbnxmGpu* gpu_init(const gmx::DeviceStreamManager& deviceStreamManager,