From c5298c24be997b3a3787cb0504f5e0ec2e5af076 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 11 Jan 2021 11:08:22 -0500 Subject: [PATCH] start creating API for querying accelerator package features --- src/info.cpp | 41 +++++++++++++++++++++++++++++++++++++++-- src/info.h | 5 ++++- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/info.cpp b/src/info.cpp index bb3111cb69..8e181a79ed 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -1120,15 +1120,52 @@ bool Info::has_exceptions() { #endif } -bool Info::has_package(const char * package_name) { +bool Info::has_package(const std::string &package_name) { for (int i = 0; LAMMPS::installed_packages[i] != nullptr; ++i) { - if (strcmp(package_name, LAMMPS::installed_packages[i]) == 0) { + if (package_name == LAMMPS::installed_packages[i]) { return true; } } return false; } +bool Info::has_accelerator_feature(const std::string &package, + const std::string &category, + const std::string &setting) +{ +#if defined(LMP_KOKKOS) + if (package == "KOKKOS") { + if (category == "precision") { + if (setting == "double") return true; + else return false; + } + } +#endif +#if defined(LMP_GPU) + if (package == "GPU") { + } +#endif +#if defined(LMP_USER_OMP) + if (package == "OPENMP") { + if (category == "precision") { + if (setting == "double") return true; + else return false; + } + } +#endif +#if defined(LMP_USER_INTEL) + if (package == "INTEL") { + if (category == "precision") { + if (setting == "double") return true; + else if (setting == "mixed") return true; + else if (setting == "single")return true; + else return false; + } + } +#endif + return false; +} + /* ---------------------------------------------------------------------- */ #define _INFOBUF_SIZE 256 diff --git a/src/info.h b/src/info.h index e14a2be8db..d8fa23489e 100644 --- a/src/info.h +++ b/src/info.h @@ -43,7 +43,10 @@ class Info : protected Pointers { static bool has_jpeg_support(); static bool has_ffmpeg_support(); static bool has_exceptions(); - static bool has_package(const char * package_name); + static bool has_package(const std::string &); + static bool has_accelerator_feature(const std::string &, + const std::string &, + const std::string &); static std::string get_os_info(); static std::string get_compiler_info();