|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +from libc.stddef cimport size_t |
| 5 | +from libcpp cimport bool as bool_t |
| 6 | +from libcpp.memory cimport unique_ptr |
| 7 | +from libcpp.string cimport string |
| 8 | +from libcpp.unordered_map cimport unordered_map |
| 9 | +from libcpp.vector cimport vector |
| 10 | + |
| 11 | + |
| 12 | +cdef extern from "<chrono>" namespace "std::chrono" nogil: |
| 13 | + cdef cppclass milliseconds: |
| 14 | + milliseconds(long long) except + |
| 15 | + |
| 16 | +cdef extern from "<cupti.h>" nogil: |
| 17 | + ctypedef enum CUpti_CallbackId: |
| 18 | + pass |
| 19 | + |
| 20 | + |
| 21 | +cdef extern from "<rapidsmpf/cupti.hpp>" nogil: |
| 22 | + cdef struct cpp_MemoryDataPoint "rapidsmpf::MemoryDataPoint": |
| 23 | + double timestamp |
| 24 | + size_t free_memory |
| 25 | + size_t total_memory |
| 26 | + size_t used_memory |
| 27 | + |
| 28 | + cdef cppclass cpp_CuptiMonitor "rapidsmpf::CuptiMonitor": |
| 29 | + cpp_CuptiMonitor( |
| 30 | + bool_t enable_periodic_sampling, |
| 31 | + milliseconds sampling_interval_ms |
| 32 | + ) except + |
| 33 | + void start_monitoring() except + |
| 34 | + void stop_monitoring() except + |
| 35 | + bool_t is_monitoring() except + |
| 36 | + void capture_memory_sample() except + |
| 37 | + const vector[cpp_MemoryDataPoint]& get_memory_samples() except + |
| 38 | + void clear_samples() except + |
| 39 | + size_t get_sample_count() except + |
| 40 | + void write_csv(const string& filename) except + |
| 41 | + void set_debug_output(bool_t enabled, size_t threshold_mb) except + |
| 42 | + unordered_map[CUpti_CallbackId, size_t] get_callback_counters() except + |
| 43 | + void clear_callback_counters() except + |
| 44 | + size_t get_total_callback_count() except + |
| 45 | + string get_callback_summary() except + |
| 46 | + |
| 47 | + |
| 48 | +cdef class MemoryDataPoint: |
| 49 | + cdef cpp_MemoryDataPoint _data |
| 50 | + |
| 51 | + @staticmethod |
| 52 | + cdef MemoryDataPoint from_cpp(cpp_MemoryDataPoint data) |
| 53 | + |
| 54 | + |
| 55 | +cdef class CuptiMonitor: |
| 56 | + cdef unique_ptr[cpp_CuptiMonitor] _handle |
0 commit comments