PAPI misc fixes (#39191)

Spack installs the hsa-rocr-dev and rocprofiler packages into different
directories. However, PAPI typically expects those to be under the same
directory and locates such directory through the PAPI_ROCM_ROOT env
variable.

The PAPI rocm component also allows users to override PAPI_ROCM_ROOT to
locate directly the librocprofiler64.so through the HSA_TOOLS_LIB env
variable that acts directly onto the HSA runtime tools mechanism.

Hence, in order to account for the decoupling of hsa and rocprofiler,
this patch sets HSA_TOOLS_LIB to librocprofiler64.so full path.
This commit is contained in:
Giuseppe Congiu 2023-08-23 10:09:54 +02:00 committed by GitHub
parent 1a0434b808
commit d355880110
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,6 +54,7 @@ class Papi(AutotoolsPackage, ROCmPackage):
variant("shared", default=True, description="Build shared libraries")
# PAPI requires building static libraries, so there is no "static" variant
variant("static_tools", default=False, description="Statically link the PAPI tools")
variant("debug", default=False, description="Enable debug symbols in PAPI")
# The PAPI configure option "--with-shlib-tools" is deprecated
# and therefore not implemented here
@ -90,6 +91,7 @@ def setup_build_environment(self, env):
env.set("PAPI_CUDA_ROOT", spec["cuda"].prefix)
if "+rocm" in spec:
env.set("PAPI_ROCM_ROOT", spec["hsa-rocr-dev"].prefix)
env.set("HSA_TOOLS_LIB", "%s/librocprofiler64.so" % spec["rocprofiler-dev"].prefix.lib)
env.append_flags("CFLAGS", "-I%s/rocprofiler/include" % spec["rocprofiler-dev"].prefix)
env.set(
"ROCP_METRICS", "%s/rocprofiler/lib/metrics.xml" % spec["rocprofiler-dev"].prefix
@ -97,9 +99,6 @@ def setup_build_environment(self, env):
env.set("ROCPROFILER_LOG", "1")
env.set("HSA_VEN_AMD_AQLPROFILE_LOG", "1")
env.set("AQLPROFILE_READ_API", "1")
# Setting HSA_TOOLS_LIB=librocprofiler64.so (as recommended) doesn't work
# due to a conflict between the spack and system-installed versions.
env.set("HSA_TOOLS_LIB", "unset")
if "+rocm_smi" in spec:
env.append_flags("CFLAGS", "-I%s/rocm_smi" % spec["rocm-smi-lib"].prefix.include)
#
@ -146,6 +145,9 @@ def configure_args(self):
if "+static_tools" in spec:
options.append("--with-static-tools")
if "+debug" in spec:
options.append("--with-debug=yes")
return options
@run_before("configure")