diff --git a/python/lammps/core.py b/python/lammps/core.py index c0cbaac533..01a3cce842 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -243,6 +243,7 @@ class lammps(object): self.lib.lammps_encode_image_flags.restype = self.c_imageint self.lib.lammps_config_package_name.argtypes = [c_int, c_char_p, c_int] + self.lib.lammps_config_accelerator.argtypes = [c_char_p, c_char_p, c_char_p] self.lib.lammps_set_variable.argtypes = [c_void_p, c_char_p, c_char_p] @@ -1435,6 +1436,33 @@ class lammps(object): # ------------------------------------------------------------------------- + @property + def accelerator_config(self): + """ Return table with available accelerator configuration settings. + + This is a wrapper around the :cpp:func:`lammps_config_accelerator` + function of the library interface which loops over all known packages + and settings and returns enabled features as a nested dictionary. + + :return: nested dictionary with all known enabled settings + :rtype: dictionary + """ + + result = {} + for p in [b'GPU', b'KOKKOS', b'USER-INTEL', b'USER-OMP']: + c = b'api' + result[p.decode()] = {} + for s in [b'cuda', b'hip', b'pthreads', b'opencl', b'openmp']: + if self.lib.lammps_config_accelerator(p,c,s): + result[p.decode()][c.decode()] = s.decode() + c = b'precision' + for s in [b'double', b'mixed', b'single']: + if self.lib.lammps_config_accelerator(p,c,s): + result[p.decode()][c.decode()] = s.decode() + return result + + # ------------------------------------------------------------------------- + @property def installed_packages(self): """ List of the names of enabled packages in the LAMMPS shared library diff --git a/src/library.cpp b/src/library.cpp index 7d3f2f8996..a4cfee979a 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -4303,6 +4303,31 @@ int lammps_config_package_name(int idx, char *buffer, int buf_size) { return 1; } +/** Check for compile time settings in accelerator packages included in LAMMPS. + * +\verbatim embed:rst +This function checks availability of compile time settings of included +:doc:`accelerator packages ` in LAMMPS. +Supported packages names are "GPU", "KOKKOS", "USER-INTEL", and "USER-OMP". +Supported categories are "api" with possible settings "cuda", "hip", "knl", +"pthreads", "opencl", "openmp", and "none", and "precision" with +possible settings "double", "mixed", and "single". If the combination +of package, category, and setting is available, the function returns 1, +otherwise 0. +\endverbatim + * + * \param package string with the name of the accelerator package + * \param category string with the category name of the setting + * \param setting string with the name of the specific setting + * \return 1 if available, 0 if not. + */ +int lammps_config_accelerator(const char *package, + const char *category, + const char *setting) +{ + return Info::has_accelerator_feature(package,category,setting) ? 1 : 0; +} + /* ---------------------------------------------------------------------- */ /** Check if a specific style has been included in LAMMPS diff --git a/src/library.h b/src/library.h index 14be4064ea..d98bf426b3 100644 --- a/src/library.h +++ b/src/library.h @@ -195,6 +195,8 @@ int lammps_config_has_package(const char *); int lammps_config_package_count(); int lammps_config_package_name(int, char *, int); +int lammps_config_accelerator(const char *, const char *, const char *); + int lammps_has_style(void *, const char *, const char *); int lammps_style_count(void *, const char *); int lammps_style_name(void *, const char *, int, char *, int);