Skip to content

Commit

Permalink
sw: Align with reduction-based exit routine
Browse files Browse the repository at this point in the history
  • Loading branch information
colluca committed Jan 16, 2024
1 parent 7b6ed0a commit 6503f98
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
3 changes: 1 addition & 2 deletions target/sim/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

def main():
args = parser('vsim', SIMULATORS.keys()).parse_args()
simulations = get_simulations(args.testlist, SIMULATORS[args.simulator])
simulations = get_simulations(args.testlist, SIMULATORS[args.simulator], run_dir=args.run_dir)
return run_simulations(simulations,
n_procs=args.n_procs,
run_dir=Path(args.run_dir),
dry_run=args.dry_run,
early_exit=args.early_exit)

Expand Down
14 changes: 12 additions & 2 deletions target/sim/sw/device/runtime/src/occamy_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,22 @@
#define SNRT_CRT0_PRE_BARRIER
#define SNRT_INVOKE_MAIN
#define SNRT_CRT0_POST_BARRIER
#define SNRT_CRT0_CALLBACK7
#define SNRT_CRT0_EXIT
#define SNRT_CRT0_ALTERNATE_EXIT

static inline void snrt_crt0_callback3() {
_snrt_cluster_hw_barrier = cluster_hw_barrier_addr(snrt_cluster_idx());
}

static inline void snrt_crt0_callback7() { return_to_cva6(SYNC_CLUSTERS); }
static inline uint32_t* snrt_exit_code_destination() {
return soc_ctrl_scratch_ptr(3);
}

static inline void snrt_exit_default(int exit_code);

static inline void snrt_exit(int exit_code) {
snrt_exit_default(exit_code);
if (snrt_global_core_idx() == 0) set_host_sw_interrupt();
}

#include "start.c"
7 changes: 2 additions & 5 deletions target/sim/sw/host/apps/offload/src/offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ int main() {
// Start Snitches
wakeup_snitches_cl();

// Wait for job done
wait_snitches_done();

// Exit routine
mcycle();
// Wait for job done and return Snitch exit code
return wait_snitches_done();
}
8 changes: 7 additions & 1 deletion target/sim/sw/host/runtime/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,15 @@ void wakeup_master_snitches() {
/**
* @brief Waits until snitches are done executing
*/
static inline void wait_snitches_done() {
static inline int wait_snitches_done() {
wait_sw_interrupt();
clear_host_sw_interrupt();
int retval = *soc_ctrl_scratch_ptr(3);
// LSB signals completion
if (retval & 1)
return retval >> 1;
else
return -1;
}

static inline volatile uint32_t* get_shared_lock() {
Expand Down

0 comments on commit 6503f98

Please sign in to comment.