Compare commits
2
Commits
776de1f593
...
karl_2d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
444ca56108 | ||
|
|
5f866c04b4 |
+10
-10
@@ -20,7 +20,7 @@ blitz::Array<double, 3> Hdf5Reader::readD3Double(std::string path) {
|
|||||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
hid_t dataspace = H5Dget_space(dataset);
|
||||||
if (dataset < 0) {
|
if (dataset < 0) {
|
||||||
ERROR("The given dataset could not be opened");
|
ERROR("The given dataset could not be opened " + path);
|
||||||
}
|
}
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
// turn error report back onby hdf5 because of check H5Dopen2
|
||||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
||||||
@@ -50,7 +50,7 @@ blitz::Array<double, 2> Hdf5Reader::readD2Double(std::string path) {
|
|||||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
hid_t dataspace = H5Dget_space(dataset);
|
||||||
if (dataset < 0) {
|
if (dataset < 0) {
|
||||||
ERROR("The given dataset could not be opened");
|
ERROR("The given dataset could not be opened " + path);
|
||||||
}
|
}
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
// turn error report back onby hdf5 because of check H5Dopen2
|
||||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
||||||
@@ -79,7 +79,7 @@ blitz::Array<double, 1> Hdf5Reader::readD1Double(std::string path) {
|
|||||||
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
hid_t dataspace = H5Dget_space(dataset);
|
||||||
if (dataset < 0) {
|
if (dataset < 0) {
|
||||||
ERROR("The given dataset could not be opened");
|
ERROR("The given dataset could not be opened " + path);
|
||||||
}
|
}
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
// turn error report back onby hdf5 because of check H5Dopen2
|
||||||
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
||||||
@@ -109,7 +109,7 @@ double Hdf5Reader::readDouble(std::string path) {
|
|||||||
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
hid_t dataspace = H5Dget_space(dataset);
|
||||||
if (dataset < 0) {
|
if (dataset < 0) {
|
||||||
ERROR("The given dataset could not be opened");
|
ERROR("The given dataset could not be opened " + path);
|
||||||
}
|
}
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
// turn error report back onby hdf5 because of check H5Dopen2
|
||||||
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
||||||
@@ -139,7 +139,7 @@ int Hdf5Reader::readInt(std::string path) {
|
|||||||
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
hid_t dataspace = H5Dget_space(dataset);
|
||||||
if (dataset < 0) {
|
if (dataset < 0) {
|
||||||
ERROR("The given dataset could not be opened");
|
ERROR("The given dataset could not be opened " + path);
|
||||||
}
|
}
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
// turn error report back onby hdf5 because of check H5Dopen2
|
||||||
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
||||||
@@ -170,7 +170,7 @@ blitz::Array<double, 4> Hdf5Reader::readD4Double(std::string path) {
|
|||||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
hid_t dataspace = H5Dget_space(dataset);
|
||||||
if (dataset < 0) {
|
if (dataset < 0) {
|
||||||
ERROR("The given dataset could not be opened");
|
ERROR("The given dataset could not be opened " + path);
|
||||||
}
|
}
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
// turn error report back onby hdf5 because of check H5Dopen2
|
||||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
||||||
@@ -200,7 +200,7 @@ blitz::Array<double, 5> Hdf5Reader::readD5Double(std::string path) {
|
|||||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
hid_t dataspace = H5Dget_space(dataset);
|
||||||
if (dataset < 0) {
|
if (dataset < 0) {
|
||||||
ERROR("The given dataset could not be opened");
|
ERROR("The given dataset could not be opened " + path);
|
||||||
}
|
}
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
// turn error report back onby hdf5 because of check H5Dopen2
|
||||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
||||||
@@ -230,7 +230,7 @@ blitz::Array<long int, 4> Hdf5Reader::readD4LongInt(std::string path) {
|
|||||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
hid_t dataspace = H5Dget_space(dataset);
|
||||||
if (dataset < 0) {
|
if (dataset < 0) {
|
||||||
ERROR("The given dataset could not be opened");
|
ERROR("The given dataset could not be opened " + path);
|
||||||
}
|
}
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
// turn error report back onby hdf5 because of check H5Dopen2
|
||||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
||||||
@@ -260,7 +260,7 @@ blitz::Array<long int, 5> Hdf5Reader::readD5LongInt(std::string path) {
|
|||||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
hid_t dataspace = H5Dget_space(dataset);
|
||||||
if (dataset < 0) {
|
if (dataset < 0) {
|
||||||
ERROR("The given dataset could not be opened");
|
ERROR("The given dataset could not be opened " + path);
|
||||||
}
|
}
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
// turn error report back onby hdf5 because of check H5Dopen2
|
||||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
||||||
@@ -293,7 +293,7 @@ std::stringstream Hdf5Reader::readEngineString(std::string path) {
|
|||||||
hid_t dataset = H5Dopen2(file, (path + "/string").c_str(), H5P_DEFAULT);
|
hid_t dataset = H5Dopen2(file, (path + "/string").c_str(), H5P_DEFAULT);
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
hid_t dataspace = H5Dget_space(dataset);
|
||||||
if (dataset < 0) {
|
if (dataset < 0) {
|
||||||
ERROR("The given dataset could not be opened");
|
ERROR("The given dataset could not be opened " + path);
|
||||||
}
|
}
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
// turn error report back onby hdf5 because of check H5Dopen2
|
||||||
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
||||||
|
|||||||
@@ -162,8 +162,10 @@ void MpiParticleReader::readParticles(
|
|||||||
io_group_size += 1;
|
io_group_size += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef debug_level3
|
||||||
fprintf(stdout, "<%d>: io_group: %d, io_rank: %d, io_group_size: %d\n",
|
fprintf(stdout, "<%d>: io_group: %d, io_rank: %d, io_group_size: %d\n",
|
||||||
MpiCommunication::mpiRank(), io_group, io_rank, io_group_size);
|
MpiCommunication::mpiRank(), io_group, io_rank, io_group_size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
@@ -239,14 +241,6 @@ void MpiParticleReader::readParticles(
|
|||||||
}
|
}
|
||||||
|
|
||||||
storage_queue.reserve(cpu_header.num_particles);
|
storage_queue.reserve(cpu_header.num_particles);
|
||||||
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
|
||||||
{
|
|
||||||
std::stringstream out;
|
|
||||||
out << io_rank << ": trying to read " << cpu_header.num_particles;
|
|
||||||
out << " many particles";
|
|
||||||
DEBUG_LEVEL_1(out.str());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// particle number if they were equally distributed across procs
|
// particle number if they were equally distributed across procs
|
||||||
size_t particle_number = cpu_header.num_particles / io_group_size;
|
size_t particle_number = cpu_header.num_particles / io_group_size;
|
||||||
@@ -256,14 +250,22 @@ void MpiParticleReader::readParticles(
|
|||||||
// calculate offset from particles read by other processes in this io_group
|
// calculate offset from particles read by other processes in this io_group
|
||||||
std::uint64_t this_offset = cpu_header.file_offset;
|
std::uint64_t this_offset = cpu_header.file_offset;
|
||||||
this_offset += io_rank*particle_number*sizeof(particle::SerializedParticle);
|
this_offset += io_rank*particle_number*sizeof(particle::SerializedParticle);
|
||||||
this_offset = io_rank < overflow ? this_offset + io_rank*particle_number*sizeof(particle::SerializedParticle)
|
// fprintf(stdout, "<%d>: offset: %ld, numpart: %ld\n", MpiCommunication::mpiRank(), this_offset, particle_number);
|
||||||
: this_offset + overflow*particle_number*sizeof(particle::SerializedParticle);
|
this_offset = io_rank < overflow ? this_offset + io_rank*sizeof(particle::SerializedParticle)
|
||||||
|
: this_offset + overflow*sizeof(particle::SerializedParticle);
|
||||||
|
// fprintf(stdout, "<%d>: offset: %ld, sizeof(SerializedParticle): %ld\n", MpiCommunication::mpiRank(), this_offset, sizeof(particle::SerializedParticle));
|
||||||
|
|
||||||
// correct number of particles for this proc
|
// correct number of particles for this proc
|
||||||
particle_number = (io_rank < overflow) ?
|
particle_number = (io_rank < overflow) ? particle_number + 1 : particle_number;
|
||||||
particle_number + 1 : particle_number;
|
|
||||||
|
|
||||||
fprintf(stdout, "<%d>: pn: %ld, thisoffset: %ld\n",MpiCommunication::mpiRank(), particle_number, this_offset - cpu_header.file_offset);
|
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
||||||
|
{
|
||||||
|
std::stringstream out;
|
||||||
|
out << io_rank << ": trying to read " << cpu_header.num_particles;
|
||||||
|
out << " many particles";
|
||||||
|
DEBUG_LEVEL_1(out.str());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// set file view to the part where the particles are stored
|
// set file view to the part where the particles are stored
|
||||||
status = MPI_File_set_view(file, this_offset, MPI_DOUBLE,
|
status = MPI_File_set_view(file, this_offset, MPI_DOUBLE,
|
||||||
@@ -282,8 +284,9 @@ void MpiParticleReader::readParticles(
|
|||||||
")!");
|
")!");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug_level3
|
||||||
{
|
{
|
||||||
|
// print first and last loaded particle to check if the alignment is sensible (i.e. no two processes load the same particle)
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << "group: " << io_group << ", rank: "<< io_rank;
|
out << "group: " << io_group << ", rank: "<< io_rank;
|
||||||
out << ": number of particles in queue: " << storage_queue.size();
|
out << ": number of particles in queue: " << storage_queue.size();
|
||||||
|
|||||||
+17
-10
@@ -51,23 +51,30 @@ void Restart::restart(
|
|||||||
SIM_INFO("Restarting from earlier state.");
|
SIM_INFO("Restarting from earlier state.");
|
||||||
|
|
||||||
if(process_number_old_ < MpiCommunication::mpiSize()) {
|
if(process_number_old_ < MpiCommunication::mpiSize()) {
|
||||||
#ifdef debug_level1
|
SIM_INFO("Warning: Restarting from a state with fewer processes. (#old: " +
|
||||||
|
std::to_string(process_number_old_) +
|
||||||
|
", #now: " +
|
||||||
|
std::to_string(MpiCommunication::mpiSize()) + ")");
|
||||||
|
|
||||||
|
#ifdef debug_level1
|
||||||
DEBUG_LEVEL_1("Restarting rng");
|
DEBUG_LEVEL_1("Restarting rng");
|
||||||
#endif
|
#endif
|
||||||
restartRandomNumbers(random_numbers, process_number_old_);
|
restartRandomNumbers(random_numbers, process_number_old_);
|
||||||
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
|
||||||
|
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
||||||
DEBUG_LEVEL_1("Reloading particles.");
|
DEBUG_LEVEL_1("Reloading particles.");
|
||||||
#endif
|
#endif
|
||||||
particle_reader_.readParticles(storage_queue, process_number_old_);
|
particle_reader_.readParticles(storage_queue, process_number_old_);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
#ifdef debug_level1
|
#ifdef debug_level1
|
||||||
DEBUG_LEVEL_1("Restarting rng");
|
DEBUG_LEVEL_1("Restarting rng");
|
||||||
#endif
|
#endif
|
||||||
restartRandomNumbers(random_numbers);
|
restartRandomNumbers(random_numbers);
|
||||||
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
|
||||||
|
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
||||||
DEBUG_LEVEL_1("Reloading particles.");
|
DEBUG_LEVEL_1("Reloading particles.");
|
||||||
#endif
|
#endif
|
||||||
particle_reader_.readParticles(storage_queue);
|
particle_reader_.readParticles(storage_queue);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -136,12 +143,12 @@ void Restart::restartRandomNumbers(RandomNumbers* random, int nold) {
|
|||||||
// draw the next value of the current engine
|
// draw the next value of the current engine
|
||||||
size_t seed = (*engine)();
|
size_t seed = (*engine)();
|
||||||
|
|
||||||
fprintf(stdout, "<%d>: io_group: %d, seed: %ld\n", MpiCommunication::mpiRank(), io_group, seed);
|
// fprintf(stdout, "<%d>: io_group: %d, seed: %ld\n", MpiCommunication::mpiRank(), io_group, seed);
|
||||||
|
|
||||||
// use this value as a seed and create a temporary mt19937 object
|
// use this value as a seed and create a temporary mt19937 object
|
||||||
std::mt19937 tmp(seed);
|
std::mt19937 tmp(seed);
|
||||||
|
|
||||||
// serialize and de-serialize it to set the pointer of the actual engine
|
// serialize and de-serialize it to set the pointer of the actual engine (likely not the best implementation)
|
||||||
engine_state << tmp;
|
engine_state << tmp;
|
||||||
engine_state >> *engine;
|
engine_state >> *engine;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,12 +82,11 @@ void SimulationOutput::writeMetaData(
|
|||||||
// find occurance of last slash in the path of the parameter
|
// find occurance of last slash in the path of the parameter
|
||||||
size_t slshidx = parameter_file_path.rfind("/");
|
size_t slshidx = parameter_file_path.rfind("/");
|
||||||
|
|
||||||
|
// if its a relative path append a slash otherwise use the substring from the last slash onwards
|
||||||
std::string hdf5path = (slshidx == std::string::npos) ?
|
std::string hdf5path = (slshidx == std::string::npos) ?
|
||||||
"/" + parameter_file_path :
|
"/" + parameter_file_path :
|
||||||
parameter_file_path.substr(slshidx);
|
parameter_file_path.substr(slshidx);
|
||||||
|
|
||||||
SIM_INFO("blubb: " + hdf5path);
|
|
||||||
|
|
||||||
writer.write(file.str(), hdf5path);
|
writer.write(file.str(), hdf5path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user