refactor: move spack.util.multiproc to llnl.util.multiproc
- multiproc doesn't depend on Spack - llnl.util.lock test uses it, but shouldn't use parts of Spack.
This commit is contained in:
		| @@ -79,14 +79,14 @@ | |||||||
| import inspect | import inspect | ||||||
| import platform as py_platform | import platform as py_platform | ||||||
|  |  | ||||||
| from llnl.util.lang import memoized, list_modules, key_ordering | import llnl.util.multiproc as mp | ||||||
| import llnl.util.tty as tty | import llnl.util.tty as tty | ||||||
|  | from llnl.util.lang import memoized, list_modules, key_ordering | ||||||
|  |  | ||||||
| import spack.paths | import spack.paths | ||||||
| import spack.error as serr | import spack.error as serr | ||||||
| from spack.util.naming import mod_to_class | from spack.util.naming import mod_to_class | ||||||
| from spack.util.environment import get_path | from spack.util.environment import get_path | ||||||
| from spack.util.multiproc import parmap |  | ||||||
| from spack.util.spack_yaml import syaml_dict | from spack.util.spack_yaml import syaml_dict | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -280,8 +280,8 @@ def find_compilers(self, *paths): | |||||||
|         # NOTE: we import spack.compilers here to avoid init order cycles |         # NOTE: we import spack.compilers here to avoid init order cycles | ||||||
|         import spack.compilers |         import spack.compilers | ||||||
|         types = spack.compilers.all_compiler_types() |         types = spack.compilers.all_compiler_types() | ||||||
|         compiler_lists = parmap(lambda cmp_cls: |         compiler_lists = mp.parmap( | ||||||
|                                 self.find_compiler(cmp_cls, *filtered_path), |             lambda cmp_cls: self.find_compiler(cmp_cls, *filtered_path), | ||||||
|             types) |             types) | ||||||
|  |  | ||||||
|         # ensure all the version calls we made are cached in the parent |         # ensure all the version calls we made are cached in the parent | ||||||
| @@ -300,7 +300,7 @@ def find_compiler(self, cmp_cls, *path): | |||||||
|            prefixes, suffixes, and versions.  e.g., gcc-mp-4.7 would |            prefixes, suffixes, and versions.  e.g., gcc-mp-4.7 would | ||||||
|            be grouped with g++-mp-4.7 and gfortran-mp-4.7. |            be grouped with g++-mp-4.7 and gfortran-mp-4.7. | ||||||
|         """ |         """ | ||||||
|         dicts = parmap( |         dicts = mp.parmap( | ||||||
|             lambda t: cmp_cls._find_matches_in_path(*t), |             lambda t: cmp_cls._find_matches_in_path(*t), | ||||||
|             [(cmp_cls.cc_names,  cmp_cls.cc_version)  + tuple(path), |             [(cmp_cls.cc_names,  cmp_cls.cc_version)  + tuple(path), | ||||||
|              (cmp_cls.cxx_names, cmp_cls.cxx_version) + tuple(path), |              (cmp_cls.cxx_names, cmp_cls.cxx_version) + tuple(path), | ||||||
|   | |||||||
| @@ -27,11 +27,11 @@ | |||||||
| import itertools | import itertools | ||||||
|  |  | ||||||
| import llnl.util.tty as tty | import llnl.util.tty as tty | ||||||
|  | import llnl.util.multiproc as mp | ||||||
|  |  | ||||||
| import spack.error | import spack.error | ||||||
| import spack.spec | import spack.spec | ||||||
| import spack.architecture | import spack.architecture | ||||||
| from spack.util.multiproc import parmap |  | ||||||
| from spack.util.executable import Executable, ProcessError | from spack.util.executable import Executable, ProcessError | ||||||
| from spack.util.environment import get_path | from spack.util.environment import get_path | ||||||
|  |  | ||||||
| @@ -280,7 +280,7 @@ def _find_matches_in_path(cls, compiler_names, detect_version, *path): | |||||||
|                         key = (full_path,) + match.groups() + (detect_version,) |                         key = (full_path,) + match.groups() + (detect_version,) | ||||||
|                         checks.append(key) |                         checks.append(key) | ||||||
|  |  | ||||||
|         successful = [k for k in parmap(_get_versioned_tuple, checks) |         successful = [k for k in mp.parmap(_get_versioned_tuple, checks) | ||||||
|                       if k is not None] |                       if k is not None] | ||||||
|  |  | ||||||
|         # The 'successful' list is ordered like the input paths. |         # The 'successful' list is ordered like the input paths. | ||||||
|   | |||||||
| @@ -25,9 +25,9 @@ | |||||||
| import re | import re | ||||||
|  |  | ||||||
| import llnl.util.tty as tty | import llnl.util.tty as tty | ||||||
|  | import llnl.util.multiproc as mp | ||||||
|  |  | ||||||
| from spack.architecture import OperatingSystem | from spack.architecture import OperatingSystem | ||||||
| from spack.util.multiproc import parmap |  | ||||||
| from spack.util.module_cmd import get_module_cmd | from spack.util.module_cmd import get_module_cmd | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -60,7 +60,7 @@ def find_compilers(self, *paths): | |||||||
|         import spack.compilers |         import spack.compilers | ||||||
|  |  | ||||||
|         types = spack.compilers.all_compiler_types() |         types = spack.compilers.all_compiler_types() | ||||||
|         compiler_lists = parmap( |         compiler_lists = mp.parmap( | ||||||
|             lambda cmp_cls: self.find_compiler(cmp_cls, *paths), types) |             lambda cmp_cls: self.find_compiler(cmp_cls, *paths), types) | ||||||
|  |  | ||||||
|         # ensure all the version calls we made are cached in the parent |         # ensure all the version calls we made are cached in the parent | ||||||
|   | |||||||
| @@ -72,10 +72,10 @@ | |||||||
|  |  | ||||||
| import pytest | import pytest | ||||||
|  |  | ||||||
|  | import llnl.util.multiproc as mp | ||||||
| from llnl.util.filesystem import touch, group_ids | from llnl.util.filesystem import touch, group_ids | ||||||
|  |  | ||||||
| import spack.util.lock | import spack.util.lock | ||||||
| from spack.util.multiproc import Barrier |  | ||||||
| from spack.util.lock import Lock, WriteTransaction, ReadTransaction, LockError | from spack.util.lock import Lock, WriteTransaction, ReadTransaction, LockError | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -205,7 +205,7 @@ def lock_path(lock_dir): | |||||||
|  |  | ||||||
| def local_multiproc_test(*functions): | def local_multiproc_test(*functions): | ||||||
|     """Order some processes using simple barrier synchronization.""" |     """Order some processes using simple barrier synchronization.""" | ||||||
|     b = Barrier(len(functions), timeout=barrier_timeout) |     b = mp.Barrier(len(functions), timeout=barrier_timeout) | ||||||
|     procs = [Process(target=f, args=(b,)) for f in functions] |     procs = [Process(target=f, args=(b,)) for f in functions] | ||||||
|  |  | ||||||
|     for p in procs: |     for p in procs: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Todd Gamblin
					Todd Gamblin