Unify gpu_init_atomdata(...) function
[alexxy/gromacs.git] / src / gromacs / nbnxm / cuda / nbnxm_cuda_data_mgmt.cu
index ac77badc413858441700703719b89e807c7ad936..e6eb1c2d51a7cc00ba31df83998d1119569eb6c3 100644 (file)
@@ -319,95 +319,6 @@ void gpu_clear_outputs(NbnxmGpu* nb, bool computeVirial)
     }
 }
 
-void gpu_init_atomdata(NbnxmGpu* nb, const nbnxn_atomdata_t* nbat)
-{
-    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->atomTypes);
-            freeDeviceBuffer(&d_atdat->ljComb);
-        }
-
-        allocateDeviceBuffer(&d_atdat->f, nalloc, deviceContext);
-        allocateDeviceBuffer(&d_atdat->xq, nalloc, deviceContext);
-        if (useLjCombRule(nb->nbparam->vdwType))
-        {
-            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_cuda_clear_f(nb, nalloc);
-    }
-
-    if (useLjCombRule(nb->nbparam->vdwType))
-    {
-        static_assert(sizeof(d_atdat->ljComb[0]) == sizeof(Float2),
-                      "Size of the LJ parameters element 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,
-                           nullptr);
-    }
-    else
-    {
-        static_assert(sizeof(d_atdat->atomTypes[0]) == sizeof(nbat->params().type[0]),
-                      "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,
-                           nullptr);
-    }
-
-    if (bDoTime)
-    {
-        timers->atdat.closeTimingRegion(localStream);
-    }
-}
-
 void gpu_free(NbnxmGpu* nb)
 {
     if (nb == nullptr)