2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
35 /*! \libinternal \file
36 * \brief Declares the GPU type traits for non-GPU builds.
38 * \author Mark Abraham <mark.j.abraham@gmail.com>
39 * \author Artem Zhmurov <zhmurov@gmail.com>
42 * \ingroup module_hardware
44 #ifndef GMX_HARDWARE_DEVICE_INFORMATION_H
45 #define GMX_HARDWARE_DEVICE_INFORMATION_H
50 # include <cuda_runtime.h>
54 # include "gromacs/gpu_utils/gmxopencl.h"
56 #include "gromacs/utility/enumerationhelpers.h"
58 //! Constant used to help minimize preprocessed code
59 static constexpr bool c_binarySupportsGpus = (GMX_GPU != 0);
61 //! Possible results of the GPU detection/check.
62 enum class DeviceStatus : int
64 //! The device is compatible
66 //! Device does not exist
68 //! Device is not compatible
70 //! OpenCL device has incompatible cluster size for non-bonded kernels.
71 IncompatibleClusterSize = 3,
72 /*! \brief An error occurred he functionality checks.
73 * That indicates malfunctioning of the device, driver, or incompatible driver/runtime.
76 /*! \brief CUDA devices are busy or unavailable.
77 * typically due to use of \p cudaComputeModeExclusive, \p cudaComputeModeProhibited modes.
84 /*! \brief Names of the GPU detection/check results
86 * Check-source wants to warn about the use of a symbol name that would
87 * require an inclusion of config.h. However the use is in a comment, so that
88 * is a false warning. So C-style string concatenation is used to fool the
89 * naive parser in check-source. That needs a clang-format suppression
90 * in order to look reasonable. Also clang-tidy wants to suggest that a comma is
91 * missing, so that is suppressed.
93 static const gmx::EnumerationArray<DeviceStatus, const char*> c_deviceStateString = {
94 "compatible", "nonexistent", "incompatible",
96 // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
97 "incompatible (please recompile with correct GMX" "_OPENCL_NB_CLUSTER_SIZE of 4)",
99 "non-functional", "unavailable"
103 enum class DeviceVendor : int
109 //! Advanced Micro Devices
118 /*! \libinternal \brief Platform-dependent device information.
120 * The device information is queried and set at detection and contains
121 * both information about the device/hardware returned by the runtime as well
122 * as additional data like support status.
124 struct DeviceInformation
128 //! ID of the device.
132 //! CUDA device properties.
135 cl_platform_id oclPlatformId; //!< OpenCL Platform ID.
136 cl_device_id oclDeviceId; //!< OpenCL Device ID.
137 char device_name[256]; //!< Device name.
138 char device_version[256]; //!< Device version.
139 char vendorName[256]; //!< Device vendor name.
140 int compute_units; //!< Number of compute units.
141 int adress_bits; //!< Number of address bits the device is capable of.
142 DeviceVendor deviceVendor; //!< Device vendor.
143 size_t maxWorkItemSizes[3]; //!< Workgroup size limits (CL_DEVICE_MAX_WORK_ITEM_SIZES).
144 size_t maxWorkGroupSize; //!< Workgroup total size limit (CL_DEVICE_MAX_WORK_GROUP_SIZE).
148 #endif // GMX_HARDWARE_DEVICE_INFORMATION_H