Skip to content

Allow reusing specs built with compilers not in config#43539

Merged
haampie merged 9 commits intospack:developfrom
alalazo:solver/reuse-non-local-compilers
Apr 11, 2024
Merged

Allow reusing specs built with compilers not in config#43539
haampie merged 9 commits intospack:developfrom
alalazo:solver/reuse-non-local-compilers

Conversation

@alalazo
Copy link
Copy Markdown
Member

@alalazo alalazo commented Apr 8, 2024

This PR allows to reuse specs that were built with compilers that are not in the current configuration. This means that specs from buildcaches don't need to have a matching compiler locally to be reused. If a node needs to be built, only available compilers will be considered as candidates.

Below most of the specs are reused and have %gcc@=9.4.0 which is not in the configuration. The root node is built and has %gcc@=11.1.0:
Screenshot from 2024-04-05 22-56-46

This limits the implicit use of globals, and can
be leveraged to have simpler unit-tests.
@spackbot-app spackbot-app bot added build-environment commands compilers core PR affects Spack core functionality environments stand-alone-tests Stand-alone (or smoke) tests for installed packages tests General test capability(ies) labels Apr 8, 2024
This commit allows reusing binaries with compilers that
don't match any in the local configuration.
@alalazo alalazo force-pushed the solver/reuse-non-local-compilers branch from 8d1385e to c2d3359 Compare April 8, 2024 21:30
@alalazo alalazo added this to the v0.22.0 milestone Apr 9, 2024
This is needed if we want to simulate x86_64
preferences on aarch64 host when running unit
tests
@alalazo alalazo force-pushed the solver/reuse-non-local-compilers branch from 70efd09 to a679dcf Compare April 9, 2024 14:35
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Apr 9, 2024

The usual performance benchmark for this test seems ok:

radiuss.develop.csv
radiuss.pr.csv
radiuss.txt

radiuss

@alalazo alalazo force-pushed the solver/reuse-non-local-compilers branch from a679dcf to d91e076 Compare April 9, 2024 15:02
module.spack_cxx = os.path.join(link_dir, pkg.compiler.link_paths["cxx"])
module.spack_f77 = os.path.join(link_dir, pkg.compiler.link_paths["f77"])
module.spack_fc = os.path.join(link_dir, pkg.compiler.link_paths["fc"])
try:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a bit too generic. Can't you catch a specific error? Maybe refactor to compiler = get_compiler(pkg) and then if compiler: module.spack_cc = ... etc?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per DM, we need to check how to deal with mpi implementations, and similar specs that have a real run dependency on the compiler.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pytest.mark.only_clingo("Old concretizer cannot reuse")
def test_reuse_specs_from_non_available_compilers(self, mutable_config, mutable_database):
"""Tests that we can reuse specs with compilers that are not configured locally."""
# All the specs in the mutable DB have been compiled with %gcc@=10.2.1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also assert this? mutable_database.query_local(...)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return False


class CompilerParser:
Copy link
Copy Markdown
Member

@haampie haampie Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parser? 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave this as is, at least here. There is also a RequirementParser - open to change both names in a following Pr.

result = sorted(self.compilers, key=lambda x: (x.spec.name, x.spec.version), reverse=True)
# Then stable sort to prefer available compilers and account for preferences
ppk = spack.package_prefs.PackagePrefs("all", "compiler", all=False)
result = sorted(result, key=lambda x: (not x.available, ppk(x.spec)))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid a copy result.sort(...)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would happen if the mpi was installed from
a buildcache, and the compiler is not available.
@alalazo alalazo force-pushed the solver/reuse-non-local-compilers branch from acca63b to 7525e7a Compare April 10, 2024 15:41
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Apr 11, 2024

@spackbot run pipeline

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Apr 11, 2024

I've started that pipeline for you!

@haampie haampie merged commit 1fe8e63 into spack:develop Apr 11, 2024
@alalazo alalazo deleted the solver/reuse-non-local-compilers branch April 11, 2024 07:24
tldahlgren pushed a commit to tldahlgren/spack that referenced this pull request Apr 23, 2024
Allow reuse of specs that were built with compilers not in the current configuration. This means that specs from build caches don't need to have a matching compiler locally to be reused. Similarly when updating a distro. If a node needs to be built, only available compilers will be considered as candidates.
stephenmsachs pushed a commit to stephenmsachs/spack that referenced this pull request Apr 29, 2024
Allow reuse of specs that were built with compilers not in the current configuration. This means that specs from build caches don't need to have a matching compiler locally to be reused. Similarly when updating a distro. If a node needs to be built, only available compilers will be considered as candidates.
danlipsa added a commit to danlipsa/spack that referenced this pull request May 22, 2024
The full error:

==> Installing hdf5-1.14.3-ohtopgtkb3nmwyxxgqdpwjvvnttospev [24/35]
==> No binary for hdf5-1.14.3-ohtopgtkb3nmwyxxgqdpwjvvnttospev found: installing from source
==> Error: AttributeError: module 'spack.pkg.builtin.hdf5' has no attribute 'spack_cc'

The 'hdf5' package cannot find an attribute while trying to build from sources. This might be due to a change in Spack's package format to support multiple build-systems for a single package. You can fix this by updating the build recipe, and you can also report the issue as a bug. More information at https://spack.readthedocs.io/en/latest/packaging_guide.html#installation-procedure

C:\Users\dan.lipsa\projects\spack\var\spack\repos\builtin\packages\msmpi\package.py:48, in setup_dependent_package:
         45        # be manually supplied to compiler by consuming package
         46        # Note: This is not typical of MPI installations
         47        dependent_module = dependent_spec.package.module
  >>     48        self.spec.mpicc = dependent_module.spack_cc
         49        self.spec.mpicxx = dependent_module.spack_cxx
         50        self.spec.mpifc = dependent_module.spack_fc
         51        self.spec.mpif77 = dependent_module.spack_f77

This reverts changes to msmpi/package.py
1fe8e63 * Reuse specs built with compilers not in config (spack#43539)
teaguesterling pushed a commit to teaguesterling/spack that referenced this pull request Jun 15, 2024
Allow reuse of specs that were built with compilers not in the current configuration. This means that specs from build caches don't need to have a matching compiler locally to be reused. Similarly when updating a distro. If a node needs to be built, only available compilers will be considered as candidates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-environment commands compilers core PR affects Spack core functionality environments intel stand-alone-tests Stand-alone (or smoke) tests for installed packages tests General test capability(ies) update-package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants