/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2017,2018,2019, by the GROMACS development team.
+ * Copyright (c) 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.
*/
/*! \internal \file
- * \brief Stub functions for non-GPU builds
+ * \brief Function definitions for non-GPU builds
*
* \author Mark Abraham <mark.j.abraham@gmail.com>
*/
#include "gpu_utils.h"
-/*! \brief Set allocation functions used by the GPU host
- *
- * Since GPU support is not configured, there is no host memory to
- * allocate. */
-void gpu_set_host_malloc_and_free(bool,
- gmx_host_alloc_t **nb_alloc,
- gmx_host_free_t **nb_free)
+#include "config.h"
+
+#include "gromacs/utility/arrayref.h"
+#include "gromacs/utility/enumerationhelpers.h"
+#include "gromacs/utility/stringutil.h"
+
+#ifdef _MSC_VER
+# pragma warning(disable : 6237)
+#endif
+
+const char* enumValueToString(GpuApiCallBehavior enumValue)
+{
+ static constexpr gmx::EnumerationArray<GpuApiCallBehavior, const char*> s_gpuApiCallBehaviorNames = {
+ "Synchronous", "Asynchronous"
+ };
+ return s_gpuApiCallBehaviorNames[enumValue];
+}
+
+bool decideGpuTimingsUsage()
{
- *nb_alloc = NULL;
- *nb_free = NULL;
+ if (GMX_GPU_CUDA || GMX_GPU_SYCL)
+ {
+ /* CUDA: timings are incorrect with multiple streams.
+ * This is the main reason why they are disabled by default.
+ * TODO: Consider turning on by default when we can detect nr of streams.
+ *
+ * SYCL: compilers and runtimes change rapidly, so we disable timings by default
+ * to avoid any possible overhead. */
+ return (getenv("GMX_ENABLE_GPU_TIMING") != nullptr);
+ }
+ else if (GMX_GPU_OPENCL)
+ {
+ return (getenv("GMX_DISABLE_GPU_TIMING") == nullptr);
+ }
+ else
+ {
+ // CPU-only build
+ return false;
+ }
}