Skip to content
Snippets Groups Projects
Commit a427a10d authored by Nils-Arne Dreier's avatar Nils-Arne Dreier
Browse files

fix: add critical regions for FDB and dont parallelize over levels

parent 36b3190a
Branches feature_openmp
No related tags found
1 merge request!48Feature openmp
......@@ -142,7 +142,10 @@ class GRIBMessage {
if (res != 0) {
throw std::runtime_error("GRIB: Failed to get raw message: " + std::string(codes_get_error_message(res)));
}
fdb.archive(key, data, data_length);
#pragma omp critical(FDB)
{
fdb.archive(key, data, data_length);
}
}
};
......@@ -347,7 +350,6 @@ void FDBWriter::Impl::handle(Collection& collection, const chrono::DateTime& tim
return has_missing_values ? "1" : "0";
});
#pragma omp taskloop
for (collection_index = 0; collection_index < collection.size(); ++collection_index) {
auto& values = collection.at(collection_index);
......@@ -377,7 +379,10 @@ void FDBWriter::Impl::handle(Collection& collection, const chrono::DateTime& tim
msg.archive(*fdb_, key);
}
fdb_->flush();
#pragma omp critical(FDB)
{
fdb_->flush();
}
}
void FDBWriter::handle(Collection& collection, const chrono::DateTime& timestep_begin, const chrono::DateTime& timestep_end)
......
......@@ -88,9 +88,10 @@ void Yac2Input::run()
}
chrono::Duration timestep_duration(timeStep_);
for (; timestep_end <= end_time; timestep_end += timestep_duration) {
#pragma omp parallel
#pragma omp single
for (; timestep_end <= end_time; timestep_end += timestep_duration) {
{
for (std::size_t collectionIdx = 0; collectionIdx < collections_.size(); ++collectionIdx) {
std::vector<double*> buffers(collections_[collectionIdx].size(), nullptr);
for (std::size_t fieldIdx = 0; fieldIdx < collections_[collectionIdx].size(); ++fieldIdx) {
......@@ -115,6 +116,7 @@ void Yac2Input::run()
}
// taskwait ensures that all data is written and the buffers can be used again
#pragma omp taskwait
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment