You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Closes#34, preparation of v2.0 release
* separate subsystem generation and __main__ more clearly
* introduce the notion of "instrumenter" and refactor the code accordingly
* introduce context managers
Since version 2.0 the python bindings support context managers for user regions:
53
50
54
-
In some cases, the user might want to define a region, log some parameters, or just disable tracing for a certain area. To do so the module implements a few functions:
51
+
```
52
+
with scorep.user.region("region_name"):
53
+
do_something()
54
+
```
55
+
56
+
The traditional calls to define a region and log some parameters, still exists:
55
57
56
58
```
57
59
scorep.user.region_begin(name)
60
+
scorep.user.parameter_int(name, val)
61
+
scorep.user.parameter_uint(name, val)
62
+
scorep.user.parameter_string(name, string)
58
63
scorep.user.region_end(name)
59
64
```
60
65
61
-
These functions allow the definition of user regions. `name` defines the name of a region. Each `user.region_begin` shall have a corresponding call to `user.region_end`.
66
+
`name` defines the name of the parameter or region, while `val` or `string` represents the value that is passed to Score-P.
67
+
68
+
Disabeling the recording with Score-P is still also possilbe:
62
69
63
70
```
64
71
scorep.user.enable_recording()
65
72
scorep.user.disable_recording()
66
73
```
67
74
68
-
These functions allow enabling and disabling of the tracing.
75
+
However, please be aware that the runtime impact is rather small, as the instrumenter is still active. For details about the instrumenter, please see [Instrumenter](#Instrumenter).
76
+
77
+
### Instrumenter
78
+
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).
79
+
80
+
The instrumenter that shall be used for tracing can be specified using `--instrumenter-type=<type>`.
81
+
Currently there are the following tacers available:
82
+
*`profile` (default) implements `call` and `return`
83
+
*`trace` implements `call` and `return`
84
+
*`dummy` does nothing, can be used without `-m scorep` (as done by user instrumentation)
85
+
86
+
The `profile` instrumenter should have a smaller overhead than `trace`.
87
+
88
+
Moreover it is possible to disable (and enable) the instrumenter in the sourcecode:
69
89
70
90
```
71
-
scorep.user.parameter_int(name, val)
72
-
scorep.user.parameter_uint(name, val)
73
-
scorep.user.parameter_string(name, string)
91
+
with scorep.instrumenter.disable():
92
+
do_something()
93
+
94
+
with scorep.instrumenter.enable():
95
+
do_something()
74
96
```
75
97
76
-
These functions allow passing user parameters to Score-P. These parameters can be int, uint and string. `name` defines the name of the parameter, while `val` or `string` defines the value that is passed to Score-P.
77
-
Please be aware, that the scorep module still needs to be preloaded, i.e. by using `python -m scorep`.
98
+
or during startup with `--noinstrumenter`. Please be aware that the function calls override the Flag.
78
99
79
-
## Additional Flags
100
+
## Overview about Flags
80
101
81
-
The Score-P bindings now also support a `--nopython` flag, which disables the python instrumentation.
82
-
This might be helpful, if only user instrumentation is required, or only some instrumented libraries shall be traced.
102
+
The following flags are special to the python bindings:
103
+
104
+
*`--noinstrumenter` disables the instrumentation of python code. Usefull for user instrumentation and to trace only specific code regions using `scorep.instrumenter.enable`.
105
+
*`--instrumenter-type=<type>` choose an instrumenter. See [Instrumenter](#Instrumenter).
106
+
*`--keep-files` temporary files are kept.
83
107
84
108
## Backward Compatibility
85
109
86
-
In order to maintain backwards Compatibility, the following flags are set per default:
110
+
To maintain backwards compatibility, the following flags are set per default:
To disable compiler instrumentation please specify:
122
+
To disable compiler instrumentation, please specify:
99
123
100
124
```
101
125
python -m scorep --nocompiler <script.py>
@@ -119,7 +143,4 @@ Please be aware the `--user` is always passed to Score-P, as this is needed for
119
143
120
144
## Not Working
121
145
* python multiprocessing
122
-
* Score-P does currently not support any non MPI or non SHMEM communication. So the different processes will not know from each other. You might want to take a look to https://mpi4py.readthedocs.io/en/stable/mpi4py.futures.html .
123
-
124
-
# Tracing
125
-
The tracing uses Score-P User instrumentation. The python trace module was reworked, to pass the region names to `SCOREP_USER_REGION_BEGIN` and `SCOREP_USER_REGION_END` instead of printing. All other features of the tracing module where striped.
146
+
* Score-P does currently only support MPI or SHMEM. Any other multiprocessing approach cannot be traced.
0 commit comments