Remove the rest of the device coordinates management from PME
authorArtem Zhmurov <zhmurov@gmail.com>
Tue, 28 Jan 2020 16:56:44 +0000 (17:56 +0100)
committerPaul Bauer <paul.bauer.q@gmail.com>
Wed, 29 Jan 2020 14:25:29 +0000 (15:25 +0100)
Although it may be convinient to keep an local copy of the
address device coordinates buffer, the management of this buffer
is not the responsibility of the PME module. This patch remove
some of the remains of this management.

Change-Id: I160adfb0319c0bf6e532061aca05ef9cc9aa8a4f

src/gromacs/ewald/pme.h
src/gromacs/ewald/pme_gpu.cpp
src/gromacs/ewald/pme_gpu_internal.cpp
src/gromacs/ewald/pme_gpu_internal.h
src/gromacs/ewald/pme_only.cpp
src/gromacs/mdlib/sim_util.cpp

index 4a2f159a5670f0787c3bc4d058de51a973dea945..a471e93e2e32126351a6b451afe0ad3f2bd5ad17 100644 (file)
@@ -447,14 +447,6 @@ GPU_FUNC_QUALIFIER void pme_gpu_wait_and_reduce(gmx_pme_t*            GPU_FUNC_A
 GPU_FUNC_QUALIFIER void pme_gpu_reinit_computation(const gmx_pme_t* GPU_FUNC_ARGUMENT(pme),
                                                    gmx_wallcycle* GPU_FUNC_ARGUMENT(wcycle)) GPU_FUNC_TERM;
 
-
-/*! \brief Get pointer to device copy of coordinate data.
- * \param[in] pme            The PME data structure.
- * \returns                  Pointer to coordinate data
- */
-GPU_FUNC_QUALIFIER DeviceBuffer<float> pme_gpu_get_device_x(const gmx_pme_t* GPU_FUNC_ARGUMENT(pme))
-        GPU_FUNC_TERM_WITH_RETURN(DeviceBuffer<float>{});
-
 /*! \brief Set pointer to device copy of coordinate data.
  * \param[in] pme            The PME data structure.
  * \param[in] d_x            The pointer to the positions buffer to be set
index 1bbdaa7de7f039e13dc4cef9ea0cd6f325df8e73..aafd5c1a4d5a4fe888e99f940eb8000f7c396cfd 100644 (file)
@@ -431,13 +431,6 @@ void pme_gpu_reinit_computation(const gmx_pme_t* pme, gmx_wallcycle* wcycle)
     wallcycle_stop(wcycle, ewcLAUNCH_GPU);
 }
 
-DeviceBuffer<float> pme_gpu_get_device_x(const gmx_pme_t* pme)
-{
-    GMX_ASSERT((pme && pme_gpu_active(pme)),
-               "PME GPU coordinates buffer was requested from uninitialized PME module");
-    return pme_gpu_get_kernelparam_coordinates(pme->gpu);
-}
-
 void* pme_gpu_get_device_f(const gmx_pme_t* pme)
 {
     if (!pme || !pme_gpu_active(pme))
index 39973556be36e960afd6b7bced387cada1b24ca7..36802e61a52d95f54a1c2e00fbf0451d09442b00 100644 (file)
@@ -231,30 +231,6 @@ void pme_gpu_copy_output_forces(PmeGpu* pmeGpu)
                          pmeGpu->settings.transferKind, nullptr);
 }
 
-void pme_gpu_realloc_coordinates(PmeGpu* pmeGpu)
-{
-    const size_t newCoordinatesSize = pmeGpu->nAtomsAlloc * DIM;
-    GMX_ASSERT(newCoordinatesSize > 0, "Bad number of atoms in PME GPU");
-    reallocateDeviceBuffer(&pmeGpu->kernelParams->atoms.d_coordinates, newCoordinatesSize,
-                           &pmeGpu->archSpecific->coordinatesSize,
-                           &pmeGpu->archSpecific->coordinatesSizeAlloc, pmeGpu->archSpecific->context);
-    if (c_usePadding)
-    {
-        const size_t paddingIndex = DIM * pmeGpu->kernelParams->atoms.nAtoms;
-        const size_t paddingCount = DIM * pmeGpu->nAtomsAlloc - paddingIndex;
-        if (paddingCount > 0)
-        {
-            clearDeviceBufferAsync(&pmeGpu->kernelParams->atoms.d_coordinates, paddingIndex,
-                                   paddingCount, pmeGpu->archSpecific->pmeStream);
-        }
-    }
-}
-
-void pme_gpu_free_coordinates(const PmeGpu* pmeGpu)
-{
-    freeDeviceBuffer(&pmeGpu->kernelParams->atoms.d_coordinates);
-}
-
 void pme_gpu_realloc_and_copy_input_coefficients(PmeGpu* pmeGpu, const float* h_coefficients)
 {
     GMX_ASSERT(h_coefficients, "Bad host-side charge buffer in PME GPU");
@@ -1535,15 +1511,6 @@ void pme_gpu_gather(PmeGpu* pmeGpu, PmeForceOutputHandling forceTreatment, const
     }
 }
 
-DeviceBuffer<float> pme_gpu_get_kernelparam_coordinates(const PmeGpu* pmeGpu)
-{
-    GMX_ASSERT(pmeGpu && pmeGpu->kernelParams,
-               "PME GPU device buffer was requested in non-GPU build or before the GPU PME was "
-               "initialized.");
-
-    return pmeGpu->kernelParams->atoms.d_coordinates;
-}
-
 void* pme_gpu_get_kernelparam_forces(const PmeGpu* pmeGpu)
 {
     if (pmeGpu && pmeGpu->kernelParams)
index f010d15456bd2217d30180e75a327146b8bb9ec5..2cd1f862602d897b1ad8ce781c07957ef06d923c 100644 (file)
@@ -185,22 +185,6 @@ void pme_gpu_copy_output_forces(PmeGpu* pmeGpu);
  */
 bool pme_gpu_stream_query(const PmeGpu* pmeGpu);
 
-/*! \libinternal \brief
- * Reallocates the input coordinates buffer on the GPU (and clears the padded part if needed).
- *
- * \param[in] pmeGpu            The PME GPU structure.
- *
- * Needs to be called on every DD step/in the beginning.
- */
-void pme_gpu_realloc_coordinates(PmeGpu* pmeGpu);
-
-/*! \libinternal \brief
- * Frees the coordinates on the GPU.
- *
- * \param[in] pmeGpu            The PME GPU structure.
- */
-void pme_gpu_free_coordinates(const PmeGpu* pmeGpu);
-
 /*! \libinternal \brief
  * Reallocates the buffer on the GPU and copies the charges/coefficients from the CPU buffer.
  * Clears the padded part if needed.
@@ -406,13 +390,6 @@ GPU_FUNC_QUALIFIER void pme_gpu_gather(PmeGpu*                GPU_FUNC_ARGUMENT(
                                        PmeForceOutputHandling GPU_FUNC_ARGUMENT(forceTreatment),
                                        const float* GPU_FUNC_ARGUMENT(h_grid)) GPU_FUNC_TERM;
 
-/*! \brief Return pointer to device copy of coordinate data.
- * \param[in] pmeGpu         The PME GPU structure.
- * \returns                  Pointer to coordinate data
- */
-GPU_FUNC_QUALIFIER DeviceBuffer<float> pme_gpu_get_kernelparam_coordinates(const PmeGpu* GPU_FUNC_ARGUMENT(pmeGpu))
-        GPU_FUNC_TERM_WITH_RETURN(DeviceBuffer<float>{});
-
 /*! \brief Sets the device pointer to coordinate data
  * \param[in] pmeGpu         The PME GPU structure.
  * \param[in] d_x            Pointer to coordinate data
index 9ca5df248cbd6991a3c2f83d2966fc341b7ecb76..d2d1d52c6e8663b8b5cf887853aacfa43a8454b9 100644 (file)
@@ -427,7 +427,7 @@ static int gmx_pme_recv_coeffs_coords(struct gmx_pme_t*            pme,
 
                     // This rank will have its data accessed directly by PP rank, so needs to send the remote addresses.
                     pme_pp->pmeCoordinateReceiverGpu->sendCoordinateBufferAddressToPpRanks(
-                            pme_gpu_get_device_x(pme));
+                            stateGpu->getCoordinates());
                     pme_pp->pmeForceSenderGpu->sendForceBufferAddressToPpRanks(
                             reinterpret_cast<rvec*>(pme_gpu_get_device_f(pme)));
                 }
index 868ef05a4a46db867b747abf1a661db99cf55094..e5864fae5685a8e868e4a2cb648a26a29ddd1a7d 100644 (file)
@@ -1305,7 +1305,6 @@ void do_force(FILE*                               fplog,
 
             if (useGpuXBufOps == BufferOpsUseGpu::True)
             {
-                // The condition here was (pme != nullptr && pme_gpu_get_device_x(fr->pmedata) != nullptr)
                 if (!useGpuPmeOnThisRank && !ddUsesGpuDirectCommunication)
                 {
                     stateGpu->copyCoordinatesToGpu(x.unpaddedArrayRef(), AtomLocality::NonLocal);