Report only compatible GPU, i.e. no GPU if mixed/double precision is requested by the hardware does not support it

This commit is contained in:
Axel Kohlmeyer
2021-10-13 21:15:16 -04:00
parent c322064ff3
commit afad3f42d5
3 changed files with 15 additions and 5 deletions

View File

@ -1039,10 +1039,18 @@ Device<PRECISION,ACC_PRECISION> global_device;
using namespace LAMMPS_AL;
bool lmp_has_gpu_device()
// check if a suitable GPU is present.
// for mixed and double precision GPU library compilation
// also the GPU needs to support double precision.
bool lmp_has_compatible_gpu_device()
{
UCL_Device gpu;
return (gpu.num_platforms() > 0);
bool compatible_gpu = gpu.num_platforms() > 0;
#if defined(_SINGLE_DOUBLE) || defined(_DOUBLE_DOUBLE)
if (!gpu.double_precision(0))
compatible_gpu = false;
#endif
return compatible_gpu;
}
std::string lmp_gpu_device_info()

View File

@ -1146,12 +1146,14 @@ bool Info::has_package(const std::string &package_name) {
#if defined(LMP_GPU)
extern bool lmp_gpu_config(const std::string &, const std::string &);
extern bool lmp_has_gpu_device();
extern bool lmp_has_compatible_gpu_device();
extern std::string lmp_gpu_device_info();
// we will only report compatible GPUs, i.e. when a GPU device is
// available *and* supports the required floating point precision
bool Info::has_gpu_device()
{
return lmp_has_gpu_device();
return lmp_has_compatible_gpu_device();
}
std::string Info::get_gpu_device_info()

View File

@ -1340,7 +1340,7 @@ void LAMMPS::print_config(FILE *fp)
fmt::print(fp,"Accelerator configuration:\n\n{}\n",
Info::get_accelerator_info());
#if defined(LMP_GPU)
fmt::print(fp,"GPU present: {}\n\n",Info::has_gpu_device() ? "yes" : "no");
fmt::print(fp,"Compatible GPU present: {}\n\n",Info::has_gpu_device() ? "yes" : "no");
#endif
fputs("Active compile time flags:\n\n",fp);