From 11d4a64548e12300eab6804aac24f80fe6d202f0 Mon Sep 17 00:00:00 2001 From: Artem Zhmurov Date: Tue, 30 Mar 2021 17:44:12 +0300 Subject: [PATCH] Use default constructor for the device buffers that can be uninitialized 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 | 6 +++--- src/gromacs/nbnxm/nbnxm_gpu_data_mgmt.cpp | 15 --------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/gromacs/nbnxm/gpu_types_common.h b/src/gromacs/nbnxm/gpu_types_common.h index ee6357e3f6..8fa52b7f9e 100644 --- a/src/gromacs/nbnxm/gpu_types_common.h +++ b/src/gromacs/nbnxm/gpu_types_common.h @@ -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 nbfp; + DeviceBuffer nbfp{}; //! texture object bound to nbfp DeviceTexture nbfp_texobj; //! nonbonded parameter table per atom type, ntype elements - DeviceBuffer nbfp_comb; + DeviceBuffer 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 coulomb_tab; + DeviceBuffer coulomb_tab{}; //! texture object bound to coulomb_tab DeviceTexture coulomb_tab_texobj; }; diff --git a/src/gromacs/nbnxm/nbnxm_gpu_data_mgmt.cpp b/src/gromacs/nbnxm/nbnxm_gpu_data_mgmt.cpp index c545a10fdd..afd969ee7f 100644 --- a/src/gromacs/nbnxm/nbnxm_gpu_data_mgmt.cpp +++ b/src/gromacs/nbnxm/nbnxm_gpu_data_mgmt.cpp @@ -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, -- 2.22.0