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 8aff773 commit 429a665
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rtlib/functions/dp_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,17 @@ void __dp_read(LID lid, ADDR addr, char *var) {

// TEST
// check for stack access
timers->start(TimerRegion::STACK_CHECK_READ_ACCESS);
bool is_stack_access = false;
if (stackAddrs->top().first && stackAddrs->top().second) {
if ((addr <= stackAddrs->top().first) &&
(addr >= stackAddrs->top().second)) {
timers->start(TimerRegion::STACK_FOUND_READ_ACCESS);
is_stack_access = true;
timers->stop_and_add(TimerRegion::STACK_FOUND_READ_ACCESS);
}
}
timers->stop_and_add(TimerRegion::STACK_CHECK_READ_ACCESS);
// !TEST

// addAccessInfo(true, lid, var, addr);
Expand Down
4 changes: 4 additions & 0 deletions rtlib/functions/dp_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,19 @@ void __dp_write(LID lid, ADDR addr, char *var) {

// TEST
// check for stack access
timers->start(TimerRegion::STACK_CHECK_WRITE_ACCESS);
bool is_stack_access = false;
if (stackAddrs->top().first && stackAddrs->top().second) {
if ((addr <= stackAddrs->top().first) &&
(addr >= stackAddrs->top().second)) {
// cout << "WRITE STACK ACCESS DETECTED! " <<
// dputil::decodeLID(lid) << " " << var << "\n";
timers->start(TimerRegion::STACK_FOUND_WRITE_ACCESS);
is_stack_access = true;
timers->stop_and_add(TimerRegion::STACK_FOUND_WRITE_ACCESS);
}
}
timers->stop_and_add(TimerRegion::STACK_CHECK_WRITE_ACCESS);
// !TEST

int64_t workerID =
Expand Down
14 changes: 14 additions & 0 deletions share/include/timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ enum class TimerRegion : unsigned int {
FINALIZE_PARALLELIZATION,
CLEAR_STACK_ACCESSES,

// These are statistics regarding stack access detection
STACK_CHECK_READ_ACCESS,
STACK_CHECK_WRITE_ACCESS,
STACK_FOUND_READ_ACCESS,
STACK_FOUND_WRITE_ACCESS,

SIZE_DONT_USE,
};

Expand Down Expand Up @@ -205,6 +211,14 @@ class Timers {
print(stream, " Add access information : ", TimerRegion::ADD_ACCESS_INFO);
print(stream, " Clear the stack accesses : ", TimerRegion::CLEAR_STACK_ACCESSES);
stream << '\n';

stream << "\n========== DiscoPoP TIMERS: stack access detection ==\n";
stream << " NOTE: times to detect stack access in read and write contained in \n";
stream << " reported times to read and write from / to memory. \n";
print(stream, " Check for read access to stack : ", TimerRegion::STACK_CHECK_READ_ACCESS);
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);
}

/**
Expand Down

0 comments on commit 429a665

Please sign in to comment.