Commit e278a67b authored by Dorel Coman's avatar Dorel Coman Committed by Oliver Horst
Browse files

memguard: improved benchmark print, in order to be able to extract data easier from the results.

parent f0c72121
......@@ -28,7 +28,7 @@ uint64_t read_cycle_counter(void)
#define printf xil_printf
#define QEMU 1
#define QEMU 0
#define MASTER_CORE_ID 0U
......@@ -76,7 +76,7 @@ volatile uint64_t bus_accesses;
volatile uint64_t instructions;
/* It keeps track of how many reset window routines are ocurring during the execution of a benchmark */
volatile uint32_t window_count;
volatile uint64_t windows_count;
/* stores the core id */
uint32_t core_id;
......@@ -147,15 +147,16 @@ void init_benchmark()
#endif
}
void start_benchmarks()
{
void start_benchmarks() {
uint64_t data[17][6] = {0};
/* setting the random function, used for getting random indexes in array */
srand(pmu_read_cyclecount());
printf("\n\rstart benchmark\n\r");
/* Iterating over all benchmarks and measuring each of them for 10s */
for(int i=0; i < NUMBER_OF_BENCHMARKS; i++){
for (int i = 0; i < NUMBER_OF_BENCHMARKS; i++) {
for (int j = 0; j < ARRAY_SIZE; ++j) {
a[j] = CONST;
......@@ -163,7 +164,7 @@ void start_benchmarks()
c[j] = CONST;
}
for (int j=0; j < TIME_FRAMES_IN_ARRAY; j++)
for (int j = 0; j < TIME_FRAMES_IN_ARRAY; j++)
trace_arr[j] = 0;
/* variable used for stoping the loop when the timer has counted 10 seconds */
......@@ -175,58 +176,77 @@ void start_benchmarks()
bus_accesses = 0;
instructions = 0;
memguard_cycle_usage = 0;
window_count = 0;
windows_count = 0;
#if(QEMU == 0)
{
pmu_write_counter(BENCH_3_CNTR_ID_CLOCK_CYCLES, 0);
}
{
pmu_write_counter(BENCH_3_CNTR_ID_CLOCK_CYCLES, 0);
}
#endif
if(core_id == MASTER_CORE_ID){
printf("ID: %u bench: %d\n\r", core_id, i);
if (core_id == MASTER_CORE_ID) {
XTtcPs_ResetCounterValue(&benchmark_timer);
XTtcPs_Start(&benchmark_timer);
while(not_stop_timer){
(* bench_arr[i])();
while (not_stop_timer) {
(*bench_arr[i])();
}
} else {
while (not_stop_timer){
while (not_stop_timer) {
//(* bench_arr[15])();
}
}
if(core_id == MASTER_CORE_ID){
int val=0;
for(int j=0; j < 1000000; j++)
val = j;
}
// if (core_id == MASTER_CORE_ID) {
// int val = 0;
// for (int j = 0; j < 1000000; j++)
// val = j;
// }
data[i][0] = instructions;
data[i][1] = window_cycle_count;
data[i][2] = bus_accesses;
data[i][3] = memguard_cycle_usage;
data[i][4] = windows_count;
}
double ipc = (double)instructions / (double)window_cycle_count;
for (int i = 0; i < NUMBER_OF_BENCHMARKS; i++) {
instructions = data[i][0];
window_cycle_count = data[i][1];
bus_accesses = data[i][2];
memguard_cycle_usage = data[i][3];
windows_count = data[i][4];
double ipc = (double) instructions / (double) window_cycle_count;
uint32_t ipc_whole = (uint32_t) ipc;
uint32_t ipc_decimal = (uint32_t) ((ipc - ipc_whole) * 1000);
uint64_t bandwidth = bus_accesses / 10 * SIZE_MEM_READ / MB_IN_BYTE;
printf("\n\rID: %u bench: %d bus accesses: %llu IPC: %u.%u B/W %u MB/s\n\r",
core_id, (i+1), bus_accesses, ipc_whole, ipc_decimal, bandwidth);
core_id, (i + 1), bus_accesses, ipc_whole, ipc_decimal, bandwidth);
double overhead = (double)memguard_cycle_usage / (double)window_cycle_count;
double overhead = (double) memguard_cycle_usage / (double) window_cycle_count;
uint32_t overhead_whole = (uint32_t) overhead;
uint32_t overhead_decimal = (uint32_t) ((overhead - overhead_whole) * 1000);
printf("Tot us: %llu - memg us: %llu Overhead: %u.%u windows: %u \n\r",
window_cycle_count, memguard_cycle_usage, overhead_whole, overhead_decimal, window_count);
printf("Tot us: %llu - memg us: %llu Overhead: %u.%u windows: %llu \n\r",
window_cycle_count, memguard_cycle_usage, overhead_whole, overhead_decimal, windows_count);
}
// if(core_id == MASTER_CORE_ID){
//
// for (int j=7500; j < 8000; j++)
// printf("%u ", trace_arr[j]);
// printf("\n\r");
// }
printf("IPC:\n\r");
for (int i = 0; i < NUMBER_OF_BENCHMARKS; i++) {
instructions = data[i][0];
window_cycle_count = data[i][1];
double ipc = (double) instructions / (double) window_cycle_count;
uint32_t ipc_whole = (uint32_t) ipc;
uint32_t ipc_decimal = (uint32_t) ((ipc - ipc_whole) * 1000);
printf("%u.%u\n\r", ipc_whole, ipc_decimal);
}
}
/****************************
* Tracing functions
****************************/
......@@ -234,10 +254,10 @@ void start_benchmarks()
void memguard_trace_tick(uint32_t bandwidth_used)
{
uint32_t window = window_count;
uint64_t window = windows_count;
trace_arr[window_count] = bandwidth_used;
window_count++;
trace_arr[windows_count] = bandwidth_used;
windows_count++;
}
void start_benchmark_trace()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment