diff --git a/CMakeLists.txt b/CMakeLists.txt index af6302d2..1871f78e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,10 +342,13 @@ if (WITH_ROCPROFILER OR WITH_ROCM) find_package(rocprofiler-sdk-roctx REQUIRED) if (rocprofiler-sdk_FOUND) set(CALIPER_HAVE_ROCPROFILER TRUE) + if (rocprofiler-sdk_VERSION VERSION_GREATER_EQUAL 1) + set(CALIPER_ROCPROFILER_HAS_COUNTERS TRUE) + endif() list(APPEND CALIPER_EXTERNAL_LIBS rocprofiler-sdk::rocprofiler-sdk rocprofiler-sdk-roctx::rocprofiler-sdk-roctx) - list(APPEND CALIPER_rocprofiler_CMAKE_MSG "Yes, using ${rocprofiler-sdk_ROOT_DIR}") + list(APPEND CALIPER_rocprofiler_CMAKE_MSG "Yes, using v${rocprofiler-sdk_VERSION} in ${rocprofiler-sdk_ROOT_DIR}") endif() else() set(CALIPER_HAVE_ROCPROFILER FALSE) diff --git a/test/ci_app_tests/CMakeLists.txt b/test/ci_app_tests/CMakeLists.txt index bb06d1bf..0371af18 100644 --- a/test/ci_app_tests/CMakeLists.txt +++ b/test/ci_app_tests/CMakeLists.txt @@ -104,6 +104,9 @@ if (CALIPER_HAVE_ROCPROFILER) target_link_libraries(vectoradd PUBLIC rocprofiler-sdk-roctx::rocprofiler-sdk-roctx caliper) if (RUN_HIP_TESTS) list(APPEND PYTHON_SCRIPTS test_rocprofiler.py) + if (CALIPER_ROCPROFILER_HAS_COUNTERS) + list(APPEND PYTHON_SCRIPTS test_rocprofiler_counters.py) + endif() endif() endif() diff --git a/test/ci_app_tests/test_rocprofiler.py b/test/ci_app_tests/test_rocprofiler.py index 17fb3bbe..f1e7b0bc 100644 --- a/test/ci_app_tests/test_rocprofiler.py +++ b/test/ci_app_tests/test_rocprofiler.py @@ -10,7 +10,7 @@ class CaliperRocmServicesTest(unittest.TestCase): """ Caliper test class for linux-specific services """ def test_rocm_activity_profile(self): - target_cmd = [ './vectoradd', 'rocm-activity-profile,profile.roctx,rocm.counters=SQ_WAVES_sum,output=stdout' ] + target_cmd = [ './vectoradd', 'rocm-activity-profile,profile.roctx,output=stdout' ] env = { 'HIP_LAUNCH_BLOCKING': '1' } out,_ = cat.run_test(target_cmd, env) @@ -37,11 +37,6 @@ def test_rocm_activity_profile(self): 'path': ['main', 'copy_d2h', 'hipMemcpy'] } )) - rec = cat.get_snapshot_with_keys(snapshots, ['path', 'sum#sum#rocm.SQ_WAVES_sum']) - self.assertIsNotNone(rec) - self.assertEqual(int(rec['sum#sum#rocm.SQ_WAVES_sum']), 16384) - self.assertEqual(rec['path'], ['main', 'vectoradd', 'hipLaunchKernel']) - def test_rocm_opts(self): target_cmd = [ './vectoradd', 'runtime-profile,profile.roctx,rocm.gputime,output=stdout' ] env = { 'HIP_LAUNCH_BLOCKING': '1' } diff --git a/test/ci_app_tests/test_rocprofiler_counters.py b/test/ci_app_tests/test_rocprofiler_counters.py new file mode 100644 index 00000000..20002929 --- /dev/null +++ b/test/ci_app_tests/test_rocprofiler_counters.py @@ -0,0 +1,47 @@ +# HIP tests + +import io +import unittest + +import caliperreader +import calipertest as cat + +class CaliperRocmCounterTest(unittest.TestCase): + """ Caliper test class for rocprofiler-sdk services w/ counters """ + + def test_rocm_activity_profile_with_counters(self): + target_cmd = [ './vectoradd', 'rocm-activity-profile,profile.roctx,rocm.counters=SQ_WAVES_sum,output=stdout' ] + env = { 'HIP_LAUNCH_BLOCKING': '1' } + + out,_ = cat.run_test(target_cmd, env) + snapshots,_ = caliperreader.read_caliper_contents(io.StringIO(out.decode())) + + self.assertTrue(len(snapshots) > 1) + + self.assertTrue(cat.has_snapshot_with_keys( + snapshots, { 'rocm.activity', + 'rocm.kernel.name', + 'scale#sum#rocm.activity.duration', + 'path', + 'rocm.marker' } + )) + self.assertTrue(cat.has_snapshot_with_attributes( + snapshots, { 'rocm.activity': 'KERNEL_DISPATCH_COMPLETE', + 'sum#sum#rocm.activity.count': '1', + 'path': ['main', 'vectoradd', 'hipLaunchKernel'] } + )) + self.assertTrue(cat.has_snapshot_with_attributes( + snapshots, { 'rocm.activity': 'MEMORY_COPY_DEVICE_TO_HOST', + 'sum#sum#rocm.activity.count': '1', + 'sum#sum#rocm.bytes': '4194304', + 'path': ['main', 'copy_d2h', 'hipMemcpy'] } + )) + + rec = cat.get_snapshot_with_keys(snapshots, ['path', 'sum#sum#rocm.SQ_WAVES_sum']) + self.assertIsNotNone(rec) + self.assertEqual(int(rec['sum#sum#rocm.SQ_WAVES_sum']), 16384) + self.assertEqual(rec['path'], ['main', 'vectoradd', 'hipLaunchKernel']) + + +if __name__ == "__main__": + unittest.main()