From 02f9b0790e036536831b3569fda6add1c3db5662 Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Tue, 16 Nov 2021 22:55:13 +0000 Subject: [PATCH 01/12] Create armccompiler.py From https://gitlab.com/arm-hpc/packages/-/wikis/packages/numpy Added `-fPIC` due to relocation errors when building shared library from static library such as quadmath. --- numpy/distutils/armccompiler.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 numpy/distutils/armccompiler.py diff --git a/numpy/distutils/armccompiler.py b/numpy/distutils/armccompiler.py new file mode 100644 index 000000000000..92385e905c5a --- /dev/null +++ b/numpy/distutils/armccompiler.py @@ -0,0 +1,23 @@ +from __future__ import division, absolute_import, print_function + +from distutils.unixccompiler import UnixCCompiler + +class ArmCCompiler(UnixCCompiler): + + """ + Arm compiler. + """ + + compiler_type = 'arm' + cc_exe = 'armclang' + cxx_exe = 'armclang++' + + def __init__ (self, verbose=0, dry_run=0, force=0): + UnixCCompiler.__init__ (self, verbose, dry_run, force) + cc_compiler = self.cc_exe + cxx_compiler = self.cxx_exe + self.set_executables(compiler=cc_compiler + ' -mcpu=native -O3 -fPIC', + compiler_so=cc_compiler + ' -mcpu=native -O3 -fPIC', + compiler_cxx=cxx_compiler + ' -mcpu=native -O3 -fPIC', + linker_exe=cc_compiler + ' -lamath', + linker_so=cc_compiler + ' -lamath -shared') From 906aa1c003a18fbf10216a9a1060da96d8101289 Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Tue, 16 Nov 2021 22:57:12 +0000 Subject: [PATCH 02/12] Update ccompiler.py Added ARM compiler. --- numpy/distutils/ccompiler.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index ef1744db2848..16f00d8edf17 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -708,6 +708,9 @@ def CCompiler_cxx_compiler(self): "Intel C Compiler for 64-bit applications on Windows") compiler_class['pathcc'] = ('pathccompiler', 'PathScaleCCompiler', "PathScale Compiler for SiCortex-based applications") +compiler_class['arm'] = ('armccompiler', 'ArmCCompiler', + "Arm C Compiler") + ccompiler._default_compilers += (('linux.*', 'intel'), ('linux.*', 'intele'), ('linux.*', 'intelem'), From 9f83930370fe9553448a856453fc38dc7c1ee017 Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Tue, 16 Nov 2021 22:58:25 +0000 Subject: [PATCH 03/12] Update __init__.py --- numpy/distutils/fcompiler/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py index c333517c0f80..94b6c2a3cfba 100644 --- a/numpy/distutils/fcompiler/__init__.py +++ b/numpy/distutils/fcompiler/__init__.py @@ -743,7 +743,7 @@ def wrap_unlinkable_objects(self, objects, output_dir, extra_dll_dir): ('win32', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang')), ('cygwin.*', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95')), - ('linux.*', ('gnu95', 'intel', 'lahey', 'pg', 'nv', 'absoft', 'nag', 'vast', 'compaq', + ('linux.*', ('arm', 'gnu95', 'intel', 'lahey', 'pg', 'nv', 'absoft', 'nag', 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor', 'fujitsu')), ('darwin.*', ('gnu95', 'nag', 'nagfor', 'absoft', 'ibm', 'intel', 'gnu', 'g95', 'pg')), From 4061f20f43645029e418d15f76d2e8d51610d759 Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Tue, 16 Nov 2021 23:01:36 +0000 Subject: [PATCH 04/12] Create arm.py Added `-fPIC` due to relocation errors. --- numpy/distutils/fcompiler/arm.py | 73 ++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 numpy/distutils/fcompiler/arm.py diff --git a/numpy/distutils/fcompiler/arm.py b/numpy/distutils/fcompiler/arm.py new file mode 100644 index 000000000000..bc491d947b29 --- /dev/null +++ b/numpy/distutils/fcompiler/arm.py @@ -0,0 +1,73 @@ +from __future__ import division, absolute_import, print_function + +import sys + +from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file +from sys import platform +from os.path import join, dirname, normpath + +compilers = ['ArmFlangCompiler'] + +import functools + +class ArmFlangCompiler(FCompiler): + compiler_type = 'arm' + description = 'Arm Compiler' + version_pattern = r'\s*Arm.*version (?P[\d.-]+).*' + + ar_exe = 'lib.exe' + possible_executables = ['armflang'] + + executables = { + 'version_cmd': ["", "--version"], + 'compiler_f77': ["armflang", "-fPIC"], + 'compiler_fix': ["armflang", "-fPIC", "-ffixed-form"], + 'compiler_f90': ["armflang", "-fPIC"], + 'linker_so': ["armflang", "-fPIC", "-shared"], + 'archiver': ["ar", "-cr"], + 'ranlib': None + } + + pic_flags = ["-fPIC", "-DPIC"] + c_compiler = 'arm' + module_dir_switch = '-module ' # Don't remove ending space! + + def get_libraries(self): + opt = FCompiler.get_libraries(self) + opt.extend(['flang', 'flangrti', 'ompstub']) + return opt + + @functools.lru_cache(maxsize=128) + def get_library_dirs(self): + """List of compiler library directories.""" + opt = FCompiler.get_library_dirs(self) + flang_dir = dirname(self.executables['compiler_f77'][0]) + opt.append(normpath(join(flang_dir, '..', 'lib'))) + + return opt + + def get_flags(self): + return [] + + def get_flags_free(self): + return [] + + def get_flags_debug(self): + return ['-g'] + + def get_flags_opt(self): + return ['-O3'] + + def get_flags_arch(self): + return [] + + def runtime_library_dir_option(self, dir): + return '-Wl,-rpath=%s' % dir + + +if __name__ == '__main__': + from distutils import log + log.set_verbosity(2) + from numpy.distutils import customized_fcompiler + print(customized_fcompiler(compiler='armflang').get_version()) + From e48bb670e7245b1dfa6353e83c63179591e9c91f Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Tue, 16 Nov 2021 23:12:53 +0000 Subject: [PATCH 05/12] Add armpl as blas/lapack provider Add support for ARMPL - requires ARMPL_DIR set - product page https://www.arm.com/products/development-tools/server-and-hpc/allinea-studio/performance-libraries --- numpy/distutils/system_info.py | 60 ++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index 7f41bb07e06c..2818d8179f3f 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -501,7 +501,11 @@ def get_info(name, notfound_action=0): 1 - display warning message 2 - raise error """ - cl = {'atlas': atlas_info, # use lapack_opt or blas_opt instead + cl = {'armpl': armpl_info, + 'blas_armpl': blas_armpl_info, + 'lapack_armpl': lapack_armpl_info, + 'fftw3_armpl' : fftw3_armpl_info, + 'atlas': atlas_info, # use lapack_opt or blas_opt instead 'atlas_threads': atlas_threads_info, # ditto 'atlas_blas': atlas_blas_info, 'atlas_blas_threads': atlas_blas_threads_info, @@ -1152,6 +1156,17 @@ class fftw3_info(fftw_info): 'macros':[('SCIPY_FFTW3_H', None)]}, ] + +class fftw3_armpl_info(fftw_info): + section = 'fftw3' + dir_env_var = 'ARMPL_DIR' + notfounderror = FFTWNotFoundError + ver_info = [{'name':'fftw3', + 'libs':['armpl_lp64_mp'], + 'includes':['fftw3.h'], + 'macros':[('SCIPY_FFTW3_H', None)]}, + ] + class dfftw_info(fftw_info): section = 'fftw' @@ -1311,6 +1326,31 @@ class blas_mkl_info(mkl_info): pass +class armpl_info(system_info): + section = 'armpl' + dir_env_var = 'ARMPL_DIR' + _lib_armpl = ['armpl_lp64_mp'] + + def calc_info(self): + lib_dirs = self.get_lib_dirs() + incl_dirs = self.get_include_dirs() + armpl_libs = self.get_libs('armpl_libs', self._lib_armpl) + info = self.check_libs2(lib_dirs, armpl_libs) + if info is None: + return + dict_append(info, + define_macros=[('SCIPY_MKL_H', None), + ('HAVE_CBLAS', None)], + include_dirs=incl_dirs) + self.set_info(**info) + +class lapack_armpl_info(armpl_info): + pass + +class blas_armpl_info(armpl_info): + pass + + class atlas_info(system_info): section = 'atlas' dir_env_var = 'ATLAS' @@ -1748,9 +1788,16 @@ class lapack_opt_info(system_info): notfounderror = LapackNotFoundError # List of all known LAPACK libraries, in the default order - lapack_order = ['mkl', 'openblas', 'flame', + lapack_order = ['armpl', 'mkl', 'openblas', 'flame', 'accelerate', 'atlas', 'lapack'] order_env_var_name = 'NPY_LAPACK_ORDER' + + def _calc_info_armpl(self): + info = get_info('lapack_armpl') + if info: + self.set_info(**info) + return True + return False def _calc_info_mkl(self): info = get_info('lapack_mkl') @@ -1925,9 +1972,16 @@ class blas_opt_info(system_info): notfounderror = BlasNotFoundError # List of all known BLAS libraries, in the default order - blas_order = ['mkl', 'blis', 'openblas', + blas_order = ['armpl', 'mkl', 'blis', 'openblas', 'accelerate', 'atlas', 'blas'] order_env_var_name = 'NPY_BLAS_ORDER' + + def _calc_info_armpl(self): + info = get_info('blas_armpl') + if info: + self.set_info(**info) + return True + return False def _calc_info_mkl(self): info = get_info('blas_mkl') From 56ee153658ffc29ff6a3cea690ace8200a0daf65 Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Thu, 18 Nov 2021 21:40:52 +0000 Subject: [PATCH 06/12] Update setup.py Force version in setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 703fe79e1694..68d074a9cf14 100755 --- a/setup.py +++ b/setup.py @@ -47,6 +47,7 @@ # The version components are changed from ints to strings, but only VERSION # seems to matter outside of this module and it was already a str. FULLVERSION = versioneer.get_version() +FULLVERSION = "1.22.0" # Capture the version string: # 1.22.0.dev0+ ... -> ISRELEASED == False, VERSION == 1.22.0 From 34b81956f2b824b5fb6ada5639a8d504227847cc Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Fri, 19 Nov 2021 22:32:19 +0000 Subject: [PATCH 07/12] Update setup.py Revert version forcing. --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 68d074a9cf14..703fe79e1694 100755 --- a/setup.py +++ b/setup.py @@ -47,7 +47,6 @@ # The version components are changed from ints to strings, but only VERSION # seems to matter outside of this module and it was already a str. FULLVERSION = versioneer.get_version() -FULLVERSION = "1.22.0" # Capture the version string: # 1.22.0.dev0+ ... -> ISRELEASED == False, VERSION == 1.22.0 From e6744fee7106a959ae603f122fbe1a60cdd7dd24 Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Thu, 2 Dec 2021 23:11:50 +0000 Subject: [PATCH 08/12] Update system_info.py --- numpy/distutils/system_info.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index 2818d8179f3f..d5a1687da322 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -504,7 +504,7 @@ def get_info(name, notfound_action=0): cl = {'armpl': armpl_info, 'blas_armpl': blas_armpl_info, 'lapack_armpl': lapack_armpl_info, - 'fftw3_armpl' : fftw3_armpl_info, + 'fftw3_armpl': fftw3_armpl_info, 'atlas': atlas_info, # use lapack_opt or blas_opt instead 'atlas_threads': atlas_threads_info, # ditto 'atlas_blas': atlas_blas_info, @@ -1161,11 +1161,10 @@ class fftw3_armpl_info(fftw_info): section = 'fftw3' dir_env_var = 'ARMPL_DIR' notfounderror = FFTWNotFoundError - ver_info = [{'name':'fftw3', - 'libs':['armpl_lp64_mp'], - 'includes':['fftw3.h'], - 'macros':[('SCIPY_FFTW3_H', None)]}, - ] + ver_info = [{'name': 'fftw3', + 'libs': ['armpl_lp64_mp'], + 'includes': ['fftw3.h'], + 'macros': [('SCIPY_FFTW3_H', None)]}] class dfftw_info(fftw_info): From 311ab52488a7d096ac3bc4c2de0fdae17ecd13ef Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Thu, 2 Dec 2021 23:18:00 +0000 Subject: [PATCH 09/12] Update armccompiler.py --- numpy/distutils/armccompiler.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/numpy/distutils/armccompiler.py b/numpy/distutils/armccompiler.py index 92385e905c5a..feb8f7e31194 100644 --- a/numpy/distutils/armccompiler.py +++ b/numpy/distutils/armccompiler.py @@ -12,12 +12,17 @@ class ArmCCompiler(UnixCCompiler): cc_exe = 'armclang' cxx_exe = 'armclang++' - def __init__ (self, verbose=0, dry_run=0, force=0): - UnixCCompiler.__init__ (self, verbose, dry_run, force) + def __init__(self, verbose=0, dry_run=0, force=0): + UnixCCompiler.__init__(self, verbose, dry_run, force) cc_compiler = self.cc_exe cxx_compiler = self.cxx_exe - self.set_executables(compiler=cc_compiler + ' -mcpu=native -O3 -fPIC', - compiler_so=cc_compiler + ' -mcpu=native -O3 -fPIC', - compiler_cxx=cxx_compiler + ' -mcpu=native -O3 -fPIC', - linker_exe=cc_compiler + ' -lamath', - linker_so=cc_compiler + ' -lamath -shared') + self.set_executables(compiler=cc_compiler + + ' -mcpu=native -O3 -fPIC', + compiler_so=cc_compiler + + ' -mcpu=native -O3 -fPIC', + compiler_cxx=cxx_compiler + + ' -mcpu=native -O3 -fPIC', + linker_exe=cc_compiler + + ' -lamath', + linker_so=cc_compiler + + ' -lamath -shared') From 7662c0789cc6a70d5ad4d950ee2e95f3afef7df6 Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Thu, 2 Dec 2021 23:22:19 +0000 Subject: [PATCH 10/12] Update __init__.py --- numpy/distutils/fcompiler/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py index 94b6c2a3cfba..d8dcfa8994e1 100644 --- a/numpy/distutils/fcompiler/__init__.py +++ b/numpy/distutils/fcompiler/__init__.py @@ -743,8 +743,9 @@ def wrap_unlinkable_objects(self, objects, output_dir, extra_dll_dir): ('win32', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang')), ('cygwin.*', ('gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95')), - ('linux.*', ('arm', 'gnu95', 'intel', 'lahey', 'pg', 'nv', 'absoft', 'nag', 'vast', 'compaq', - 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor', 'fujitsu')), + ('linux.*', ('arm', 'gnu95', 'intel', 'lahey', 'pg', 'nv', 'absoft', 'nag', + 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', + 'pathf95', 'nagfor', 'fujitsu')), ('darwin.*', ('gnu95', 'nag', 'nagfor', 'absoft', 'ibm', 'intel', 'gnu', 'g95', 'pg')), ('sunos.*', ('sun', 'gnu', 'gnu95', 'g95')), From d93b14e3d7abaa1d837825e51671f817788e120f Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Thu, 2 Dec 2021 23:27:50 +0000 Subject: [PATCH 11/12] Update test_public_api.py --- numpy/tests/test_public_api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index 0754df402d5a..bb15e10e8241 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -189,6 +189,7 @@ def test_NPY_NO_EXPORT(): "core.shape_base", "core.umath", "core.umath_tests", + "distutils.armccompiler", "distutils.ccompiler", 'distutils.ccompiler_opt', "distutils.command", @@ -214,6 +215,7 @@ def test_NPY_NO_EXPORT(): "distutils.extension", "distutils.fcompiler", "distutils.fcompiler.absoft", + "distutils.fcompiler.arm", "distutils.fcompiler.compaq", "distutils.fcompiler.environment", "distutils.fcompiler.g95", From 794b36f7e1bf2a8c42774ab0db86a74bd32f674b Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Tue, 14 Dec 2021 22:51:23 +0000 Subject: [PATCH 12/12] Update armccompiler.py Remove `-mcpu=native` since it should be decided by the configuration. --- numpy/distutils/armccompiler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/numpy/distutils/armccompiler.py b/numpy/distutils/armccompiler.py index feb8f7e31194..968504c7b4c1 100644 --- a/numpy/distutils/armccompiler.py +++ b/numpy/distutils/armccompiler.py @@ -17,11 +17,11 @@ def __init__(self, verbose=0, dry_run=0, force=0): cc_compiler = self.cc_exe cxx_compiler = self.cxx_exe self.set_executables(compiler=cc_compiler + - ' -mcpu=native -O3 -fPIC', + ' -O3 -fPIC', compiler_so=cc_compiler + - ' -mcpu=native -O3 -fPIC', + ' -O3 -fPIC', compiler_cxx=cxx_compiler + - ' -mcpu=native -O3 -fPIC', + ' -O3 -fPIC', linker_exe=cc_compiler + ' -lamath', linker_so=cc_compiler +