Skip to content

Commit

Permalink
feat: add stack detection to time measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasrothenberger committed May 15, 2024
1 parent 429a665 commit f17bc74
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rtlib/functions/dp_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,14 @@ void __dp_read(LID lid, ADDR addr, char *var) {
current.AAvar = getMemoryRegionIdFromAddr(var, addr);
current.addr = addr;
current.isStackAccess = is_stack_access;
timers->start(TimerRegion::STACK_CHECK_ADDR_IS_OWNED_BY_SCOPE);
current.addrIsOwnedByScope =
scopeManager->isOwnedByScope(addr, false);
timers->stop_and_add(TimerRegion::STACK_CHECK_ADDR_IS_OWNED_BY_SCOPE);
if(current.addrIsOwnedByScope){
timers->start(TimerRegion::STACK_CHECK_ADDR_IS_OWNED_BY_SCOPE_TRUE);
timers->stop_and_add(TimerRegion::STACK_CHECK_ADDR_IS_OWNED_BY_SCOPE_TRUE);
}
current.positiveScopeChangeOccuredSinceLastAccess =
scopeManager->positiveScopeChangeOccuredSinceLastAccess(addr);

Expand Down
6 changes: 6 additions & 0 deletions rtlib/functions/dp_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,14 @@ void __dp_write(LID lid, ADDR addr, char *var) {
current.AAvar = getMemoryRegionIdFromAddr(var, addr);
current.addr = addr;
current.isStackAccess = is_stack_access;
timers->start(TimerRegion::STACK_CHECK_ADDR_IS_OWNED_BY_SCOPE);
current.addrIsOwnedByScope =
scopeManager->isOwnedByScope(addr, true);
timers->stop_and_add(TimerRegion::STACK_CHECK_ADDR_IS_OWNED_BY_SCOPE);
if(current.addrIsOwnedByScope){
timers->start(TimerRegion::STACK_CHECK_ADDR_IS_OWNED_BY_SCOPE_TRUE);
timers->stop_and_add(TimerRegion::STACK_CHECK_ADDR_IS_OWNED_BY_SCOPE_TRUE);
}
current.positiveScopeChangeOccuredSinceLastAccess =
scopeManager->positiveScopeChangeOccuredSinceLastAccess(addr);

Expand Down
4 changes: 4 additions & 0 deletions share/include/timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ enum class TimerRegion : unsigned int {
STACK_CHECK_WRITE_ACCESS,
STACK_FOUND_READ_ACCESS,
STACK_FOUND_WRITE_ACCESS,
STACK_CHECK_ADDR_IS_OWNED_BY_SCOPE,
STACK_CHECK_ADDR_IS_OWNED_BY_SCOPE_TRUE,

SIZE_DONT_USE,
};
Expand Down Expand Up @@ -219,6 +221,8 @@ class Timers {
print(stream, " Check for write access to stack : ", TimerRegion::STACK_CHECK_WRITE_ACCESS);
print(stream, " Found read access to stack : ", TimerRegion::STACK_FOUND_READ_ACCESS);
print(stream, " Found write access to stack : ", TimerRegion::STACK_FOUND_WRITE_ACCESS);
print(stream, " Check for addr is owned by scope : ", TimerRegion::STACK_CHECK_ADDR_IS_OWNED_BY_SCOPE);
print(stream, " Found addr is owned by scope : ", TimerRegion::STACK_CHECK_ADDR_IS_OWNED_BY_SCOPE_TRUE);
}

/**
Expand Down

0 comments on commit f17bc74

Please sign in to comment.