AMReX-Codes / pyamrex

GPU-Enabled, Zero-Copy AMReX Python Bindings including AI/ML
http://pyamrex.readthedocs.io
Other
36 stars 19 forks source link

AMReX Tiny Profiler Context #54

Open ax3l opened 2 years ago

ax3l commented 2 years ago

As users start to extend routines on the Python side - and we add more wrappers on bindings - we should start profiling these sections to catch unexpected bottlenecks. For that, we should wrap and expose the BL_PROFILE logic.

BL_PROFILE are lightweight macros that wrap C++ object that start/stop profiling. We might want to wrap the underling C++ objects directly first. Then, we might add some convenience helper functions/objects as well, if needed.

ax3l commented 1 year ago

This could be implemented similar to cupy's profiler with an __enter__/__exit__ that can be used within a with: context manager (and thus does not rely on destructor calls for the time measurement).

Example: