Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk committed May 17, 2024
1 parent b9d57db commit 0e2f19c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 41 deletions.
1 change: 0 additions & 1 deletion include/rmm/mr/device/statistics_resource_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class statistics_resource_adaptor final : public device_memory_resource {
*/
counter& operator+=(const counter& val)
{
// We count the peak from value
peak = std::max(value + val.peak, peak);
value += val.value;
total += val.total;
Expand Down
79 changes: 39 additions & 40 deletions python/rmm/rmm/tests/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,46 +57,45 @@ def test_multiple_mr(stats_mr):
# Push a new Tracking adaptor
mr2 = rmm.mr.StatisticsResourceAdaptor(stats_mr)
rmm.mr.set_current_device_resource(mr2)

for _ in range(2):
buffers.append(rmm.DeviceBuffer(size=1000))

assert mr2.allocation_counts == {
"current_bytes": 2016,
"current_count": 2,
"peak_bytes": 2016,
"peak_count": 2,
"total_bytes": 2016,
"total_count": 2,
}
assert stats_mr.allocation_counts == {
"current_bytes": 7056,
"current_count": 7,
"peak_bytes": 10080,
"peak_count": 10,
"total_bytes": 12096,
"total_count": 12,
}

del buffers

assert mr2.allocation_counts == {
"current_bytes": 0,
"current_count": 0,
"peak_bytes": 2016,
"peak_count": 2,
"total_bytes": 2016,
"total_count": 2,
}
assert stats_mr.allocation_counts == {
"current_bytes": 0,
"current_count": 0,
"peak_bytes": 10080,
"peak_count": 10,
"total_bytes": 12096,
"total_count": 12,
}
rmm.mr.set_current_device_resource(stats_mr)
try:
for _ in range(2):
buffers.append(rmm.DeviceBuffer(size=1000))

assert mr2.allocation_counts == {
"current_bytes": 2016,
"current_count": 2,
"peak_bytes": 2016,
"peak_count": 2,
"total_bytes": 2016,
"total_count": 2,
}
assert stats_mr.allocation_counts == {
"current_bytes": 7056,
"current_count": 7,
"peak_bytes": 10080,
"peak_count": 10,
"total_bytes": 12096,
"total_count": 12,
}
del buffers
assert mr2.allocation_counts == {
"current_bytes": 0,
"current_count": 0,
"peak_bytes": 2016,
"peak_count": 2,
"total_bytes": 2016,
"total_count": 2,
}
assert stats_mr.allocation_counts == {
"current_bytes": 0,
"current_count": 0,
"peak_bytes": 10080,
"peak_count": 10,
"total_bytes": 12096,
"total_count": 12,
}
finally:
rmm.mr.set_current_device_resource(stats_mr)


def test_counter_stack(stats_mr):
Expand Down

0 comments on commit 0e2f19c

Please sign in to comment.