Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/ci_app_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
7 changes: 1 addition & 6 deletions test/ci_app_tests/test_rocprofiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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' }
Expand Down
47 changes: 47 additions & 0 deletions test/ci_app_tests/test_rocprofiler_counters.py
Original file line number Diff line number Diff line change
@@ -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()
Loading