Skip to content

Commit fc4ef96

Browse files
authored
Save address in alloc tracking snapshots (LLNL#302)
1 parent 421c667 commit fc4ef96

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

src/services/alloc/AllocService.cpp

+15-6
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,20 @@ class AllocService
152152
Channel* chn,
153153
cali::Node* label_node,
154154
const Variant& v_size,
155-
const Variant& v_uid) {
155+
const Variant& v_uid,
156+
const Variant& v_addr) {
156157
cali_id_t attr[] = {
157158
alloc_total_size_attr.id(),
158-
alloc_uid_attr.id()
159+
alloc_uid_attr.id(),
160+
alloc_addr_attr.id()
159161
};
160162
Variant data[] = {
161163
v_size,
162-
v_uid
164+
v_uid,
165+
v_addr
163166
};
164167

165-
SnapshotRecord trigger_info(1, &label_node, 2, attr, data);
168+
SnapshotRecord trigger_info(1, &label_node, 3, attr, data);
166169
c->push_snapshot(chn, &trigger_info);
167170
}
168171

@@ -199,7 +202,10 @@ class AllocService
199202
}
200203

201204
if (g_track_allocations)
202-
track_mem_snapshot(c, chn, info.alloc_label_node, Variant(static_cast<int>(total_size)), info.v_uid);
205+
track_mem_snapshot(c, chn, info.alloc_label_node,
206+
Variant(static_cast<int>(total_size)),
207+
info.v_uid,
208+
Variant(CALI_TYPE_ADDR, &ptr, sizeof(void*)));
203209

204210
{
205211
std::lock_guard<std::mutex>
@@ -242,7 +248,10 @@ class AllocService
242248
}
243249

244250
if (g_track_allocations)
245-
track_mem_snapshot(c, chn, info.free_label_node, Variant(-static_cast<int>(info.total_size)), info.v_uid);
251+
track_mem_snapshot(c, chn, info.free_label_node,
252+
Variant(-static_cast<int>(info.total_size)),
253+
info.v_uid,
254+
Variant(CALI_TYPE_ADDR, &ptr, sizeof(void*)));
246255

247256
{
248257
std::lock_guard<std::mutex>

test/ci_app_tests/test_allocservice.py

+9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ def test_alloc(self):
2424

2525
# test allocated.0
2626

27+
self.assertTrue(cat.has_snapshot_with_keys(
28+
snapshots, { 'mem.alloc', 'alloc.uid', 'alloc.address', 'alloc.total_size' }))
29+
self.assertTrue(cat.has_snapshot_with_keys(
30+
snapshots, { 'mem.free', 'alloc.uid', 'alloc.address', 'alloc.total_size' }))
31+
self.assertTrue(cat.has_snapshot_with_attributes(
32+
snapshots, { 'mem.alloc': 'test_alloc_A' }))
33+
self.assertTrue(cat.has_snapshot_with_attributes(
34+
snapshots, { 'mem.free': 'test_alloc_A' }))
35+
2736
self.assertTrue(cat.has_snapshot_with_keys(
2837
snapshots, { 'test_alloc.allocated.0', 'ptr_in', 'ptr_out' }))
2938

0 commit comments

Comments
 (0)