-
Notifications
You must be signed in to change notification settings - Fork 35
ENH: Python derived/accum interface #839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
shanedsnyder
merged 20 commits into
darshan-hpc:main
from
tylerjereddy:treddy_derived_metrics_1
Feb 14, 2023
Merged
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3fc254b
WIP: Python derived/accum interface
tylerjereddy 6bd2c2c
fix pydarshan defs for darshan-util accumulators
6640472
MAINT: PR 839 revisions
tylerjereddy 6bd237c
bug fix: missing array in derived metrics struct
carns 7747764
silence warning: convert enum arg to int
carns e306f8e
added some free wrapper calls
carns e3f7764
MAINT: PR 839 revisions
tylerjereddy f85add6
MAINT: PR 839 revisions
tylerjereddy b95dbcb
MAINT: PR 839 revisions
tylerjereddy e47d3cf
MAINT: PR 839 revisions
tylerjereddy 2eeb136
MAINT: PR 839 revisions
tylerjereddy a9b9765
MAINT: PR 839 revisions
tylerjereddy d0704fd
MAINT: PR 839 revisions
tylerjereddy 029b7c9
MAINT: PR 839 revisions
tylerjereddy aa46cad
MAINT: PR 839 revisions
tylerjereddy f1bac18
MAINT: PR 839 revisions
tylerjereddy 96806fa
MAINT: PR 839 revisions
tylerjereddy 8f83274
make sure to call accumulator_destroy()
02bf33f
sync gitignore
6f5f716
Merge branch 'main' into treddy_derived_metrics_1
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from darshan.backend.cffi_backend import log_get_derived_metrics | ||
|
||
|
||
def log_get_bytes_bandwidth(log_path: str, mod_name: str) -> str: | ||
""" | ||
Summarize I/O performance for a given darshan module. | ||
|
||
Parameters | ||
---------- | ||
log_path : str | ||
Path to the darshan binary log file. | ||
mod_name : str | ||
Name of the darshan module to summarize the I/O | ||
performance for. | ||
|
||
Returns | ||
------- | ||
out: str | ||
A short string summarizing the performance of the given module | ||
in the provided log file, including bandwidth and total data | ||
transferred. | ||
|
||
Raises | ||
------ | ||
RuntimeError | ||
When a provided module name is not supported for the accumulator | ||
interface for provision of the summary data, or for any other | ||
error that occurs in the C/CFFI interface. | ||
ValueError | ||
When a provided module name does not exist in the log file. | ||
|
||
Examples | ||
-------- | ||
|
||
>>> from darshan.log_utils import get_log_path | ||
>>> from darshan.lib.accum import log_get_bytes_bandwidth | ||
|
||
>>> log_path = get_log_path("imbalanced-io.darshan") | ||
>>> log_get_bytes_bandwidth(log_path, "POSIX") | ||
I/O performance estimate (at the POSIX layer): transferred 101785.8 MiB at 164.99 MiB/s | ||
|
||
>>> log_get_bytes_bandwidth(log_path, "MPI-IO") | ||
I/O performance estimate (at the MPI-IO layer): transferred 126326.8 MiB at 101.58 MiB/s | ||
""" | ||
# get total bytes (in MiB) and bandwidth (in MiB/s) for | ||
# a given module -- this information was commonly reported | ||
# in the old perl-based summary reports | ||
darshan_derived_metrics = log_get_derived_metrics(log_path=log_path, | ||
mod_name=mod_name) | ||
total_mib = darshan_derived_metrics.total_bytes / 2 ** 20 | ||
total_bw = darshan_derived_metrics.agg_perf_by_slowest | ||
ret_str = f"I/O performance estimate (at the {mod_name} layer): transferred {total_mib:.1f} MiB at {total_bw:.2f} MiB/s" | ||
return ret_str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
from darshan.lib.accum import log_get_bytes_bandwidth | ||
from darshan.log_utils import get_log_path | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize("log_path, mod_name, expected_str", [ | ||
# the expected bytes/bandwidth strings are pasted | ||
# directly from the old perl summary reports; | ||
# exceptions noted below | ||
# in some cases we defer to darshan-parser for the expected | ||
# values; see discussion in gh-839 | ||
("imbalanced-io.darshan", | ||
"STDIO", | ||
"I/O performance estimate (at the STDIO layer): transferred 1.1 MiB at 0.01 MiB/s"), | ||
("imbalanced-io.darshan", | ||
"MPI-IO", | ||
"I/O performance estimate (at the MPI-IO layer): transferred 126326.8 MiB at 101.58 MiB/s"), | ||
# imbalanced-io.darshan does have LUSTRE data, | ||
# but it doesn't support derived metrics at time | ||
# of writing | ||
("imbalanced-io.darshan", | ||
"LUSTRE", | ||
"RuntimeError"), | ||
("imbalanced-io.darshan", | ||
"POSIX", | ||
"I/O performance estimate (at the POSIX layer): transferred 101785.8 MiB at 164.99 MiB/s"), | ||
("laytonjb_test1_id28730_6-7-43012-2131301613401632697_1.darshan", | ||
"STDIO", | ||
"I/O performance estimate (at the STDIO layer): transferred 0.0 MiB at 4.22 MiB/s"), | ||
("runtime_and_dxt_heatmaps_diagonal_write_only.darshan", | ||
"POSIX", | ||
"I/O performance estimate (at the POSIX layer): transferred 0.0 MiB at 0.02 MiB/s"), | ||
("treddy_mpi-io-test_id4373053_6-2-60198-9815401321915095332_1.darshan", | ||
"STDIO", | ||
"I/O performance estimate (at the STDIO layer): transferred 0.0 MiB at 16.47 MiB/s"), | ||
("e3sm_io_heatmap_only.darshan", | ||
"STDIO", | ||
"I/O performance estimate (at the STDIO layer): transferred 0.0 MiB at 3.26 MiB/s"), | ||
("e3sm_io_heatmap_only.darshan", | ||
"MPI-IO", | ||
"I/O performance estimate (at the MPI-IO layer): transferred 73880.2 MiB at 105.69 MiB/s"), | ||
("partial_data_stdio.darshan", | ||
"MPI-IO", | ||
"I/O performance estimate (at the MPI-IO layer): transferred 32.0 MiB at 2317.98 MiB/s"), | ||
("partial_data_stdio.darshan", | ||
"STDIO", | ||
"I/O performance estimate (at the STDIO layer): transferred 16336.0 MiB at 2999.14 MiB/s"), | ||
# the C derived metrics code can't distinguish | ||
# between different kinds of errors at this time, | ||
# but we can still intercept in some cases... | ||
("partial_data_stdio.darshan", | ||
"GARBAGE", | ||
"ValueError"), | ||
# TODO: determine if the lack of APMPI and | ||
# any other "add-ons" in _structdefs is a bug | ||
# in the control flow for `log_get_derived_metrics()`? | ||
("e3sm_io_heatmap_only.darshan", | ||
"APMPI", | ||
"KeyError"), | ||
("skew-app.darshan", | ||
"POSIX", | ||
"I/O performance estimate (at the POSIX layer): transferred 41615.8 MiB at 157.49 MiB/s"), | ||
("skew-app.darshan", | ||
"MPI-IO", | ||
"I/O performance estimate (at the MPI-IO layer): transferred 41615.8 MiB at 55.22 MiB/s"), | ||
]) | ||
def test_derived_metrics_bytes_and_bandwidth(log_path, mod_name, expected_str): | ||
# test the basic scenario of retrieving | ||
# the total data transferred and bandwidth | ||
# for all records in a given module; the situation | ||
# of accumulating drived metrics with filtering | ||
# (i.e., for a single filename) is not tested here | ||
|
||
log_path = get_log_path(log_path) | ||
if expected_str == "RuntimeError": | ||
with pytest.raises(RuntimeError, | ||
match=f"{mod_name} module does not support derived"): | ||
log_get_bytes_bandwidth(log_path=log_path, | ||
mod_name=mod_name) | ||
elif expected_str == "ValueError": | ||
with pytest.raises(ValueError, | ||
match=f"{mod_name} is not in the available log"): | ||
log_get_bytes_bandwidth(log_path=log_path, | ||
mod_name=mod_name) | ||
elif expected_str == "KeyError": | ||
with pytest.raises(KeyError, match=f"{mod_name}"): | ||
log_get_bytes_bandwidth(log_path=log_path, | ||
mod_name=mod_name) | ||
else: | ||
actual_str = log_get_bytes_bandwidth(log_path=log_path, | ||
mod_name=mod_name) | ||
assert actual_str == expected_str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.