Skip to content

Commit d1fac89

Browse files
authored
Update README.md
1 parent 3abdb1a commit d1fac89

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ scorep is a module that allows tracing of python scripts using [Score-P](https:/
1313
* [Instrumenter](#instrumenter)
1414
+ [Instrumenter Types](#instrumenter-types)
1515
+ [Instrumenter User Interface](#instrumenter-user-interface)
16+
+ [Instrumenter File](#instrumenter-file)
1617
* [MPI](#mpi)
1718
* [User Regions](#user-regions)
1819
* [Overview about Flags](#overview-about-flags)
@@ -155,6 +156,45 @@ with scorep.instrumenter.disable():
155156
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.
156157
Please look to [User Regions](#user-regions), if you want to annotate a region, no matter what the instrumenter state is.
157158

159+
### Instrumenter File
160+
161+
Handing a Python file to `--instrumenter-file` allows the instrumentation of modules and functions without changing their code.
162+
The file handed to `--instrumenter-file` is executed before the script is executed so that the original function definition can be overwritten before the function is executed.
163+
However, using this approach, it is no longer possible to track the bring up of the module.
164+
165+
To simplify the instrumentation, the user instrumentation contains two helper calls:
166+
```
167+
scorep.user.instrument_function(function, instrumenter_fun=scorep.user.region)
168+
scorep.user.instrument_module(module, instrumenter_fun=scorep.user.region):
169+
```
170+
while `instrumenter_fun` might be one of:
171+
* `scorep.user.region`, decorator as explained below
172+
* `scorep.instrumenter.enable`, decorator as explained above
173+
* `scorep.instrumenter.disable`, decorator as explained above
174+
175+
Using the `scorep.instrumenter` decorators, the instrumentation can be enabled or disabled from the given function.
176+
The function is executed below `enable` or `disable`.
177+
Using `scorep.user.region`, it is possible to instrument a full python program.
178+
However, I discourage this usage, as the overhead of the user instrumentation is higher than the built-in instrumenters.
179+
180+
Using `scorep.user.instrument_module`, all functions of the given Python Module are instrumented.
181+
182+
An example instrumenter file might look like the following:
183+
```
184+
import scorep.user
185+
186+
# import module that shall be instrumented
187+
import module_to_instrument
188+
import module
189+
190+
# hand over the imported module, containing functions which shall be instrumented
191+
scorep.user.instrument_module(module_to_instrument)
192+
193+
# hand the function to be instrumented, and overwrite the original definiton of that function
194+
module.function_to_instrument = scorep.user.instrument_function(module.function_to_instrument)
195+
196+
```
197+
158198
## MPI
159199

160200
To use trace an MPI parallel application, please specify

0 commit comments

Comments
 (0)