Skip to content
Snippets Groups Projects
Commit 86e477f8 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Prepare parallel synchronization

parent e51fe6de
No related branches found
No related tags found
1 merge request!11Feature/mpi
#ifndef ITEM_VALUE_SYNCHRONIZER_HPP
#define ITEM_VALUE_SYNCHRONIZER_HPP
#include <ItemValue.hpp>
#include <Connectivity.hpp>
class ItemValueSynchronizer
{
public:
template <typename DataType,
ItemType item_type,
typename ConnectivityPtr>
PASTIS_INLINE
void synchronize(ItemValue<DataType, item_type, ConnectivityPtr>& item_value)
{
pout() << "Calling synchronize...\n";
auto connectivity_ptr = item_value.connectivity_ptr();
Assert(connectivity_ptr.use_count()>0, "No connectivity is associated to this ItemValue");
parallel::barrier();
parallel::Messenger::destroy();
pout() << __FILE__ << ':' << __LINE__ << ": NIY!\n";
std::exit(0);
}
PASTIS_INLINE
ItemValueSynchronizer()
{
;
}
};
#endif // ITEM_VALUE_SYNCHRONIZER_HPP
......@@ -6,6 +6,8 @@
#include <Connectivity.hpp>
#include <ItemValueSynchronizer.hpp>
template <typename DataType,
ItemType item_type>
std::remove_const_t<DataType>
......@@ -282,4 +284,16 @@ sum(const ItemValue<DataType, item_type>& item_value)
return parallel::allReduceSum(local_sum);
}
template <typename DataType,
ItemType item_type,
typename ConnectivityPtr>
void synchronize(ItemValue<DataType, item_type, ConnectivityPtr>& item_value)
{
static_assert(not std::is_const_v<DataType>, "cannot synchronize ItemValue of const data");
if (parallel::size() > 1) {
ItemValueSynchronizer synchronizer;
synchronizer.synchronize(item_value);
}
}
#endif // ITEM_VALUE_UTILS_HPP
......@@ -210,13 +210,16 @@ class AcousticSolver
computeAjr(rhocj, Cjr, ljr, njr);
NodeValuePerCell<const Rdd> Ajr = m_Ajr;
const NodeValue<const Rdd> Ar = computeAr(Ajr);
const NodeValue<const Rd> br = computeBr(m_Ajr, Cjr, uj, pj);
this->computeAr(Ajr);
this->computeBr(m_Ajr, Cjr, uj, pj);
this->applyBoundaryConditions();
synchronize(m_Ar);
synchronize(m_br);
NodeValue<Rd>& ur = m_ur;
ur = computeUr(Ar, br);
ur = computeUr(m_Ar, m_br);
computeFjr(m_Ajr, ur, Cjr, uj, pj);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment