-
Notifications
You must be signed in to change notification settings - Fork 51
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
Joined arrays in ADIOS2 #1382
Merged
Merged
Joined arrays in ADIOS2 #1382
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0df4704
Extract verifyChunk
franzpoeschel af6eaad
Main implementation
franzpoeschel 07b0331
Python bindings
franzpoeschel 3d5dcf7
Throw errors if unsupported
franzpoeschel b79af4f
Testing
franzpoeschel e55233e
Documentation
franzpoeschel 403c0a9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ea09b71
Fix ADIOS2 checks for multidimensional joined arrays
franzpoeschel c45ccd2
Python test
franzpoeschel 70d6f3f
Expose this to the sliced Python API
franzpoeschel 5af59b1
Fix
franzpoeschel 51eca2a
Fix formatting
franzpoeschel 32dbc60
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 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 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 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 |
---|---|---|
|
@@ -14,13 +14,21 @@ | |
import numpy as np | ||
import openpmd_api as io | ||
|
||
try: | ||
import adios2 | ||
from packaging import version | ||
USE_JOINED_DIMENSION = \ | ||
version.parse(adios2.__version__) >= version.parse('2.9.0') | ||
except ImportError: | ||
USE_JOINED_DIMENSION = False | ||
|
||
if __name__ == "__main__": | ||
# also works with any other MPI communicator | ||
comm = MPI.COMM_WORLD | ||
|
||
# global data set to write: [MPI_Size * 10, 300] | ||
# each rank writes a 10x300 slice with its MPI rank as values | ||
local_value = comm.size | ||
local_value = comm.rank | ||
local_data = np.ones(10 * 300, | ||
dtype=np.double).reshape(10, 300) * local_value | ||
if 0 == comm.rank: | ||
|
@@ -29,7 +37,9 @@ | |
|
||
# open file for writing | ||
series = io.Series( | ||
"../samples/5_parallel_write_py.h5", | ||
"../samples/5_parallel_write_py.bp" | ||
if USE_JOINED_DIMENSION | ||
else "../samples/5_parallel_write_py.h5", | ||
io.Access.create, | ||
comm | ||
) | ||
|
@@ -51,7 +61,9 @@ | |
meshes["mymesh"] | ||
|
||
# example 1D domain decomposition in first index | ||
global_extent = [comm.size * 10, 300] | ||
global_extent = [io.Dataset.JOINED_DIMENSION, 300] \ | ||
if USE_JOINED_DIMENSION else [comm.size * 10, 300] | ||
|
||
dataset = io.Dataset(local_data.dtype, global_extent) | ||
|
||
if 0 == comm.rank: | ||
|
@@ -64,7 +76,15 @@ | |
"mymesh in iteration 1") | ||
|
||
# example shows a 1D domain decomposition in first index | ||
mymesh[comm.rank*10:(comm.rank+1)*10, :] = local_data | ||
|
||
if USE_JOINED_DIMENSION: | ||
# explicit API | ||
# mymesh.store_chunk(local_data, [], [10, 300]) | ||
mymesh[:, :] = local_data | ||
# or short: | ||
# mymesh[()] = local_data | ||
Comment on lines
+80
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fancy! |
||
else: | ||
mymesh[comm.rank*10:(comm.rank+1)*10, :] = local_data | ||
if 0 == comm.rank: | ||
print("Registered a single chunk per MPI rank containing its " | ||
"contribution, ready to write content to disk") | ||
|
This file contains 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 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 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 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 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 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 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.