Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a stack to the statistics resource #1563

Merged
Merged
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
6cf4ee7
use std::shared_mutex
madsbk May 16, 2024
d13ee6b
clean up
madsbk May 16, 2024
25ff814
impl. push_counters() and pop_counters()
madsbk May 16, 2024
b453393
python bindings
madsbk May 16, 2024
1f7daa1
python tests
madsbk May 16, 2024
d6fd147
doc
madsbk May 17, 2024
fc49fe9
test_statistics
madsbk May 17, 2024
b9d57db
current allocation statistics
madsbk May 17, 2024
0e2f19c
clean up
madsbk May 17, 2024
7f7f940
Context to enable allocation statistics
madsbk May 17, 2024
68fcd08
Apply suggestions from code review
madsbk May 23, 2024
0254b73
doc
madsbk May 23, 2024
e6dd682
add_counters_from_tracked_sub_block
madsbk May 23, 2024
bf49dab
c++ tests
madsbk May 23, 2024
aef3b9f
Merge branch 'branch-24.06' into statistics_resource_counters_stack
madsbk May 23, 2024
145cb96
Merge branch 'branch-24.06' of github.com:rapidsai/rmm into statistic…
madsbk May 24, 2024
9bd1c2e
Merge branch 'branch-24.08' of github.com:rapidsai/rmm into statistic…
madsbk May 24, 2024
cef74e5
Merge branch 'branch-24.08' of github.com:rapidsai/rmm into statistic…
madsbk May 27, 2024
04b39cb
use dataclass Statistics
madsbk May 27, 2024
1dbd022
memory profiler
madsbk May 27, 2024
badbb56
clean up
madsbk May 27, 2024
6f35d23
fix typo
madsbk May 27, 2024
d8ee633
descriptive name
madsbk May 27, 2024
2df77d1
default_profiler_records
madsbk May 27, 2024
89827ad
tracking_resource_adaptor: use std::shared_mutex
madsbk May 28, 2024
24157b5
fix pytorch test
madsbk May 28, 2024
8df2d0a
pretty_print: added memory units
madsbk May 28, 2024
a82a7b6
doc
madsbk May 28, 2024
2b4b7d3
profiler: accept name argument
madsbk May 28, 2024
0067c05
profiler: now also a context manager
madsbk May 28, 2024
ab97d2a
cleanup
madsbk May 28, 2024
189ca30
pretty_print: output format
madsbk May 28, 2024
6debd83
fix doc build
madsbk May 28, 2024
796e159
Apply suggestions from code review
madsbk May 29, 2024
d2d64a1
style clean up
madsbk May 29, 2024
394d39f
doc
madsbk May 29, 2024
499c173
rename Data => MemoryRecord
madsbk May 29, 2024
463172d
rename pretty_print => report
madsbk May 29, 2024
c11b1c5
ruff check --fix --select D400
madsbk May 29, 2024
3d929d6
report: style
madsbk May 29, 2024
62a3870
doc
madsbk May 29, 2024
8d71415
spelling
madsbk May 30, 2024
8b8176b
Merge branch 'branch-24.08' of github.com:rapidsai/rmm into statistic…
madsbk May 30, 2024
a230794
style
madsbk May 30, 2024
17d9fd9
doc
madsbk May 30, 2024
23eb075
doc
madsbk Jun 4, 2024
9e92414
doc
madsbk Jun 4, 2024
42fb6c7
Merge branch 'branch-24.08' of github.com:rapidsai/rmm into statistic…
madsbk Jun 5, 2024
8b52c83
Update python/rmm/docs/guide.md
madsbk Jun 6, 2024
0b59246
Merge branch 'branch-24.08' into statistics_resource_counters_stack
madsbk Jun 6, 2024
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
Prev Previous commit
Next Next commit
python bindings
madsbk committed May 17, 2024
commit b4533934ff36420c7be0611f0d361a8575017a70
40 changes: 40 additions & 0 deletions python/rmm/rmm/_lib/memory_resource.pyx
Original file line number Diff line number Diff line change
@@ -189,6 +189,8 @@ cdef extern from "rmm/mr/device/statistics_resource_adaptor.hpp" \

counter get_bytes_counter() except +
counter get_allocations_counter() except +
pair[counter, counter] pop_counters() except +
pair[counter, counter] push_counters() except +

cdef extern from "rmm/mr/device/tracking_resource_adaptor.hpp" \
namespace "rmm::mr" nogil:
@@ -791,6 +793,9 @@ cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor):
allocations/deallocations performed by an upstream memory resource.
Includes the ability to query these statistics at any time.

The resource maintains a stack of counters, use `.push_counters()`
and `.pop_counters()` to record statistics at different nested levels.

Parameters
----------
upstream : DeviceMemoryResource
@@ -824,6 +829,41 @@ cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor):
"total_count": counts.total,
}

def pop_counters(self) -> dict:
"""
Pop a counter pair (bytes and allocations) from the stack
"""
cdef statistics_resource_adaptor[device_memory_resource]* mr = \
<statistics_resource_adaptor[device_memory_resource]*> self.c_obj.get()

bytes_and_allocs = deref(mr).pop_counters()
return {
"current_bytes": bytes_and_allocs.first.value,
"current_count": bytes_and_allocs.second.value,
"peak_bytes": bytes_and_allocs.first.peak,
"peak_count": bytes_and_allocs.second.peak,
"total_bytes": bytes_and_allocs.first.total,
"total_count": bytes_and_allocs.second.total,
}

def push_counters(self) -> dict:
"""
Push a new counter pair (bytes and allocations) on the stack
"""

cdef statistics_resource_adaptor[device_memory_resource]* mr = \
<statistics_resource_adaptor[device_memory_resource]*> self.c_obj.get()

bytes_and_allocs = deref(mr).push_counters()
return {
"current_bytes": bytes_and_allocs.first.value,
"current_count": bytes_and_allocs.second.value,
"peak_bytes": bytes_and_allocs.first.peak,
"peak_count": bytes_and_allocs.second.peak,
"total_bytes": bytes_and_allocs.first.total,
"total_count": bytes_and_allocs.second.total,
}

cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor):

def __cinit__(