-
Notifications
You must be signed in to change notification settings - Fork 225
Read IO plugin configuration (openPMD plugin) from reading applications (TOML) #3720
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
steindev
merged 4 commits into
ComputationalRadiationPhysics:dev
from
franzpoeschel:toml
Jan 28, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # The following parameters need not be specified | ||
| # If a parameter is left unspecified, it falls back to its default value | ||
| file = "simData" # replaces --openPMD.file, | ||
| # given value is the default | ||
| infix = "" # replaces --openPMD.infix, | ||
| # default is "%06T" | ||
| ext = "bp" # replaces --openPMD.ext, | ||
| # given value is the default | ||
| backend_config = "@./adios_config.json" # replaces --openPMD.json, | ||
| # default is "{}" | ||
| data_preparation_strategy = "mappedMemory" # replaces --openPMD.dataPreparationStrategy, | ||
| # default is "doubleBuffer" | ||
|
|
||
|
|
||
| # Periods and data sources are specified independently per reading application | ||
| # The application names can be arbitrary and are not interpreted, except | ||
| # potentially for logging and other messages. | ||
| [sink.saxs_scattering.period] | ||
| # Each entry here denotes a periodicity combined with data sources requested | ||
| # by the reading code from PIConGPU at the specified periodicity | ||
| 500 = "species_all" | ||
|
|
||
| # A second data sink needs other output data | ||
| # All reading requests are merged into one single instance of the openPMD plugin | ||
| # Overlapping requests are no problem | ||
| [sink.some_other_name.period] | ||
| # Data sources can be specified as a list if needed | ||
| "400:400" = ["E", "B"] | ||
| # Time slice syntax is equivalent to that used by --openPMD.period | ||
| "100:300:200,444:444" = "fields_all" |
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,86 @@ | ||
| /* Copyright 2021 Franz Poeschel | ||
| * | ||
| * This file is part of PIConGPU. | ||
| * | ||
| * PIConGPU is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * PIConGPU is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with PIConGPU. | ||
| * If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #include "picongpu/plugins/common/MPIHelpers.hpp" | ||
|
|
||
| #include <pmacc/communication/manager_common.hpp> | ||
|
|
||
| #include <algorithm> | ||
| #include <fstream> | ||
| #include <numeric> | ||
| #include <sstream> | ||
| #include <vector> | ||
|
|
||
|
|
||
| namespace picongpu | ||
| { | ||
| /** | ||
| * @brief Read a file in MPI-collective manner. | ||
| * | ||
| * The file is read on rank 0 and its contents subsequently distributed | ||
| * to all other ranks. | ||
| * | ||
| * @param path Path for the file to read. | ||
| * @param comm MPI communicator. | ||
| * @return std::string Full file content. | ||
| */ | ||
| std::string collective_file_read(std::string const& path, MPI_Comm comm) | ||
| { | ||
| int rank, size; | ||
| MPI_CHECK(MPI_Comm_rank(comm, &rank)); | ||
| MPI_CHECK(MPI_Comm_size(comm, &size)); | ||
|
|
||
| std::string res; | ||
| size_t stringLength = 0; | ||
| if(rank == 0) | ||
| { | ||
| std::fstream handle; | ||
| handle.open(path, std::ios_base::in); | ||
| std::stringstream stream; | ||
| stream << handle.rdbuf(); | ||
| res = stream.str(); | ||
| if(!handle.good()) | ||
| { | ||
| throw std::runtime_error("Failed reading JSON config from file " + path + "."); | ||
| } | ||
| stringLength = res.size() + 1; | ||
| } | ||
| MPI_Datatype datatype = MPI_Types<size_t>{}.value; | ||
| int err = MPI_Bcast(&stringLength, 1, datatype, 0, comm); | ||
| if(err != MPI_SUCCESS) | ||
| { | ||
| throw std::runtime_error("[collective_file_read] MPI_Bcast stringLength failure."); | ||
| } | ||
| std::vector<char> recvbuf(stringLength, 0); | ||
| if(rank == 0) | ||
| { | ||
| std::copy_n(res.c_str(), stringLength, recvbuf.data()); | ||
| } | ||
| err = MPI_Bcast(recvbuf.data(), stringLength, MPI_CHAR, 0, comm); | ||
| if(err != MPI_SUCCESS) | ||
| { | ||
| throw std::runtime_error("[collective_file_read] MPI_Bcast file content failure."); | ||
| } | ||
| if(rank != 0) | ||
| { | ||
| res = recvbuf.data(); | ||
| } | ||
| return res; | ||
| } | ||
| } // namespace picongpu |
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,67 @@ | ||
| /* Copyright 2021 Franz Poeschel | ||
| * | ||
| * This file is part of PIConGPU. | ||
| * | ||
| * PIConGPU is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * PIConGPU is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with PIConGPU. | ||
| * If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include <mpi.h> | ||
|
|
||
| namespace picongpu | ||
| { | ||
| /** | ||
| * @brief Helper class to help figure out a platform-independent | ||
| * MPI_Datatype for size_t. | ||
| */ | ||
| template<typename> | ||
| struct MPI_Types; | ||
|
|
||
| template<> | ||
| struct MPI_Types<unsigned long> | ||
| { | ||
| // can't make this constexpr due to MPI | ||
| // so, make this non-static for simplicity | ||
| MPI_Datatype value = MPI_UNSIGNED_LONG; | ||
| }; | ||
|
|
||
| template<> | ||
| struct MPI_Types<unsigned long long> | ||
| { | ||
| MPI_Datatype value = MPI_UNSIGNED_LONG_LONG; | ||
| }; | ||
|
|
||
| template<> | ||
| struct MPI_Types<unsigned> | ||
| { | ||
| MPI_Datatype value = MPI_UNSIGNED; | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Read a file in MPI-collective manner. | ||
| * | ||
| * The file is read on rank 0 and its contents subsequently distributed | ||
| * to all other ranks. | ||
| * | ||
| * @param path Path for the file to read. | ||
| * @param comm MPI communicator. | ||
| * @return std::string Full file content. | ||
| */ | ||
| std::string collective_file_read(std::string const& path, MPI_Comm comm); | ||
| } // namespace picongpu | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.