Skip to content

Commit

Permalink
Changes following review
Browse files Browse the repository at this point in the history
Signed-off-by: Shamser Ahmed <[email protected]>
  • Loading branch information
shamser committed Jan 13, 2025
1 parent 9462169 commit d75b6e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 0 additions & 4 deletions common/thorhelper/thorcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1801,8 +1801,6 @@ void ActivityTimeAccumulator::addStatistics(IStatisticGatherer & builder) const
if (blockedCycles)
builder.addStatistic(StTimeBlocked, cycle_to_nanosec(blockedCycles));
}
if (lookAheadCycles)
builder.addStatistic(StTimeLookAhead, (unsigned __int64)cycle_to_nanosec(lookAheadCycles));
}

void ActivityTimeAccumulator::addStatistics(CRuntimeStatisticCollection & merged) const
Expand All @@ -1816,8 +1814,6 @@ void ActivityTimeAccumulator::addStatistics(CRuntimeStatisticCollection & merged
if (blockedCycles)
merged.mergeStatistic(StTimeBlocked, cycle_to_nanosec(blockedCycles));
}
if (lookAheadCycles)
merged.mergeStatistic(StTimeLookAhead, (unsigned __int64)cycle_to_nanosec(lookAheadCycles));
}

void ActivityTimeAccumulator::merge(const ActivityTimeAccumulator & other)
Expand Down
20 changes: 16 additions & 4 deletions thorlcr/graph/thgraphslave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ MemoryBuffer &CSlaveActivity::getInitializationData(unsigned slave, MemoryBuffer
return mb.append(queryInitializationData(slave));
}

unsigned __int64 CSlaveActivity::queryLocalCycles() const
unsigned __int64 CSlaveActivity::queryLocalCycles(unsigned __int64 totalCycles, unsigned __int64 blockedCycles, unsigned __int64 lookAheadCycles) const
{
unsigned __int64 inputCycles = 0;
if (1 == inputs.ordinality())
Expand Down Expand Up @@ -587,11 +587,10 @@ unsigned __int64 CSlaveActivity::queryLocalCycles() const
break;
}
}
unsigned __int64 processCycles = queryTotalCycles() + queryLookAheadCycles();
unsigned __int64 processCycles = totalCycles + lookAheadCycles;
if (processCycles < inputCycles) // not sure how/if possible, but guard against
return 0;
processCycles -= inputCycles;
const unsigned __int64 blockedCycles = queryBlockedCycles();
if (processCycles < blockedCycles)
{
ActPrintLog("CSlaveActivity::queryLocalCycles - process %" I64F "uns < blocked %" I64F "uns", cycle_to_nanosec(processCycles), cycle_to_nanosec(blockedCycles));
Expand All @@ -600,6 +599,11 @@ unsigned __int64 CSlaveActivity::queryLocalCycles() const
return processCycles-blockedCycles;
}

unsigned __int64 CSlaveActivity::queryLocalCycles() const
{
return queryLocalCycles(queryTotalCycles(), queryBlockedCycles(), queryLookAheadCycles());
}

void CSlaveActivity::serializeStats(MemoryBuffer &mb)
{
CriticalBlock b(crit); // JCSMORE not sure what this is protecting..
Expand All @@ -619,7 +623,15 @@ void CSlaveActivity::serializeStats(MemoryBuffer &mb)
queryCodeContext()->gatherStats(serializedStats);

// JCS->GH - should these be serialized as cycles, and a different mapping used on master?
serializedStats.setStatistic(StTimeLocalExecute, (unsigned __int64)cycle_to_nanosec(queryLocalCycles()));
//
// Note: Look ahead cycles are not being kept up to date in slaverStats as multiple objects and threads are updating
// look ahead cycles. At the moment, each thread and objects that generate look ahead cycles, track its own look ahead
// cycles and the up to date lookahead cycles is only available with a call to queryLookAheadCycles(). The code would
// need to be refactored to change this behaviour.
unsigned __int64 lookAheadCycles = queryLookAheadCycles();
unsigned __int64 localCycles = queryLocalCycles(queryTotalCycles(), queryBlockedCycles(), lookAheadCycles);
serializedStats.setStatistic(StTimeLookAhead, (unsigned __int64)cycle_to_nanosec(lookAheadCycles));
serializedStats.setStatistic(StTimeLocalExecute, (unsigned __int64)cycle_to_nanosec(localCycles));
slaveTimerStats.addStatistics(serializedStats);
serializedStats.serialize(mb);
ForEachItemIn(i, outputs)
Expand Down
1 change: 1 addition & 0 deletions thorlcr/graph/thgraphslave.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ class graphslave_decl CSlaveActivity : public CActivityBase, public CEdgeProgres
bool canStall() const;
bool isFastThrough() const;
bool suppressLookAhead() const;
unsigned __int64 queryLocalCycles(unsigned __int64 totalCycles, unsigned __int64 blockedCycles, unsigned __int64 lookAheadCycles) const;

// IThorDataLink
virtual CSlaveActivity *queryFromActivity() override { return this; }
Expand Down

0 comments on commit d75b6e6

Please sign in to comment.