Commit 04a50871 authored by GILLES Sebastien's avatar GILLES Sebastien

#451 Update XCode template accordingly.

parent 570cb2c4
......@@ -261,8 +261,7 @@ namespace HappyHeart
const double yz = components[4]; assert(Yuni::Math::Equals(yz, tensor.yz()));
const double xz = components[5]; assert(Yuni::Math::Equals(xz, tensor.xz()));
// #451 LINE COMMENTED ON PURPOSE FOR TEST! Do not forget to reactivate it!
// out.Zero();
// out.Zero();
out(3, 3) = -0.5 * zz;
out(4, 4) = -0.5 * xx;
......
......@@ -86,6 +86,8 @@ namespace HappyHeart
MPI_Comm_rank(communicator, &rank_);
MPI_Comm_size(communicator, &Nprocessor_);
MPI_Errhandler_set(communicator, MPI_ERRORS_ARE_FATAL);
IncrementNalive();
}
......@@ -149,15 +151,12 @@ namespace HappyHeart
std::vector<bool> Mpi::AllReduce(const std::vector<bool>& sent_data, MpiNS::Op mpi_operation) const
{
std::cout << "BOOL SPEC" << std::endl;
assert(!sent_data.empty());
// As there is no mpi type for bool, we'll make the mpi operation with short int and then convert
// back to bool.
auto&& converted_sent_data = BoolToShortInt(sent_data);
Utilities::PrintContainer(converted_sent_data, std::cout, ", ", "CONVERTED SENT [");
auto&& converted_gathered_data = AllReduce(converted_sent_data, mpi_operation);
std::vector<bool> ret;
......
......@@ -154,19 +154,8 @@ namespace HappyHeart
std::vector<T> buf(Nprocessor<unsigned int>(), 0);
buf[GetRank<unsigned int>()] = sent_data;
if (sent_data)
std::cout << "SENT TRUE!" << std::endl;
// DEV #451
auto ret = AllReduce(buf, Wrappers::MpiNS::Op::Sum);
for (auto val : ret)
std::cout << val << " : ";
std::cout << std::endl;
return ret;
return AllReduce(buf, Wrappers::MpiNS::Op::Sum);
}
......
......@@ -154,29 +154,31 @@ namespace HappyHeart
}
}
// Inform other processors whether the exception is thrown or not on this rank.
// The reason is that this pecular exception might arise on one rank an not on another!
auto&& mpi_state = mpi.CollectFromEachProcessor(is_nan);
Utilities::PrintContainer(mpi_state);
// auto&& mpi_state = mpi.CollectFromEachProcessor(is_nan);
if (is_nan)
throw Exception("NaN value found in local matrix!", invoking_file, invoking_line);
else
{
const bool is_nan_on_other_processor = std::any_of(mpi_state.cbegin(), mpi_state.cend(),
[](auto value)
{
return value == true;
});
if (is_nan_on_other_processor)
{
std::cout << "THROW ON PROC " << mpi.GetRank<int>() << std::endl;
throw Exception("Terminating exception found on another processor!",
invoking_file, invoking_line);
}
}
// else
// {
// const bool is_nan_on_other_processor = std::any_of(mpi_state.cbegin(), mpi_state.cend(),
// [](auto value)
// {
// return value == true;
// });
//
// std::cout << mpi.GetRankPreffix() << "THROW 20" << std::endl;
// if (is_nan_on_other_processor)
// {
// std::cout << mpi.GetRankPreffix() << "THROW 30" << std::endl;
// throw Exception("Terminating exception found on another processor!",
// invoking_file, invoking_line);
// }
// }
//
// std::cout << mpi.GetRankPreffix() << "THROW 40" << std::endl;
}
......
......@@ -6,6 +6,8 @@
//___COPYRIGHT___
//
#include "Utilities/Exceptions/PrintAndAbort.hpp"
#include "Core/InitHappyHeart.hpp"
#include "ModelInstances/___VARIABLE_groupName:identifier___/Model.hpp"
......@@ -17,19 +19,20 @@ using namespace HappyHeart;
int main(int argc, char ** argv)
{
using InputParameterList = ___VARIABLE_problemName:identifier___NS::InputParameterList;
InitHappyHeart<InputParameterList> happy_heart(argc, argv);
const auto& input_parameter_data = happy_heart.GetInputParameterList();
const auto& mpi = happy_heart.GetMpi();
try
{
using InputParameterList = ___VARIABLE_problemName:identifier___NS::InputParameterList;
InitHappyHeart<InputParameterList> happy_heart(argc, argv);
// Happens if the input file wasn't found.
if (!happy_heart.IsOk())
return -1;
const auto& input_parameter_data = happy_heart.GetInputParameterList();
const auto& mpi = happy_heart.GetMpi();
___VARIABLE_problemName:identifier___NS::Model model(mpi, input_parameter_data);
model.Run(input_parameter_data);
......@@ -37,15 +40,12 @@ int main(int argc, char ** argv)
}
catch(const std::exception& e)
{
std::cerr << "Exception caught: " << e.what() << std::endl;
std::cerr << "Program has therefore been terminated" << std::endl;
ExceptionNS::PrintAndAbort(mpi, e.what());
}
catch(Seldon::Error& e)
{
std::cerr << "Exception caught: " << e.What() << std::endl;
std::cerr << "Program has therefore been terminated" << std::endl;
// exit(-1);
ExceptionNS::PrintAndAbort(mpi, e.What());
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment