Access the device status directly, remove the getter
[alexxy/gromacs.git] / src / gromacs / hardware / device_management.cpp
index 1d03f1b0be0e78abfa28665507b7ed2e9b2e061c..873d1258c153ff57ccba5f06443927662a8e3b44 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2015,2017 The GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016, by the GROMACS development team.
+ * Copyright (c) 2017,2018,2019,2020, 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.
 /*! \internal \file
  *  \brief Defines the CPU stubs for the device management.
  *
+ *  \author Anca Hamuraru <anca@streamcomputing.eu>
+ *  \author Dimitrios Karkoulis <dimitris.karkoulis@gmail.com>
+ *  \author Teemu Virolainen <teemu@streamcomputing.eu>
+ *  \author Mark Abraham <mark.j.abraham@gmail.com>
+ *  \author Szilárd Páll <pall.szilard@gmail.com>
  *  \author Artem Zhmurov <zhmurov@gmail.com>
  *
  * \ingroup module_hardware
 
 #include "device_management.h"
 
-bool isGpuDetectionFunctional(std::string* errorMessage)
-{
-    if (errorMessage != nullptr)
-    {
-        errorMessage->assign("GROMACS has been built without GPU support.");
-    }
-    return false;
-}
+#include "gromacs/gpu_utils/gputraits.h"
+#include "gromacs/utility/fatalerror.h"
 
-void findGpus(gmx_gpu_info_t* /* gpu_info */)
-{
-    GMX_RELEASE_ASSERT(false, "Trying to initialize GPUs in the build that does not support them.");
-}
+#include "device_information.h"
 
-void init_gpu(const DeviceInformation* /* deviceInfo */)
+std::vector<std::unique_ptr<DeviceInformation>> findDevices()
 {
-    GMX_RELEASE_ASSERT(false, "Trying to initialize GPU in the build that does not support GPUs.");
+    return {};
 }
 
-void free_gpu(const DeviceInformation* /* deviceInfo */) {}
+void setActiveDevice(const DeviceInformation& /* deviceInfo */) {}
 
-DeviceInformation* getDeviceInfo(const gmx_gpu_info_t& /* gpu_info */, int /* deviceId */)
-{
-    GMX_RELEASE_ASSERT(
-            false, "Trying to get GPU device information in the build that does not support GPUs.");
-    return nullptr;
-}
+void releaseDevice(DeviceInformation* /* deviceInfo */) {}
 
-void get_gpu_device_info_string(char* /* s */, const gmx_gpu_info_t& /* gpu_info */, int /* index */)
+std::string getDeviceInformationString(const DeviceInformation& /* deviceInfo */)
 {
-    GMX_RELEASE_ASSERT(
-            false,
-            "Trying to get the GPU device description in the build that does not support GPUs.");
+    gmx_fatal(FARGS, "Device information requested in CPU build.");
 }
 
-size_t sizeof_gpu_dev_info()
+bool isDeviceDetectionFunctional(std::string* /* errorMessage */)
 {
-    return 0;
-}
-
-DeviceStatus gpu_info_get_stat(const gmx_gpu_info_t& /* gpu_info */, int /* index */)
-{
-    return DeviceStatus::Nonexistent;
+    return false;
 }