spack/lib/spack/docs
John Gouwar bf16f0bf74
Add solver capability for synthesizing splices of ABI compatible packages. (#46729)
This PR provides complementary 2 features:
1. An augmentation to the package language to express ABI compatibility relationships among packages. 
2. An extension to the concretizer that can synthesize splices between ABI compatible packages.

1.  The `can_splice` directive and ABI compatibility 
We augment the package language with a single directive: `can_splice`. Here is an example of a package `Foo` exercising the `can_splice` directive:

class Foo(Package):
    version("1.0")
    version("1.1")
    variant("compat", default=True)
    variant("json", default=False)
    variant("pic", default=False)
    can_splice("foo@1.0", when="@1.1")
    can_splice("bar@1.0", when="@1.0+compat")
    can_splice("baz@1.0+compat", when="@1.0+compat", match_variants="*")
    can_splice("quux@1.0", when=@1.1~compat", match_variants="json")

Explanations of the uses of each directive: 
- `can_splice("foo@1.0", when="@1.1")`:  If `foo@1.0` is the dependency of an already installed spec and `foo@1.1` could be a valid dependency for the parent spec, then `foo@1.1` can be spliced in for `foo@1.0` in the parent spec.
- `can_splice("bar@1.0", when="@1.0+compat")`: If `bar@1.0` is the dependency of an already installed spec and `foo@1.0+compat` could be a valid dependency for the parent spec, then `foo@1.0+compat` can be spliced in for `bar@1.0+compat` in the parent spec
-  `can_splice("baz@1.0", when="@1.0+compat", match_variants="*")`: If `baz@1.0+compat` is the dependency of an already installed spec and `foo@1.0+compat` could be a valid dependency for the parent spec, then `foo@1.0+compat` can be spliced in for `baz@1.0+compat` in the parent spec, provided that they have the same value for all other variants (regardless of what those values are). 
-  `can_splice("quux@1.0", when=@1.1~compat", match_variants="json")`:If `quux@1.0` is the dependency of an already installed spec and `foo@1.1~compat` could be a valid dependency for the parent spec, then `foo@1.0~compat` can be spliced in for `quux@1.0` in the parent spec, provided that they have the same value for their `json` variant. 

2. Augmenting the solver to synthesize splices
### Changes to the hash encoding in `asp.py`
Previously, when including concrete specs in the solve, they would have the following form:

installed_hash("foo", "xxxyyy")
imposed_constraint("xxxyyy", "foo", "attr1", ...)
imposed_constraint("xxxyyy", "foo", "attr2", ...)
% etc. 

Concrete specs now have the following form:
installed_hash("foo", "xxxyyy")
hash_attr("xxxyyy", "foo", "attr1", ...)
hash_attr("xxxyyy", "foo", "attr2", ...)

This transformation allows us to control which constraints are imposed when we select a hash, to facilitate the splicing of dependencies. 

2.1 Compiling `can_splice` directives in `asp.py`
Consider the concrete spec:
foo@2.72%gcc@11.4 arch=linux-ubuntu22.04-icelake build_system=autotools ^bar ...
It will emit the following facts for reuse (below is a subset)

installed_hash("foo", "xxxyyy")
hash_attr("xxxyyy", "hash", "foo", "xxxyyy")
hash_attr("xxxyyy", "version", "foo", "2.72")
hash_attr("xxxyyy", "node_os", "ubuntu22.04")
hash_attr("xxxyyy", "hash", "bar", "zzzqqq")
hash_attr("xxxyyy", "depends_on", "foo", "bar", "link")

Rules that derive abi_splice_conditions_hold will be generated from 
use of the `can_splice` directive. They will have the following form:
can_splice("foo@1.0.0+a", when="@1.0.1+a", match_variants=["b"]) --->

abi_splice_conditions_hold(0, node(SID, "foo"), "foo", BaseHash) :-
  installed_hash("foo", BaseHash),
  attr("node", node(SID, SpliceName)),
  attr("node_version_satisfies", node(SID, "foo"), "1.0.1"),
  hash_attr("hash", "node_version_satisfies", "foo", "1.0.1"),
  attr("variant_value", node(SID, "foo"), "a", "True"),
  hash_attr("hash", "variant_value", "foo", "a", "True"),
  attr("variant_value", node(SID, "foo"), "b", VariVar0),
  hash_attr("hash", "variant_value", "foo", "b", VariVar0).


2.2 Synthesizing splices in `concretize.lp` and `splices.lp`

The ASP solver generates "splice_at_hash" attrs to indicate that a particular node has a splice in one of its immediate dependencies. 

Splices can be introduced in the dependencies of concrete specs when `splices.lp` is conditionally loaded (based on the config option `concretizer:splice:True`. 

2.3 Constructing spliced specs in `asp.py`

The method `SpecBuilder._resolve_splices` implements a top-down memoized implementation of hybrid splicing. This is an optimization over the more general `Spec.splice`, since the solver gives a global view of exactly which specs can be shared, to ensure the minimal number of splicing operations. 

Misc changes to facilitate configuration and benchmarking 
- Added the method `Solver.solve_with_stats` to expose timers from the public interface for easier benchmarking 
- Added the boolean config option `concretizer:splice` to conditionally load splicing behavior 

Co-authored-by: Greg Becker <becker33@llnl.gov>
2024-11-12 20:51:19 -08:00
..
_gh_pages_redirect Use https for links (#19244) 2020-10-09 11:24:09 -05:00
_pygments Update copyright year to 2024 (#41919) 2024-01-02 09:21:30 +01:00
_static make empty _static directory "exist" to git 2014-01-09 14:03:32 +01:00
_templates docs: re-enable google analytics (#43974) 2024-05-02 21:56:19 -04:00
build_systems Stand-alone testing: remove deprecated methods (#45752) 2024-10-03 11:36:18 +00:00
example_files Implement an optional compiler bootstrapping phase 2019-09-13 22:57:15 -07:00
images Update release documentation (#46991) 2024-10-16 09:11:53 +02:00
tables AutotoolsPackage / MakefilePackage: add gmake build dependency (#40380) 2023-10-18 19:56:54 +02:00
.gitignore docs: Replace package list with packages.spack.io (#40251) 2023-10-01 05:36:22 +02:00
basic_usage.rst Feature: Allow variants to propagate if not available in source pkg (#42931) 2024-11-06 00:53:52 -08:00
binary_caches.rst Allow packages to be pushed to build cache after install from source (#42423) 2024-04-11 19:43:13 -06:00
bootstrapping.rst Fix spack find bootstrapping docs (#43074) 2024-03-07 14:13:32 +01:00
build_settings.rst Add solver capability for synthesizing splices of ABI compatible packages. (#46729) 2024-11-12 20:51:19 -08:00
build_systems.rst Update copyright year to 2024 (#41919) 2024-01-02 09:21:30 +01:00
chain.rst docs: refer to upstreams.yaml in chain.rst title (#46475) 2024-09-19 13:08:05 +02:00
command_index.in Rework command reference in docs, add spack commands command 2018-02-12 20:25:17 -08:00
conf.py spack.compiler/spack.util.libc: add caching (#47213) 2024-11-08 16:25:02 -08:00
config_yaml.rst certs: fix interpolation and disallow relative paths (#44030) 2024-05-07 11:16:32 +02:00
configuration.rst Add spack short version in config variables (#47016) 2024-10-25 07:34:59 +02:00
containers.rst containers: rm centos7 since EOL (#45049) 2024-07-04 22:22:23 +02:00
contribution_guide.rst Fix malformed RST link in documentation (#47309) 2024-10-30 09:40:35 +01:00
developer_guide.rst hooks: run in clear, fixed order (#47329) 2024-10-30 18:57:49 +00:00
environments.rst Docs: clarify include path options (#47083) 2024-10-21 07:26:18 +02:00
extensions.rst Allow loading extensions through python entry-points (#42370) 2024-03-06 11:18:49 +01:00
features.rst Update copyright year to 2024 (#41919) 2024-01-02 09:21:30 +01:00
frequently_asked_questions.rst Update copyright year to 2024 (#41919) 2024-01-02 09:21:30 +01:00
getting_started.rst getting_started.rst: fix list of spack deps (#47557) 2024-11-12 08:59:07 +01:00
gpu_configuration.rst Update copyright year to 2024 (#41919) 2024-01-02 09:21:30 +01:00
index.rst Docs: remove reference to pyspack (#47346) 2024-10-31 11:15:51 +01:00
Makefile API Docs: fix broken reference targets 2021-07-16 08:30:56 -07:00
mirrors.rst Update copyright year to 2024 (#41919) 2024-01-02 09:21:30 +01:00
module_file_generation.svg SC17: reworked module file tutorial section (#5657) 2017-11-12 00:27:20 -08:00
module_file_support.rst Modules suffixes config are now spec format strings (#38411) 2024-10-21 09:08:59 +02:00
packages_yaml.rst develop: Add -b/--build-directory option to set build_directory package attribute (#39606) 2024-02-16 06:30:58 +00:00
packaging_guide.rst Add solver capability for synthesizing splices of ABI compatible packages. (#46729) 2024-11-12 20:51:19 -08:00
pipelines.rst ci: Remove deprecated logic from the ci module (#47062) 2024-10-23 12:50:55 -06:00
replace_conda_homebrew.rst Update copyright year to 2024 (#41919) 2024-01-02 09:21:30 +01:00
repositories.rst docs: remove warning about repositories and package extension (#44247) 2024-05-17 22:03:57 +00:00
requirements.txt build(deps): bump python-levenshtein in /lib/spack/docs (#47372) 2024-11-01 23:55:18 +00:00
signing.rst Update copyright year to 2024 (#41919) 2024-01-02 09:21:30 +01:00
spack.yaml Update copyright year to 2024 (#41919) 2024-01-02 09:21:30 +01:00