forked from llnl/Caliper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_rocprofiler.py
More file actions
62 lines (47 loc) · 2.36 KB
/
Copy pathtest_rocprofiler.py
File metadata and controls
62 lines (47 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# HIP tests
import io
import unittest
import caliperreader
import calipertest as cat
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' ]
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'])
def test_rocm_opts(self):
target_cmd = [ './vectoradd', 'runtime-profile,profile.roctx,rocm.gputime,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, { 'iscale#t.gpu.r', 'path' }))
rec = cat.get_snapshot_with_keys(snapshots, ['path', 'scale#t.gpu.r'])
self.assertIsNotNone(rec)
self.assertGreater(float(rec['scale#t.gpu.r']), 0.0)
if __name__ == "__main__":
unittest.main()