Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the right event for dep mod with context #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/runtime/Events/configs/DepModule_TrackContext_Events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ events:
target_loop_invoc: []
target_loop_iter: []
target_loop_exit: []
func_entry: [function_id] # optional if tracking context
func_exit: [function_id] # optional if tracking context
func_call_push: [inst_id] # optional if tracking context
func_call_pop: [] # optional if tracking context
finished: []

# func_entry: [function_id] # optional if tracking context
# func_exit: [function_id] # optional if tracking context
4 changes: 4 additions & 0 deletions src/runtime/Events/configs/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ events:
function_id: 32
func_exit:
function_id: 32
func_call_push:
inst_id: 32
func_call_pop:
# no arg
points_to_inst:
inst_id: 32
ptr: 64
Expand Down
6 changes: 4 additions & 2 deletions src/runtime/ProfilingModules/DependenceWithContextModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,15 @@ void DependenceWithContextModule::loop_exit() __attribute__((always_inline)) {
}

void DependenceWithContextModule::func_entry(uint32_t instr) {
if (nested_level == 1) {
if(callgraph_level == 0) {
context = instr;
}
callgraph_level++;
}

void DependenceWithContextModule::func_exit(uint32_t instr) {
if (nested_level == 1) {
callgraph_level--;
if(callgraph_level == 0) {
context = 0;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/runtime/ProfilingModules/DependenceWithContextModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class DependenceWithContextModule : public LocalWriteModule {

unsigned int context = 0;
int nested_level = 0;
int callgraph_level = 0;

#ifdef COLLECT_TRACE
// Collect trace
Expand Down
21 changes: 19 additions & 2 deletions src/runtime/SLAMPcustom/consumer/consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ enum class UnifiedAction : char {
FUNC_EXIT,
POINTS_TO_INST,
POINTS_TO_ARG,
FUNC_CALL_PUSH,
FUNC_CALL_POP,
FINISHED
};

Expand Down Expand Up @@ -1273,7 +1275,8 @@ void consume_loop(DoubleQueue &dq,
}

void consume_loop_dep_with_context(DoubleQueue &dq,
DependenceWithContextModule &depMod) CONSUME_LOOP_ATTRIBUTES {
DependenceWithContextModule &depMod)
CONSUME_LOOP_ATTRIBUTES {
uint64_t rdtsc_start = 0;
uint64_t counter = 0;
uint32_t loop_id;
Expand Down Expand Up @@ -1414,6 +1417,17 @@ void consume_loop_dep_with_context(DoubleQueue &dq,
depMod.func_exit(func_id);
break;
};
case Action::FUNC_CALL_PUSH: {
uint32_t caller_id;
dq.unpack_32(caller_id);
depMod.func_entry(caller_id);
break;
};
case Action::FUNC_CALL_POP: {
depMod.func_exit(0);
break;
};

#ifdef UNIFIED_WORKFLOW
case Action::FREE:
case Action::LOOP_ENTRY:
Expand Down Expand Up @@ -1718,7 +1732,10 @@ int main(int argc, char **argv) {
std::cout << "Running in " << THREAD_COUNT << " threads" << std::endl;
for (unsigned i = 0; i < THREAD_COUNT; i++) {
threads.emplace_back(
[&](unsigned id) { consume_loop_dep_with_context(*dqs[id], *depMods[id]); }, i);
[&](unsigned id) {
consume_loop_dep_with_context(*dqs[id], *depMods[id]);
},
i);
}

for (auto &t : threads) {
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/frontend/custom_produce.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ enum UnifiedAction : char {
FUNC_EXIT,
POINTS_TO_INST,
POINTS_TO_ARG,
FUNC_CALL_PUSH,
FUNC_CALL_POP,
FINISHED
};

Expand Down
13 changes: 11 additions & 2 deletions src/runtime/frontend/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ static uint32_t ext_fn_inst_id = 0;
#define PRODUCE_STORE(size, instr, addr)
#endif

#ifndef PRODUCE_FUNC_CALL_PUSH
#define PRODUCE_FUNC_CALL_PUSH(inst_id)
#endif

#ifndef PRODUCE_FUNC_CALL_POP
#define PRODUCE_FUNC_CALL_POP()
#endif

static volatile char *lc_dummy = NULL;

PRODUCE_QUEUE_DEFINE();
Expand Down Expand Up @@ -342,8 +350,9 @@ void memalign_callback(void *ptr, size_t alignment, size_t size) {

// FIXME: a bunch of unused functions
void SLAMP_main_entry(uint32_t argc, char **argv, char **env) {}
void SLAMP_push(const uint32_t instr) {}
void SLAMP_pop() {}
void SLAMP_push(const uint32_t instr) { if(on_profiling) PRODUCE_FUNC_CALL_PUSH(instr); }
void SLAMP_pop() { if(on_profiling) PRODUCE_FUNC_CALL_POP(); }

void SLAMP_allocated(uint64_t addr) {}

void SLAMP_callback_stack_alloca(uint32_t instr, void *ptr, uint64_t array_size,
Expand Down
Loading