Skip to content

Commit 488b9e3

Browse files
authored
Rework README.md
* restructure text * clarify the usage of the instrumenter
1 parent 66900f2 commit 488b9e3

File tree

1 file changed

+93
-72
lines changed

1 file changed

+93
-72
lines changed

README.md

Lines changed: 93 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@ scorep is a module that allows tracing of python scripts using [Score-P](http://
66
# Table of Content
77

88
- [scorep](#scorep)
9-
- [Table of Content](#table-of-Content)
9+
- [Table of Content](#table-of-content)
1010
- [Install](#install)
1111
- [Use](#use)
12+
* [Instrumenter](#instrumenter)
13+
+ [Instrumenter Types](#instrumenter-types)
14+
+ [Instrumenter User Interface](#instrumenter-user-interface)
1215
* [MPI](#mpi)
13-
* [User instrumentation](#user-instrumentation)
14-
+ [User Regions](#user-regions)
15-
+ [Instrumenter](#instrumenter)
16+
* [User Regions](#user-regions)
1617
* [Overview about Flags](#overview-about-flags)
1718
* [Backward Compatibility](#backward-compatibility)
1819
- [Compatibility](#compatibility)
1920
* [Working](#working)
2021
* [Not Working](#not-working)
2122
- [Acknowledgments](#acknowledgments)
2223

24+
<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>
25+
2326
# Install
2427
You need at least Score-P 5.0, build with `--enable-shared` and the gcc compiler plugin.
2528
Please make sure that `scorep-config` is in your `PATH` variable.
@@ -55,67 +58,13 @@ Since version 0.9 it is possible to pass the traditional Score-P commands to the
5558
python -m scorep --mpp=mpi --thread=pthread <script.py>
5659
```
5760

58-
## MPI
59-
60-
To use trace an MPI parallel application, please specify
61-
62-
```
63-
python -m scorep --mpp=mpi <script.py>
64-
```
65-
66-
## User instrumentation
67-
### User Regions
68-
Since version 2.0 the python bindings support context managers for user regions:
69-
70-
```
71-
with scorep.user.region("region_name"):
72-
do_something()
73-
```
74-
75-
Since version 2.1 the python bindings support also decorators for functions:
76-
77-
```
78-
@scorep.user.region("region_name")
79-
def do_something():
80-
#do some things
81-
```
82-
If no region name is given, the function name will be used e.g.:
83-
84-
```
85-
@scorep.user.region()
86-
def do_something():
87-
#do some things
88-
```
89-
90-
will result in `__main__:do_something`.
61+
## Instrumenter
62+
The instrumenter ist the key part of the bindings.
63+
He registers with the Python tracing interface, and cares about the fowarding of events to Score-P.
64+
There are currently three different instrumenter types available as described in the following section [Instrumenter Types](#instrumenter-types) .
65+
A user interface, to dynamically enable and disable the automatic instrumentation, using the python hooks, is also available and described under [Instrumenter User Interface](instrumenter-user-interface)
9166

92-
The traditional calls to define a region still exists, but the usage is discouraged:
93-
94-
```
95-
scorep.user.region_begin("region_name")
96-
scorep.user.region_end("region_name")
97-
```
98-
99-
User parameters can be used in any case:
100-
101-
```
102-
scorep.user.parameter_int(name, val)
103-
scorep.user.parameter_uint(name, val)
104-
scorep.user.parameter_string(name, string)
105-
```
106-
107-
where `name` defines the name of the parameter or region, while `val` or `string` represents the value that is passed to Score-P.
108-
109-
Disabeling the recording with Score-P is still also possilbe:
110-
111-
```
112-
scorep.user.enable_recording()
113-
scorep.user.disable_recording()
114-
```
115-
116-
However, please be aware that the runtime impact of disabeling Score-P is rather small, as the instrumenter is still active. For details about the instrumenter, please see [Instrumenter](#Instrumenter).
117-
118-
### Instrumenter
67+
### Instrumenter Types
11968
With version 2.0 of the python bindings, the term "instrumenter" is introduced. The instrumenter describes the class that maps the Python `trace` or `profile` events to Score-P. Please be aware, that `trace` and `profile` does not refer to the traditional Score-P terms of tracing and profiling, but to the Python functions [sys.settrace](https://docs.python.org/3/library/sys.html#sys.settrace) and [sys.setprofile](https://docs.python.org/3/library/sys.html#sys.setprofile).
12069

12170
The instrumenter that shall be used for tracing can be specified using `--instrumenter-type=<type>`.
@@ -124,9 +73,14 @@ Currently there are the following tacers available:
12473
* `trace` implements `call` and `return`
12574
* `dummy` does nothing, can be used without `-m scorep` (as done by user instrumentation)
12675

127-
The `profile` instrumenter should have a smaller overhead than `trace`.
76+
The `profile` instrumenter should have a smaller overhead than `trace`.
77+
78+
It is possible to disable the instrumenter passing `--noinstrumenter`.
79+
However, the [Instrumenter User Interface](instrumenter-user-interface) may override this flag.
80+
81+
### Instrumenter User Interface
12882

129-
Moreover it is possible to disable (and enable) the instrumenter in the sourcecode:
83+
It is possible to enable or disable the instrumenter during the program runtime using a user interface:
13084

13185
```
13286
with scorep.instrumenter.disable():
@@ -136,10 +90,9 @@ with scorep.instrumenter.enable():
13690
do_something()
13791
```
13892

139-
or during startup with `--noinstrumenter`. The given function calls override this flag.
140-
14193
The main idea is to reduce the instrumentation overhead for regions that are not of interest.
14294
Whenever the instrumenter is disabled, function enter or exits will not be trace.
95+
However, user regions as described in [User Regions](#user-regions) are not affected.
14396

14497
As an example:
14598

@@ -164,11 +117,9 @@ with scorep.instrumenter.enable():
164117
[...]
165118
```
166119
and run the code with `python -m scorep --noinstrumenter run.py` only the call to np.dot and everything below will be instrumented.
167-
Please be aware, that user instrumentation, using scorep.user will always be recorded.
168-
169120

170-
With version 3.1 the bindings support the annotation of regions where the instrumenter was explicit enabled or disabled.
171-
You can now pass a `region_name` to `scorep.instrumenter.enable("enabled_region_name")` and `scorep.instrumenter.disable("disabled_region_name")`.
121+
With version 3.1 the bindings support the annotation of regions where the instrumenter setting was changed.
122+
You can pass a `region_name` to the instrumenter calls, e.g. `scorep.instrumenter.enable("enabled_region_name")` or `scorep.instrumenter.disable("disabled_region_name")`.
172123
This might be useful if you do something expensive, and just want to know how long it takes, but you do not care what happens exactly e.g.:
173124

174125
```
@@ -184,6 +135,76 @@ with scorep.instrumenter.disable("my_fun_calls"):
184135

185136
`my_fun_calls` will be present in the trace or profile but `fun_calls` will not.
186137

138+
However, doing
139+
```
140+
[...]
141+
with scorep.instrumenter.disable():
142+
with scorep.instrumenter.disable("my_fun_calls"):
143+
fun_calls(1000000)
144+
[...]
145+
```
146+
will only disable the instrumenter, but `my_fun_calls` will not appear in the trace or profile, as the second call to `scorep.instrumenter.disable` did not change the state of the instrumenter.
147+
Please look to [User Regions](#user-regions), if you want to annotate a region, no matter what the instrumenter state is.
148+
149+
## MPI
150+
151+
To use trace an MPI parallel application, please specify
152+
153+
```
154+
python -m scorep --mpp=mpi <script.py>
155+
```
156+
157+
## User Regions
158+
Since version 2.0 the python bindings support context managers for user regions:
159+
160+
```
161+
with scorep.user.region("region_name"):
162+
do_something()
163+
```
164+
165+
Since version 2.1 the python bindings support also decorators for functions:
166+
167+
```
168+
@scorep.user.region("region_name")
169+
def do_something():
170+
#do some things
171+
```
172+
If no region name is given, the function name will be used e.g.:
173+
174+
```
175+
@scorep.user.region()
176+
def do_something():
177+
#do some things
178+
```
179+
180+
will result in `__main__:do_something`.
181+
182+
The traditional calls to define a region still exists, but the usage is discouraged:
183+
184+
```
185+
scorep.user.region_begin("region_name")
186+
scorep.user.region_end("region_name")
187+
```
188+
189+
User parameters can be used in any case:
190+
191+
```
192+
scorep.user.parameter_int(name, val)
193+
scorep.user.parameter_uint(name, val)
194+
scorep.user.parameter_string(name, string)
195+
```
196+
197+
where `name` defines the name of the parameter or region, while `val` or `string` represents the value that is passed to Score-P.
198+
199+
Disabeling the recording with Score-P is still also possilbe:
200+
201+
```
202+
scorep.user.enable_recording()
203+
scorep.user.disable_recording()
204+
```
205+
206+
However, please be aware that the runtime impact of disabeling Score-P is rather small, as the instrumenter is still active. For details about the instrumenter, please see [Instrumenter](#Instrumenter).
207+
187208
## Overview about Flags
188209

189210
The following flags are special to the python bindings:

0 commit comments

Comments
 (0)