Commit 12288d0e authored by Simon Tenbusch's avatar Simon Tenbusch

[sequencechart]

- implemented second ordering for the events (getNextEventRealTime / getPreviousEventRealTime) for better performance
parent 50468190
......@@ -306,6 +306,24 @@ Event *Event::getNextEvent()
return (Event *)nextEvent;
}
Event *Event::getPreviousEventRealTime()
{
if (eventLog->getFirstEventRealTime() == this) {
return NULL;
}
Assert(previousEventRealTime != NULL);
return (Event*)previousEventRealTime;
}
Event *Event::getNextEventRealTime()
{
if (eventLog->getLastEventRealTime() == this) {
return NULL;
}
Assert(nextEventRealTime != NULL);
return (Event*)nextEventRealTime;
}
Event *Event::getCauseEvent()
{
int causeEventNumber = getCauseEventNumber();
......
......@@ -100,6 +100,9 @@ class EVENTLOG_API Event : public IEvent
virtual Event *getPreviousEvent();
virtual Event *getNextEvent();
virtual Event *getPreviousEventRealTime();
virtual Event *getNextEventRealTime();
virtual Event *getCauseEvent();
virtual BeginSendEntry *getCauseBeginSendEntry();
virtual MessageDependency *getCause();
......
......@@ -286,6 +286,18 @@ Event *EventLog::getLastEvent()
return lastEvent;
}
Event *EventLog::getFirstEventRealTime()
{
Assert(firstEventRealTime != NULL);
return firstEventRealTime;
}
Event *EventLog::getLastEventRealTime()
{
Assert(lastEventRealTime != NULL);
return lastEventRealTime;
}
Event *EventLog::getEventForEventNumber(eventnumber_t eventNumber, MatchKind matchKind)
{
Assert(eventNumber >= 0);
......
......@@ -52,6 +52,9 @@ class EVENTLOG_API EventLog : public IEventLog, public EventLogIndex
Event *firstEvent;
Event *lastEvent;
Event *firstEventRealTime;
Event *lastEventRealTime;
bool legacyTrace; // is legacy trace that does not contain EventEndEntries
typedef std::vector<EventLogEntry *> EventLogEntryList;
......@@ -109,6 +112,17 @@ class EVENTLOG_API EventLog : public IEventLog, public EventLogIndex
virtual Event *getFirstEvent();
virtual Event *getLastEvent();
virtual Event *getFirstEventRealTime();
virtual Event *getLastEventRealTime();
virtual void setFirstEventRealTime(Event* e) {
firstEventRealTime = e;;
}
virtual void setLastEventRealTime(Event* e){
lastEventRealTime = e;
}
virtual Event *getNeighbourEvent(IEvent *event, eventnumber_t distance = 1);
virtual Event *getEventForEventNumber(eventnumber_t eventNumber, MatchKind matchKind = EXACT);
virtual Event *getEventForSimulationTime(simtime_t simulationTime, MatchKind matchKind = EXACT);
......
......@@ -95,6 +95,25 @@ class EVENTLOG_API FilteredEvent : public IEvent
virtual FilteredEvent *getPreviousEvent();
virtual FilteredEvent *getNextEvent();
virtual FilteredEvent *getPreviousEventRealTime() {
Assert(false);
return NULL; //Not Supported
}
virtual FilteredEvent *getNextEventRealTime() {
Assert(false);
return NULL;//Not Supported
}
virtual void setNextEventRealTime(IEvent* e) {
nextEventRealTime = e;
}
virtual void setPreviousEventRealTime(IEvent* e) {
previousEventRealTime = e;
}
virtual FilteredEvent *getCauseEvent();
virtual IMessageDependency *getCause();
virtual BeginSendEntry *getCauseBeginSendEntry();
......
......@@ -163,6 +163,23 @@ class EVENTLOG_API FilteredEventLog : public IEventLog
virtual bool isEmpty();
virtual FilteredEvent *getFirstEvent();
virtual FilteredEvent *getLastEvent();
virtual Event *getFirstEventRealTime() {
Assert(false);
return NULL;
}
virtual Event *getLastEventRealTime() {
Assert(false);
return NULL;
}
virtual void setFirstEventRealTime(Event* e) {
Assert(false);
}
virtual void setLastEventRealTime(Event* e){
Assert(false);
}
virtual FilteredEvent *getNeighbourEvent(IEvent *event, eventnumber_t distance = 1);
virtual FilteredEvent *getEventForEventNumber(eventnumber_t eventNumber, MatchKind matchKind = EXACT);
virtual FilteredEvent *getEventForSimulationTime(simtime_t simulationTime, MatchKind matchKind = EXACT);
......
......@@ -30,6 +30,9 @@ class EVENTLOG_API IEvent
IEvent *previousEvent;
IEvent *nextEvent;
IEvent *previousEventRealTime;
IEvent *nextEventRealTime;
IEvent* criticalPredecessor;
public:
......@@ -103,6 +106,23 @@ class EVENTLOG_API IEvent
*/
virtual IEvent *getNextEvent() = 0;
/**
* Returns the immediately preceding event in RealTime or NULL if there is no such event.
*/
virtual IEvent *getPreviousEventRealTime() = 0;
/**
* Returns the immediately following event in RealTime or NULL if there is no such event.
*/
virtual IEvent *getNextEventRealTime() = 0;
virtual void setNextEventRealTime(IEvent* e) {
nextEventRealTime = e;
}
virtual void setPreviousEventRealTime(IEvent* e) {
previousEventRealTime = e;
}
/**
* Returns the closest preceding event which caused this event by sending a message.
*/
......
......@@ -135,6 +135,17 @@ class EVENTLOG_API IEventLog
* Returns the last event or NULL if the log is empty.
*/
virtual IEvent *getLastEvent() = 0;
/**
* Returns the first event in RealTime or NULL if the log is empty.
*/
virtual IEvent *getFirstEventRealTime() = 0;
/**
* Returns the last event in RealTime or NULL if the log is empty.
*/
virtual IEvent *getLastEventRealTime() = 0;
virtual void setFirstEventRealTime(Event* e) = 0;
virtual void setLastEventRealTime(Event* e) = 0;
/**
* Returns the requested event or NULL if there is no such event included in the log.
* The given event number may not be included in the log.
......
......@@ -17,6 +17,7 @@
#include <stdio.h>
#include <algorithm>
#include <set>
#include <list>
#include <math.h>
#include "lcgrandom.h"
#include "ievent.h"
......@@ -950,6 +951,7 @@ bool SequenceChartFacade::isOnCriticalPath(IEvent* event) {
/*
* Calculates the critical path of the run and stores it in the set cachedCriticalPath
* Caches the earliestStartTimes of all events
*/
void SequenceChartFacade::calculateCriticalPath() {
long maxEarliestProcessingTime = 0;
......@@ -969,7 +971,7 @@ void SequenceChartFacade::calculateCriticalPath() {
break; //We have to consider earlier events only
}
if(antecessor->getModuleId() != moduleId && current->getCauseEvent() != antecessor) {
continue; // Check if this is an antecesor
continue; // Check if this is an antecessor
}
if(antecessor->_earliestProcessingTime+current->getComplexity() > current->_earliestProcessingTime) {
current->_earliestProcessingTime = antecessor->_earliestProcessingTime+current->getComplexity();
......@@ -982,6 +984,9 @@ void SequenceChartFacade::calculateCriticalPath() {
maxEarliestProcessingTimeEvent = current;
}
}
//Cache an additional event ordering sorted by their earliestStartingTimes
cacheRealTimeEventOrder();
//Now produce the convex hull of critical antecessors/predecessors:
cachedCriticalPath.clear();
//Cache largest processing time:
......@@ -1146,3 +1151,41 @@ bool SequenceChartFacade::isOverlappingInRealTimeDomain(ptr_t eventPtr1, ptr_t e
return !(eventProcessingTime1 < eventStartTime2 || eventProcessingTime2 < eventStartTime1);
}
bool compare_events_realtime (IEvent* a, IEvent* b)
{
return a->getEarliestStartTime() <= b->getEarliestStartTime();
}
void SequenceChartFacade::cacheRealTimeEventOrder() {
//First Event is the same in both domains
eventLog->setFirstEventRealTime((Event*)eventLog->getFirstEvent());
int i = 0;
std::list<IEvent*> eventMap;
for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
i++;
eventMap.push_back(current);
}
eventMap.sort(compare_events_realtime);
IEvent* current = NULL;
IEvent* prev = NULL;
for (std::list<IEvent*>::iterator it = eventMap.begin(); it != eventMap.end(); it++) {
current = *it;
if (prev != NULL) {
prev->setNextEventRealTime(current);
current->setPreviousEventRealTime(prev);
}
prev = current;
}
//Set last event in eventlog
eventLog->setLastEventRealTime((Event*)prev);
//Test:
for (IEvent *current = eventLog->getFirstEventRealTime(); current; current = current->getNextEventRealTime()) {
printf("event %i, simtime %f, time %i \n",current->getEventNumber(), current->getSimulationTime().dbl(), current->getEarliestStartTime());
}
}
......@@ -173,6 +173,8 @@ class EVENTLOG_API SequenceChartFacade : public EventLogFacade
void calculateCriticalPath();
void cacheRealTimeEventOrder();
double getOverlapping(ptr_t eventPtr);
double getMaximumOverlapping();
......
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