Commit ff97334f authored by Martin Bauer's avatar Martin Bauer
Browse files

Extracted JSON conversion of timing data structures

- CUDA compiler has problems to compile external json library
- timing pool is included by BlockForest, and previously timing pool
  included JSON library
parent bdfa6981
......@@ -27,7 +27,6 @@
#include "CpuPolicy.h"
#include "WcPolicy.h"
#include "core/DataTypes.h"
#include "core/extern/json.hpp"
#include <limits>
......@@ -442,21 +441,6 @@ inline void Timer<TP>::merge( const Timer<TP> & other )
}
//**********************************************************************************************************************
//**********************************************************************************************************************
/*!\brief Converts timer to json The signature is required by the json library
// \relates Timer
*/
template < typename TP > // Timing policy
void to_json( nlohmann::json& j, const Timer< TP >& timer )
{
j = nlohmann::json{{"total", timer.total()},
{"average", timer.average()},
{"count", timer.getCounter()},
{"min", timer.min()},
{"max", timer.max()},
{"variance", timer.variance()}};
}
//**********************************************************************************************************************
} // namespace timing
......
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file Timer.h
//! \ingroup core
//!
//
//======================================================================================================================
#include "core/extern/json.hpp"
#include "core/timing/Timer.h"
#include "core/timing/TimingNode.h"
#include "core/timing/TimingTree.h"
namespace walberla {
namespace timing {
/*! Converts timer to json The signature is required by the json library
// \relates Timer
*/
template < typename TP > // Timing policy
void to_json( nlohmann::json& j, const Timer< TP >& timer )
{
j = nlohmann::json{{"total", timer.total()},
{"average", timer.average()},
{"count", timer.getCounter()},
{"min", timer.min()},
{"max", timer.max()},
{"variance", timer.variance()}};
}
/// Converts a TimingNode to json. The signature is required by the json library
/// \relates TimingNode
template < typename TP > // Timing policy
void to_json( nlohmann::json& j, const TimingNode< TP >& tn )
{
/// ignore the first timer in the timing node since it is empty
if( tn.last_ == nullptr )
{
j = nlohmann::json( tn.tree_ );
} else
{
j = nlohmann::json( tn.timer_ );
j["childs"] = nlohmann::json( tn.tree_ );
}
}
/// Converts a TimingTree to json. The signature is required by the json library
/// \relates TimingTree
template < typename TP > // Timing policy
void to_json( nlohmann::json& j, const TimingTree< TP >& tt )
{
j = nlohmann::json( tt.getRawData() );
}
}
}
\ No newline at end of file
......@@ -30,7 +30,6 @@
#include "core/mpi/MPIManager.h"
#include "core/mpi/Reduce.h"
#include "core/mpi/SetReduction.h"
#include "core/extern/json.hpp"
#include <algorithm>
......@@ -483,21 +482,6 @@ std::ostream& operator<<(std::ostream& os, const TimingNode<TP>& tn)
return os;
}
/// convertes a TimingNode to json. The signature is required by the json library
/// \relates TimingNode
template < typename TP > // Timing policy
void to_json( nlohmann::json& j, const TimingNode< TP >& tn )
{
/// ignore the first timer in the timing node since it is empty
if( tn.last_ == nullptr )
{
j = nlohmann::json( tn.tree_ );
} else
{
j = nlohmann::json( tn.timer_ );
j["childs"] = nlohmann::json( tn.tree_ );
}
}
namespace internal {
/// adds a sub timer containing the remainder of all other subtimers on the same hierarchy level
......
......@@ -28,7 +28,6 @@
#include "core/logging/Logging.h"
#include "core/mpi/MPIManager.h"
#include "core/mpi/Reduce.h"
#include "core/extern/json.hpp"
#include <algorithm>
#include <iostream>
......@@ -252,13 +251,6 @@ TimingTree< TP > TimingTree< TP >::getCopyWithRemainder() const
return tt;
}
/// convertes a TimingTree to json. The signature is required by the json library
/// \relates TimingTree
template < typename TP > // Timing policy
void to_json( nlohmann::json& j, const TimingTree< TP >& tt )
{
j = nlohmann::json( tt.getRawData() );
}
}
typedef timing::TimingTree<timing::WcPolicy> WcTimingTree;
......
Supports Markdown
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