From a30ea66d78955517ecdc6ded659b7711ef5c7c21 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Fri, 9 Feb 2024 15:31:41 +0100 Subject: [PATCH 1/5] explore --- .azure_pipeline.yml | 7 +++++++ threadpoolctl.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/.azure_pipeline.yml b/.azure_pipeline.yml index 99d0f841..bd799feb 100644 --- a/.azure_pipeline.yml +++ b/.azure_pipeline.yml @@ -189,6 +189,13 @@ stages: INSTALL_BLAS: 'flexiblas' CC_OUTER_LOOP: 'clang' CC_INNER_LOOP: 'clang' + pylatest_accelerate: + PACKAGER: 'conda-forge' + PYTHON_VERSION: '*' + BLAS: 'accelerate' + CC_OUTER_LOOP: 'clang' + CC_INNER_LOOP: 'clang' + INSTALL_LIBOMP: 'conda-forge' - stage: jobs: diff --git a/threadpoolctl.py b/threadpoolctl.py index cfebcb5e..ec92d711 100644 --- a/threadpoolctl.py +++ b/threadpoolctl.py @@ -1060,6 +1060,8 @@ def _make_controller_from_path(self, filepath): # (vcomp, VCOMP, Vcomp, ...) filename = os.path.basename(filepath).lower() + print(filename) + # Loop through supported libraries to find if this filename corresponds # to a supported one. for controller_class in _ALL_CONTROLLERS: From 14a3d51a67789632799e69e659674250393f6989 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Fri, 9 Feb 2024 17:35:25 +0100 Subject: [PATCH 2/5] iter --- threadpoolctl.py | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/threadpoolctl.py b/threadpoolctl.py index ec92d711..7f780452 100644 --- a/threadpoolctl.py +++ b/threadpoolctl.py @@ -438,6 +438,29 @@ def _get_threading_layer(self): -1: "not specified", } return layer_map[set_threading_layer(-1)] + + +class AccelerateController(LibController): + """Controller class for Accelerate""" + + user_api = "blas" + internal_api = "accelerate" + filename_prefixes = ("libblas") + check_symbols = ( + "_veclib", + ) + + def set_additional_attributes(self): + self.remark = "Number of threads cannot be changed at runtime." + + def get_num_threads(self): + return "Not available" + + def set_num_threads(self, num_threads): + pass + + def get_version(self): + return None class OpenMPController(LibController): @@ -472,6 +495,7 @@ def get_version(self): MKLController, OpenMPController, FlexiBLASController, + AccelerateController, ] # Helpers for the doc and test names @@ -1060,8 +1084,6 @@ def _make_controller_from_path(self, filepath): # (vcomp, VCOMP, Vcomp, ...) filename = os.path.basename(filepath).lower() - print(filename) - # Loop through supported libraries to find if this filename corresponds # to a supported one. for controller_class in _ALL_CONTROLLERS: @@ -1085,13 +1107,13 @@ def _make_controller_from_path(self, filepath): for func in controller_class.check_symbols ): continue - else: - # We ignore libblas on other platforms than windows because there - # might be a libblas dso comming with openblas for instance that - # can't be used to instantiate a pertinent LibController (many - # symbols are missing) and would create confusion by making a - # duplicate entry in threadpool_info. - continue + # else: + # # We ignore libblas on other platforms than windows because there + # # might be a libblas dso comming with openblas for instance that + # # can't be used to instantiate a pertinent LibController (many + # # symbols are missing) and would create confusion by making a + # # duplicate entry in threadpool_info. + # continue # filename matches a prefix. Now we check if the library has the symbols we # are looking for. If none of the symbols exists, it's very likely not the From e034778ac4af4ca1d0aa6be6907887f7b771af86 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Fri, 9 Feb 2024 17:49:12 +0100 Subject: [PATCH 3/5] iter --- threadpoolctl.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/threadpoolctl.py b/threadpoolctl.py index 7f780452..9ed0c8fd 100644 --- a/threadpoolctl.py +++ b/threadpoolctl.py @@ -438,17 +438,15 @@ def _get_threading_layer(self): -1: "not specified", } return layer_map[set_threading_layer(-1)] - + class AccelerateController(LibController): """Controller class for Accelerate""" user_api = "blas" internal_api = "accelerate" - filename_prefixes = ("libblas") - check_symbols = ( - "_veclib", - ) + filename_prefixes = "libblas" + check_symbols = ("_veclib",) def set_additional_attributes(self): self.remark = "Number of threads cannot be changed at runtime." @@ -1121,6 +1119,10 @@ def _make_controller_from_path(self, filepath): # our supported libraries). Otherwise, create and store the library # controller. lib_controller = controller_class(filepath=filepath, prefix=prefix) + + if prefix == "libblas": + print(hasattr, lib_controller.dynlib, "_veclib") + print(hasattr, lib_controller.dynlib, "_sdot") if not hasattr(controller_class, "check_symbols") or any( hasattr(lib_controller.dynlib, func) for func in controller_class.check_symbols From a5800e65a73d60177c10781b772bc70c5a3709e0 Mon Sep 17 00:00:00 2001 From: jeremie du boisberranger Date: Fri, 9 Feb 2024 18:28:10 +0100 Subject: [PATCH 4/5] iter --- threadpoolctl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/threadpoolctl.py b/threadpoolctl.py index 9ed0c8fd..265a7b76 100644 --- a/threadpoolctl.py +++ b/threadpoolctl.py @@ -1121,8 +1121,8 @@ def _make_controller_from_path(self, filepath): lib_controller = controller_class(filepath=filepath, prefix=prefix) if prefix == "libblas": - print(hasattr, lib_controller.dynlib, "_veclib") - print(hasattr, lib_controller.dynlib, "_sdot") + print(hasattr(lib_controller.dynlib, "_veclib")) + print(hasattr(lib_controller.dynlib, "_sdot")) if not hasattr(controller_class, "check_symbols") or any( hasattr(lib_controller.dynlib, func) for func in controller_class.check_symbols From ee6978ff22d46207a5f77f00cfedaf4a566089aa Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Fri, 9 Feb 2024 19:15:24 +0100 Subject: [PATCH 5/5] Tweak --- threadpoolctl.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/threadpoolctl.py b/threadpoolctl.py index 265a7b76..bb868e19 100644 --- a/threadpoolctl.py +++ b/threadpoolctl.py @@ -445,8 +445,8 @@ class AccelerateController(LibController): user_api = "blas" internal_api = "accelerate" - filename_prefixes = "libblas" - check_symbols = ("_veclib",) + filename_prefixes = ["libveclib"] + # check_symbols = ("_veclib",) def set_additional_attributes(self): self.remark = "Number of threads cannot be changed at runtime." @@ -1081,6 +1081,7 @@ def _make_controller_from_path(self, filepath): # `lower` required to take account of OpenMP dll case on Windows # (vcomp, VCOMP, Vcomp, ...) filename = os.path.basename(filepath).lower() + # print(filename) # Loop through supported libraries to find if this filename corresponds # to a supported one. @@ -1121,8 +1122,8 @@ def _make_controller_from_path(self, filepath): lib_controller = controller_class(filepath=filepath, prefix=prefix) if prefix == "libblas": - print(hasattr(lib_controller.dynlib, "_veclib")) - print(hasattr(lib_controller.dynlib, "_sdot")) + print(f"{hasattr(lib_controller.dynlib, '_veclib') = }") + print(f"{hasattr(lib_controller.dynlib, '_sdot') = }") if not hasattr(controller_class, "check_symbols") or any( hasattr(lib_controller.dynlib, func) for func in controller_class.check_symbols