diff options
Diffstat (limited to 'var/spack/repos/builtin/packages/lammps/package.py')
-rw-r--r-- | var/spack/repos/builtin/packages/lammps/package.py | 212 |
1 files changed, 167 insertions, 45 deletions
diff --git a/var/spack/repos/builtin/packages/lammps/package.py b/var/spack/repos/builtin/packages/lammps/package.py index ce760e817f..6b8287b49c 100644 --- a/var/spack/repos/builtin/packages/lammps/package.py +++ b/var/spack/repos/builtin/packages/lammps/package.py @@ -5,8 +5,8 @@ import datetime as dt import os -import archspec - +from spack.build_environment import optimization_flags +from spack.build_systems.python import PythonPipBuilder from spack.package import * @@ -23,7 +23,7 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): maintainers("rbberger") - license("GPL-2.0-or-later") + license("GPL-2.0-only") # rules for new versions and deprecation # * new stable versions should be added to stable_versions set @@ -31,11 +31,58 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): # marked deprecated=True # * patch releases older than a stable release should be marked deprecated=True version("develop", branch="develop") - version("20231121", sha256="704d8a990874a425bcdfe0245faf13d712231ba23f014a3ebc27bc14398856f1") + version( + "20240829.1", + sha256="3aea41869aa2fb8120fc4814cab645686f969e2eb7c66aa5587e500597d482dc", + preferred=True, + ) + version( + "20240829", + sha256="6112e0cc352c3140a4874c7f74db3c0c8e30134024164509ecf3772b305fde2e", + deprecated=True, + ) + version( + "20240627", + sha256="2174a99d266279823a8c57629ee1c21ec357816aefd85f964d9f859fe9222aa5", + deprecated=True, + ) + version( + "20240417", + sha256="158b288725c251fd8b30dbcf61749e0d6a042807da92af865a7d3c413efdd8ea", + deprecated=True, + ) + version( + "20240207.1", + sha256="3ba62c2a1ed463fceedf313a1c3ea2997994aa102379a8d35b525ea424f56776", + deprecated=True, + ) + version( + "20240207", + sha256="d518f32de4eb2681f2543be63926411e72072dd7d67c1670c090b5baabed98ac", + deprecated=True, + ) + version( + "20231121", + sha256="704d8a990874a425bcdfe0245faf13d712231ba23f014a3ebc27bc14398856f1", + deprecated=True, + ) + version( + "20230802.4", sha256="6eed007cc24cda80b5dd43372b2ad4268b3982bb612669742c8c336b79137b5b" + ) + version( + "20230802.3", + sha256="6666e28cb90d3ff01cbbda6c81bdb85cf436bbb41604a87f2ab2fa559caa8510", + deprecated=True, + ) + version( + "20230802.2", + sha256="3bcecabc9cad08d0a4e4d989b52d29c58505f7ead8ebacf43c9db8d9fd3d564a", + deprecated=True, + ) version( "20230802.1", sha256="0e5568485e5ee080412dba44a1b7a93f864f1b5c75121f11d528854269953ed0", - preferred=True, + deprecated=True, ) version( "20230802", @@ -351,7 +398,22 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): deprecated=True, ) + depends_on("cxx", type="build") + + # mdi, scafacos, ml-quip, qmmm require C, but not available in Spack + for c_pkg in ("adios", "atc", "awpmd", "ml-pod", "electrode", "kim", "h5md", "tools", "rheo"): + depends_on("c", type="build", when=f"+{c_pkg}") + + # scafacos, ml-quip require Fortran, but not available in Spack + for fc_pkg in ("kim",): + depends_on("fortran", type="build", when=f"+{fc_pkg}") + stable_versions = { + "20240829.1", + "20240829", + "20230802.4", + "20230802.3", + "20230802.2", "20230802.1", "20230802", "20220623.4", @@ -443,6 +505,7 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): "ml-pod": {"when": "@20221222:"}, "ml-rann": {"when": "@20210702:"}, "ml-snap": {"when": "@20210702:"}, + "ml-uf3": {"when": "@20240627:"}, "mliap": {"when": "@20200630:20210527"}, "mofff": {"when": "@20210702:"}, "molecule": {"default": True}, @@ -464,6 +527,7 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): "reaction": {"when": "@20210702:"}, "reax": {"when": "@:20181212"}, "reaxff": {"when": "@20210702:"}, + "rheo": {"when": "@20240829:"}, "replica": {}, "rigid": {"default": True}, "shock": {}, @@ -538,6 +602,7 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): variant("jpeg", default=False, description="Build with jpeg support") variant("png", default=False, description="Build with png support") variant("ffmpeg", default=False, description="Build with ffmpeg support") + variant("curl", default=False, description="Build with curl support", when="@20240829:") variant("openmp", default=True, description="Build with OpenMP") variant("opencl", default=False, description="Build with OpenCL") variant( @@ -570,6 +635,29 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): multi=False, ) variant( + "fft", + default="fftw3", + when="+kspace", + description="FFT library for KSPACE package", + values=("kiss", "fftw3", "mkl"), + multi=False, + ) + variant( + "heffte", + default=False, + when="+kspace @20240207:", + description="Use heffte as distubuted FFT engine", + ) + + variant( + "fft_kokkos", + default="fftw3", + when="@20240417: +kspace+kokkos", + description="FFT library for Kokkos-enabled KSPACE package", + values=("kiss", "fftw3", "mkl", "hipfft", "cufft"), + multi=False, + ) + variant( "gpu_precision", default="mixed", when="~kokkos", @@ -577,13 +665,20 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): values=("double", "mixed", "single"), multi=False, ) + variant("tools", default=False, description="Build LAMMPS tools (msi2lmp, binary2txt, chain)") - depends_on("cmake@3.16:", when="@20231121:") + depends_on("cmake@3.16:", when="@20231121:", type="build") depends_on("mpi", when="+mpi") depends_on("mpi", when="+mpiio") - depends_on("fftw-api@3", when="+kspace") - depends_on("hipfft", when="+kspace+kokkos+rocm") - depends_on("voropp+pic", when="+voronoi") + depends_on("fftw-api@3", when="+kspace fft=fftw3") + depends_on("heffte", when="+heffte") + depends_on("heffte+fftw", when="+heffte fft=fftw3") + depends_on("heffte+mkl", when="+heffte fft=mkl") + depends_on("mkl", when="+kspace fft=mkl") + depends_on("hipfft", when="+kokkos+kspace+rocm fft_kokkos=hipfft") + depends_on("fftw-api@3", when="+kokkos+kspace fft_kokkos=fftw3") + depends_on("mkl", when="+kokkos+kspace fft_kokkos=mkl") + depends_on("voropp", when="+voronoi") depends_on("netcdf-c+mpi", when="+user-netcdf") depends_on("netcdf-c+mpi", when="+netcdf") depends_on("blas", when="+user-atc") @@ -607,11 +702,14 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): depends_on("jpeg", when="+jpeg") depends_on("kim-api", when="+kim") depends_on("curl", when="@20190329:+kim") + depends_on("curl", when="+curl") depends_on("libpng", when="+png") depends_on("ffmpeg", when="+ffmpeg") depends_on("kokkos+deprecated_code+shared@3.0.00", when="@20200303+kokkos") depends_on("kokkos+shared@3.1:", when="@20200505:+kokkos") depends_on("kokkos@3.7.01:", when="@20230208: +kokkos") + depends_on("kokkos@4.3.00:", when="@20240417: +kokkos") + depends_on("kokkos@4.3.01:", when="@20240627: +kokkos") depends_on("adios2", when="+user-adios") depends_on("adios2", when="+adios") depends_on("plumed", when="+user-plumed") @@ -626,13 +724,16 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): depends_on("py-numpy", when="+python", type=("build", "run")) depends_on("py-mpi4py", when="+python+mpi", type=("build", "run")) depends_on("py-setuptools@42:", when="@20220217:+python", type=("build", "run")) - depends_on("n2p2@2.1.4:", when="+user-hdnnp") - depends_on("n2p2@2.1.4:", when="+ml-hdnnp") - depends_on("n2p2+shared", when="+lib ^n2p2") + for _n2p2_cond in ("+user-hdnnp", "+ml-hdnnp"): + with when(_n2p2_cond): + depends_on("n2p2@2.1.4:") + depends_on("n2p2+shared", when="+lib") depends_on("vtk", when="+user-vtk") depends_on("vtk", when="+vtk") depends_on("hipcub", when="~kokkos +rocm") - depends_on("llvm-amdgpu +openmp", when="+rocm +openmp", type="build") + depends_on("llvm-amdgpu ", when="+rocm", type="build") + depends_on("rocm-openmp-extras", when="+rocm +openmp", type="build") + depends_on("gsl@2.6:", when="+rheo") # propagate CUDA and ROCm architecture when +kokkos for arch in CudaPackage.cuda_arch_values: @@ -651,7 +752,6 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): conflicts("+cuda", when="+opencl") conflicts("+rocm", when="+opencl") conflicts("+body", when="+poems@:20180628") - conflicts("+latte", when="@:20170921") conflicts("+python", when="~lib") conflicts("+qeq", when="~manybody") conflicts("+user-atc", when="~manybody") @@ -701,6 +801,12 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): sha256="3dedd807f63a21c543d1036439099f05c6031fd98e7cb1ea7825822fc074106e", when="@20220623.3:20230208 +kokkos +rocm +kspace", ) + # Fixed in https://github.com/lammps/lammps/pull/4305 + patch( + "https://github.com/lammps/lammps/commit/49bdc3e26449634f150602a66d0dab34d09dbc0e.patch?full_index=1", + sha256="b8d1f08a82329e493e040de2bde9d2291af173a0fe6c7deb24750cc22823c421", + when="@20240829 %cce", + ) # Older LAMMPS does not compile with Kokkos 4.x conflicts( @@ -751,15 +857,16 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): self.define_from_variant("LAMMPS_EXCEPTIONS", "exceptions"), self.define_from_variant("{}_MPI".format(mpi_prefix), "mpi"), self.define_from_variant("BUILD_OMP", "openmp"), + self.define_from_variant("BUILD_TOOLS", "tools"), self.define("ENABLE_TESTING", self.run_tests), self.define("DOWNLOAD_POTENTIALS", False), ] - if "~kokkos" in spec: + if spec.satisfies("~kokkos"): # LAMMPS can be build with the GPU package OR the KOKKOS package # Using both in a single build is discouraged. # +cuda only implies that one of the two is used # by default it will use the GPU package if kokkos wasn't enabled - if "+cuda" in spec: + if spec.satisfies("+cuda"): args.append(self.define("PKG_GPU", True)) args.append(self.define("GPU_API", "cuda")) args.append(self.define_from_variant("GPU_PREC", "gpu_precision")) @@ -767,19 +874,23 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): if cuda_arch != "none": args.append(self.define("GPU_ARCH", "sm_{0}".format(cuda_arch[0]))) args.append(self.define_from_variant("CUDA_MPS_SUPPORT", "cuda_mps")) - elif "+opencl" in spec: + elif spec.satisfies("+opencl"): # LAMMPS downloads and bundles its own OpenCL ICD Loader by default args.append(self.define("USE_STATIC_OPENCL_LOADER", False)) args.append(self.define("PKG_GPU", True)) args.append(self.define("GPU_API", "opencl")) args.append(self.define_from_variant("GPU_PREC", "gpu_precision")) - elif "+rocm" in spec: + elif spec.satisfies("+rocm"): args.append(self.define("PKG_GPU", True)) args.append(self.define("GPU_API", "hip")) args.append(self.define_from_variant("GPU_PREC", "gpu_precision")) args.append(self.define_from_variant("HIP_ARCH", "amdgpu_target")) else: args.append(self.define("PKG_GPU", False)) + else: + args.append(self.define("EXTERNAL_KOKKOS", True)) + if spec.satisfies("@20240207: +kokkos+kspace"): + args.append(self.define_from_variant("FFT_KOKKOS", "fft_kokkos")) if spec.satisfies("@20180629:+lib"): args.append(self.define("BUILD_LIB", True)) @@ -787,22 +898,30 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): if spec.satisfies("%aocc"): if spec.satisfies("+intel"): cxx_flags = ( - "-Ofast -fno-math-errno -fno-unroll-loops " + "-O3 -fno-math-errno -fno-unroll-loops " "-fveclib=AMDLIBM -muse-unaligned-vector-move" ) + if spec.satisfies("%aocc@4.1:4.2"): + cxx_flags += ( + " -mllvm -force-gather-overhead-cost=50" + " -mllvm -enable-masked-gather-sequence=false" + ) + elif spec.satisfies("%aocc@5.0:"): + cxx_flags += " -mllvm -enable-aggressive-gather" + if spec.target >= "zen5": + cxx_flags += " -fenable-restrict-based-lv" + # add -fopenmp-simd if OpenMP not already turned on if spec.satisfies("~openmp"): cxx_flags += " -fopenmp-simd" cxx_flags += " -DLMP_SIMD_COMPILER -DUSE_OMP_SIMD -DLMP_INTEL_USELRT" else: - cxx_flags = "-Ofast -mfma -fvectorize -funroll-loops" + cxx_flags = "-O3 -mfma -fvectorize -funroll-loops" args.append(self.define("CMAKE_CXX_FLAGS_RELEASE", cxx_flags)) args.append(self.define("CMAKE_CXX_FLAGS_RELWITHDEBINFO", cxx_flags)) # Overwrite generic cpu tune option - cmake_tune_flags = archspec.cpu.TARGETS[spec.target.name].optimization_flags( - spec.compiler.name, spec.compiler.version - ) + cmake_tune_flags = optimization_flags(self.compiler, spec.target) args.append(self.define("CMAKE_TUNE_FLAGS", cmake_tune_flags)) args.append(self.define_from_variant("LAMMPS_SIZES", "lammps_sizes")) @@ -810,21 +929,17 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): args.append(self.define_from_variant("WITH_JPEG", "jpeg")) args.append(self.define_from_variant("WITH_PNG", "png")) args.append(self.define_from_variant("WITH_FFMPEG", "ffmpeg")) + args.append(self.define_from_variant("WITH_CURL", "curl")) for pkg, params in self.supported_packages.items(): if "when" not in params or spec.satisfies(params["when"]): opt = "{0}_{1}".format(pkg_prefix, pkg.replace("-package", "").upper()) args.append(self.define(opt, "+{0}".format(pkg) in spec)) - if "+kspace" in spec: - # If FFTW3 is selected, then CMake will try to detect, if threaded - # FFTW libraries are available and enable them by default. - if "^fftw" in spec or "^cray-fftw" in spec or "^amdfftw" in spec: - args.append(self.define("FFT", "FFTW3")) - elif spec["fftw-api"].name in INTEL_MATH_LIBRARIES: - args.append(self.define("FFT", "MKL")) - elif "^armpl-gcc" in spec or "^acfl" in spec: - args.append(self.define("FFT", "FFTW3")) + if spec.satisfies("+kspace"): + args.append(self.define_from_variant("FFT", "fft")) + args.append(self.define_from_variant("FFT_USE_HEFFTE", "heffte")) + if spec.satisfies("fft=fftw3 ^armpl-gcc") or spec.satisfies("fft=fftw3 ^acfl"): args.append(self.define("FFTW3_LIBRARY", self.spec["fftw-api"].libs[0])) args.append( self.define("FFTW3_INCLUDE_DIR", self.spec["fftw-api"].headers.directories[0]) @@ -834,28 +949,28 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): # for transposing 3d FFT data. args.append(self.define("FFT_SINGLE", spec.satisfies("fftw_precision=single"))) - if "+kokkos" in spec: - args.append(self.define("EXTERNAL_KOKKOS", True)) - if "+user-adios" in spec or "+adios" in spec: + if spec.satisfies("+user-adios") or spec.satisfies("+adios"): args.append(self.define("ADIOS2_DIR", self.spec["adios2"].prefix)) - if "+user-plumed" in spec or "+plumed" in spec: + if spec.satisfies("+user-plumed") or spec.satisfies("+plumed"): args.append(self.define("DOWNLOAD_PLUMED", False)) if "+shared" in self.spec["plumed"]: args.append(self.define("PLUMED_MODE", "shared")) else: args.append(self.define("PLUMED_MODE", "static")) - if "+user-smd" in spec or "+machdyn" in spec: + if spec.satisfies("+user-smd") or spec.satisfies("+machdyn"): args.append(self.define("DOWNLOAD_EIGEN3", False)) args.append(self.define("EIGEN3_INCLUDE_DIR", self.spec["eigen"].prefix.include)) - if "+user-hdnnp" in spec or "+ml-hdnnp" in spec: + if spec.satisfies("+user-hdnnp") or spec.satisfies("+ml-hdnnp"): args.append(self.define("DOWNLOAD_N2P2", False)) args.append(self.define("N2P2_DIR", self.spec["n2p2"].prefix)) - if "+rocm" in spec: + if spec.satisfies("+rocm"): args.append(self.define("CMAKE_CXX_COMPILER", spec["hip"].hipcc)) - - if "+python" in spec: - args.append(self.define("Python_EXECUTABLE", spec["python"].command.path)) + if spec.satisfies("@:20231121"): + if spec.satisfies("^hip@:5.4"): + args.append(self.define("HIP_PATH", f"{spec['hip'].prefix}/hip")) + elif spec.satisfies("^hip@5.5:"): + args.append(self.define("HIP_PATH", spec["hip"].prefix)) return args @@ -865,13 +980,21 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): def setup_run_environment(self, env): env.set("LAMMPS_POTENTIALS", self.prefix.share.lammps.potentials) - if "+python" in self.spec: + if self.spec.satisfies("+python"): if self.spec.platform == "darwin": env.prepend_path("DYLD_FALLBACK_LIBRARY_PATH", self.prefix.lib) env.prepend_path("DYLD_FALLBACK_LIBRARY_PATH", self.prefix.lib64) else: env.prepend_path("LD_LIBRARY_PATH", self.prefix.lib) env.prepend_path("LD_LIBRARY_PATH", self.prefix.lib64) + if self.spec.satisfies("+plugin"): + env.prepend_path("LAMMPS_PLUGIN_PATH", self.prefix.lib.lammps.plugins) + env.prepend_path("LAMMPS_PLUGIN_PATH", self.prefix.lib64.lammps.plugins) + + @run_after("install") + def make_plugins_directories(self): + os.makedirs(self.prefix.lib.lammps.plugins, exist_ok=True) + os.makedirs(self.prefix.lib64.lammps.plugins, exist_ok=True) @run_after("install") def install_python(self): @@ -881,5 +1004,4 @@ class Lammps(CMakePackage, CudaPackage, ROCmPackage, PythonExtension): os.environ["LAMMPS_VERSION_FILE"] = join_path( self.stage.source_path, "src", "version.h" ) - args = std_pip_args + ["--prefix=" + self.prefix, "."] - pip(*args) + pip(*PythonPipBuilder.std_args(self), f"--prefix={self.prefix}", ".") |