Skip to content

Commit

Permalink
changing pyitt to ittapi
Browse files Browse the repository at this point in the history
  • Loading branch information
lalithsharan-intel committed Jun 4, 2024
1 parent 9f783d5 commit d5e6347
Show file tree
Hide file tree
Showing 44 changed files with 206 additions and 206 deletions.
4 changes: 2 additions & 2 deletions python/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ include README.md
include MANIFEST.in
include pyproject.toml
include setup.py
recursive-include pyitt *.py
recursive-include pyitt.native *.cpp *.hpp
recursive-include ittapi *.py
recursive-include ittapi.native *.cpp *.hpp
recursive-include ../include *.h
recursive-include ../LICENSES *
recursive-include ../src *
Expand Down
42 changes: 21 additions & 21 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# pyitt
# ittapi

pyitt is a Python binding to Intel Instrumentation and Tracing Technology (ITT) API. It provides a convenient way
ittapi is a Python binding to Intel Instrumentation and Tracing Technology (ITT) API. It provides a convenient way
to mark up the Python code for further performance analysis using performance analyzers from Intel like Intel VTune
or others.

pyitt supports following ITT APIs:
ittapi supports following ITT APIs:
- Collection Control API
- Domain API
- Event API
Expand All @@ -16,56 +16,56 @@ pyitt supports following ITT APIs:
## Usage

The main goal of the project is to provide the ability to instrument a Python code using ITT API in the Pythonic way.
pyitt provides wrappers that simplify markup of Python code.
ittapi provides wrappers that simplify markup of Python code.

```python
import pyitt
import ittapi

@pyitt.task
@ittapi.task
def workload():
pass

workload()
```

`pyitt.task` can be used as a decorator. In this case, the name of a callable object (`workload` function in this
example) will be used as a name of the task and the task will be attributed to a default domain named 'pyitt'.
`ittapi.task` can be used as a decorator. In this case, the name of a callable object (`workload` function in this
example) will be used as a name of the task and the task will be attributed to a default domain named 'ittapi'.
If you want to change the default name and/or other parameters for the task (e.g. task domain), you can pass
them as arguments to `pyitt.task`:
them as arguments to `ittapi.task`:

```python
import pyitt
import ittapi

@pyitt.task('My Task', domain='My Task Domain')
@ittapi.task('My Task', domain='My Task Domain')
def workload():
pass

workload()
```

Also, `pyitt.task` returns the object that can be used as a context manager:
Also, `ittapi.task` returns the object that can be used as a context manager:

```python
import pyitt
import ittapi

with pyitt.task():
with ittapi.task():
# some code here...
pass
```

If the task name is not specified, the `pyitt.task` uses call site information (filename and line number) to give
If the task name is not specified, the `ittapi.task` uses call site information (filename and line number) to give
the name to the task. A custom name for the task and other task parameters can be specified via arguments
for `pyitt.task` in the same way as for the decorator form.
for `ittapi.task` in the same way as for the decorator form.

## Installation

[TODO] intel-pyitt package is available on PyPi and can be installed in the usual way for the supported configurations:
[TODO] intel-ittapi package is available on PyPi and can be installed in the usual way for the supported configurations:

[TODO] pip install intel-pyitt
[TODO] pip install intel-ittapi

## Build

The native part of pyitt module is written using C++20 standard, therefore you need a compiler that supports this
The native part of ittapi module is written using C++20 standard, therefore you need a compiler that supports this
standard, for example GCC-10 for Linux and Visual Studio 2022 for Windows.

### Ubuntu 22.04
Expand All @@ -78,7 +78,7 @@ standard, for example GCC-10 for Linux and Visual Studio 2022 for Windows.

git clone https://github.com/intel/ittapi.git

3. Build and install pyitt:
3. Build and install ittapi:

cd python
pip install .
Expand All @@ -94,7 +94,7 @@ standard, for example GCC-10 for Linux and Visual Studio 2022 for Windows.

git clone https://github.com/intel/ittapi.git

4. Build and install pyitt
4. Build and install ittapi

cd python
pip install .
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static PyMemberDef domain_attrs[] =
PyTypeObject DomainType =
{
.ob_base = PyVarObject_HEAD_INIT(nullptr, 0)
.tp_name = "pyitt.native.Domain",
.tp_name = "ittapi.native.Domain",
.tp_basicsize = sizeof(Domain),
.tp_itemsize = 0,

Expand Down Expand Up @@ -137,7 +137,7 @@ static PyObject* domain_new(PyTypeObject* type, PyObject* args, PyObject* kwargs

if (name == nullptr || name == Py_None)
{
self->name = PyUnicode_FromString("pyitt");
self->name = PyUnicode_FromString("ittapi");
}
else if (PyUnicode_Check(name))
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static PyMethodDef event_methods[] =
PyTypeObject EventType =
{
.ob_base = PyVarObject_HEAD_INIT(nullptr, 0)
.tp_name = "pyitt.native.Event",
.tp_name = "ittapi.native.Event",
.tp_basicsize = sizeof(Event),
.tp_itemsize = 0,

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion python/pyitt.native/id.cpp → python/ittapi.native/id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static PyMemberDef id_attrs[] =
PyTypeObject IdType =
{
.ob_base = PyVarObject_HEAD_INIT(nullptr, 0)
.tp_name = "pyitt.native.Id",
.tp_name = "ittapi.native.Id",
.tp_basicsize = sizeof(Id),
.tp_itemsize = 0,

Expand Down
File renamed without changes.
28 changes: 14 additions & 14 deletions python/pyitt.native/pyitt.cpp → python/ittapi.native/ittapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace pyitt
{

/**
Initialize pyitt.
Initialize ittapi.
May be called multiple times, so avoid using static state.
*/
static int exec_pyitt_module(PyObject* module)
static int exec_ittapi_module(PyObject* module)
{
static PyMethodDef pyitt_functions[] =
static PyMethodDef ittapi_functions[] =
{
/* Collection Control API */
{"pause", pause, METH_NOARGS, "Pause data collection."},
Expand All @@ -36,7 +36,7 @@ static int exec_pyitt_module(PyObject* module)
{ nullptr },
};

PyModule_AddFunctions(module, pyitt_functions);
PyModule_AddFunctions(module, ittapi_functions);

PyModule_AddStringConstant(module, "__author__", "Egor Suldin");
PyModule_AddStringConstant(module, "__version__", "1.1.0");
Expand All @@ -45,38 +45,38 @@ static int exec_pyitt_module(PyObject* module)
return 0;
}

static void destroy_pyitt_module(void*)
static void destroy_ittapi_module(void*)
{
__itt_release_resources();
}

PyMODINIT_FUNC PyInit_native()
{
PyDoc_STRVAR(pyitt_doc, "The pyitt module.");
PyDoc_STRVAR(ittapi_doc, "The ittapi module.");

static PyModuleDef_Slot pyitt_slots[] =
static PyModuleDef_Slot ittapi_slots[] =
{
{ Py_mod_exec, reinterpret_cast<void*>(exec_pyitt_module) },
{ Py_mod_exec, reinterpret_cast<void*>(exec_ittapi_module) },
{ Py_mod_exec, reinterpret_cast<void*>(exec_domain) },
{ Py_mod_exec, reinterpret_cast<void*>(exec_event) },
{ Py_mod_exec, reinterpret_cast<void*>(exec_id) },
{ Py_mod_exec, reinterpret_cast<void*>(exec_string_handle) },
{ 0, nullptr }
};

static PyModuleDef pyitt_def = {
static PyModuleDef ittapi_def = {
PyModuleDef_HEAD_INIT,
"pyitt",
pyitt_doc,
"ittapi",
ittapi_doc,
0, /* m_size */
nullptr, /* m_methods */
pyitt_slots,
ittapi_slots,
nullptr, /* m_traverse */
nullptr, /* m_clear */
destroy_pyitt_module, /* m_free */
destroy_ittapi_module, /* m_free */
};

return PyModuleDef_Init(&pyitt_def);
return PyModuleDef_Init(&ittapi_def);
}

} // namespace pyitt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static PyMemberDef string_handle_attrs[] =
PyTypeObject StringHandleType =
{
.ob_base = PyVarObject_HEAD_INIT(nullptr, 0)
.tp_name = "pyitt.native.StringHandle",
.tp_name = "ittapi.native.StringHandle",
.tp_basicsize = sizeof(StringHandle),
.tp_itemsize = 0,

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions python/pyitt/__init__.py → python/ittapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
analyzers from Intel like Intel VTune or others.
"""

from pyitt.native import Domain, Id, StringHandle
from pyitt.native import task_begin, task_end, task_begin_overlapped, task_end_overlapped
from ittapi.native import Domain, Id, StringHandle
from ittapi.native import task_begin, task_end, task_begin_overlapped, task_end_overlapped
from .collection_control import detach, pause, resume, active_region, paused_region, ActiveRegion, PausedRegion
from .event import event, Event
from .domain import domain
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
collection_control.py - Python module wrapper for ITT Collection Control API
"""
from pyitt.native import detach as _detach, pause as _pause, resume as _resume
from ittapi.native import detach as _detach, pause as _pause, resume as _resume

from .region import _Region

Expand Down
2 changes: 1 addition & 1 deletion python/pyitt/domain.py → python/ittapi/domain.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
domain.py - Python module wrapper for ITT Domain API
"""
from pyitt.native import Domain as _Domain
from ittapi.native import Domain as _Domain


def domain(name=None):
Expand Down
2 changes: 1 addition & 1 deletion python/pyitt/event.py → python/ittapi/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
from functools import partial as _partial

from pyitt.native import Event as _Event
from ittapi.native import Event as _Event

from .region import _CallSite, _NamedRegion

Expand Down
2 changes: 1 addition & 1 deletion python/pyitt/id.py → python/ittapi/id.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
id.py - Python module wrapper for ITT ID API
"""
from pyitt.native import Id as _Id
from ittapi.native import Id as _Id


def id(domain):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
string_handle.py - Python module wrapper for ITT String Handle API
"""
from pyitt.native import StringHandle as _StringHandle
from ittapi.native import StringHandle as _StringHandle


def string_handle(string: str):
Expand Down
4 changes: 2 additions & 2 deletions python/pyitt/task.py → python/ittapi/task.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
task.py - Python module wrapper for ITT Task API
"""
from pyitt.native import task_begin as _task_begin, task_end as _task_end
from pyitt.native import task_begin_overlapped as _task_begin_overlapped, task_end_overlapped as _task_end_overlapped
from ittapi.native import task_begin as _task_begin, task_end as _task_end
from ittapi.native import task_begin_overlapped as _task_begin_overlapped, task_end_overlapped as _task_end_overlapped

from .domain import domain as _domain
from .id import id as _id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
thread_naming.py - Python module wrapper for ITT Thread Naming API
"""
from pyitt.native import thread_set_name as _thread_set_name
from ittapi.native import thread_set_name as _thread_set_name


def thread_set_name(name: str):
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "intel-pyitt"
name = "intel-ittapi"
version = "1.1.0"
authors = [
{ name="Egor Suldin", email="[email protected]" },
Expand Down
18 changes: 9 additions & 9 deletions python/samples/collection_control_sample.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
import pyitt
import ittapi

# pylint: disable=C0411
from argparse import ArgumentParser
Expand All @@ -8,25 +8,25 @@


def run_sample():
@pyitt.active_region
@pyitt.task
@ittapi.active_region
@ittapi.task
def run_workload():
workload()

run_workload()

for i in range(4):
with pyitt.active_region(activator=lambda: i % 2): # pylint: disable=W0640
with pyitt.task(f'for loop iteration {i}'):
with ittapi.active_region(activator=lambda: i % 2): # pylint: disable=W0640
with ittapi.task(f'for loop iteration {i}'):
workload()

pyitt.collection_control.resume()
ittapi.collection_control.resume()

with pyitt.task('resumed region'):
with ittapi.task('resumed region'):
workload()

with pyitt.paused_region():
with pyitt.task('paused region'):
with ittapi.paused_region():
with ittapi.task('paused region'):
workload()


Expand Down
Loading

0 comments on commit d5e6347

Please sign in to comment.