mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: additional 'other' category for profilingPstream
- eg, for user MPI operations that are to be tracked separately
This commit is contained in:
@ -70,7 +70,7 @@ void Foam::profilingPstream::enable()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::profilingPstream::disable()
|
void Foam::profilingPstream::disable() noexcept
|
||||||
{
|
{
|
||||||
timer_.reset(nullptr);
|
timer_.reset(nullptr);
|
||||||
suspend_ = false;
|
suspend_ = false;
|
||||||
|
|||||||
@ -65,11 +65,12 @@ public:
|
|||||||
BROADCAST,
|
BROADCAST,
|
||||||
REDUCE,
|
REDUCE,
|
||||||
WAIT,
|
WAIT,
|
||||||
ALL_TO_ALL
|
ALL_TO_ALL,
|
||||||
|
OTHER
|
||||||
};
|
};
|
||||||
|
|
||||||
//- The timing values
|
//- The timing values
|
||||||
typedef FixedList<double, 6> timingList;
|
typedef FixedList<double, 7> timingList;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -104,40 +105,40 @@ public:
|
|||||||
static void enable();
|
static void enable();
|
||||||
|
|
||||||
//- Remove timer for measuring communication activity
|
//- Remove timer for measuring communication activity
|
||||||
static void disable();
|
static void disable() noexcept;
|
||||||
|
|
||||||
//- Suspend use of timer (if active)
|
//- Suspend use of timer (if active)
|
||||||
inline static void suspend()
|
static void suspend() noexcept
|
||||||
{
|
{
|
||||||
suspend_ = bool(timer_);
|
suspend_ = bool(timer_);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Resume use of timer (if previously active)
|
//- Resume use of timer (if previously active)
|
||||||
static void resume()
|
static void resume() noexcept
|
||||||
{
|
{
|
||||||
suspend_ = false;
|
suspend_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Timer is active
|
//- Timer is active (not suspended and enabled)
|
||||||
inline static bool active()
|
static bool active() noexcept
|
||||||
{
|
{
|
||||||
return !suspend_ && bool(timer_);
|
return !suspend_ && bool(timer_);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Access to the timing information
|
//- Access to the timing information
|
||||||
inline static timingList& times()
|
static timingList& times() noexcept
|
||||||
{
|
{
|
||||||
return times_;
|
return times_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Access to the timing information at given index
|
//- Access to the timing information at given index
|
||||||
inline static double times(const enum timingType idx)
|
static double times(const timingType idx)
|
||||||
{
|
{
|
||||||
return times_[idx];
|
return times_[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Update timer prior to measurement
|
//- Update timer prior to measurement
|
||||||
inline static void beginTiming()
|
static void beginTiming()
|
||||||
{
|
{
|
||||||
if (active())
|
if (active())
|
||||||
{
|
{
|
||||||
@ -146,7 +147,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Add time increment
|
//- Add time increment
|
||||||
inline static void addTime(const enum timingType idx)
|
static void addTime(const timingType idx)
|
||||||
{
|
{
|
||||||
if (active())
|
if (active())
|
||||||
{
|
{
|
||||||
@ -154,40 +155,46 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Add time increment to gatherTime
|
//- Add time increment to \em gather time
|
||||||
inline static void addGatherTime()
|
static void addGatherTime()
|
||||||
{
|
{
|
||||||
addTime(GATHER);
|
addTime(timingType::GATHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Add time increment to scatterTime
|
//- Add time increment to \em scatter time
|
||||||
inline static void addScatterTime()
|
static void addScatterTime()
|
||||||
{
|
{
|
||||||
addTime(SCATTER);
|
addTime(timingType::SCATTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Add time increment to broadcastTime
|
//- Add time increment to \em broadcast time
|
||||||
inline static void addBroadcastTime()
|
static void addBroadcastTime()
|
||||||
{
|
{
|
||||||
addTime(BROADCAST);
|
addTime(timingType::BROADCAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Add time increment to reduceTime
|
//- Add time increment to \em reduce time
|
||||||
inline static void addReduceTime()
|
static void addReduceTime()
|
||||||
{
|
{
|
||||||
addTime(REDUCE);
|
addTime(timingType::REDUCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Add time increment to waitTime
|
//- Add time increment to \em wait time
|
||||||
inline static void addWaitTime()
|
static void addWaitTime()
|
||||||
{
|
{
|
||||||
addTime(WAIT);
|
addTime(timingType::WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Add time increment to allToAllTime
|
//- Add time increment to \em allToAll time
|
||||||
inline static void addAllToAllTime()
|
static void addAllToAllTime()
|
||||||
{
|
{
|
||||||
addTime(ALL_TO_ALL);
|
addTime(timingType::ALL_TO_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Add time increment to \em other time
|
||||||
|
static void addOtherTime()
|
||||||
|
{
|
||||||
|
addTime(timingType::OTHER);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,7 @@ void Foam::functionObjects::parProfiling::report()
|
|||||||
|
|
||||||
// (Time, Processor) for each of: min/max/sum
|
// (Time, Processor) for each of: min/max/sum
|
||||||
typedef FixedList<Tuple2<double, int>, 3> statData;
|
typedef FixedList<Tuple2<double, int>, 3> statData;
|
||||||
typedef FixedList<statData, 2> statDataTimes;
|
typedef FixedList<statData, 3> statDataTimes;
|
||||||
|
|
||||||
// Reduction: if x and y are unequal assign value.
|
// Reduction: if x and y are unequal assign value.
|
||||||
auto statsEqOp = [](statDataTimes& xStats, const statDataTimes& yStats)
|
auto statsEqOp = [](statDataTimes& xStats, const statDataTimes& yStats)
|
||||||
@ -111,8 +111,9 @@ void Foam::functionObjects::parProfiling::report()
|
|||||||
|
|
||||||
statDataTimes times;
|
statDataTimes times;
|
||||||
|
|
||||||
|
// Master time
|
||||||
{
|
{
|
||||||
const double masterTime =
|
const double total =
|
||||||
(
|
(
|
||||||
profilingPstream::times(profilingPstream::REDUCE)
|
profilingPstream::times(profilingPstream::REDUCE)
|
||||||
+ profilingPstream::times(profilingPstream::GATHER)
|
+ profilingPstream::times(profilingPstream::GATHER)
|
||||||
@ -121,17 +122,29 @@ void Foam::functionObjects::parProfiling::report()
|
|||||||
+ profilingPstream::times(profilingPstream::BROADCAST)
|
+ profilingPstream::times(profilingPstream::BROADCAST)
|
||||||
);
|
);
|
||||||
|
|
||||||
times[0] = Tuple2<double, int>(masterTime, Pstream::myProcNo());
|
times[0] = Tuple2<double, int>(total, Pstream::myProcNo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All time
|
||||||
{
|
{
|
||||||
const double allTime =
|
const double total =
|
||||||
(
|
(
|
||||||
profilingPstream::times(profilingPstream::WAIT)
|
profilingPstream::times(profilingPstream::WAIT)
|
||||||
+ profilingPstream::times(profilingPstream::ALL_TO_ALL)
|
+ profilingPstream::times(profilingPstream::ALL_TO_ALL)
|
||||||
|
+ profilingPstream::times(profilingPstream::OTHER)
|
||||||
);
|
);
|
||||||
|
|
||||||
times[1] = Tuple2<double, int>(allTime, Pstream::myProcNo());
|
times[1] = Tuple2<double, int>(total, Pstream::myProcNo());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other time
|
||||||
|
{
|
||||||
|
const double total =
|
||||||
|
(
|
||||||
|
profilingPstream::times(profilingPstream::OTHER)
|
||||||
|
);
|
||||||
|
|
||||||
|
times[2] = Tuple2<double, int>(total, Pstream::myProcNo());
|
||||||
}
|
}
|
||||||
|
|
||||||
profilingPstream::suspend();
|
profilingPstream::suspend();
|
||||||
@ -143,27 +156,43 @@ void Foam::functionObjects::parProfiling::report()
|
|||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
const statData& reduceStats = times[0];
|
|
||||||
const statData& allToAllStats = times[1];
|
|
||||||
|
|
||||||
double reduceAvg = reduceStats[2].first()/Pstream::nProcs();
|
|
||||||
double allToAllAvg = allToAllStats[2].first()/Pstream::nProcs();
|
|
||||||
|
|
||||||
Info<< type() << ':' << nl
|
Info<< type() << ':' << nl
|
||||||
<< incrIndent
|
<< incrIndent;
|
||||||
|
|
||||||
<< indent << "reduce : avg = " << reduceAvg << 's' << nl
|
{
|
||||||
<< indent << " min = " << reduceStats[0].first()
|
const statData& stats = times[0];
|
||||||
<< "s (processor " << reduceStats[0].second() << ')' << nl
|
double avg = stats[2].first()/Pstream::nProcs();
|
||||||
<< indent << " max = " << reduceStats[1].first()
|
|
||||||
<< "s (processor " << reduceStats[1].second() << ')' << nl
|
|
||||||
|
|
||||||
<< indent << "all-all : avg = " << allToAllAvg << 's' << nl
|
Info<< indent << "reduce : avg = " << avg << 's' << nl
|
||||||
<< indent << " min = " << allToAllStats[0].first()
|
<< indent << " min = " << stats[0].first()
|
||||||
<< "s (processor " << allToAllStats[0].second() << ')' << nl
|
<< "s (processor " << stats[0].second() << ')' << nl
|
||||||
<< indent << " max = " << allToAllStats[1].first()
|
<< indent << " max = " << stats[1].first()
|
||||||
<< "s (processor " << allToAllStats[1].second() << ')'
|
<< "s (processor " << stats[1].second() << ')' << nl;
|
||||||
<< decrIndent << endl;
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const statData& stats = times[1];
|
||||||
|
double avg = stats[2].first()/Pstream::nProcs();
|
||||||
|
|
||||||
|
Info<< indent << "all-all : avg = " << avg << 's' << nl
|
||||||
|
<< indent << " min = " << stats[0].first()
|
||||||
|
<< "s (processor " << stats[0].second() << ')' << nl
|
||||||
|
<< indent << " max = " << stats[1].first()
|
||||||
|
<< "s (processor " << stats[1].second() << ')' << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const statData& stats = times[2];
|
||||||
|
double avg = stats[2].first()/Pstream::nProcs();
|
||||||
|
|
||||||
|
Info<< indent << "other : avg = " << avg << 's' << nl
|
||||||
|
<< indent << " min = " << stats[0].first()
|
||||||
|
<< "s (processor " << stats[0].second() << ')' << nl
|
||||||
|
<< indent << " max = " << stats[1].first()
|
||||||
|
<< "s (processor " << stats[1].second() << ')' << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< decrIndent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -51,8 +51,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef functionObjects_parProfiling_H
|
#ifndef Foam_functionObjects_parProfiling_H
|
||||||
#define functionObjects_parProfiling_H
|
#define Foam_functionObjects_parProfiling_H
|
||||||
|
|
||||||
#include "functionObject.H"
|
#include "functionObject.H"
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of classes
|
// Forward Declarations
|
||||||
class Time;
|
class Time;
|
||||||
|
|
||||||
namespace functionObjects
|
namespace functionObjects
|
||||||
@ -92,7 +92,7 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from Time and dictionary
|
//- Construct from Time and dictionary. Enables profilingPstream
|
||||||
parProfiling
|
parProfiling
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -101,7 +101,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor. Disables profilingPstream
|
||||||
virtual ~parProfiling();
|
virtual ~parProfiling();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user