|
| 1 | +# Copyright 2023 Lawrence Livermore National Security, LLC and other |
| 2 | +# Benchpark Project Developers. See the top-level COPYRIGHT file for details. |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: Apache-2.0 |
| 5 | + |
| 6 | +import os |
| 7 | +import sys |
| 8 | + |
| 9 | +from spack.package import * |
| 10 | + |
| 11 | + |
| 12 | +class Caliper(CachedCMakePackage, CudaPackage, ROCmPackage): |
| 13 | + """Caliper is a program instrumentation and performance measurement |
| 14 | + framework. It is designed as a performance analysis toolbox in a |
| 15 | + library, allowing one to bake performance analysis capabilities |
| 16 | + directly into applications and activate them at runtime. |
| 17 | + """ |
| 18 | + |
| 19 | + homepage = "https://github.com/LLNL/Caliper" |
| 20 | + git = "https://github.com/LLNL/Caliper.git" |
| 21 | + url = "https://github.com/LLNL/Caliper/archive/v2.12.1.tar.gz" |
| 22 | + tags = ["e4s", "radiuss"] |
| 23 | + |
| 24 | + maintainers("daboehme", "adrienbernede") |
| 25 | + |
| 26 | + test_requires_compiler = True |
| 27 | + |
| 28 | + license("BSD-3-Clause") |
| 29 | + |
| 30 | + version("master", branch="master") |
| 31 | + version("2.12.1", sha256="2b5a8f98382c94dc75cc3f4517c758eaf9a3f9cea0a8dbdc7b38506060d6955c") |
| 32 | + version("2.11.0", sha256="b86b733cbb73495d5f3fe06e6a9885ec77365c8aa9195e7654581180adc2217c") |
| 33 | + version("2.10.0", sha256="14c4fb5edd5e67808d581523b4f8f05ace8549698c0e90d84b53171a77f58565") |
| 34 | + version("2.9.1", sha256="4771d630de505eff9227e0ec498d0da33ae6f9c34df23cb201b56181b8759e9e") |
| 35 | + version("2.9.0", sha256="507ea74be64a2dfd111b292c24c4f55f459257528ba51a5242313fa50978371f") |
| 36 | + version( |
| 37 | + "2.8.0", |
| 38 | + sha256="17807b364b5ac4b05997ead41bd173e773f9a26ff573ff2fe61e0e70eab496e4", |
| 39 | + deprecated=True, |
| 40 | + ) |
| 41 | + version( |
| 42 | + "2.7.0", |
| 43 | + sha256="b3bf290ec2692284c6b4f54cc0c507b5700c536571d3e1a66e56626618024b2b", |
| 44 | + deprecated=True, |
| 45 | + ) |
| 46 | + version( |
| 47 | + "2.6.0", |
| 48 | + sha256="6efcd3e4845cc9a6169e0d934840766b12182c6d09aa3ceca4ae776e23b6360f", |
| 49 | + deprecated=True, |
| 50 | + ) |
| 51 | + version( |
| 52 | + "2.5.0", |
| 53 | + sha256="d553e60697d61c53de369b9ca464eb30710bda90fba9671201543b64eeac943c", |
| 54 | + deprecated=True, |
| 55 | + ) |
| 56 | + version( |
| 57 | + "2.4.0", tag="v2.4.0", commit="30577b4b8beae104b2b35ed487fec52590a99b3d", deprecated=True |
| 58 | + ) |
| 59 | + version( |
| 60 | + "2.3.0", tag="v2.3.0", commit="9fd89bb0120750d1f9dfe37bd963e24e478a2a20", deprecated=True |
| 61 | + ) |
| 62 | + version( |
| 63 | + "2.2.0", tag="v2.2.0", commit="c408e9b3642c7aa80eff37b0826d819c57e7bc04", deprecated=True |
| 64 | + ) |
| 65 | + version( |
| 66 | + "2.1.1", tag="v2.1.1", commit="0593b0e01c1d8d3e50c990399cc0fee403485599", deprecated=True |
| 67 | + ) |
| 68 | + version( |
| 69 | + "2.0.1", tag="v2.0.1", commit="4d7ff46381c53a461e62edd949e2d9dea9db7b08", deprecated=True |
| 70 | + ) |
| 71 | + version( |
| 72 | + "1.9.1", tag="v1.9.1", commit="cfc1defbbee20b50dd3e3477badd09a92b1df970", deprecated=True |
| 73 | + ) |
| 74 | + version( |
| 75 | + "1.9.0", tag="v1.9.0", commit="8356e747349b285aa621c5b74e71559f0babc4a1", deprecated=True |
| 76 | + ) |
| 77 | + version( |
| 78 | + "1.8.0", tag="v1.8.0", commit="117c1ef596b617dc71407b8b67eebef094a654f8", deprecated=True |
| 79 | + ) |
| 80 | + version( |
| 81 | + "1.7.0", tag="v1.7.0", commit="898277c93d884d4e7ca1ffcf3bbea81d22364f26", deprecated=True |
| 82 | + ) |
| 83 | + |
| 84 | + #depends_on("c", type="build") # generated |
| 85 | + #depends_on("cxx", type="build") # generated |
| 86 | + #depends_on("fortran", type="build") # generated |
| 87 | + |
| 88 | + is_linux = sys.platform.startswith("linux") |
| 89 | + variant("shared", default=True, description="Build shared libraries") |
| 90 | + variant("adiak", default=True, description="Enable Adiak support") |
| 91 | + variant("mpi", default=True, description="Enable MPI support") |
| 92 | + # libunwind has some issues on Mac |
| 93 | + variant( |
| 94 | + "libunwind", default=sys.platform != "darwin", description="Enable stack unwind support" |
| 95 | + ) |
| 96 | + variant("libdw", default=is_linux, description="Enable DWARF symbol lookup") |
| 97 | + # pthread_self() signature is incompatible with PAPI_thread_init() on Mac |
| 98 | + variant("papi", default=sys.platform != "darwin", description="Enable PAPI service") |
| 99 | + variant("libpfm", default=False, description="Enable libpfm (perf_events) service") |
| 100 | + # Gotcha is Linux-only |
| 101 | + variant("gotcha", default=is_linux, description="Enable GOTCHA support") |
| 102 | + variant("sampler", default=is_linux, description="Enable sampling support on Linux") |
| 103 | + variant("sosflow", default=False, description="Enable SOSflow support") |
| 104 | + variant("fortran", default=False, description="Enable Fortran support") |
| 105 | + variant("variorum", default=False, description="Enable Variorum support") |
| 106 | + variant("vtune", default=False, description="Enable Intel Vtune support") |
| 107 | + variant("kokkos", default=True, when="@2.3.0:", description="Enable Kokkos profiling support") |
| 108 | + variant("tests", default=False, description="Enable tests") |
| 109 | + variant("tools", default=True, description="Enable tools") |
| 110 | + variant("python", default=False, when="@v2.12:", description="Build Python bindings") |
| 111 | + |
| 112 | + depends_on( "[email protected]:0", when="@2.2:2.10 +adiak") |
| 113 | + depends_on( "[email protected]:0", when="@2.11: +adiak") |
| 114 | + |
| 115 | + depends_on( "[email protected]:5", when="@:2.2 +papi") |
| 116 | + depends_on( "[email protected]:", when="@2.3: +papi") |
| 117 | + |
| 118 | + depends_on( "[email protected]:4", when="+libpfm") |
| 119 | + |
| 120 | + depends_on("mpi", when="+mpi") |
| 121 | + depends_on( "[email protected]:1", when="+libunwind") |
| 122 | + depends_on("elfutils", when="+libdw") |
| 123 | + depends_on("variorum", when="+variorum") |
| 124 | + depends_on("intel-oneapi-vtune", when="+vtune") |
| 125 | + |
| 126 | + depends_on("sosflow@spack", when="@1.0:1+sosflow") |
| 127 | + |
| 128 | + depends_on("cmake", type="build") |
| 129 | + depends_on("python", type="build") |
| 130 | + |
| 131 | + depends_on("python@3", when="+python", type=("build", "link", "run")) |
| 132 | + depends_on("py-pybind11", when="+python", type=("build", "link", "run")) |
| 133 | + |
| 134 | + # sosflow support not yet in 2.0 |
| 135 | + conflicts("+sosflow", "@2:") |
| 136 | + conflicts("+adiak", "@:2.1") |
| 137 | + conflicts("+libdw", "@:2.4") |
| 138 | + conflicts("+rocm", "@:2.7") |
| 139 | + conflicts("+rocm+cuda") |
| 140 | + |
| 141 | + patch("for_aarch64.patch", when="@:2.11 target=aarch64:") |
| 142 | + patch( |
| 143 | + "sampler-service-missing-libunwind-include-dir.patch", |
| 144 | + when="@2.9.0:2.9.1 +libunwind +sampler", |
| 145 | + ) |
| 146 | + |
| 147 | + def _get_sys_type(self, spec): |
| 148 | + sys_type = spec.architecture |
| 149 | + if "SYS_TYPE" in env: |
| 150 | + sys_type = env["SYS_TYPE"] |
| 151 | + return sys_type |
| 152 | + |
| 153 | + def initconfig_compiler_entries(self): |
| 154 | + spec = self.spec |
| 155 | + entries = super().initconfig_compiler_entries() |
| 156 | + |
| 157 | + if spec.satisfies("+rocm"): |
| 158 | + entries.insert(0, cmake_cache_path("CMAKE_CXX_COMPILER", spec["hip"].hipcc)) |
| 159 | + |
| 160 | + entries.append(cmake_cache_option("WITH_FORTRAN", spec.satisfies("+fortran"))) |
| 161 | + |
| 162 | + entries.append(cmake_cache_option("BUILD_SHARED_LIBS", spec.satisfies("+shared"))) |
| 163 | + entries.append(cmake_cache_option("BUILD_TESTING", spec.satisfies("+tests"))) |
| 164 | + entries.append(cmake_cache_option("WITH_TOOLS", spec.satisfies("+tools"))) |
| 165 | + entries.append(cmake_cache_option("BUILD_DOCS", False)) |
| 166 | + entries.append(cmake_cache_path("PYTHON_EXECUTABLE", spec["python"].command.path)) |
| 167 | + |
| 168 | + return entries |
| 169 | + |
| 170 | + def initconfig_hardware_entries(self): |
| 171 | + spec = self.spec |
| 172 | + entries = super().initconfig_hardware_entries() |
| 173 | + |
| 174 | + if spec.satisfies("+cuda"): |
| 175 | + entries.append(cmake_cache_option("WITH_CUPTI", True)) |
| 176 | + entries.append(cmake_cache_option("WITH_NVTX", True)) |
| 177 | + entries.append(cmake_cache_path("CUDA_TOOLKIT_ROOT_DIR", spec["cuda"].prefix)) |
| 178 | + entries.append(cmake_cache_path("CUPTI_PREFIX", spec["cuda"].prefix)) |
| 179 | + else: |
| 180 | + entries.append(cmake_cache_option("WITH_CUPTI", False)) |
| 181 | + entries.append(cmake_cache_option("WITH_NVTX", False)) |
| 182 | + |
| 183 | + if spec.satisfies("+rocm"): |
| 184 | + entries.append(cmake_cache_option("WITH_ROCTRACER", True)) |
| 185 | + entries.append(cmake_cache_option("WITH_ROCTX", True)) |
| 186 | + else: |
| 187 | + entries.append(cmake_cache_option("WITH_ROCTRACER", False)) |
| 188 | + entries.append(cmake_cache_option("WITH_ROCTX", False)) |
| 189 | + |
| 190 | + return entries |
| 191 | + |
| 192 | + def initconfig_mpi_entries(self): |
| 193 | + spec = self.spec |
| 194 | + entries = super().initconfig_mpi_entries() |
| 195 | + |
| 196 | + entries.append(cmake_cache_option("WITH_MPI", spec.satisfies("+mpi"))) |
| 197 | + |
| 198 | + return entries |
| 199 | + |
| 200 | + def initconfig_package_entries(self): |
| 201 | + spec = self.spec |
| 202 | + entries = [] |
| 203 | + |
| 204 | + # TPL locations |
| 205 | + entries.append("#------------------{0}".format("-" * 60)) |
| 206 | + entries.append("# TPLs") |
| 207 | + entries.append("#------------------{0}\n".format("-" * 60)) |
| 208 | + |
| 209 | + if spec.satisfies("+adiak"): |
| 210 | + entries.append(cmake_cache_path("adiak_DIR", spec["adiak"].prefix)) |
| 211 | + if spec.satisfies("+papi"): |
| 212 | + entries.append(cmake_cache_path("PAPI_PREFIX", spec["papi"].prefix)) |
| 213 | + if spec.satisfies("+libdw"): |
| 214 | + entries.append(cmake_cache_path("LIBDW_PREFIX", spec["elfutils"].prefix)) |
| 215 | + if spec.satisfies("+libpfm"): |
| 216 | + entries.append(cmake_cache_path("LIBPFM_INSTALL", spec["libpfm4"].prefix)) |
| 217 | + if spec.satisfies("+sosflow"): |
| 218 | + entries.append(cmake_cache_path("SOS_PREFIX", spec["sosflow"].prefix)) |
| 219 | + if spec.satisfies("+variorum"): |
| 220 | + entries.append(cmake_cache_path("VARIORUM_PREFIX", spec["variorum"].prefix)) |
| 221 | + if spec.satisfies("+vtune"): |
| 222 | + itt_dir = join_path(spec["intel-oneapi-vtune"].prefix, "vtune", "latest") |
| 223 | + entries.append(cmake_cache_path("ITT_PREFIX", itt_dir)) |
| 224 | + if spec.satisfies("+libunwind"): |
| 225 | + entries.append(cmake_cache_path("LIBUNWIND_PREFIX", spec["unwind"].prefix)) |
| 226 | + |
| 227 | + # Build options |
| 228 | + entries.append("#------------------{0}".format("-" * 60)) |
| 229 | + entries.append("# Build Options") |
| 230 | + entries.append("#------------------{0}\n".format("-" * 60)) |
| 231 | + |
| 232 | + entries.append(cmake_cache_option("WITH_ADIAK", spec.satisfies("+adiak"))) |
| 233 | + entries.append(cmake_cache_option("WITH_GOTCHA", spec.satisfies("+gotcha"))) |
| 234 | + entries.append(cmake_cache_option("WITH_SAMPLER", spec.satisfies("+sampler"))) |
| 235 | + entries.append(cmake_cache_option("WITH_PAPI", spec.satisfies("+papi"))) |
| 236 | + entries.append(cmake_cache_option("WITH_LIBDW", spec.satisfies("+libdw"))) |
| 237 | + entries.append(cmake_cache_option("WITH_LIBPFM", spec.satisfies("+libpfm"))) |
| 238 | + entries.append(cmake_cache_option("WITH_SOSFLOW", spec.satisfies("+sosflow"))) |
| 239 | + entries.append(cmake_cache_option("WITH_KOKKOS", spec.satisfies("+kokkos"))) |
| 240 | + entries.append(cmake_cache_option("WITH_VARIORUM", spec.satisfies("+variorum"))) |
| 241 | + entries.append(cmake_cache_option("WITH_VTUNE", spec.satisfies("+vtune"))) |
| 242 | + entries.append(cmake_cache_option("WITH_PYTHON_BINDINGS", spec.satisfies("+python"))) |
| 243 | + |
| 244 | + # -DWITH_CALLPATH was renamed -DWITH_LIBUNWIND in 2.5 |
| 245 | + callpath_flag = "LIBUNWIND" if spec.satisfies("@2.5:") else "CALLPATH" |
| 246 | + entries.append(cmake_cache_option("WITH_%s" % callpath_flag, spec.satisfies("+libunwind"))) |
| 247 | + |
| 248 | + return entries |
| 249 | + |
| 250 | + def cmake_args(self): |
| 251 | + return [] |
| 252 | + |
| 253 | + def setup_run_environment(self, env): |
| 254 | + if self.spec.satisfies("+python"): |
| 255 | + env.prepend_path("PYTHONPATH", self.spec.prefix.join(python_platlib)) |
| 256 | + env.prepend_path("PYTHONPATH", self.spec.prefix.join(python_purelib)) |
| 257 | + |
| 258 | + @run_after("install") |
| 259 | + def cache_test_sources(self): |
| 260 | + """Copy the example source files after the package is installed to an |
| 261 | + install test subdirectory for use during `spack test run`.""" |
| 262 | + cache_extra_test_sources(self, [join_path("examples", "apps")]) |
| 263 | + |
| 264 | + def test_cxx_example(self): |
| 265 | + """build and run cxx-example""" |
| 266 | + |
| 267 | + exe = "cxx-example" |
| 268 | + source_file = "{0}.cpp".format(exe) |
| 269 | + |
| 270 | + source_path = find_required_file( |
| 271 | + self.test_suite.current_test_cache_dir, source_file, expected=1, recursive=True |
| 272 | + ) |
| 273 | + |
| 274 | + lib_dir = self.prefix.lib if os.path.exists(self.prefix.lib) else self.prefix.lib64 |
| 275 | + |
| 276 | + cxx = which(os.environ["CXX"]) |
| 277 | + test_dir = os.path.dirname(source_path) |
| 278 | + with working_dir(test_dir): |
| 279 | + cxx( |
| 280 | + "-L{0}".format(lib_dir), |
| 281 | + "-I{0}".format(self.prefix.include), |
| 282 | + source_path, |
| 283 | + "-o", |
| 284 | + exe, |
| 285 | + "-std=c++11", |
| 286 | + "-lcaliper", |
| 287 | + "-lstdc++", |
| 288 | + ) |
| 289 | + |
| 290 | + cxx_example = which(exe) |
| 291 | + cxx_example() |
0 commit comments