[TAU package] Update with +rocprofv2. Updated some tests. (#43937)
* [TAU package] Update with +rocprofv2. Updated some tests. pdated with +rocprofv2 flag. Only works with rocm-core >= 6.0.0 Can be tested with (Omnia): spack install tau@master +rocm+rocprofv2 %gcc@11 Needs the last commit in our local repository, can be done by modifying the "git = " line, or waiting until the public one is updated. In the case that tests cause issues when building TAU, there is the flag: disable_tests = False The rocm test is disabled by default, as the PR regarding tests loading dependencies is not solved (PR#43682). * [@spackbot] updating style on behalf of jordialcaraz --------- Co-authored-by: jordialcaraz <jordialcaraz@users.noreply.github.com>
This commit is contained in:
		| @@ -85,6 +85,7 @@ class Tau(Package): | |||||||
|     variant("level_zero", default=False, description="Activates Intel OneAPI Level Zero support") |     variant("level_zero", default=False, description="Activates Intel OneAPI Level Zero support") | ||||||
|     variant("rocprofiler", default=False, description="Activates ROCm rocprofiler support") |     variant("rocprofiler", default=False, description="Activates ROCm rocprofiler support") | ||||||
|     variant("roctracer", default=False, description="Activates ROCm roctracer support") |     variant("roctracer", default=False, description="Activates ROCm roctracer support") | ||||||
|  |     variant("rocprofv2", default=False, description="Activates ROCm rocprofiler support") | ||||||
|     variant("opencl", default=False, description="Activates OpenCL support") |     variant("opencl", default=False, description="Activates OpenCL support") | ||||||
|     variant("fortran", default=darwin_default, description="Activates Fortran support") |     variant("fortran", default=darwin_default, description="Activates Fortran support") | ||||||
|     variant("io", default=True, description="Activates POSIX I/O support") |     variant("io", default=True, description="Activates POSIX I/O support") | ||||||
| @@ -140,6 +141,7 @@ class Tau(Package): | |||||||
|     depends_on("sqlite", when="+sqlite") |     depends_on("sqlite", when="+sqlite") | ||||||
|     depends_on("hwloc") |     depends_on("hwloc") | ||||||
|     depends_on("rocprofiler-dev", when="+rocprofiler") |     depends_on("rocprofiler-dev", when="+rocprofiler") | ||||||
|  |     depends_on("rocprofiler-dev@6.0.0:", when="@2.34: +rocprofv2") | ||||||
|     depends_on("roctracer-dev", when="+roctracer") |     depends_on("roctracer-dev", when="+roctracer") | ||||||
|     depends_on("hsa-rocr-dev", when="+rocm") |     depends_on("hsa-rocr-dev", when="+rocm") | ||||||
|     depends_on("rocm-smi-lib", when="@2.32.1: +rocm") |     depends_on("rocm-smi-lib", when="@2.32.1: +rocm") | ||||||
| @@ -161,15 +163,18 @@ class Tau(Package): | |||||||
|     patch("unwind.patch", when="@2.29.0") |     patch("unwind.patch", when="@2.29.0") | ||||||
| 
 | 
 | ||||||
|     conflicts("+rocprofiler", when="+roctracer", msg="Use either rocprofiler or roctracer") |     conflicts("+rocprofiler", when="+roctracer", msg="Use either rocprofiler or roctracer") | ||||||
|  |     conflicts("+rocprofv2", when="+rocprofiler", msg="Rocprofv2 does not need rocprofiler") | ||||||
|  |     conflicts("+rocprofv2", when="+roctracer", msg="Rocprofv2 does not need roctracer") | ||||||
|     requires("+rocm", when="+rocprofiler", msg="Rocprofiler requires ROCm") |     requires("+rocm", when="+rocprofiler", msg="Rocprofiler requires ROCm") | ||||||
|     requires("+rocm", when="+roctracer", msg="Roctracer requires ROCm") |     requires("+rocm", when="+roctracer", msg="Roctracer requires ROCm") | ||||||
| 
 | 
 | ||||||
|     requires( |     requires( | ||||||
|         "+rocprofiler", |         "+rocprofiler", | ||||||
|         "+roctracer", |         "+roctracer", | ||||||
|  |         "+rocprofv2", | ||||||
|         policy="one_of", |         policy="one_of", | ||||||
|         when="+rocm", |         when="+rocm", | ||||||
|         msg="When using ROCm, you need to select either +rocprofiler or +roctracer", |         msg="Using ROCm, select either +rocprofiler, +roctracer or +rocprofv2", | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     filter_compiler_wrappers("Makefile", relative_root="include") |     filter_compiler_wrappers("Makefile", relative_root="include") | ||||||
| @@ -344,6 +349,10 @@ def install(self, spec, prefix): | |||||||
|             if spec.satisfies("@2.34:"): |             if spec.satisfies("@2.34:"): | ||||||
|                 options.append("-hip=%s" % spec["hip"].prefix) |                 options.append("-hip=%s" % spec["hip"].prefix) | ||||||
| 
 | 
 | ||||||
|  |         if "+rocprofv2" in spec: | ||||||
|  |             options.append("-rocprofiler=%s" % spec["rocprofiler-dev"].prefix) | ||||||
|  |             options.append("-rocprofv2") | ||||||
|  | 
 | ||||||
|         if "+adios2" in spec: |         if "+adios2" in spec: | ||||||
|             options.append("-adios=%s" % spec["adios2"].prefix) |             options.append("-adios=%s" % spec["adios2"].prefix) | ||||||
| 
 | 
 | ||||||
| @@ -442,9 +451,9 @@ def setup_run_environment(self, env): | |||||||
|     syscall_test = join_path("examples", "syscall") |     syscall_test = join_path("examples", "syscall") | ||||||
|     ompt_test = join_path("examples", "openmp", "c++") |     ompt_test = join_path("examples", "openmp", "c++") | ||||||
|     python_test = join_path("examples", "python") |     python_test = join_path("examples", "python") | ||||||
|  |     disable_tests = False | ||||||
| 
 | 
 | ||||||
|     # Disabled, see PR#43682 comments |     @run_after("install") | ||||||
|     # @run_after("install") |  | ||||||
|     def setup_build_tests(self): |     def setup_build_tests(self): | ||||||
|         """Copy the build test files after the package is installed to an |         """Copy the build test files after the package is installed to an | ||||||
|         install test subdirectory for use during `spack test run`.""" |         install test subdirectory for use during `spack test run`.""" | ||||||
| @@ -466,157 +475,106 @@ def setup_build_tests(self): | |||||||
|         if "+python" in self.spec: |         if "+python" in self.spec: | ||||||
|             self.cache_extra_test_sources(self.python_test) |             self.cache_extra_test_sources(self.python_test) | ||||||
| 
 | 
 | ||||||
|     def _run_dyninst_test(self, test_dir): |     def _run_python_test(self, test_name, purpose, work_dir): | ||||||
|         dyn_dir = join_path(test_dir, self.dyninst_test) |         tau_python = which(self.prefix.bin.tau_python) | ||||||
|         flags = "serial" |         tau_py_inter = "-tau-python-interpreter=" + self.spec["python"].prefix.bin.python | ||||||
|         if "+mpi" in self.spec: |         pprof = which(self.prefix.bin.pprof) | ||||||
|             flags = "mpi" |         with test_part(self, f"{test_name}", purpose, work_dir): | ||||||
|         self.run_test("make", ["all"], [], 0, False, "Build example code", False, dyn_dir) |             if "+mpi" in self.spec: | ||||||
|         self.run_test( |                 flag = "mpi" | ||||||
|             "tau_run", |                 mpirun = which(self.spec["mpi"].prefix.bin.mpirun) | ||||||
|             ["-T", flags, "./klargest", "-v", "-o", "./klargest.i"], |                 mpirun( | ||||||
|             [], |                     "-np", | ||||||
|             0, |                     "4", | ||||||
|             False, |                     self.prefix.bin.tau_python, | ||||||
|             "Instrument code with dyninst", |                     tau_py_inter, | ||||||
|             False, |                     "-T", | ||||||
|             dyn_dir, |                     flag, | ||||||
|         ) |                     "firstprime.py", | ||||||
|         self.run_test( |                 ) | ||||||
|             "./klargest.i", [], [], 0, False, "Execute instrumented code", False, dyn_dir |  | ||||||
|         ) |  | ||||||
|         self.run_test( |  | ||||||
|             "pprof", |  | ||||||
|             [], |  | ||||||
|             [], |  | ||||||
|             0, |  | ||||||
|             False, |  | ||||||
|             "Run pprof profile analysis tool on profile output", |  | ||||||
|             False, |  | ||||||
|             dyn_dir, |  | ||||||
|         ) |  | ||||||
| 
 |  | ||||||
|     def _run_tau_test( |  | ||||||
|         self, main_test_dir, test_dir, test_name, test_exe, tau_exec_flags=[], use_tau_exec=False |  | ||||||
|     ): |  | ||||||
|         inst_test_dir = join_path(main_test_dir, test_dir) |  | ||||||
|         print(inst_test_dir) |  | ||||||
|         test_description = "Build {} test code".format(test_name) |  | ||||||
|         self.run_test("make", ["all"], [], 0, False, test_description, False, inst_test_dir) |  | ||||||
|         if "+mpi" in self.spec: |  | ||||||
|             if use_tau_exec: |  | ||||||
|                 test_args = ["-n", "4", "tau_exec", "-T", "mpi"] + tau_exec_flags |  | ||||||
|             else: |             else: | ||||||
|                 test_args = ["-n", "4"] + tau_exec_flags |                 flag = "serial" | ||||||
|             test_args.append(test_exe) |                 tau_python(tau_py_inter, "-T", flag, "firstprime.py") | ||||||
|             mpiexe_list = ["mpirun", "mpiexec", "srun"] |             pprof() | ||||||
|             for mpiexe in mpiexe_list: | 
 | ||||||
|                 if which(mpiexe) is not None: |     def _run_default_test(self, test_name, purpose, work_dir): | ||||||
|                     test_description = "Run {} test with mpi".format(test_name) |         tau_exec = which(self.prefix.bin.tau_exec) | ||||||
|                     self.run_test( |         pprof = which(self.prefix.bin.pprof) | ||||||
|                         mpiexe, test_args, [], 0, False, test_description, False, inst_test_dir |         with test_part(self, f"{test_name}", purpose, work_dir): | ||||||
|                     ) |             make("all") | ||||||
|                     break |             if "+mpi" in self.spec: | ||||||
|         else: |                 flags = ["-T", "mpi"] | ||||||
|             if use_tau_exec: |                 mpirun = which(self.spec["mpi"].prefix.bin.mpirun) | ||||||
|                 test_app = "tau_exec" |                 mpirun("-np", "4", self.prefix.bin.tau_exec, *flags, "./matmult") | ||||||
|                 test_args = ["-T", "serial"] + tau_exec_flags |  | ||||||
|                 test_args.append(test_exe) |  | ||||||
|             else: |             else: | ||||||
|                 test_app = test_exe |                 flags = ["-T", "serial"] | ||||||
|                 test_args = [] |                 tau_exec(*flags, "./matmult") | ||||||
|             test_description = "Run sequential {} test".format(test_name) |             pprof() | ||||||
|             self.run_test( |  | ||||||
|                 test_app, test_args, [], 0, False, test_description, False, inst_test_dir |  | ||||||
|             ) |  | ||||||
|         self.run_test( |  | ||||||
|             "pprof", |  | ||||||
|             [], |  | ||||||
|             [], |  | ||||||
|             0, |  | ||||||
|             False, |  | ||||||
|             "Run pprof profile analysis tool on profile output", |  | ||||||
|             False, |  | ||||||
|             inst_test_dir, |  | ||||||
|         ) |  | ||||||
| 
 | 
 | ||||||
|     def _run_python_test(self, test_dir): |     def _run_ompt_test(self, test_name, purpose, work_dir): | ||||||
|         python_dir = join_path(test_dir, self.python_test) |         tau_exec = which(self.prefix.bin.tau_exec) | ||||||
|         flags = "serial" |         pprof = which(self.prefix.bin.pprof) | ||||||
|         if "+mpi" in self.spec: |         with test_part(self, f"{test_name}", purpose, work_dir): | ||||||
|             flags = "mpi" |             make("all") | ||||||
|         self.run_test( |             if "+mpi" in self.spec: | ||||||
|             "tau_python", |                 flags = ["-T", "mpi", "-ompt"] | ||||||
|             ["-T", flags, "firstprime.py"], |                 mpirun = which(self.spec["mpi"].prefix.bin.mpirun) | ||||||
|             [], |                 mpirun("-np", "4", self.prefix.bin.tau_exec, *flags, "./mandel") | ||||||
|             0, |             else: | ||||||
|             False, |                 flags = ["-T", "serial", "-ompt"] | ||||||
|             "Pyhon example", |                 tau_exec(*flags, "./mandel") | ||||||
|             False, |             pprof() | ||||||
|             python_dir, |  | ||||||
|         ) |  | ||||||
|         self.run_test( |  | ||||||
|             "pprof", |  | ||||||
|             [], |  | ||||||
|             [], |  | ||||||
|             0, |  | ||||||
|             False, |  | ||||||
|             "Run pprof profile analysis tool on profile output", |  | ||||||
|             False, |  | ||||||
|             python_dir, |  | ||||||
|         ) |  | ||||||
| 
 | 
 | ||||||
|     def test(self): |     def _run_rocm_test(self, test_name, purpose, work_dir): | ||||||
|         # Temporarily disable tests, will update them with the new test method. |         tau_exec = which(self.prefix.bin.tau_exec) | ||||||
|         return |         pprof = which(self.prefix.bin.pprof) | ||||||
|         test_dir = self.test_suite.current_test_cache_dir |         with test_part(self, f"{test_name}", purpose, work_dir): | ||||||
|         # Run mm test program pulled from the build |             make("all") | ||||||
|         if "+ompt" in self.spec: |             if "+mpi" in self.spec: | ||||||
|             tau_exec_flags = ["-ompt"] |                 flags = ["-T", "mpi", "-rocm"] | ||||||
|             self._run_tau_test(test_dir, self.ompt_test, "OMPT example", "mandel", tau_exec_flags) |                 mpirun = which(self.spec["mpi"].prefix.bin.mpirun) | ||||||
|         else: |                 mpirun("-np", "4", self.prefix.bin.tau_exec, *flags, "./gpu-stream-hip") | ||||||
|             self._run_tau_test(test_dir, self.matmult_test, "matrix multiplication", "matmult") |             else: | ||||||
|         if "+dyninst" in self.spec: |                 flags = ["-T", "serial", "-rocm"] | ||||||
|             self._run_dyninst_test(test_dir) |                 tau_exec(*flags, "./gpu-stream-hip") | ||||||
|  |             pprof() | ||||||
|  | 
 | ||||||
|  |     def test_python(self): | ||||||
|  |         """test python variant""" | ||||||
|  |         if self.disable_tests: | ||||||
|  |             return | ||||||
|         if "+python" in self.spec: |         if "+python" in self.spec: | ||||||
|             self._run_python_test(test_dir) |             # current_test_cache_dir.examples.python | ||||||
|         if "+cuda" in self.spec: |             python_test_dir = join_path(self.test_suite.current_test_cache_dir, self.python_test) | ||||||
|             tau_exec_flags = ["-cupti"] |             self._run_python_test("test_tau_python", "Testing tau_python", python_test_dir) | ||||||
|             self._run_tau_test( | 
 | ||||||
|                 test_dir, |     def test_default(self): | ||||||
|                 self.cuda_test, |         """default matmult test""" | ||||||
|                 "CUDA example", |         if self.disable_tests: | ||||||
|                 "dataElem_um", |             return | ||||||
|                 tau_exec_flags, |         if "+ompt" in self.spec: | ||||||
|                 use_tau_exec=True, |             return | ||||||
|             ) |         default_test_dir = join_path(self.test_suite.current_test_cache_dir, self.matmult_test) | ||||||
|         if "+level_zero" in self.spec: |         self._run_default_test("test_default", "Testing TAU", default_test_dir) | ||||||
|             tau_exec_flags = ["-l0"] | 
 | ||||||
|             self._run_tau_test( |     def test_ompt(self): | ||||||
|                 test_dir, |         """ompt test""" | ||||||
|                 self.level_zero_test, |         if self.disable_tests: | ||||||
|                 "Level Zero example", |             return | ||||||
|                 "complex_mult.exe", |         if "+ompt" in self.spec: | ||||||
|                 tau_exec_flags, |             ompt_test_dir = join_path(self.test_suite.current_test_cache_dir, self.ompt_test) | ||||||
|                 use_tau_exec=True, |             self._run_ompt_test("test_ompt", "Testing ompt", ompt_test_dir) | ||||||
|             ) | 
 | ||||||
|         if "+rocm" in self.spec and ("+rocprofiler" in self.spec or "+roctracer" in self.spec): |     def test_rocm(self): | ||||||
|             tau_exec_flags = ["-rocm"] |         """rocm test""" | ||||||
|             self._run_tau_test( |         # Disabled, see PR#43682 | ||||||
|                 test_dir, |         # make is unable to find rocm_agent_enumerator | ||||||
|                 self.rocm_test, |         # when testing, with spack load, there is no issue | ||||||
|                 "Rocm example", |         return | ||||||
|                 "vectoradd_hip.exe", |         if self.disable_tests: | ||||||
|                 tau_exec_flags, |             return | ||||||
|                 use_tau_exec=True, |         if "+rocm" in self.spec and ( | ||||||
|             ) |             "+rocprofiler" in self.spec or "+roctracer" in self.spec or "+rocprofv2" in self.spec | ||||||
|         if "+syscall" in self.spec: |         ): | ||||||
|             tau_exec_flags = ["-syscall"] |             rocm_test_dir = join_path(self.test_suite.current_test_cache_dir, self.rocm_test) | ||||||
|             self._run_tau_test( |             self._run_rocm_test("test_rocm", "Testing rocm", rocm_test_dir) | ||||||
|                 test_dir, |  | ||||||
|                 self.syscall_test, |  | ||||||
|                 "Syscall example", |  | ||||||
|                 "syscall_test", |  | ||||||
|                 tau_exec_flags, |  | ||||||
|                 use_tau_exec=True, |  | ||||||
|             ) |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 jalcaraz
					jalcaraz