From ca95c0fdb2ef12454a65c25907d7c739a3a1b50a Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 29 May 2024 14:09:06 +0200 Subject: [PATCH] Add -j option to spack compiler find --- lib/spack/spack/cmd/compiler.py | 3 ++- lib/spack/spack/compilers/__init__.py | 5 +++-- share/spack/spack-completion.bash | 4 ++-- share/spack/spack-completion.fish | 8 ++++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/spack/spack/cmd/compiler.py b/lib/spack/spack/cmd/compiler.py index 0194eda698f..f6b076c5fe6 100644 --- a/lib/spack/spack/cmd/compiler.py +++ b/lib/spack/spack/cmd/compiler.py @@ -50,6 +50,7 @@ def setup_parser(subparser): default=lambda: spack.config.default_modify_scope("compilers"), help="configuration scope to modify", ) + arguments.add_common_arguments(find_parser, ["jobs"]) # Remove remove_parser = sp.add_parser("remove", aliases=["rm"], help="remove compiler by spec") @@ -84,7 +85,7 @@ def compiler_find(args): if new_compilers: n = len(new_compilers) s = "s" if n > 1 else "" - filename = spack.config.CONFIG.get_config_filename(args.scope, "compilers") + filename = spack.config.CONFIG.get_config_filename(args.scope, "packages") tty.msg(f"Added {n:d} new compiler{s} to {filename}") compiler_strs = sorted(f"{c.spec}" for c in new_compilers) colify(reversed(compiler_strs), indent=4) diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index 403fc8e7cb2..cb30d293276 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -271,6 +271,7 @@ def find_compilers( *, scope: Optional[str] = None, mixed_toolchain: bool = False, + max_workers: Optional[int] = None, ) -> List["spack.compiler.Compiler"]: """Searches for compiler in the paths given as argument. If any new compiler is found, the configuration is updated, and the list of new compiler objects is returned. @@ -281,14 +282,14 @@ def find_compilers( scope: configuration scope to modify mixed_toolchain: allow mixing compilers from different toolchains if otherwise missing for a certain language + max_workers: number of processes used to search for compilers """ - # TODO: pass max_workers to this function if path_hints is None: path_hints = get_path("PATH") default_paths = fs.search_paths_for_executables(*path_hints) compiler_pkgs = spack.repo.PATH.packages_with_tags(COMPILER_TAG, full=True) detected_packages = spack.detection.by_path( - compiler_pkgs, path_hints=default_paths, max_workers=1 + compiler_pkgs, path_hints=default_paths, max_workers=max_workers ) new_compilers = spack.detection.update_configuration( detected_packages, buildable=True, scope=scope diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash index eba6b5a96d5..079f021706d 100644 --- a/share/spack/spack-completion.bash +++ b/share/spack/spack-completion.bash @@ -752,7 +752,7 @@ _spack_compiler() { _spack_compiler_find() { if $list_options then - SPACK_COMPREPLY="-h --help --mixed-toolchain --no-mixed-toolchain --scope" + SPACK_COMPREPLY="-h --help --mixed-toolchain --no-mixed-toolchain --scope -j --jobs" else SPACK_COMPREPLY="" fi @@ -761,7 +761,7 @@ _spack_compiler_find() { _spack_compiler_add() { if $list_options then - SPACK_COMPREPLY="-h --help --mixed-toolchain --no-mixed-toolchain --scope" + SPACK_COMPREPLY="-h --help --mixed-toolchain --no-mixed-toolchain --scope -j --jobs" else SPACK_COMPREPLY="" fi diff --git a/share/spack/spack-completion.fish b/share/spack/spack-completion.fish index 01da46115b5..464c001d0c2 100644 --- a/share/spack/spack-completion.fish +++ b/share/spack/spack-completion.fish @@ -1059,7 +1059,7 @@ complete -c spack -n '__fish_spack_using_command compiler' -s h -l help -f -a he complete -c spack -n '__fish_spack_using_command compiler' -s h -l help -d 'show this help message and exit' # spack compiler find -set -g __fish_spack_optspecs_spack_compiler_find h/help mixed-toolchain no-mixed-toolchain scope= +set -g __fish_spack_optspecs_spack_compiler_find h/help mixed-toolchain no-mixed-toolchain scope= j/jobs= complete -c spack -n '__fish_spack_using_command compiler find' -s h -l help -f -a help complete -c spack -n '__fish_spack_using_command compiler find' -s h -l help -d 'show this help message and exit' @@ -1069,9 +1069,11 @@ complete -c spack -n '__fish_spack_using_command compiler find' -l no-mixed-tool complete -c spack -n '__fish_spack_using_command compiler find' -l no-mixed-toolchain -d '(DEPRECATED) Do not allow mixed toolchains (for example: clang, clang++, gfortran)' complete -c spack -n '__fish_spack_using_command compiler find' -l scope -r -f -a '_builtin defaults system site user command_line' complete -c spack -n '__fish_spack_using_command compiler find' -l scope -r -d 'configuration scope to modify' +complete -c spack -n '__fish_spack_using_command compiler find' -s j -l jobs -r -f -a jobs +complete -c spack -n '__fish_spack_using_command compiler find' -s j -l jobs -r -d 'explicitly set number of parallel jobs' # spack compiler add -set -g __fish_spack_optspecs_spack_compiler_add h/help mixed-toolchain no-mixed-toolchain scope= +set -g __fish_spack_optspecs_spack_compiler_add h/help mixed-toolchain no-mixed-toolchain scope= j/jobs= complete -c spack -n '__fish_spack_using_command compiler add' -s h -l help -f -a help complete -c spack -n '__fish_spack_using_command compiler add' -s h -l help -d 'show this help message and exit' @@ -1081,6 +1083,8 @@ complete -c spack -n '__fish_spack_using_command compiler add' -l no-mixed-toolc complete -c spack -n '__fish_spack_using_command compiler add' -l no-mixed-toolchain -d '(DEPRECATED) Do not allow mixed toolchains (for example: clang, clang++, gfortran)' complete -c spack -n '__fish_spack_using_command compiler add' -l scope -r -f -a '_builtin defaults system site user command_line' complete -c spack -n '__fish_spack_using_command compiler add' -l scope -r -d 'configuration scope to modify' +complete -c spack -n '__fish_spack_using_command compiler add' -s j -l jobs -r -f -a jobs +complete -c spack -n '__fish_spack_using_command compiler add' -s j -l jobs -r -d 'explicitly set number of parallel jobs' # spack compiler remove set -g __fish_spack_optspecs_spack_compiler_remove h/help a/all scope=