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

memguard: in lab tests and benchmarking

parent e278a67b
......@@ -42,8 +42,9 @@ uint64_t read_cycle_counter(void)
#define ICI_INT_PRIORITY 232
#define BENCHMARK_ICI_INT_ID 2
#define SECONDS_OF_BENCHMARKING 2
#define TIMER_HZ 4
#define TIMES_TO_COUNT (10 * TIMER_HZ)
#define TIMES_TO_COUNT (SECONDS_OF_BENCHMARKING * TIMER_HZ)
#define NUMBER_OF_BENCHMARKS 17
......@@ -58,6 +59,7 @@ ARRAY_TYPE c[ARRAY_SIZE];
/* Array used for tracing the usage of bandwidth in each window*/
#define TIME_FRAMES_IN_ARRAY 80000
uint32_t trace_arr[TIME_FRAMES_IN_ARRAY];
uint64_t trace_band;
/* Used for stopping the while loop when the timer has counted 10 seconds */
static volatile uint32_t not_stop_timer;
......@@ -177,6 +179,7 @@ void start_benchmarks() {
instructions = 0;
memguard_cycle_usage = 0;
windows_count = 0;
trace_band = 0;
#if(QEMU == 0)
{
......@@ -195,57 +198,60 @@ void start_benchmarks() {
}
} else {
while (not_stop_timer) {
//(* bench_arr[15])();
(* bench_arr[16])();
}
}
// 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;
data[i][5] = trace_band;
}
if(core_id == MASTER_CORE_ID){
int val = 0;
for (int j = 0; j < 50000000; j++)
val = j;
}
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];
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];
trace_band = data[i][5];
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);
// trace_band /= windows_count;
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);
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);
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);
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: %llu \n\r",
window_cycle_count, memguard_cycle_usage, overhead_whole, overhead_decimal, windows_count);
}
uint64_t bandwidth = bus_accesses / SECONDS_OF_BENCHMARKING * SIZE_MEM_READ / MB_IN_BYTE;
printf("IPC:\n\r");
for (int i = 0; i < NUMBER_OF_BENCHMARKS; i++) {
instructions = data[i][0];
window_cycle_count = data[i][1];
printf("\n\rc: %u b: %d bus acc: %llu IPC: %u.%03u B/W %u MB/s cycl: %llu - mem cycl: %llu Overhead: %u.%03u windows: %llu trace %llu inst: %llu\n\r",
core_id, (i + 1), bus_accesses, ipc_whole, ipc_decimal, bandwidth, window_cycle_count,
memguard_cycle_usage, overhead_whole, overhead_decimal, windows_count, trace_band, instructions);
}
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("\n\rIPC:\n\r");
for (int i = 0; i < NUMBER_OF_BENCHMARKS; i++) {
instructions = data[i][0];
window_cycle_count = data[i][1];
printf("%u.%u\n\r", ipc_whole, ipc_decimal);
}
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.%03u\n\r", ipc_whole, ipc_decimal);
}
}
/****************************
* Tracing functions
......@@ -256,7 +262,7 @@ void memguard_trace_tick(uint32_t bandwidth_used)
uint64_t window = windows_count;
trace_arr[windows_count] = bandwidth_used;
trace_band += bandwidth_used;
windows_count++;
}
......@@ -410,8 +416,10 @@ void handler_timer_interrupt(void *callback_ref)
*/
void _1_3_bench()
{
for (int i = 0; i < ARRAY_SIZE / 100 && not_stop_timer; ++i) {
b[i] = CONST;
int val=0;
for (int i = 0; i < ARRAY_SIZE / 200 && not_stop_timer; ++i) {
val = i * CONST;
b[i] = val;
}
}
......
......@@ -116,7 +116,7 @@
/* Minimum assigned quota to be given when the static assigned quota of a task finished
called Qmin in memguard - generally should be small - in this case 25MB/s */
#define MIN_ASSIGNED_QUOTA (MEM_ACCESS_PER_MB_PER_MS * 25)
#define MIN_ASSIGNED_QUOTA (25 * ACCESSES_PER_MB * WINDOW_TIME)
/* quota assigned to memguard just for being able to execute the task, this doesn't influence
the bandwidth cause it is deleted before memguard starts monitoring */
......@@ -338,6 +338,9 @@ void memguard_set_new_task(TaskHandle_t task_handle, uint32_t quota_in_MB_s, Bas
atomic_fetch_add(&(memguard_info.tot_bw_claimed_in_setup), new_task_info->static_ass_quota);
atomic_uint val_read = atomic_load(&(memguard_info.tot_bw_claimed_in_setup));
uint64_t test = MIN_GUARANTEED_BANDWIDTH;
uint64_t test2 = MIN_GUARANTEED_BANDWIDTH + BANDWIDTH_ASS_MEMGUARD_TASK*NUMBER_CORES;
/* We check that the sum of the allocated quota for each task is not higher than the minimum
guaranteed bandwidth */
configASSERT(val_read <= MIN_GUARANTEED_BANDWIDTH + BANDWIDTH_ASS_MEMGUARD_TASK*NUMBER_CORES);
......@@ -408,6 +411,7 @@ void memguard_reset_task_info(TaskHandle_t task_handle)
if(task_info->finished_quota == 1){
task_info->curr_used_quota += task_info->curr_budget;
// TODO: check
/* The substraction represents how much quota the task wasn't able to use in the last time window */
if(task_info->static_ass_quota > task_info->curr_used_quota)
new_quota = task_info->static_ass_quota + (task_info->static_ass_quota - task_info->curr_used_quota);
......@@ -442,11 +446,11 @@ void memguard_reset_task_info(TaskHandle_t task_handle)
new_quota = task_info->static_ass_quota;
}
#if (MEMGUARD_TEST)
{
memguard_trace_tick(task_info->curr_used_quota);
}
#endif
// #if (MEMGUARD_TEST)
// {
// memguard_trace_tick(task_info->curr_used_quota);
// }
// #endif
task_info->curr_budget = mask_value(new_quota);
task_info->dynamic_ass_quota = new_quota;
......@@ -481,7 +485,7 @@ void memguard_switch_in()
{
pmu_start_counter(task_info->curr_budget);
#if(MEMGUARD_TRACE)
#if(MEMGUARD_TRACE == 1)
start_benchmark_trace();
#endif
}
......@@ -516,7 +520,7 @@ void memguard_switch_out()
{
task_info->curr_budget = pmu_read_counter(MEMGUARD_CNTR_ID);
#if(MEMGUARD_TRACE)
#if(MEMGUARD_TRACE == 1)
stop_benchmark_trace();
#endif
}
......@@ -880,10 +884,10 @@ void overflow_interrupt_handler(void *callback_ref)
#endif
/* Checking if PMU has really really overflowed */
if(pmu_counter_has_overflowed() != COUNTER_OVERFLOWED){
if(pmu_counter_has_overflowed() < COUNTER_OVERFLOWED){
#if (MEMGUARD_TEST == 1)
stop_memguard_trace();
stop_memguard_trace();
#endif
return;
}
......@@ -932,20 +936,20 @@ void overflow_interrupt_handler(void *callback_ref)
/* We didn't use all the static_ass_quota but there is no global_budget because it was taken by other tasks.
We allow the task to continue, hoping that it may use more bandwidth until the window is reset */
if (mem_task->curr_used_quota < mem_task->static_ass_quota){
mem_task->dynamic_ass_quota = 0;
mem_task->finished_quota = 1;
#if (MEMGUARD_TEST == 1)
stop_memguard_trace();
#endif
/* The task will be free to try to use some bandwidth until the end of the window;
we are collecting info of how much bandwidth it is using to know how much to allocate
the next window */
return;
}
// if (mem_task->curr_used_quota < mem_task->static_ass_quota){
//
// mem_task->dynamic_ass_quota = 0;
// mem_task->finished_quota = 1;
//
// #if (MEMGUARD_TEST == 1)
// stop_memguard_trace();
// #endif
//
// /* The task will be free to try to use some bandwidth until the end of the window;
// we are collecting info of how much bandwidth it is using to know how much to allocate
// the next window */
// return;
// }
/* incrementing quota used by all tasks in current window with the quota used by the current task */
atomic_fetch_add(&(memguard_info.quota_used_in_window), mem_task->curr_used_quota);
......@@ -998,6 +1002,12 @@ void suspend_task_routine(void *pvParameter1, uint32_t ulParameter2)
TaskHandle_t task_handle = pvParameter1;
memguard_task_info *task_info = (memguard_task_info *) pvTaskGetMemguardTaskInfo(task_handle);
#if (MEMGUARD_TEST)
{
memguard_trace_tick(pmu_read_counter(MEMGUARD_CNTR_ID));
}
#endif
/* taking notice that memguard suspended the task in order to not let other tasks
to resume it before the new window starts */
task_info->tsk_susp_by_memguard = pdTRUE;
......
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