return retval;
}
-int getGpuCompatibilityStatus(const gmx_gpu_info_t *gpu_info,
- int index)
+bool isGpuCompatible(const gmx_gpu_info_t *gpu_info,
+ int index)
{
assert(gpu_info);
- return (index >= gpu_info->n_dev) ? egpuNonexistent : gpu_info->gpu_dev[index].stat;
+ return (index >= gpu_info->n_dev ?
+ false :
+ gpu_info->gpu_dev[index].stat == egpuCompatible);
+}
+
+const char *getGpuCompatibilityDescription(const gmx_gpu_info_t *gpu_info,
+ int index)
+{
+ assert(gpu_info);
+
+ return (index >= gpu_info->n_dev ?
+ gpu_detect_res_str[egpuNonexistent] :
+ gpu_detect_res_str[gpu_info->gpu_dev[index].stat]);
}
void free_gpu_info(const gmx_gpu_info_t *gpu_info)
GPU_FUNC_QUALIFIER
int detect_gpus(struct gmx_gpu_info_t *GPU_FUNC_ARGUMENT(gpu_info), char *GPU_FUNC_ARGUMENT(err_str)) GPU_FUNC_TERM_WITH_RETURN(-1)
-/*! \brief Return compatibility status of GPU with given \c index.
+/*! \brief Return whether the GPU with given \c index is compatible, ie suitable for use.
*
* \param[in] gpu_info pointer to structure holding GPU information
* \param[in] index index of GPU to ask about
- * \returns A e_gpu_detect_res_t value describing the status
+ * \returns Whether the GPU is compatible.
*/
GPU_FUNC_QUALIFIER
-int getGpuCompatibilityStatus(const gmx_gpu_info_t *GPU_FUNC_ARGUMENT(gpu_info),
- int GPU_FUNC_ARGUMENT(index)) GPU_FUNC_TERM_WITH_RETURN(-1)
+bool isGpuCompatible(const gmx_gpu_info_t *GPU_FUNC_ARGUMENT(gpu_info),
+ int GPU_FUNC_ARGUMENT(index)) GPU_FUNC_TERM_WITH_RETURN(false)
+
+/*! \brief Return a string describing how compatible the GPU with given \c index is.
+ *
+ * \param[in] gpu_info pointer to structure holding GPU information
+ * \param[in] index index of GPU to ask about
+ * \returns A null-terminated C string describing the compatibility status, useful for error messages.
+ */
+GPU_FUNC_QUALIFIER
+const char *getGpuCompatibilityDescription(const gmx_gpu_info_t *GPU_FUNC_ARGUMENT(gpu_info),
+ int GPU_FUNC_ARGUMENT(index)) GPU_FUNC_TERM_WITH_RETURN("")
/*! \brief Frees the gpu_dev and dev_use array fields of \p gpu_info.
*
}
//! This function is documented in the header file
-int getGpuCompatibilityStatus(const gmx_gpu_info_t *gpu_info,
- int index)
+bool isGpuCompatible(const gmx_gpu_info_t *gpu_info,
+ int index)
{
assert(gpu_info);
- return (index >= gpu_info->n_dev) ? egpuNonexistent : gpu_info->gpu_dev[index].stat;
+ return (index >= gpu_info->n_dev ?
+ false :
+ gpu_info->gpu_dev[index].stat == egpuCompatible);
+}
+
+//! This function is documented in the header file
+const char *getGpuCompatibilityDescription(const gmx_gpu_info_t *gpu_info,
+ int index)
+{
+ assert(gpu_info);
+
+ return (index >= gpu_info->n_dev ?
+ gpu_detect_res_str[egpuNonexistent] :
+ gpu_detect_res_str[gpu_info->gpu_dev[index].stat]);
}
//! This function is documented in the header file
};
static const bool bMultiGpuPerNodeSupported = multiGpuSupport[GMX_GPU];
+// TODO If/when we unify CUDA and OpenCL support code, this should
+// move to a single place in gpu_utils.
/* Names of the GPU detection/check results (see e_gpu_detect_res_t in hw_info.h). */
const char * const gpu_detect_res_str[egpuNR] =
{
GMX_ASSERT(gpu_opt->dev_use, "Invalid gpu_opt->dev_use");
int id = gpu_opt->dev_use[i];
- int status = getGpuCompatibilityStatus(gpu_info, id);
- if (status != egpuCompatible)
+ if (!isGpuCompatible(gpu_info, id))
{
allOK = false;
message += gmx::formatString(" GPU #%d: %s\n",
id,
- gpu_detect_res_str[status]);
+ getGpuCompatibilityDescription(gpu_info, id));
}
}
if (!allOK && errorMessage)
for (int i = 0; i < gpu_info->n_dev; i++)
{
GMX_ASSERT(gpu_info->gpu_dev, "Invalid gpu_info->gpu_dev");
- if (getGpuCompatibilityStatus(gpu_info, i) == egpuCompatible)
+ if (isGpuCompatible(gpu_info, i))
{
gpu_opt->dev_compatible[gpu_opt->n_dev_compatible] = i;
gpu_opt->n_dev_compatible++;