-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3720 from franzpoeschel/toml
Read IO plugin configuration (openPMD plugin) from reading applications (TOML)
- Loading branch information
Showing
37 changed files
with
11,770 additions
and
128 deletions.
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 |
---|---|---|
@@ -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 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 |
---|---|---|
@@ -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 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 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.