#include "gromacs/gpu_utils/device_context.h"
#include "gromacs/gpu_utils/device_stream.h"
#include "gromacs/gpu_utils/gpu_utils.h"
+#include "gromacs/gpu_utils/pmalloc.h"
+#if GMX_GPU_SYCL
+# include "gromacs/gpu_utils/syclutils.h"
+#endif
#include "gromacs/hardware/device_information.h"
#include "gromacs/math/invertmatrix.h"
#include "gromacs/math/units.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/logger.h"
#include "gromacs/utility/stringutil.h"
+#include "gromacs/ewald/pme.h"
#if GMX_GPU_CUDA
-# include "gromacs/gpu_utils/pmalloc_cuda.h"
-
# include "pme.cuh"
-#elif GMX_GPU_OPENCL
-# include "gromacs/gpu_utils/gmxopencl.h"
-#elif GMX_GPU_SYCL
-# include "gromacs/gpu_utils/syclutils.h"
#endif
-#include "gromacs/ewald/pme.h"
-
#include "pme_gpu_3dfft.h"
#include "pme_gpu_calculate_splines.h"
#include "pme_gpu_constants.h"
gmx_add_libgromacs_sources(
device_context_ocl.cpp
device_stream_ocl.cpp
+ pmalloc_ocl.cpp
ocl_compiler.cpp
ocl_caching.cpp
oclutils.cpp
device_stream.cu
gpu_utils.cu
pinning.cu
- pmalloc_cuda.cu
+ pmalloc.cu
)
_gmx_add_files_to_property(CUDA_SOURCES
device_stream_manager.cpp
devicebuffer_sycl.cpp
device_context_sycl.cpp
device_stream_sycl.cpp
- syclutils.cpp
+ pmalloc_sycl.cpp
)
_gmx_add_files_to_property(SYCL_SOURCES
devicebuffer_sycl.cpp
device_context_sycl.cpp
device_stream_manager.cpp
device_stream_sycl.cpp
- syclutils.cpp
+ pmalloc_sycl.cpp
)
else()
gmx_add_libgromacs_sources(
#include "gromacs/gpu_utils/cudautils.cuh"
#include "gromacs/gpu_utils/device_context.h"
#include "gromacs/gpu_utils/device_stream.h"
-#include "gromacs/gpu_utils/pmalloc_cuda.h"
#include "gromacs/hardware/device_information.h"
#include "gromacs/hardware/device_management.h"
#include "gromacs/utility/basedefinitions.h"
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2014,2015,2016,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include <string>
#include "gromacs/gpu_utils/gpu_utils.h"
-#include "gromacs/utility/fatalerror.h"
-#include "gromacs/utility/smalloc.h"
-/*! \brief \brief Allocates nbytes of host memory. Use ocl_free to free memory allocated with this function.
- *
- * \todo
- * This function should allocate page-locked memory to help reduce D2H and H2D
- * transfer times, similar with pmalloc from pmalloc_cuda.cu.
- *
- * \param[in,out] h_ptr Pointer where to store the address of the newly allocated buffer.
- * \param[in] nbytes Size in bytes of the buffer to be allocated.
- */
-void pmalloc(void** h_ptr, size_t nbytes)
-{
- /* Need a temporary type whose size is 1 byte, so that the
- * implementation of snew_aligned can cope without issuing
- * warnings. */
- char** temporary = reinterpret_cast<char**>(h_ptr);
-
- /* 16-byte alignment is required by the neighbour-searching code,
- * because it uses four-wide SIMD for bounding-box calculation.
- * However, when we organize using page-locked memory for
- * device-host transfers, it will probably need to be aligned to a
- * 4kb page, like CUDA does. */
- snew_aligned(*temporary, nbytes, 16);
-}
-
-/*! \brief Frees memory allocated with pmalloc.
- *
- * \param[in] h_ptr Buffer allocated with pmalloc that needs to be freed.
- */
-void pfree(void* h_ptr)
-{
-
- if (h_ptr)
- {
- sfree_aligned(h_ptr);
- }
-}
/*! \brief Convert error code to diagnostic string */
std::string ocl_get_error_string(cl_int error)
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2014,2015,2016,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
cl_program program;
};
-/*! \brief Allocate host memory in malloc style */
-void pmalloc(void** h_ptr, size_t nbytes);
-
-/*! \brief Free host memory in malloc style */
-void pfree(void* h_ptr);
-
/*! \brief Convert error code to diagnostic string */
std::string ocl_get_error_string(cl_int error);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2014,2015,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gmxpre.h"
-#include "pmalloc_cuda.h"
+#include "pmalloc.h"
#include <stdlib.h>
CU_RET_ERR(stat, strbuf);
}
-/*! Allocates nbytes of page-locked memory with write-combining.
- * This memory should always be freed using pfree (or with the page-locked
- * free functions provied by the CUDA library).
- */
-void pmalloc_wc(void** h_ptr, size_t nbytes)
-{
- cudaError_t stat;
- char strbuf[STRLEN];
- int flag = cudaHostAllocDefault | cudaHostAllocWriteCombined;
-
- if (nbytes == 0)
- {
- *h_ptr = nullptr;
- return;
- }
-
- gmx::ensureNoPendingDeviceError("Could not allocate page-locked memory with write-combining.");
-
- stat = cudaMallocHost(h_ptr, nbytes, flag);
- sprintf(strbuf, "cudaMallocHost of size %d bytes failed", (int)nbytes);
- CU_RET_ERR(stat, strbuf);
-}
-
/*! Frees page locked memory allocated with pmalloc.
* This function can safely be called also with a pointer to a page-locked
* memory allocated directly with CUDA API calls.
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2012,2013,2014,2015,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* the research papers on the package. Check out http://www.gromacs.org.
*/
/*! \libinternal \file
- * \brief Declare functions for host-side memory handling when using CUDA devices.
+ * \brief Declare functions for host-side memory handling.
*
* \author Szilard Pall <pall.szilard@gmail.com>
* \inlibraryapi
*/
-#ifndef GMX_GPU_UTILS_PMALLOC_CUDA_H
-#define GMX_GPU_UTILS_PMALLOC_CUDA_H
+#ifndef GMX_GPU_UTILS_PMALLOC_H
+#define GMX_GPU_UTILS_PMALLOC_H
#include <stdlib.h>
/*! \brief Allocates nbytes of page-locked memory. */
void pmalloc(void** h_ptr, size_t nbytes);
-/*! \brief Allocates nbytes of page-locked memory with write-combining. */
-void pmalloc_wc(void** h_ptr, size_t nbytes);
-
/*! \brief Frees page locked memory allocated with pmalloc. */
void pfree(void* h_ptr);
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2012,2014,2015,2018,2019,2020,2021, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \internal \file
+ * \brief Define functions for host-side memory handling when using OpenCL devices.
+ *
+ * \author Anca Hamuraru <anca@streamcomputing.eu>
+ */
+
+#include "gmxpre.h"
+
+#include "pmalloc.h"
+
+#include "gromacs/utility/smalloc.h"
+
+/*! \brief \brief Allocates nbytes of host memory. Use pfree to free memory allocated with this function.
+ *
+ * \todo
+ * This function should allocate page-locked memory to help reduce D2H and H2D
+ * transfer times, similar with pmalloc from pmalloc.cu.
+ *
+ * \param[in,out] h_ptr Pointer where to store the address of the newly allocated buffer.
+ * \param[in] nbytes Size in bytes of the buffer to be allocated.
+ */
+void pmalloc(void** h_ptr, size_t nbytes)
+{
+ /* Need a temporary type whose size is 1 byte, so that the
+ * implementation of snew_aligned can cope without issuing
+ * warnings. */
+ char** temporary = reinterpret_cast<char**>(h_ptr);
+
+ /* 16-byte alignment is required by the neighbour-searching code,
+ * because it uses four-wide SIMD for bounding-box calculation.
+ * However, when we organize using page-locked memory for
+ * device-host transfers, it will probably need to be aligned to a
+ * 4kb page, like CUDA does. */
+ snew_aligned(*temporary, nbytes, 16);
+}
+
+/*! \brief Frees memory allocated with pmalloc.
+ *
+ * \param[in] h_ptr Buffer allocated with pmalloc that needs to be freed.
+ */
+void pfree(void* h_ptr)
+{
+
+ if (h_ptr)
+ {
+ sfree_aligned(h_ptr);
+ }
+}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2020,2021, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*/
#include "gmxpre.h"
-#include "syclutils.h"
+#include "pmalloc.h"
#include "gromacs/utility/smalloc.h"
#ifndef DOXYGEN
-/*! \brief Allocate host memory in malloc style */
-void pmalloc(void** h_ptr, size_t nbytes);
-
-/*! \brief Free host memory in malloc style */
-void pfree(void* h_ptr);
-
/* To properly mark function as [[noreturn]], we must do it everywhere it is declared, which
* will pollute common headers.*/
# pragma clang diagnostic push
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
# include "gromacs/gpu_utils/gpu_utils.h"
# include "gromacs/gpu_utils/hostallocator.h"
-# include "gromacs/gpu_utils/pmalloc_cuda.h"
+# include "gromacs/gpu_utils/pmalloc.h"
# include "gromacs/utility/real.h"
# include "gromacs/utility/smalloc.h"
#include "gromacs/gpu_utils/device_stream_manager.h"
#include "gromacs/gpu_utils/gpu_utils.h"
#include "gromacs/gpu_utils/gpueventsynchronizer.cuh"
-#include "gromacs/gpu_utils/pmalloc_cuda.h"
+#include "gromacs/gpu_utils/pmalloc.h"
#include "gromacs/hardware/device_information.h"
#include "gromacs/hardware/device_management.h"
#include "gromacs/math/vectypes.h"
#include <cmath>
#include "gromacs/gpu_utils/device_stream_manager.h"
-#include "gromacs/gpu_utils/oclutils.h"
+#include "gromacs/gpu_utils/pmalloc.h"
#include "gromacs/hardware/device_information.h"
#include "gromacs/hardware/device_management.h"
#include "gromacs/math/vectypes.h"
#include "gmxpre.h"
#include "gromacs/gpu_utils/device_stream_manager.h"
+#include "gromacs/gpu_utils/pmalloc.h"
#include "gromacs/hardware/device_information.h"
#include "gromacs/mdtypes/interaction_const.h"
#include "gromacs/nbnxm/atomdata.h"