|
Message
From: =?unknown-8bit?Q?Gy=F6rgy?= 'nog' Jeney<nog@s...>
Date: Mon Jan 31 10:42:01 CET 2005
Subject: [openrisc] [or1ksim #11] Optimise execution history
Hi,This patch optimises the execution history tracking. With this patch and execution history enabled, my linux is booting ~40 seconds faster (~10%).
ChangeLog: * Optimise execution history tracking
nog. -------------- next part -------------- --- cpu/or32/execute.c 2005-01-31 09:51:41.000000000 +0100 +++ ../or1ksim-ac/cpu/or32/execute.c 2005-01-31 09:21:00.000000000 +0100 @@ -104,6 +104,9 @@ * only used to get dump_exe_log correct */ static oraddr_t insn_ea; +/* History of execution */ +struct hist_exec *hist_exec_tail = NULL; + /* Implementation specific. Get an actual value of a specific register. */ @@ -377,12 +381,9 @@ memcpy (&icomplet[0], current, sizeof (struct iqueue_entry)); if (config.sim.history) { - int i; - /* History of execution */ - for (i = HISTEXEC_LEN - 1; i; i--) - histexec[i] = histexec[i - 1]; - histexec[0] = icomplet[0].insn_addr; /* add last insn */ + hist_exec_tail = hist_exec_tail->next; + hist_exec_tail->addr = icomplet[0].insn_addr; } if (config.sim.exe_log) dump_exe_log(); @@ -603,6 +604,9 @@ void cpu_reset() { int i; + struct hist_exec *hist_exec_head = NULL; + struct hist_exec *hist_exec_new; + runtime.sim.cycles = 0; runtime.sim.loadcycles = 0; runtime.sim.storecycles = 0; @@ -619,6 +623,25 @@ sbuf_count = 0; sbuf_prev_cycles = 0; + /* Initialise execution history circular buffer */ + for (i = 0; i < HISTEXEC_LEN; i++) { + hist_exec_new = malloc(sizeof(struct hist_exec)); + if(!hist_exec_new) { + fprintf(stderr, "Out-of-memory\n"); + exit(1); + } + if(!hist_exec_head) + hist_exec_head = hist_exec_new; + else + hist_exec_tail->next = hist_exec_new; + + hist_exec_new->prev = hist_exec_tail; + hist_exec_tail = hist_exec_new; + } + /* Make hist_exec_tail->next point to hist_exec_head */ + hist_exec_tail->next = hist_exec_head; + hist_exec_head->prev = hist_exec_tail; + /* Cpu configuration */ mtspr(SPR_UPR, config.cpu.upr); setsprbits(SPR_VR, SPR_VR_VER, config.cpu.ver); --- cpu/common/abstract.h 2005-01-31 09:51:36.000000000 +0100 +++ ../or1ksim-ac/cpu/common/abstract.h 2005-01-31 09:24:39.000000000 +0100 @@ -166,5 +166,10 @@ /* History of execution */ #define HISTEXEC_LEN 200 -extern int histexec[HISTEXEC_LEN]; +struct hist_exec { + oraddr_t addr; + struct hist_exec *prev; + struct hist_exec *next; +}; +extern struct hist_exec *hist_exec_tail; --- toplevel.c 2005-01-31 09:51:42.000000000 +0100 +++ ../or1ksim-ac/toplevel.c 2005-01-31 09:56:55.000000000 +0100 @@ -84,9 +84,6 @@ /* CVS revision number. */ const char rcsrev[] = "$Revision: 1.100 $"; -/* History of execution */ -int histexec[HISTEXEC_LEN]; - char *sim_commands [] = { "q", "t", "help", "de", "dm", "run", "pr", "pm", "pc", "reset", "break", "breaks", "hist", "stats", "stall" "info", @@ -706,8 +704,9 @@ #endif if (strcmp(item1, "hist") == 0) { /* dump history */ int i;
- for(i = HISTEXEC_LEN; i; i--)
- dumpmemory(histexec[i - 1], histexec[i - 1] + 4, 1, 1);
+ struct hist_exec *cur;
+ for(i = HISTEXEC_LEN, cur = hist_exec_tail->prev; i; i--, cur = cur->prev)
+ dumpmemory(cur->addr, cur->addr + 4, 1, 1);
PRINTF("\n");
} else
if (strcmp(item1, "run") == 0) { /* run */
|
 |