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

feat: use yac_cget_sasync

parent a427a10d
No related branches found
Tags v0.4.3
No related merge requests found
......@@ -87,35 +87,39 @@ void Yac2Input::run()
}
}
std::vector<int> yac_infos(collections_.size());
chrono::Duration timestep_duration(timeStep_);
for (; timestep_end <= end_time; timestep_end += timestep_duration) {
#pragma omp parallel
#pragma omp single
{
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) {
buffers[fieldIdx] = collections_[collectionIdx].at(fieldIdx).data();
}
int info = 0;
int ierror = 0;
yac_cget(collectionId[collectionIdx], static_cast<int>(collections_[collectionIdx].size()), buffers.data(), &info, &ierror);
std::vector<double*> buffers(collections_[collectionIdx].size(), nullptr);
for (std::size_t fieldIdx = 0; fieldIdx < collections_[collectionIdx].size(); ++fieldIdx) {
buffers[fieldIdx] = collections_[collectionIdx].at(fieldIdx).data();
}
int info = 0;
int ierror = 0;
yac_cget_async(collectionId[collectionIdx], static_cast<int>(collections_[collectionIdx].size()), buffers.data(), &yac_infos[collectionIdx], &ierror);
if (ierror != 0) {
throw std::runtime_error("Error " + std::to_string(ierror) + " in yac_cget");
}
}
if (ierror != 0) {
throw std::runtime_error("Error " + std::to_string(ierror) + " in yac_cget");
}
for (std::size_t collectionIdx = 0; collectionIdx < collections_.size(); ++collectionIdx) {
yac_cwait(collectionId[collectionIdx]);
}
if (info != YAC_ACTION_NONE) {
#pragma omp task
{
handler_->handle(collections_[collectionIdx], timestep_begin[collectionIdx], timestep_end);
timestep_begin[collectionIdx] = timestep_end;
}
#pragma omp parallel for default(shared)
for (std::size_t collectionIdx = 0; collectionIdx < collections_.size(); ++collectionIdx) {
if (yac_infos[collectionIdx] != YAC_ACTION_NONE) {
{
handler_->handle(collections_[collectionIdx], timestep_begin[collectionIdx], timestep_end);
timestep_begin[collectionIdx] = timestep_end;
}
}
}
// 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