Compare commits

...

10 Commits

Author SHA1 Message Date
Harmen Stoppels
eff56cd845 rocm-openmp-extras: do not mutate llvm-amdgpu 2025-02-13 15:46:09 +01:00
Harmen Stoppels
9747978c7f Spec.package_class -> spack.repo.PATH.get_pkg_class (#48985) 2025-02-12 11:52:04 +01:00
Harmen Stoppels
f043455ccc gmake: fix def libs/headers (#49009) 2025-02-12 11:07:55 +01:00
Harmen Stoppels
fb9d6427e6 package_hash.py: move metadata_attrs inline out of package_base (#48981) 2025-02-12 10:38:35 +01:00
Tara Drwenski
76e83e10c1 gmake: add empty libs property, remove link deptypes from dependents (#48995) 2025-02-12 10:16:30 +01:00
Massimiliano Culpo
af89bdf632 kokkos et al. : don't monkeypatch spec in callbacks (#48916)
Currently, a few packages using kokkos rely on
kokkos itself monkeypatching its own spec to
provide some attribute.

In this commit we change this attribute to be
defined on the package, and never be monkeypatched.
2025-02-12 07:27:49 +01:00
Adam J. Stewart
46f5b192ef PyTorch: build flash attention by default, except in CI (#48521)
* PyTorch: build flash attention by default, except in CI

* Variant is boolean, only available when +cuda/+rocm

* desc -> _desc
2025-02-11 13:20:10 -08:00
Harmen Stoppels
18cd922aab style.py: fix false negative in redundant import statements (#48980) 2025-02-11 19:30:50 +01:00
Massimiliano Culpo
5518ad9611 Fix performance issue on macOS (#48997)
archspec.cpu.host() is not memoized, so compute
it as less as possible.

---------

Co-authored-by: alalazo <alalazo@users.noreply.github.com>
2025-02-11 18:54:32 +01:00
Wouter Deconinck
57a1807443 hep: rivet: require hepmc=3 (#48976) 2025-02-11 01:33:45 -07:00
37 changed files with 133 additions and 130 deletions

View File

@@ -125,7 +125,7 @@ def develop(parser, args):
version = spec.versions.concrete_range_as_version
if not version:
# look up the maximum version so infintiy versions are preferred for develop
version = max(spec.package_class.versions.keys())
version = max(spack.repo.PATH.get_pkg_class(spec.fullname).versions.keys())
tty.msg(f"Defaulting to highest version: {spec.name}@{version}")
spec.versions = spack.version.VersionList([version])

View File

@@ -545,7 +545,7 @@ def _not_license_excluded(self, x):
package does not explicitly forbid redistributing source."""
if self.private:
return True
elif x.package_class.redistribute_source(x):
elif spack.repo.PATH.get_pkg_class(x.fullname).redistribute_source(x):
return True
else:
tty.debug(

View File

@@ -6,7 +6,7 @@
import os
import re
import sys
from itertools import zip_longest
from itertools import islice, zip_longest
from typing import Dict, List, Optional
import llnl.util.tty as tty
@@ -423,7 +423,8 @@ def _run_import_check(
continue
for m in is_abs_import.finditer(contents):
if contents.count(m.group(1)) == 1:
# Find at most two occurences: the first is the import itself, the second is its usage.
if len(list(islice(re.finditer(rf"{re.escape(m.group(1))}(?!\w)", contents), 2))) == 1:
to_remove.append(m.group(0))
exit_code = 1
print(f"{pretty_path}: redundant import: {m.group(1)}", file=out)
@@ -438,7 +439,7 @@ def _run_import_check(
module = _module_part(root, m.group(0))
if not module or module in to_add:
continue
if re.search(rf"import {re.escape(module)}\b(?!\.)", contents):
if re.search(rf"import {re.escape(module)}(?!\w|\.)", contents):
continue
to_add.add(module)
exit_code = 1

View File

@@ -252,7 +252,9 @@ def has_test_and_tags(pkg_class):
hashes = env.all_hashes() if env else None
specs = spack.store.STORE.db.query(hashes=hashes)
specs = list(filter(lambda s: has_test_and_tags(s.package_class), specs))
specs = list(
filter(lambda s: has_test_and_tags(spack.repo.PATH.get_pkg_class(s.fullname)), specs)
)
spack.cmd.display_specs(specs, long=True)

View File

@@ -566,7 +566,7 @@ def copy_test_files(pkg: Pb, test_spec: spack.spec.Spec):
# copy test data into test stage data dir
try:
pkg_cls = test_spec.package_class
pkg_cls = spack.repo.PATH.get_pkg_class(test_spec.fullname)
except spack.repo.UnknownPackageError:
tty.debug(f"{test_spec.name}: skipping test data copy since no package class found")
return
@@ -623,7 +623,7 @@ def test_functions(
vpkgs = virtuals(pkg)
for vname in vpkgs:
try:
classes.append((Spec(vname)).package_class)
classes.append(spack.repo.PATH.get_pkg_class(vname))
except spack.repo.UnknownPackageError:
tty.debug(f"{vname}: virtual does not appear to have a package file")
@@ -668,7 +668,7 @@ def process_test_parts(pkg: Pb, test_specs: List[spack.spec.Spec], verbose: bool
# grab test functions associated with the spec, which may be virtual
try:
tests = test_functions(spec.package_class)
tests = test_functions(spack.repo.PATH.get_pkg_class(spec.fullname))
except spack.repo.UnknownPackageError:
# Some virtuals don't have a package so we don't want to report
# them as not having tests when that isn't appropriate.

View File

@@ -709,19 +709,6 @@ class PackageBase(WindowsRPath, PackageViewMixin, metaclass=PackageMeta):
#: Do not include @ here in order not to unnecessarily ping the users.
maintainers: List[str] = []
#: List of attributes to be excluded from a package's hash.
metadata_attrs = [
"homepage",
"url",
"urls",
"list_url",
"extendable",
"parallel",
"make_jobs",
"maintainers",
"tags",
]
#: Set to ``True`` to indicate the stand-alone test requires a compiler.
#: It is used to ensure a compiler and build dependencies like 'cmake'
#: are available to build a custom test code.

View File

@@ -3472,7 +3472,7 @@ def external_spec_selected(self, node, idx):
self._specs[node].extra_attributes = spec_info.get("extra_attributes", {})
# If this is an extension, update the dependencies to include the extendee
package = self._specs[node].package_class(self._specs[node])
package = spack.repo.PATH.get_pkg_class(self._specs[node].fullname)(self._specs[node])
extendee_spec = package.extendee_spec
if extendee_spec:

View File

@@ -72,6 +72,9 @@ def __init__(self, *, configuration: spack.config.Configuration, repo: spack.rep
self.repo = repo
self.runtime_pkgs = set(self.repo.packages_with_tags(RUNTIME_TAG))
self.runtime_virtuals = set()
self._platform_condition = spack.spec.Spec(
f"platform={spack.platforms.host()} target={archspec.cpu.host().family}:"
)
for x in self.runtime_pkgs:
pkg_class = self.repo.get_pkg_class(x)
self.runtime_virtuals.update(pkg_class.provided_virtual_names())
@@ -88,14 +91,11 @@ def is_virtual(self, name: str) -> bool:
def is_allowed_on_this_platform(self, *, pkg_name: str) -> bool:
"""Returns true if a package is allowed on the current host"""
pkg_cls = self.repo.get_pkg_class(pkg_name)
platform_condition = (
f"platform={spack.platforms.host()} target={archspec.cpu.host().family}:"
)
for when_spec, conditions in pkg_cls.requirements.items():
if not when_spec.intersects(platform_condition):
if not when_spec.intersects(self._platform_condition):
continue
for requirements, _, _ in conditions:
if not any(x.intersects(platform_condition) for x in requirements):
if not any(x.intersects(self._platform_condition) for x in requirements):
tty.debug(f"[{__name__}] {pkg_name} is not for this platform")
return False
return True

View File

@@ -1905,6 +1905,12 @@ def package_class(self):
"""Internal package call gets only the class object for a package.
Use this to just get package metadata.
"""
warnings.warn(
"`Spec.package_class` is deprecated and will be removed in version 1.0.0. Use "
"`spack.repo.PATH.get_pkg_class(spec.fullname) instead.",
category=spack.error.SpackAPIWarning,
stacklevel=2,
)
return spack.repo.PATH.get_pkg_class(self.fullname)
@property
@@ -2864,7 +2870,7 @@ def inject_patches_variant(root):
# Add any patches from the package to the spec.
patches = set()
for cond, patch_list in s.package_class.patches.items():
for cond, patch_list in spack.repo.PATH.get_pkg_class(s.fullname).patches.items():
if s.satisfies(cond):
for patch in patch_list:
patches.add(patch)
@@ -2877,7 +2883,7 @@ def inject_patches_variant(root):
if dspec.spec.concrete:
continue
pkg_deps = dspec.parent.package_class.dependencies
pkg_deps = spack.repo.PATH.get_pkg_class(dspec.parent.fullname).dependencies
patches = []
for cond, deps_by_name in pkg_deps.items():
@@ -3111,7 +3117,7 @@ def ensure_valid_variants(spec):
if spec.concrete:
return
pkg_cls = spec.package_class
pkg_cls = spack.repo.PATH.get_pkg_class(spec.fullname)
pkg_variants = pkg_cls.variant_names()
# reserved names are variants that may be set on any package
# but are not necessarily recorded by the package's class
@@ -4705,7 +4711,7 @@ def concrete(self):
bool: True or False
"""
return self.spec._concrete or all(
v in self for v in self.spec.package_class.variant_names()
v in self for v in spack.repo.PATH.get_pkg_class(self.spec.fullname).variant_names()
)
def copy(self) -> "VariantMap":
@@ -4765,14 +4771,14 @@ def substitute_abstract_variants(spec: Spec):
elif name in vt.reserved_names:
continue
variant_defs = spec.package_class.variant_definitions(name)
variant_defs = spack.repo.PATH.get_pkg_class(spec.fullname).variant_definitions(name)
valid_defs = []
for when, vdef in variant_defs:
if when.intersects(spec):
valid_defs.append(vdef)
if not valid_defs:
if name not in spec.package_class.variant_names():
if name not in spack.repo.PATH.get_pkg_class(spec.fullname).variant_names():
unknown.append(name)
else:
whens = [str(when) for when, _ in variant_defs]

View File

@@ -304,6 +304,8 @@ def test_run_import_check(tmp_path: pathlib.Path):
contents = '''
import spack.cmd
import spack.config # do not drop this import because of this comment
import spack.repo
import spack.repo_utils
# this comment about spack.error should not be removed
class Example(spack.build_systems.autotools.AutotoolsPackage):
@@ -314,6 +316,7 @@ def foo(config: "spack.error.SpackError"):
# the type hint is quoted, so it should not be removed
spack.util.executable.Executable("example")
print(spack.__version__)
print(spack.repo_utils.__file__)
'''
file.write_text(contents)
root = str(tmp_path)
@@ -329,6 +332,7 @@ def foo(config: "spack.error.SpackError"):
output = output_buf.getvalue()
assert "issues.py: redundant import: spack.cmd" in output
assert "issues.py: redundant import: spack.repo" in output
assert "issues.py: redundant import: spack.config" not in output # comment prevents removal
assert "issues.py: missing import: spack" in output # used by spack.__version__
assert "issues.py: missing import: spack.build_systems.autotools" in output

View File

@@ -206,7 +206,7 @@ def test_repo(_create_test_repo, monkeypatch, mock_stage):
)
def test_redistribute_directive(test_repo, spec_str, distribute_src, distribute_bin):
spec = spack.spec.Spec(spec_str)
assert spec.package_class.redistribute_source(spec) == distribute_src
assert spack.repo.PATH.get_pkg_class(spec.fullname).redistribute_source(spec) == distribute_src
concretized_spec = spack.concretize.concretize_one(spec)
assert concretized_spec.package.redistribute_binary == distribute_bin

View File

@@ -8,7 +8,6 @@
import spack.directives_meta
import spack.error
import spack.fetch_strategy
import spack.package_base
import spack.repo
import spack.spec
import spack.util.hash
@@ -61,10 +60,18 @@ class RemoveDirectives(ast.NodeTransformer):
"""
def __init__(self, spec):
# list of URL attributes and metadata attributes
# these will be removed from packages.
self.metadata_attrs = [s.url_attr for s in spack.fetch_strategy.all_strategies]
self.metadata_attrs += spack.package_base.PackageBase.metadata_attrs
#: List of attributes to be excluded from a package's hash.
self.metadata_attrs = [s.url_attr for s in spack.fetch_strategy.all_strategies] + [
"homepage",
"url",
"urls",
"list_url",
"extendable",
"parallel",
"make_jobs",
"maintainers",
"tags",
]
self.spec = spec
self.in_classdef = False # used to avoid nested classdefs

View File

@@ -19,6 +19,8 @@ spack:
require: +geant4 +hepmc3 +root +shared cxxstd=20
hip:
require: '@5.7.1 +rocm'
rivet:
require: hepmc=3
root:
require: +davix +dcache +examples +fftw +fits +fortran +gdml +graphviz +gsl +http +math +minuit +mlp +mysql +opengl +postgres +pythia8 +python +r +roofit +root7 +rpath ~shadow +spectrum +sqlite +ssl +tbb +threads +tmva +tmva-cpu +unuran +vc +vdt +veccore +webgui +x +xml +xrootd # cxxstd=20
# note: root cxxstd=20 not concretizable within sherpa
@@ -93,7 +95,7 @@ spack:
- py-uproot +lz4 +xrootd +zstd
- py-vector
- pythia8 +evtgen +fastjet +hdf5 +hepmc +hepmc3 +lhapdf ~madgraph5amc +python +rivet ~root # pythia8 and root circularly depend
- rivet hepmc=3
- rivet
- root ~cuda
- sherpa +analysis ~blackhat +gzip +hepmc3 +hepmc3root +lhapdf +lhole +openloops +pythia ~python ~recola ~rivet +root +ufo cxxstd=20
- tauola +hepmc3 +lhapdf cxxstd=20

View File

@@ -12,6 +12,13 @@ spack:
require: ~cuda
mpi:
require: openmpi
py-torch:
require:
- target=aarch64
- ~rocm
- +cuda
- cuda_arch=80
- ~flash_attention
specs:
# Horovod

View File

@@ -12,6 +12,13 @@ spack:
require: ~cuda
mpi:
require: openmpi
py-torch:
require:
- target=x86_64_v3
- ~rocm
- +cuda
- cuda_arch=80
- ~flash_attention
specs:
# Horovod

View File

@@ -11,6 +11,13 @@ spack:
require: "osmesa"
mpi:
require: openmpi
py-torch:
require:
- target=x86_64_v3
- ~cuda
- +rocm
- amdgpu_target=gfx90a
- ~flash_attention
specs:
# Horovod

View File

@@ -110,22 +110,15 @@ class Arborx(CMakePackage, CudaPackage, ROCmPackage):
conflicts("~serial", when="+trilinos")
def cmake_args(self):
spec = self.spec
if "+trilinos" in spec:
kokkos_spec = spec["trilinos"]
else:
kokkos_spec = spec["kokkos"]
kokkos_pkg = self["trilinos"] if self.spec.satisfies("+trilinos") else self["kokkos"]
options = [
f"-DKokkos_ROOT={kokkos_spec.prefix}",
self.define("Kokkos_ROOT", kokkos_pkg.prefix),
self.define_from_variant("ARBORX_ENABLE_MPI", "mpi"),
]
if spec.satisfies("+cuda"):
options.append(f"-DCMAKE_CXX_COMPILER={kokkos_spec.kokkos_cxx}")
if spec.satisfies("+rocm"):
options.append("-DCMAKE_CXX_COMPILER=%s" % spec["hip"].hipcc)
if self.spec.satisfies("+cuda"):
options.append(self.define("CMAKE_CXX_COMPILER", kokkos_pkg.kokkos_cxx))
if self.spec.satisfies("+rocm"):
options.append(self.define("CMAKE_CXX_COMPILER", self.spec["hip"].hipcc))
return options

View File

@@ -125,9 +125,9 @@ class Cmake(Package):
patch("mr-9623.patch", when="@3.22.0:3.30")
depends_on("ninja", when="platform=windows")
depends_on("gmake", when="platform=linux")
depends_on("gmake", when="platform=darwin")
depends_on("gmake", when="platform=freebsd")
depends_on("gmake", type=("build", "run"), when="platform=linux")
depends_on("gmake", type=("build", "run"), when="platform=darwin")
depends_on("gmake", type=("build", "run"), when="platform=freebsd")
depends_on("qt", when="+qtgui")
# Qt depends on libmng, which is a CMake package;

View File

@@ -66,7 +66,7 @@ def cmake_args(self):
[
"-DKokkosCore_PREFIX={0}".format(kokkos.prefix),
"-DKokkosKernels_PREFIX={0}".format(kokkos_kernels.prefix),
"-DCMAKE_CXX_COMPILER:STRING={0}".format(spec["kokkos"].kokkos_cxx),
"-DCMAKE_CXX_COMPILER:STRING={0}".format(self["kokkos"].kokkos_cxx),
# Compadre_USE_PYTHON is OFF by default
"-DCompadre_USE_PYTHON=OFF",
]

View File

@@ -552,7 +552,7 @@ def cmake_args(self):
)
# Make sure we use the same compiler that Trilinos uses
if spec.satisfies("+trilinos"):
options.extend([self.define("CMAKE_CXX_COMPILER", spec["trilinos"].kokkos_cxx)])
options.extend([self.define("CMAKE_CXX_COMPILER", self["trilinos"].kokkos_cxx)])
# Complex support
options.append(self.define_from_variant("DEAL_II_WITH_COMPLEX_VALUES", "complex"))

View File

@@ -121,9 +121,9 @@ def setup_build_environment(self, env):
# Manually turn off device self.defines to solve Kokkos issues in Nalu-Wind headers
env.append_flags("CXXFLAGS", "-U__HIP_DEVICE_COMPILE__ -DDESUL_HIP_RDC")
if self.spec.satisfies("+cuda"):
env.set("OMPI_CXX", self.spec["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("MPICH_CXX", self.spec["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("MPICXX_CXX", self.spec["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("OMPI_CXX", self["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("MPICH_CXX", self["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("MPICXX_CXX", self["kokkos-nvcc-wrapper"].kokkos_cxx)
if self.spec.satisfies("+rocm"):
env.set("OMPI_CXX", self.spec["hip"].hipcc)
env.set("MPICH_CXX", self.spec["hip"].hipcc)

View File

@@ -147,7 +147,7 @@ def cmake_args(self):
# CMake pulled in via find_package(Legion) won't work without this
options.append(self.define("HIP_PATH", "{0}/hip".format(spec["hip"].prefix)))
elif self.spec.satisfies("^kokkos"):
options.append(self.define("CMAKE_CXX_COMPILER", self.spec["kokkos"].kokkos_cxx))
options.append(self.define("CMAKE_CXX_COMPILER", self["kokkos"].kokkos_cxx))
else:
# kept for supporing version prior to 2.2
options = [

View File

@@ -11,6 +11,7 @@
import spack.compiler
import spack.platforms
import spack.repo
import spack.util.libc
from spack.operating_systems.mac_os import macos_sdk_path, macos_version
from spack.package import *
@@ -1217,7 +1218,7 @@ def _post_buildcache_install_hook(self):
)
if header_dir and all(
os.path.exists(os.path.join(header_dir, h))
for h in libc.package_class.representative_headers
for h in spack.repo.PATH.get_pkg_class(libc.fullname).representative_headers
):
relocation_args.append(f"-idirafter {header_dir}")
else:

View File

@@ -99,3 +99,11 @@ def setup_dependent_package(self, module, dspec):
self.spec.prefix.bin.make,
jobs=determine_number_of_jobs(parallel=dspec.package.parallel),
)
@property
def libs(self):
return LibraryList([])
@property
def headers(self):
return HeaderList([])

View File

@@ -267,7 +267,7 @@ def cmake_args(self):
options.append("-DCMAKE_CXX_COMPILER=%s" % spec["hip"].hipcc)
else:
# Compiler weirdness due to nvcc_wrapper
options.append("-DCMAKE_CXX_COMPILER=%s" % spec["kokkos"].kokkos_cxx)
options.append("-DCMAKE_CXX_COMPILER=%s" % self["kokkos"].kokkos_cxx)
if self.run_tests:
options.append("-DKokkosKernels_ENABLE_TESTS=ON")

View File

@@ -69,6 +69,6 @@ def setup_dependent_build_environment(self, env, dependent_spec):
env.set("OMPI_CXX", wrapper)
env.set("MPICXX_CXX", wrapper) # HPE MPT
def setup_dependent_package(self, module, dependent_spec):
wrapper = join_path(self.prefix.bin, "nvcc_wrapper")
self.spec.kokkos_cxx = wrapper
@property
def kokkos_cxx(self) -> str:
return join_path(self.prefix.bin, "nvcc_wrapper")

View File

@@ -408,11 +408,12 @@ def append_args(self, cmake_prefix, cmake_options, spack_options):
if option:
spack_options.append(option)
def setup_dependent_package(self, module, dependent_spec):
try:
self.spec.kokkos_cxx = self.spec["kokkos-nvcc-wrapper"].kokkos_cxx
except Exception:
self.spec.kokkos_cxx = spack_cxx
@property
def kokkos_cxx(self) -> str:
if self.spec.satisfies("+wrapper"):
return self["kokkos-nvcc-wrapper"].kokkos_cxx
# Assumes build-time globals have been set already
return spack_cxx
def cmake_args(self):
spec = self.spec
@@ -474,9 +475,7 @@ def cmake_args(self):
options.append(self.define(tpl + "_DIR", spec[tpl].prefix))
if self.spec.satisfies("+wrapper"):
options.append(
self.define("CMAKE_CXX_COMPILER", self.spec["kokkos-nvcc-wrapper"].kokkos_cxx)
)
options.append(self.define("CMAKE_CXX_COMPILER", self.kokkos_cxx))
elif "+rocm" in self.spec:
if "+cmake_lang" in self.spec:
options.append(

View File

@@ -406,7 +406,7 @@ def cmake_args(self):
if spec.satisfies("+kokkos"):
# default is off.
options.append("-DLegion_USE_Kokkos=ON")
os.environ["KOKKOS_CXX_COMPILER"] = spec["kokkos"].kokkos_cxx
os.environ["KOKKOS_CXX_COMPILER"] = self["kokkos"].kokkos_cxx
if spec.satisfies("+cuda+cuda_unsupported_compiler ^kokkos%clang +cuda"):
# Keep CMake CUDA compiler detection happy
options.append(

View File

@@ -140,9 +140,9 @@ def setup_build_environment(self, env):
spec = self.spec
env.append_flags("CXXFLAGS", "-DUSE_STK_SIMD_NONE")
if spec.satisfies("+cuda"):
env.set("OMPI_CXX", self.spec["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("MPICH_CXX", self.spec["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("MPICXX_CXX", self.spec["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("OMPI_CXX", self["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("MPICH_CXX", self["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("MPICXX_CXX", self["kokkos-nvcc-wrapper"].kokkos_cxx)
if spec.satisfies("+rocm"):
env.append_flags("CXXFLAGS", "-fgpu-rdc")

View File

@@ -116,7 +116,7 @@ def cmake_args(self):
if "+cuda%gcc" in self.spec:
options += [
self.define(
"CMAKE_CXX_COMPILER", "{0}".format(self.spec["kokkos-nvcc-wrapper"].kokkos_cxx)
"CMAKE_CXX_COMPILER", "{0}".format(self["kokkos-nvcc-wrapper"].kokkos_cxx)
)
]

View File

@@ -335,8 +335,7 @@ def check_fortran_compiler(self):
patch("revert-3.18.0-ver-format-for-dealii.patch", when="@3.18.0")
depends_on("diffutils", type="build")
# not listed as a "build" dependency - so that slepc build gets the same dependency
depends_on("gmake")
depends_on("gmake", type="build")
# Virtual dependencies
# Git repository needs sowing to build Fortran interface

View File

@@ -61,7 +61,7 @@ def set_cmake_from_variants(self):
with open("cmake_opts.txt", "w") as f:
f.write("KokkosCore_PREFIX:PATH=%s\n" % spec["kokkos"].prefix)
f.write("KokkosKernels_PREFIX:PATH=%s\n" % spec["kokkos-kernels"].prefix)
f.write("CMAKE_CXX_COMPILER:STRING={0}\n".format(spec["kokkos"].kokkos_cxx))
f.write("CMAKE_CXX_COMPILER:STRING={0}\n".format(self["kokkos"].kokkos_cxx))
if spec.variants["debug"].value == "0":
f.write(
"CMAKE_CXX_FLAGS:STRING=%s\n"

View File

@@ -114,6 +114,12 @@ class PyTorch(PythonPackage, CudaPackage, ROCmPackage):
description="Enable breakpad crash dump library",
when="@1.10:1.11",
)
# Flash attention has very high memory requirements that may cause the build to fail
# https://github.com/pytorch/pytorch/issues/111526
# https://github.com/pytorch/pytorch/issues/124018
_desc = "Build the flash_attention kernel for scaled dot product attention"
variant("flash_attention", default=True, description=_desc, when="@1.13:+cuda")
variant("flash_attention", default=True, description=_desc, when="@1.13:+rocm")
# py-torch has strict dependencies on old protobuf/py-protobuf versions that
# cause problems with other packages that require newer versions of protobuf
# and py-protobuf --> provide an option to use the internal/vendored protobuf.
@@ -594,17 +600,13 @@ def enable_or_disable(variant, keyword="USE", var=None):
env.set("CUDNN_INCLUDE_DIR", self.spec["cudnn"].prefix.include)
env.set("CUDNN_LIBRARY", self.spec["cudnn"].libs[0])
# Flash attention has very high memory requirements that may cause the build to fail
# https://github.com/pytorch/pytorch/issues/111526
# https://github.com/pytorch/pytorch/issues/124018
env.set("USE_FLASH_ATTENTION", "OFF")
enable_or_disable("fbgemm")
enable_or_disable("kineto")
enable_or_disable("magma")
enable_or_disable("metal")
enable_or_disable("mps")
enable_or_disable("breakpad")
enable_or_disable("flash_attention")
enable_or_disable("nccl")
if "+cuda+nccl" in self.spec:

View File

@@ -516,9 +516,7 @@ def install(self, spec, prefix):
llvm_inc = "/rocm-openmp-extras/llvm-project/llvm/include"
llvm_prefix = self.spec["llvm-amdgpu"].prefix
omp_bin_dir = "{0}/bin".format(openmp_extras_prefix)
omp_lib_dir = "{0}/lib".format(openmp_extras_prefix)
bin_dir = "{0}/bin".format(llvm_prefix)
lib_dir = "{0}/lib".format(llvm_prefix)
flang_warning = "-Wno-incompatible-pointer-types-discards-qualifiers"
libpgmath = "/rocm-openmp-extras/flang/runtime/libpgmath/lib/common"
elfutils_inc = spec["elfutils"].prefix.include
@@ -527,34 +525,6 @@ def install(self, spec, prefix):
ncurses_lib_dir = self.spec["ncurses"].prefix.lib
zlib_lib_dir = self.spec["zlib"].prefix.lib
# flang1 and flang2 symlink needed for build of flang-runtime
# libdevice symlink to rocm-openmp-extras for runtime
# libdebug symlink to rocm-openmp-extras for runtime
if os.path.islink((os.path.join(bin_dir, "flang1"))):
os.unlink(os.path.join(bin_dir, "flang1"))
if os.path.islink((os.path.join(bin_dir, "flang2"))):
os.unlink(os.path.join(bin_dir, "flang2"))
if self.spec.version >= Version("6.1.0"):
if os.path.islink((os.path.join(bin_dir, "flang-legacy"))):
os.unlink(os.path.join(bin_dir, "flang-legacy"))
if os.path.islink((os.path.join(lib_dir, "libdevice"))):
os.unlink(os.path.join(lib_dir, "libdevice"))
if os.path.islink((os.path.join(llvm_prefix, "lib-debug"))):
os.unlink(os.path.join(llvm_prefix, "lib-debug"))
if not os.path.exists(os.path.join(bin_dir, "flang1")):
os.symlink(os.path.join(omp_bin_dir, "flang1"), os.path.join(bin_dir, "flang1"))
if not os.path.exists(os.path.join(bin_dir, "flang2")):
os.symlink(os.path.join(omp_bin_dir, "flang2"), os.path.join(bin_dir, "flang2"))
if self.spec.version >= Version("6.1.0"):
os.symlink(
os.path.join(omp_bin_dir, "flang-legacy"), os.path.join(bin_dir, "flang-legacy")
)
os.symlink(os.path.join(omp_lib_dir, "libdevice"), os.path.join(lib_dir, "libdevice"))
os.symlink(
os.path.join(openmp_extras_prefix, "lib-debug"), os.path.join(llvm_prefix, "lib-debug")
)
# Set cmake args
components = dict()

View File

@@ -184,7 +184,7 @@ def cmake_args(self):
]
if "+kokkos+cuda" in self.spec:
args.append(self.define("CMAKE_CXX_COMPILER", self.spec["kokkos"].kokkos_cxx))
args.append(self.define("CMAKE_CXX_COMPILER", self["kokkos"].kokkos_cxx))
return args

View File

@@ -98,5 +98,5 @@ def cmake_args(self):
args.append(self.define("CMAKE_CXX_COMPILER", self.spec["hip"].hipcc))
args.append(self.define("CMAKE_C_COMPILER", self.spec["hip"].hipcc))
if self.spec.satisfies("^kokkos+cuda"):
args.append(self.define("CMAKE_CXX_COMPILER", self.spec["kokkos"].kokkos_cxx))
args.append(self.define("CMAKE_CXX_COMPILER", self["kokkos"].kokkos_cxx))
return args

View File

@@ -589,21 +589,22 @@ def setup_dependent_run_environment(self, env, dependent_spec):
# in case the dependent app also run a CUDA backend via Trilinos
env.set("CUDA_LAUNCH_BLOCKING", "1")
def setup_dependent_package(self, module, dependent_spec):
if "+wrapper" in self.spec:
self.spec.kokkos_cxx = self.spec["kokkos-nvcc-wrapper"].kokkos_cxx
else:
self.spec.kokkos_cxx = spack_cxx
@property
def kokkos_cxx(self) -> str:
if self.spec.satisfies("+wrapper"):
return self["kokkos-nvcc-wrapper"].kokkos_cxx
# Assumes build-time globals have been set already
return spack_cxx
def setup_build_environment(self, env):
spec = self.spec
if "+cuda" in spec and "+wrapper" in spec:
if "+mpi" in spec:
env.set("OMPI_CXX", spec["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("MPICH_CXX", spec["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("MPICXX_CXX", spec["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("OMPI_CXX", self["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("MPICH_CXX", self["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("MPICXX_CXX", self["kokkos-nvcc-wrapper"].kokkos_cxx)
else:
env.set("CXX", spec["kokkos-nvcc-wrapper"].kokkos_cxx)
env.set("CXX", self["kokkos-nvcc-wrapper"].kokkos_cxx)
if "+rocm" in spec:
if "+mpi" in spec: