From 634b135687ce5cae5d716a9d694008462f61d85e Mon Sep 17 00:00:00 2001 From: eugeneswalker Date: Fri, 18 Aug 2023 14:12:48 -0700 Subject: [PATCH] tau@2.32.1 +rocm: properly specify rocm-smi dir via patch --- .../repos/builtin/packages/tau/package.py | 7 ++ .../tau/tau-2.32.1-rocm-smi-dir.patch | 87 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 var/spack/repos/builtin/packages/tau/tau-2.32.1-rocm-smi-dir.patch diff --git a/var/spack/repos/builtin/packages/tau/package.py b/var/spack/repos/builtin/packages/tau/package.py index 173b0d4a6ac..4e00d95a4c4 100644 --- a/var/spack/repos/builtin/packages/tau/package.py +++ b/var/spack/repos/builtin/packages/tau/package.py @@ -125,6 +125,7 @@ class Tau(Package): depends_on("rocprofiler-dev", when="+rocprofiler") depends_on("roctracer-dev", when="+roctracer") depends_on("hsa-rocr-dev", when="+rocm") + depends_on("rocm-smi-lib", when="+rocm") depends_on("java", type="run") # for paraprof depends_on("oneapi-level-zero", when="+level_zero") @@ -137,6 +138,7 @@ class Tau(Package): conflicts("+sqlite", when="@:2.29.1") patch("unwind.patch", when="@2.29.0") + patch("tau-2.32.1-rocm-smi-dir.patch", when="@2.32.1 +rocm") filter_compiler_wrappers("Makefile", relative_root="include") filter_compiler_wrappers("Makefile.tau*", relative_root="lib") @@ -145,6 +147,9 @@ class Tau(Package): def set_compiler_options(self, spec): useropt = ["-O2 -g", self.rpath_args] + if self.spec.satisfies("@2.32.1 +rocm"): + useropt.append("-I{0}/include".format(spec["rocm-smi-lib"].prefix)) + if self.spec.satisfies("%oneapi"): useropt.append("-Wno-error=implicit-function-declaration") @@ -289,6 +294,8 @@ def install(self, spec, prefix): if "+rocm" in spec: options.append("-rocm=%s" % spec["hsa-rocr-dev"].prefix) + if spec.satisfies("@2.32.1"): + options.append("-rocmsmi=%s" % spec["rocm-smi-lib"].prefix) if "+rocprofiler" in spec: options.append("-rocprofiler=%s" % spec["rocprofiler-dev"].prefix) diff --git a/var/spack/repos/builtin/packages/tau/tau-2.32.1-rocm-smi-dir.patch b/var/spack/repos/builtin/packages/tau/tau-2.32.1-rocm-smi-dir.patch new file mode 100644 index 00000000000..8f4eba81b17 --- /dev/null +++ b/var/spack/repos/builtin/packages/tau/tau-2.32.1-rocm-smi-dir.patch @@ -0,0 +1,87 @@ +diff -ruN spack-src/configure spack-src-patched/configure +--- spack-src/configure 2023-08-17 17:01:17.000000000 -0700 ++++ spack-src-patched/configure 2023-08-18 11:08:49.959762310 -0700 +@@ -768,6 +768,7 @@ + echo "-rocm[=] ...... Specify alternate path to ROCm (/opt/rocm default)." + echo "-rocprofiler= .............. Specify location of ROCm rocprofiler." + echo "-rocprofv2 .......................................... Enable rocprofv2." ++ echo "-rocmsmi= ..................... Specify location of RoCm rocm_smi." + # echo "-rocprofilerinc= .... Specify location of rocprofiler include dir." + # echo "-rocprofilerlibrary= .... Specify name of rocprofiler library." + echo "-level_zero[=] ................. Specify path to Intel Level Zero." +@@ -936,6 +937,7 @@ + echo "-rocm[=] ..... Specify alternate path to ROCm (/opt/rocm default)." + echo "-rocprofiler= .............. Specify location of ROCm rocprofiler." + echo "-rocprofv2 .......................................... Enable rocprofv2." ++ echo "-rocmsmi= ..................... Specify location of RoCm rocm_smi." + #echo "-rocprofilerinc= .... Specify location of rocprofiler include dir." + #echo "-rocprofilerlibrary= .... Specify name of rocprofiler library." + echo "-roctracer= .................. Specify location of ROCm roctracer." +@@ -1364,6 +1366,7 @@ + rocprofiler=no + rocprofv2=no + roctracer=no ++rocmsmi=no + hip=no + use_opencl=no + use_openacc=no +@@ -3057,6 +3060,17 @@ + shift + ;; + ++ -rocmsmi=*) ++ rocmsmidir=`echo $arg | sed -e 's/-rocmsmi=//' -e 's/ /#/g'` ++ if [ ! -d $rocmsmidir ]; then ++ echo "Error: Cannot access ROCm smi directory $rocmsmidir" ++ exit 1 ++ else ++ fixmakeargs="$fixmakeargs rocmsmidir=$rocmsmidir" ++ rocmsmi=yes ++ fi ++ shift ++ ;; + + -hip=*) + hipdir=`echo $arg | sed -e 's/-hip=//' -e 's/ /#/g'` +@@ -3324,6 +3338,11 @@ + pthread=yes + fi + ++if [ "x$rocmsmi" = "xno" ]; then ++ echo "No rocmsmi specified, using $rocmdir" ++ fixmakeargs="$fixmakeargs rocmsmidir=$rocmdir" ++fi ++ + if [ "x$use_opencl" = "xyes" -a "x$openclinclude" = "x" ]; then + ld_lib_path=`echo $LD_LIBRARY_PATH | sed -e "s@:@ @g" ` + for d in $ld_lib_path +diff -ruN spack-src/include/Makefile.skel spack-src-patched/include/Makefile.skel +--- spack-src/include/Makefile.skel 2023-08-17 17:01:17.000000000 -0700 ++++ spack-src-patched/include/Makefile.skel 2023-08-18 11:09:02.763832652 -0700 +@@ -182,8 +182,9 @@ + TAU_ROCPROFILER_LIBRARY= + TAU_ROCTRACER= + TAU_ROCTRACER_LIB_DIR=$(TAU_ROCTRACER)/lib +-TAU_ROCM_SMI_INC=$(TAU_ROCM_DIR)/include/rocm_smi +-TAU_ROCM_SMI_LIB_DIR=$(TAU_ROCM_DIR)/rocm_smi/lib ++TAU_ROCM_SMI_DIR= ++TAU_ROCM_SMI_INC=$(TAU_ROCM_SMI_DIR)/include/rocm_smi ++TAU_ROCM_SMI_LIB_DIR=$(TAU_ROCM_SMI_DIR)/lib + TAU_CMAKE= + TAU_HIP= + PIN_ROOT= +diff -ruN spack-src/utils/FixMakefile spack-src-patched/utils/FixMakefile +--- spack-src/utils/FixMakefile 2023-08-15 08:11:00.000000000 -0700 ++++ spack-src-patched/utils/FixMakefile 2023-08-18 11:08:50.803766947 -0700 +@@ -1082,6 +1082,10 @@ + roctracerlibdir=`echo $1 | sed -e 's/^roctracerlibdir=//' -e 's/#/ /g'` + echo "s@^TAU_ROCTRACER_LIB_DIR=\(.*\)@TAU_ROCTRACER_LIB_DIR=$roctracerlibdir@g" >> $sedout + ;; ++ rocmsmidir=*) ++ rocmsmidir=`echo $1 | sed -e 's/^rocmsmidir=//' -e 's/#/ /g'` ++ echo "s@^TAU_ROCM_SMI_DIR=\(.*\)@TAU_ROCM_SMI_DIR=$rocmsmidir@g" >> $sedout ++ ;; + hipdir=*) + hipdir=`echo $1 | sed -e 's/^hipdir=//' -e 's/#/ /g'` + echo "s@^TAU_HIP=\(.*\)@TAU_HIP=$hipdir@g" >> $sedout +