finalize available GPU hardware introspection functions
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
#include <map>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#if (LAL_USE_OMP == 1)
|
||||
#include <omp.h>
|
||||
#endif
|
||||
@ -1027,12 +1028,19 @@ Device<PRECISION,ACC_PRECISION> global_device;
|
||||
|
||||
using namespace LAMMPS_AL;
|
||||
|
||||
bool lmp_has_device()
|
||||
bool lmp_has_gpu_device()
|
||||
{
|
||||
auto tmpgpu = new UCL_Device();
|
||||
int num = tmpgpu->num_platforms();
|
||||
delete tmpgpu;
|
||||
return num > 0;
|
||||
UCL_Device gpu;
|
||||
return (gpu.num_platforms() > 0);
|
||||
}
|
||||
|
||||
std::string lmp_gpu_device_info()
|
||||
{
|
||||
std::ostringstream out;
|
||||
UCL_Device gpu;
|
||||
if (gpu.num_platforms() > 0)
|
||||
gpu.print_all(out);
|
||||
return out.str();
|
||||
}
|
||||
|
||||
int lmp_init_device(MPI_Comm world, MPI_Comm replica, const int ngpu,
|
||||
|
||||
17
src/info.cpp
17
src/info.cpp
@ -320,7 +320,8 @@ void Info::command(int narg, char **arg)
|
||||
if (flags & ACCELERATOR) {
|
||||
fmt::print(out,"\nAccelerator configuration:\n\n{}",
|
||||
get_accelerator_info());
|
||||
fmt::print(out,"\nGPU present: {}\n",has_gpu_device() ? "yes" : "no");
|
||||
if (Info::has_gpu_device())
|
||||
fmt::print(out,"\nAvailable GPU devices:\n{}\n",get_gpu_device_info());
|
||||
}
|
||||
|
||||
if (flags & MEMORY) {
|
||||
@ -1140,17 +1141,27 @@ 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_device();
|
||||
extern bool lmp_has_gpu_device();
|
||||
extern std::string lmp_gpu_device_info();
|
||||
|
||||
bool Info::has_gpu_device()
|
||||
{
|
||||
return lmp_has_device();
|
||||
return lmp_has_gpu_device();
|
||||
}
|
||||
|
||||
std::string Info::get_gpu_device_info()
|
||||
{
|
||||
return lmp_gpu_device_info();
|
||||
}
|
||||
#else
|
||||
bool Info::has_gpu_device()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
std::string Info::get_gpu_device_info()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LMP_KOKKOS)
|
||||
|
||||
@ -48,6 +48,7 @@ class Info : public Command {
|
||||
const std::string &,
|
||||
const std::string &);
|
||||
static bool has_gpu_device();
|
||||
static std::string get_gpu_device_info();
|
||||
|
||||
static std::string get_os_info();
|
||||
static std::string get_compiler_info();
|
||||
|
||||
@ -1328,6 +1328,7 @@ void LAMMPS::print_config(FILE *fp)
|
||||
|
||||
fmt::print(fp,"Accelerator configuration:\n\n{}\n",
|
||||
Info::get_accelerator_info());
|
||||
fmt::print(fp,"GPU present: {}\n\n",Info::has_gpu_device() ? "yes" : "no");
|
||||
|
||||
fputs("Active compile time flags:\n\n",fp);
|
||||
if (Info::has_gzip_support()) fputs("-DLAMMPS_GZIP\n",fp);
|
||||
|
||||
Reference in New Issue
Block a user