k4bench.plugin.runtime¶
k4bench.plugin.runtime ¶
find_plugin_lib_dir ¶
Return directory containing the k4Bench plugin libraries.
The returned directory must contain both the .so files AND the .components manifests that DDG4 uses to resolve factory names. Without the .components files, DDG4 can only load plugins whose library name matches the class name exactly (e.g. libFoo.so for class Foo), so bundled plugins like k4BenchRegionEventAction (which lives in libk4BenchRegionTimingAction.so) would be silently skipped.
Source code in k4bench/plugin/runtime.py
find_auditor_dir ¶
Return the directory holding the k4BenchAuditor Gaudi plugin.
Gaudi's plugin service finds a component through the .components
manifest next to its library, so the directory must hold both. Gaudi
installs plugins into lib/gaudi-plugins or, in older releases, lib,
where the DDG4 plugins' manifests also live, so the manifest must be the
one registering the auditor.
Source code in k4bench/plugin/runtime.py
auditor_options_file ¶
ensure_plugin_built ¶
ensure_auditor_built ¶
Build the k4Bench auditor if it is missing or stale.
Always runs build.sh, which rebuilds only when a library is older than its sources, so an installed auditor never outlives a change to them. Only the auditor is built, so a DDG4 plugin that fails to build does not disable it.
Source code in k4bench/plugin/runtime.py
setup_plugin_environment ¶
setup_plugin_environment(*, env: dict[str, str], event_json_path: Path, region_json_path: Path | None = None) -> bool
Prepare environment variables for the k4Bench timing plugins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
dict[str, str]
|
Environment dictionary to mutate (typically a copy of os.environ). |
required |
event_json_path
|
Path
|
Output path for the per-event timing JSON. |
required |
region_json_path
|
Path | None
|
Output path for the per-region timing JSON. If None, the region plugin will still be loadable but will write to its default location (k4bench_regions.json in CWD) only if it ends up being activated by the steering script. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if plugins are available and enabled. False if ddsim should run without per-event timing. |
Source code in k4bench/plugin/runtime.py
setup_auditor_environment ¶
setup_auditor_environment(*, env: dict[str, str], components_json_path: Path, event_json_path: Path, joboptions_path: Path, setup_script: Path | None = None, heap_json_path: Path | None = None) -> bool
Prepare environment variables for a k4run job audited by k4Bench.
The job must also be given :func:auditor_options_file as its last options
file; this only makes the auditor findable, names its outputs and preloads
the allocation counter, without which the auditor records no allocations.
A setup_script sourced before the job may set LD_PRELOAD itself, so
with one the counter is only named in K4BENCH_ALLOC_COUNTER, and the
job's command must run :data:ALLOC_COUNTER_PRELOAD after the script.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
dict[str, str]
|
Environment dictionary to mutate (typically a copy of os.environ). |
required |
components_json_path
|
Path
|
Output path for the per-component JSON. |
required |
event_json_path
|
Path
|
Output path for the per-event JSON, in the ddsim event format. |
required |
joboptions_path
|
Path
|
Output path for the resolved job options dump. |
required |
setup_script
|
Path | None
|
Shell script the job's command sources before running it, if any. |
None
|
heap_json_path
|
Path | None
|
Output path for the heap each component held. Given one, the job
records which component allocated every heap block
( |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the auditor is available and enabled. False if the job should run without per-component and per-event measurements. |
Source code in k4bench/plugin/runtime.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |