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

Replace std::source_location by SourceLocation

parent 31fefbeb
No related branches found
No related tags found
1 merge request!176Add HDF5 support
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <utils/HDF5.hpp> #include <utils/HDF5.hpp>
#include <utils/Messenger.hpp> #include <utils/Messenger.hpp>
#include <experimental/source_location> #include <utils/SourceLocation.hpp>
#include <fstream> #include <fstream>
#include <utils/Demangle.hpp> #include <utils/Demangle.hpp>
...@@ -18,7 +18,7 @@ namespace parallel ...@@ -18,7 +18,7 @@ namespace parallel
template <typename DataType, ItemType item_type, typename ConnectivityPtr> template <typename DataType, ItemType item_type, typename ConnectivityPtr>
void check(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value, void check(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value,
const std::string& name, const std::string& name,
const std::experimental::source_location& source_location = std::experimental::source_location::current()); const SourceLocation& source_location = SourceLocation{});
class ParallelChecker class ParallelChecker
{ {
...@@ -32,13 +32,13 @@ class ParallelChecker ...@@ -32,13 +32,13 @@ class ParallelChecker
ParallelChecker() = default; ParallelChecker() = default;
void void
_printHeader(const std::string& name, const std::experimental::source_location& source_location) const _printHeader(const std::string& name, const SourceLocation& source_location) const
{ {
std::cout << rang::fg::cyan << " | " << rang::fgB::cyan << "parallel checker" << rang::fg::cyan << " for \"" std::cout << rang::fg::cyan << " | " << rang::fgB::cyan << "parallel checker" << rang::fg::cyan << " for \""
<< rang::fgB::magenta << name << rang::fg::cyan << "\" tag " << rang::fgB::blue << m_tag << rang::fgB::magenta << name << rang::fg::cyan << "\" tag " << rang::fgB::blue << m_tag
<< rang::fg::reset << '\n'; << rang::fg::reset << '\n';
std::cout << rang::fg::cyan << " | from " << rang::fgB::blue << source_location.file_name() << rang::fg::reset std::cout << rang::fg::cyan << " | from " << rang::fgB::blue << source_location.filename() << rang::fg::reset << ':'
<< ':' << rang::style::bold << source_location.line() << rang::style::reset << '\n'; << rang::style::bold << source_location.line() << rang::style::reset << '\n';
} }
public: public:
...@@ -52,16 +52,14 @@ class ParallelChecker ...@@ -52,16 +52,14 @@ class ParallelChecker
} }
template <typename DataType, ItemType item_type, typename ConnectivityPtr> template <typename DataType, ItemType item_type, typename ConnectivityPtr>
friend void check(const ItemValue<DataType, item_type, ConnectivityPtr>&, friend void check(const ItemValue<DataType, item_type, ConnectivityPtr>&, const std::string&, const SourceLocation&);
const std::string&,
const std::experimental::source_location&);
private: private:
template <typename DataType, ItemType item_type, typename ConnectivityPtr> template <typename DataType, ItemType item_type, typename ConnectivityPtr>
void void
write(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value, write(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value,
const std::string& name, const std::string& name,
const std::experimental::source_location& source_location) const SourceLocation& source_location)
{ {
this->_printHeader(name, source_location); this->_printHeader(name, source_location);
...@@ -76,8 +74,8 @@ class ParallelChecker ...@@ -76,8 +74,8 @@ class ParallelChecker
auto values_group_id = HDF5::createOrOpenGroup(file_id, "/values"); auto values_group_id = HDF5::createOrOpenGroup(file_id, "/values");
auto group_id = HDF5::createOrOpenGroup(values_group_id, std::to_string(m_tag)); auto group_id = HDF5::createOrOpenGroup(values_group_id, std::to_string(m_tag));
HDF5::writeAttribute(group_id, "filename", std::string{source_location.file_name()}); HDF5::writeAttribute(group_id, "filename", std::string{source_location.filename()});
HDF5::writeAttribute(group_id, "function", source_location.function_name()); HDF5::writeAttribute(group_id, "function", source_location.function());
HDF5::writeAttribute(group_id, "line", static_cast<size_t>(source_location.line())); HDF5::writeAttribute(group_id, "line", static_cast<size_t>(source_location.line()));
HDF5::writeAttribute(group_id, "name", name); HDF5::writeAttribute(group_id, "name", name);
...@@ -122,7 +120,7 @@ class ParallelChecker ...@@ -122,7 +120,7 @@ class ParallelChecker
void void
compare(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value, compare(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value,
const std::string& name, const std::string& name,
const std::experimental::source_location& source_location) const SourceLocation& source_location)
{ {
this->_printHeader(name, source_location); this->_printHeader(name, source_location);
...@@ -172,7 +170,7 @@ class ParallelChecker ...@@ -172,7 +170,7 @@ class ParallelChecker
std::cout << rang::fg::cyan << " | " << rang::fgB::magenta << "reference function " << rang::fgB::blue std::cout << rang::fg::cyan << " | " << rang::fgB::magenta << "reference function " << rang::fgB::blue
<< reference_function_name << rang::fg::reset << '\n'; << reference_function_name << rang::fg::reset << '\n';
std::cout << rang::fg::cyan << " | " << rang::fgB::magenta << "target function " << rang::fgB::blue std::cout << rang::fg::cyan << " | " << rang::fgB::magenta << "target function " << rang::fgB::blue
<< source_location.function_name() << rang::fg::reset << '\n'; << source_location.function() << rang::fg::reset << '\n';
} }
if (not parallel::allReduceAnd(is_comparable)) { if (not parallel::allReduceAnd(is_comparable)) {
...@@ -318,7 +316,7 @@ template <typename DataType, ItemType item_type, typename ConnectivityPtr> ...@@ -318,7 +316,7 @@ template <typename DataType, ItemType item_type, typename ConnectivityPtr>
void void
check(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value, check(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value,
const std::string& name, const std::string& name,
const std::experimental::source_location& source_location) const SourceLocation& source_location)
{ {
const bool write_mode = (parallel::size() == 1); const bool write_mode = (parallel::size() == 1);
...@@ -337,7 +335,7 @@ template <typename DataType, ItemType item_type, typename ConnectivityPtr> ...@@ -337,7 +335,7 @@ template <typename DataType, ItemType item_type, typename ConnectivityPtr>
void void
check(const ItemValue<DataType, item_type, ConnectivityPtr>&, check(const ItemValue<DataType, item_type, ConnectivityPtr>&,
const std::string&, const std::string&,
const std::experimental::source_location& = std::experimental::source_location::current()) const SourceLocation& = SourceLocation{})
{ {
throw UnexpectedError("parallel checker cannot be used without HDF5 support"); throw UnexpectedError("parallel checker cannot be used without HDF5 support");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment