Repository: spack/spack

Issue:
intel-mpi-benchmarks is outdated and incomplete
### Summary

Currently, the available version of intel-mpi-benchmarks range from 2019.2 till 2019.6.
https://github.com/spack/spack/blob/v0.18.1/var/spack/repos/builtin/packages/intel-mpi-benchmarks/package.py#L22-L26

Intel has released much newer versions (latest being the 2021.3)
https://github.com/intel/mpi-benchmarks

Could you update the package.py including not only the latest versions but also all the former ones?

### Rationale

_No response_

### Description

_No response_

### Additional information

_No response_

### General information

- [x] I have run `spack --version` and reported the version of Spack
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
@carsonwoods is the maintainer of this build recipe

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/intel-mpi-benchmarks/package.py b/var/spack/repos/builtin/packages/intel-mpi-benchmarks/package.py
--- a/var/spack/repos/builtin/packages/intel-mpi-benchmarks/package.py
+++ b/var/spack/repos/builtin/packages/intel-mpi-benchmarks/package.py
@@ -18,74 +18,103 @@ class IntelMpiBenchmarks(MakefilePackage):
     """
 
     homepage = "https://software.intel.com/en-us/articles/intel-mpi-benchmarks"
-    url = "https://github.com/intel/mpi-benchmarks/archive/IMB-v2019.5.tar.gz"
-
+    url = "https://github.com/intel/mpi-benchmarks/archive/IMB-v2021.3.tar.gz"
     maintainers = ["carsonwoods"]
 
+    version("2021.3", sha256="9b58a4a7eef7c0c877513152340948402fd87cb06270d2d81308dc2ef740f4c7")
+    version("2021.2", sha256="ade3bfe18b4313a31fc09f0bf038e0a6c169c4145089bfc6f1f827687b81be6a")
+    version("2021.1", sha256="9089bb81e3091af3481e03b898b339fb2d9fb6574d4ef059adb1f5410112b23a")
     version("2019.6", sha256="1cd0bab9e947228fced4666d907f77c51336291533919896a923cff5fcad62e9")
     version("2019.5", sha256="61f8e872a3c3076af53007a68e4da3a8d66be2ba7a051dc21e626a4e2d26e651")
     version("2019.4", sha256="aeb336be10275c1a2f579b491b6631122876b461ac7148b1d0764f13b7552690")
     version("2019.3", sha256="4f256d11bfed9ca6166548486d61a062e67be61f13dd9f30690232720e185f31")
     version("2019.2", sha256="0bc2224a913073aaa5958f6ae08341e5fcd39cedc6722a09bfd4a3d7591a340b")
+    version("2019.1", sha256="fe0d065b9936b6943ea83cb3d00aede43b17565285c6b1791fee8e340853ef79")
+    version("2019.0", sha256="1c7d44aa7fd86ca84ac7cae1a69a8426243048d6294582337f1de7b4ffe68d37")
+    version("2018.1", sha256="718a4eb155f18cf15a736f6496332407b5837cf1f19831723d4cfe5266c43507")
+    version("2018.0", sha256="2e60a9894a686a95791be2227bc569bf81ca3875421b5307df7d83f885b1de88")
+
+    depends_on("mpi", when="@2019:")
+    depends_on("intel-mpi", when="@2018")
+    depends_on("gmake", type="build", when="@2018")
 
-    depends_on("mpi")
+    conflicts(
+        "^openmpi",
+        when="@:2019.0",
+        msg="intel-mpi-benchmarks <= v2019.0 cannot be built with OpenMPI, "
+        "please specify a different MPI implementation",
+    )
 
     # https://github.com/intel/mpi-benchmarks/pull/19
-    patch("add_const.patch", when="@:2019.6")
+    patch("add_const.patch", when="@2019")
     # https://github.com/intel/mpi-benchmarks/pull/20
-    patch("reorder_benchmark_macros.patch", when="@:2019.6")
-
-    variant(
-        "benchmark",
-        default="all",
-        values=("mpi1", "ext", "io", "nbc", "p2p", "rma", "mt", "all"),
-        multi=False,
-        description="Specify which benchmark to build",
-    )
+    patch("reorder_benchmark_macros.patch", when="@2019.1:2019.6")
 
-    def build(self, spec, prefix):
-        env["CC"] = spec["mpi"].mpicc
-        env["CXX"] = spec["mpi"].mpicxx
+    variant("mpi1", default=True, description="Build MPI1 benchmark")
+    variant("ext", default=True, description="Build MPI1 benchmark")
+    variant("io", default=True, description="Build MPI1 benchmark")
+    variant("nbc", default=True, description="Build MPI1 benchmark")
+    variant("p2p", default=True, description="Build MPI1 benchmark", when="@2018")
+    variant("rma", default=True, description="Build MPI1 benchmark")
+    variant("mt", default=True, description="Build MPI1 benchmark")
+
+    def url_for_version(self, version):
+        if version <= Version("2019.1"):
+            url = "https://github.com/intel/mpi-benchmarks/archive/refs/tags/v{0}.tar.gz"
+        else:
+            url = "https://github.com/intel/mpi-benchmarks/archive/refs/tags/IMB-v{0}.tar.gz"
+        return url.format(version)
 
-        if "benchmark=mpi1" in spec:
-            make("IMB-MPI1")
-        elif "benchmark=ext" in spec:
-            make("IMB-EXT")
-        elif "benchmark=io" in spec:
-            make("IMB-IO")
-        elif "benchmark=nbc" in spec:
-            make("IMB-NBC")
-        elif "benchmark=p2p" in spec:
-            make("IMB-P2P")
-        elif "benchmark=rma" in spec:
-            make("IMB-RMA")
-        elif "benchmark=mt" in spec:
-            make("IMB-MT")
+    @property
+    def build_directory(self):
+        if self.spec.satisfies("@2018"):
+            return "src"
         else:
-            make("all")
+            return "."
+
+    @property
+    def build_targets(self):
+        spec = self.spec
+        targets = []
+        if "+mpi1" in spec:
+            targets.append("MPI1")
+        elif "+ext" in spec:
+            targets.append("EXT")
+        elif "+io" in spec:
+            targets.append("IO")
+        elif "+nbc" in spec:
+            targets.append("NBC")
+        elif "+p2p" in spec:
+            targets.append("P2P")
+        elif "+rma" in spec:
+            targets.append("RMA")
+        elif "+mt" in spec:
+            targets.append("MT")
+
+        if self.spec.satisfies("@2019:"):
+            targets = ["TARGET=" + target for target in targets]
+
+        return targets
+
+    def edit(self, spec, prefix):
+        env["CC"] = spec["mpi"].mpicc
+        env["CXX"] = spec["mpi"].mpicxx
 
     def install(self, spec, prefix):
         mkdir(prefix.bin)
 
-        if "benchmark=mpi1" in spec:
-            install("IMB-MPI1", prefix.bin)
-        elif "benchmark=ext" in spec:
-            install("IMB-EXT", prefix.bin)
-        elif "benchmark=io" in spec:
-            install("IMB-IO", prefix.bin)
-        elif "benchmark=nbc" in spec:
-            install("IMB-NBC", prefix.bin)
-        elif "benchmark=p2p" in spec:
-            install("IMB-P2P", prefix.bin)
-        elif "benchmark=rma" in spec:
-            install("IMB-RMA", prefix.bin)
-        elif "benchmark=mt" in spec:
-            install("IMB-MT", prefix.bin)
-        else:
-            install("IMB-EXT", prefix.bin)
-            install("IMB-IO", prefix.bin)
-            install("IMB-MPI1", prefix.bin)
-            install("IMB-MT", prefix.bin)
-            install("IMB-NBC", prefix.bin)
-            install("IMB-P2P", prefix.bin)
-            install("IMB-RMA", prefix.bin)
+        with working_dir(self.build_directory):
+            if "+mpi1" in spec:
+                install("IMB-MPI1", prefix.bin)
+            elif "+ext" in spec:
+                install("IMB-EXT", prefix.bin)
+            elif "+io" in spec:
+                install("IMB-IO", prefix.bin)
+            elif "+nbc" in spec:
+                install("IMB-NBC", prefix.bin)
+            elif "+p2p" in spec:
+                install("IMB-P2P", prefix.bin)
+            elif "+rma" in spec:
+                install("IMB-RMA", prefix.bin)
+            elif "+mt" in spec:
+                install("IMB-MT", prefix.bin)


Test patch: