add c-library interface and export to python

This commit is contained in:
Axel Kohlmeyer
2021-01-12 20:10:47 -05:00
parent 2b1a93bd15
commit 3d3590f02d
3 changed files with 55 additions and 0 deletions

View File

@ -243,6 +243,7 @@ class lammps(object):
self.lib.lammps_encode_image_flags.restype = self.c_imageint 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_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] 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 @property
def installed_packages(self): def installed_packages(self):
""" List of the names of enabled packages in the LAMMPS shared library """ List of the names of enabled packages in the LAMMPS shared library

View File

@ -4303,6 +4303,31 @@ int lammps_config_package_name(int idx, char *buffer, int buf_size) {
return 1; 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 <Speed_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 /** Check if a specific style has been included in LAMMPS

View File

@ -195,6 +195,8 @@ int lammps_config_has_package(const char *);
int lammps_config_package_count(); int lammps_config_package_count();
int lammps_config_package_name(int, char *, int); 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_has_style(void *, const char *, const char *);
int lammps_style_count(void *, const char *); int lammps_style_count(void *, const char *);
int lammps_style_name(void *, const char *, int, char *, int); int lammps_style_name(void *, const char *, int, char *, int);