From a2d7d47cac6738b7718c1d5d56379352e0881011 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 16 Jan 2021 17:12:29 -0500 Subject: [PATCH] add unittest for python interface of accelerator config introspection --- unittest/python/python-capabilities.py | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/unittest/python/python-capabilities.py b/unittest/python/python-capabilities.py index 2b47b8ca90..372eecc869 100644 --- a/unittest/python/python-capabilities.py +++ b/unittest/python/python-capabilities.py @@ -123,5 +123,40 @@ class PythonCapabilities(unittest.TestCase): self.lmp.command('run 10') self.assertEqual(self.lmp.extract_global('ntimestep'),20) + def test_accelerator_config(self): + + settings = self.lmp.accelerator_config + if self.cmake_cache['PKG_USER-OMP']: + if self.cmake_cache['BUILD_OMP']: + self.assertIn('openmp',settings['USER-OMP']['api']) + else: + self.assertIn('serial',settings['USER-OMP']['api']) + self.assertIn('double',settings['USER-OMP']['precision']) + + if self.cmake_cache['PKG_USER-INTEL']: + if 'LMP_INTEL_OFFLOAD' in self.cmake_cache.keys(): + self.assertIn('phi',settings['USER-INTEL']['api']) + elif self.cmake_cache['BUILD_OMP']: + self.assertIn('openmp',settings['USER-INTEL']['api']) + else: + self.assertIn('serial',settings['USER-INTEL']['api']) + self.assertIn('double',settings['USER-INTEL']['precision']) + self.assertIn('mixed',settings['USER-INTEL']['precision']) + self.assertIn('single',settings['USER-INTEL']['precision']) + + if self.cmake_cache['PKG_GPU']: + if self.cmake_cache['GPU_API'].lower() == 'opencl': + self.assertIn('opencl',settings['GPU']['api']) + if self.cmake_cache['GPU_API'].lower() == 'cuda': + self.assertIn('cuda',settings['GPU']['api']) + if self.cmake_cache['GPU_API'].lower() == 'hip': + self.assertIn('hip',settings['GPU']['api']) + if self.cmake_cache['GPU_PREC'].lower() == 'double': + self.assertIn('double',settings['GPU']['precision']) + if self.cmake_cache['GPU_PREC'].lower() == 'mixed': + self.assertIn('mixed',settings['GPU']['precision']) + if self.cmake_cache['GPU_PREC'].lower() == 'single': + self.assertIn('single',settings['GPU']['precision']) + if __name__ == "__main__": unittest.main()