Unify gpu_init_atomdata(...) function
[alexxy/gromacs.git] / src / gromacs / nbnxm / opencl / nbnxm_ocl_data_mgmt.cpp
index b927bd319645ebc687e961892251c3634fd71ba4..36e538d22bedfb93c9d106233f6884120d35186c 100644 (file)
@@ -426,106 +426,6 @@ void gpu_upload_shiftvec(NbnxmGpu* nb, const nbnxn_atomdata_t* nbatom)
     }
 }
 
-//! This function is documented in the header file
-void gpu_init_atomdata(NbnxmGpu* nb, const nbnxn_atomdata_t* nbat)
-{
-    cl_int               cl_error;
-    int                  nalloc, natoms;
-    bool                 realloced;
-    bool                 bDoTime       = nb->bDoTime;
-    Nbnxm::GpuTimers*    timers        = nb->timers;
-    NBAtomData*          d_atdat       = nb->atdat;
-    const DeviceContext& deviceContext = *nb->deviceContext_;
-    const DeviceStream&  localStream   = *nb->deviceStreams[InteractionLocality::Local];
-
-    natoms    = nbat->numAtoms();
-    realloced = false;
-
-    if (bDoTime)
-    {
-        /* time async copy */
-        timers->atdat.openTimingRegion(localStream);
-    }
-
-    /* need to reallocate if we have to copy more atoms than the amount of space
-       available and only allocate if we haven't initialized yet, i.e d_atdat->natoms == -1 */
-    if (natoms > d_atdat->numAtomsAlloc)
-    {
-        nalloc = over_alloc_small(natoms);
-
-        /* free up first if the arrays have already been initialized */
-        if (d_atdat->numAtomsAlloc != -1)
-        {
-            freeDeviceBuffer(&d_atdat->f);
-            freeDeviceBuffer(&d_atdat->xq);
-            freeDeviceBuffer(&d_atdat->ljComb);
-            freeDeviceBuffer(&d_atdat->atomTypes);
-        }
-
-
-        allocateDeviceBuffer(&d_atdat->f, nalloc, deviceContext);
-        allocateDeviceBuffer(&d_atdat->xq, nalloc, deviceContext);
-
-        if (useLjCombRule(nb->nbparam->vdwType))
-        {
-            // Two Lennard-Jones parameters per atom
-            allocateDeviceBuffer(&d_atdat->ljComb, nalloc, deviceContext);
-        }
-        else
-        {
-            allocateDeviceBuffer(&d_atdat->atomTypes, nalloc, deviceContext);
-        }
-
-        d_atdat->numAtomsAlloc = nalloc;
-        realloced              = true;
-    }
-
-    d_atdat->numAtoms      = natoms;
-    d_atdat->numAtomsLocal = nbat->natoms_local;
-
-    /* need to clear GPU f output if realloc happened */
-    if (realloced)
-    {
-        nbnxn_ocl_clear_f(nb, nalloc);
-    }
-
-    if (useLjCombRule(nb->nbparam->vdwType))
-    {
-        static_assert(
-                sizeof(Float2) == 2 * sizeof(*nbat->params().lj_comb.data()),
-                "Size of a pair of LJ parameters elements should be equal to the size of Float2.");
-        copyToDeviceBuffer(&d_atdat->ljComb,
-                           reinterpret_cast<const Float2*>(nbat->params().lj_comb.data()),
-                           0,
-                           natoms,
-                           localStream,
-                           GpuApiCallBehavior::Async,
-                           bDoTime ? timers->atdat.fetchNextEvent() : nullptr);
-    }
-    else
-    {
-        static_assert(sizeof(int) == sizeof(*nbat->params().type.data()),
-                      "Sizes of host- and device-side atom types should be the same.");
-        copyToDeviceBuffer(&d_atdat->atomTypes,
-                           nbat->params().type.data(),
-                           0,
-                           natoms,
-                           localStream,
-                           GpuApiCallBehavior::Async,
-                           bDoTime ? timers->atdat.fetchNextEvent() : nullptr);
-    }
-
-    if (bDoTime)
-    {
-        timers->atdat.closeTimingRegion(localStream);
-    }
-
-    /* kick off the tasks enqueued above to ensure concurrency with the search */
-    cl_error = clFlush(localStream.stream());
-    GMX_RELEASE_ASSERT(cl_error == CL_SUCCESS,
-                       ("clFlush failed: " + ocl_get_error_string(cl_error)).c_str());
-}
-
 /*! \brief Releases an OpenCL kernel pointer */
 static void free_kernel(cl_kernel* kernel_ptr)
 {