diff --git a/PyNVTX/__init__.py b/PyNVTX/__init__.py index 391f42a..d25c04e 100644 --- a/PyNVTX/__init__.py +++ b/PyNVTX/__init__.py @@ -10,16 +10,16 @@ major_version = 0; -minor_version = 2; -release_version = 3; +minor_version = 3; +release_version = 0; NVTX_IDENTIFIER = "NVTX" REGISTRY = Registry() -def mark(label): - def _mark(func): +def annotate(label): + def _annotate(func): @wraps(func) def wrapped(*args, **kwargs): RangePushA(label) @@ -27,7 +27,7 @@ def wrapped(*args, **kwargs): RangePop() return ret return wrapped - return _mark + return _annotate @@ -43,7 +43,7 @@ def dec_id_str(identifier): -def mark_all_methods(cls): +def annotate_all_methods(cls): if is_decorated(cls, NVTX_IDENTIFIER): return @@ -52,7 +52,7 @@ def mark_all_methods(cls): continue if callable(cls.__dict__[attr]): - dec = mark(f"{cls}.{attr}") + dec = annotate(f"{cls}.{attr}") type.__setattr__(cls, attr, dec(cls.__dict__[attr])) type.__setattr__(cls, dec_id_str(NVTX_IDENTIFIER), True) @@ -60,4 +60,4 @@ def mark_all_methods(cls): for base in cls.__bases__: if base == object: continue - mark_all_methods(base) + annotate_all_methods(base) diff --git a/README.md b/README.md index 646eb25..d9baa64 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ A thin python wrapper for the nvToolsExt (NVTX) library, using pybind11. This wrapper is meant to be as thin as possible -- so only provides minimal support. Currently supported features are: -1. NVTX markers: `nvtxRangePushA` and `nvtxRangePop` -2. Function decorator: `PyNVTX.mark` -3. Automatic decorator generation `PyNVTX.mark_all_methods()` +1. NVTX annotations: `nvtxRangePushA` and `nvtxRangePop` +2. Function decorator: `PyNVTX.annotate` +3. Automatic decorator generation `PyNVTX.annotate_all_methods()` @@ -56,12 +56,12 @@ nvtx.RangePop() ### Function Decorator -The `PyNVTX.mark` will put `RangePushA` and `RangePop` the the beginning and of +The `PyNVTX.annotate` will put `RangePushA` and `RangePop` the the beginning and of the function call: ```python import PyNVTX as nvtx -@nvtx.mark("test_function") +@nvtx.annotate("test_function") def test(): # You code goes here ``` @@ -69,7 +69,7 @@ def test(): ### Automatic Instrumentation -The `PyNVTX.mark_all_methods` will automatically decorate all methods in a +The `PyNVTX.annotate_all_methods` will automatically decorate all methods in a class, as well as all methods it inherits. A guard prevents accidentally decorating any method twice. Eg.: ```python @@ -90,16 +90,16 @@ class MyClassB(MyClassA): pass -nvtx.mark_all_methods(MyClassB) +nvtx.annotate_all_methods(MyClassB) ``` Will instrument `MyClassB`'s `__init__`, as well as `f` and `g`, but _not_ `MyClassA`'s `__init__`. Adding a class/method name to `PyNVTX.REGISTRY` will prevent it from being -instrumented by `PyNVTX.mark_all_methods`. For example: +instrumented by `PyNVTX.annotate_all_methods`. For example: ```python nvtx.REGISTRY.add(MyClassB, "f") # note the method name is a string -nvtx.mark_all_methods(MyClassB) +nvtx.annotate_all_methods(MyClassB) ``` will not instrument `f`. diff --git a/setup.py b/setup.py index 140034b..1716556 100644 --- a/setup.py +++ b/setup.py @@ -180,7 +180,7 @@ def build_extensions(self): setup( name="PyNVTX", - version="0.2.3", + version="0.3.0", author="Johannes Blaschke", author_email="johannes@blaschke.science", description="A thin python wrapper for the nvToolsExt (NVTX) library, using pybind11 ... with some bells and whistles thrown in for good measure.", diff --git a/test/test-nvtx.py b/test/test-nvtx.py index 6de38dc..5cbb61c 100644 --- a/test/test-nvtx.py +++ b/test/test-nvtx.py @@ -41,7 +41,7 @@ -@nvtx.mark("Build CUDA code") +@nvtx.annotate("Build CUDA code") def init(): #___________________________________________________________________________ @@ -113,7 +113,7 @@ def apply_fn(self, fn): print(f"Running test for {size} elements") - nvtx.mark_all_methods(Test) + nvtx.annotate_all_methods(Test) fn = init() test = Test(size)