implement accelerator introspection for GPU package
This commit is contained in:
@ -783,3 +783,39 @@ double lmp_gpu_forces(double **f, double **tor, double *eatom,
|
|||||||
double **vatom, double *virial, double &ecoul) {
|
double **vatom, double *virial, double &ecoul) {
|
||||||
return global_device.fix_gpu(f,tor,eatom,vatom,virial,ecoul);
|
return global_device.fix_gpu(f,tor,eatom,vatom,virial,ecoul);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lmp_gpu_config(const std::string &category, const std::string &setting)
|
||||||
|
{
|
||||||
|
if (category == "api") {
|
||||||
|
#if defined(USE_OPENCL)
|
||||||
|
return setting == "opencl";
|
||||||
|
#elif defined(USE_HIP)
|
||||||
|
return setting == "hip";
|
||||||
|
#elif defined(USE_CUDA)
|
||||||
|
return setting == "cuda";
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (category == "precision") {
|
||||||
|
if (setting == "single") {
|
||||||
|
#if defined(_SINGLE_SINGLE)
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
} else if (setting == "mixed") {
|
||||||
|
#if defined(_SINGLE_DOUBLE)
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
} else if (setting == "double") {
|
||||||
|
#if defined(_DOUBLE_DOUBLE)
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
25
src/info.cpp
25
src/info.cpp
@ -94,6 +94,7 @@ enum {COMPUTES=1<<0,
|
|||||||
REGION_STYLES=1<<23,
|
REGION_STYLES=1<<23,
|
||||||
DUMP_STYLES=1<<24,
|
DUMP_STYLES=1<<24,
|
||||||
COMMAND_STYLES=1<<25,
|
COMMAND_STYLES=1<<25,
|
||||||
|
ACCELERATOR=1<<26,
|
||||||
ALL=~0};
|
ALL=~0};
|
||||||
|
|
||||||
static const int STYLES = ATOM_STYLES | INTEGRATE_STYLES | MINIMIZE_STYLES
|
static const int STYLES = ATOM_STYLES | INTEGRATE_STYLES | MINIMIZE_STYLES
|
||||||
@ -198,6 +199,9 @@ void Info::command(int narg, char **arg)
|
|||||||
} else if (strncmp(arg[idx],"coeffs",3) == 0) {
|
} else if (strncmp(arg[idx],"coeffs",3) == 0) {
|
||||||
flags |= COEFFS;
|
flags |= COEFFS;
|
||||||
++idx;
|
++idx;
|
||||||
|
} else if (strncmp(arg[idx],"accelerator",3) == 0) {
|
||||||
|
flags |= ACCELERATOR;
|
||||||
|
++idx;
|
||||||
} else if (strncmp(arg[idx],"styles",3) == 0) {
|
} else if (strncmp(arg[idx],"styles",3) == 0) {
|
||||||
if (idx+1 < narg) {
|
if (idx+1 < narg) {
|
||||||
++idx;
|
++idx;
|
||||||
@ -314,6 +318,22 @@ void Info::command(int narg, char **arg)
|
|||||||
fputs("\n",out);
|
fputs("\n",out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & ACCELERATOR) {
|
||||||
|
fputs("\nAccelerator configuration:\n\n",out);
|
||||||
|
std::string mesg;
|
||||||
|
if (has_package("GPU")) {
|
||||||
|
mesg = "GPU package API: ";
|
||||||
|
if (has_accelerator_feature("GPU","api","cuda")) mesg += "CUDA\n";
|
||||||
|
if (has_accelerator_feature("GPU","api","hip")) mesg += "HIP\n";
|
||||||
|
if (has_accelerator_feature("GPU","api","opencl")) mesg += "OpenCL\n";
|
||||||
|
mesg += "GPU package precision: ";
|
||||||
|
if (has_accelerator_feature("GPU","precision","single")) mesg += "single\n";
|
||||||
|
if (has_accelerator_feature("GPU","precision","mixed")) mesg += "mixed\n";
|
||||||
|
if (has_accelerator_feature("GPU","precision","double")) mesg += "double\n";
|
||||||
|
fputs(mesg.c_str(),out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & MEMORY) {
|
if (flags & MEMORY) {
|
||||||
double meminfo[3];
|
double meminfo[3];
|
||||||
|
|
||||||
@ -1129,6 +1149,10 @@ bool Info::has_package(const std::string &package_name) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(LMP_GPU)
|
||||||
|
extern bool lmp_gpu_config(const std::string &, const std::string &);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool Info::has_accelerator_feature(const std::string &package,
|
bool Info::has_accelerator_feature(const std::string &package,
|
||||||
const std::string &category,
|
const std::string &category,
|
||||||
const std::string &setting)
|
const std::string &setting)
|
||||||
@ -1143,6 +1167,7 @@ bool Info::has_accelerator_feature(const std::string &package,
|
|||||||
#endif
|
#endif
|
||||||
#if defined(LMP_GPU)
|
#if defined(LMP_GPU)
|
||||||
if (package == "GPU") {
|
if (package == "GPU") {
|
||||||
|
return lmp_gpu_config(category,setting);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(LMP_USER_OMP)
|
#if defined(LMP_USER_OMP)
|
||||||
|
|||||||
Reference in New Issue
Block a user