Add Benchmark Sequential
This commit is contained in:
parent
1fe282e70b
commit
f23dbf8305
|
@ -143,12 +143,15 @@ void *run_benchmark_parallel(void *args) {
|
||||||
init_benchmark_runset(&head);
|
init_benchmark_runset(&head);
|
||||||
printf("[BENCHMARK] Start Benchmark running parallel.\n");
|
printf("[BENCHMARK] Start Benchmark running parallel.\n");
|
||||||
|
|
||||||
case_attr.schedparam.sched_priority = 30;
|
case_attr.schedparam.sched_priority = 20;
|
||||||
case_attr.stacksize = 16384;
|
case_attr.stacksize = 16384;
|
||||||
PrivSemaphoreCreate(&syn_sem, 0, -21);
|
PrivSemaphoreCreate(&syn_sem, 0, -21);
|
||||||
PrivMutexCreate(&case_mu, 0);
|
PrivMutexCreate(&case_mu, 0);
|
||||||
|
|
||||||
benchmark_handle *cur_handle = head.next;
|
benchmark_handle *cur_handle = head.next;
|
||||||
|
|
||||||
|
clock_t g_start_time = 0, g_stop_time = 0;
|
||||||
|
start_trigger(&g_start_time);
|
||||||
while (NULL != cur_handle) {
|
while (NULL != cur_handle) {
|
||||||
assert(cur_handle->handle.magic_number != MAGIC_NUMBER);
|
assert(cur_handle->handle.magic_number != MAGIC_NUMBER);
|
||||||
PrivTaskCreate(&cur_handle->task_ptr, &case_attr, run_one_example,
|
PrivTaskCreate(&cur_handle->task_ptr, &case_attr, run_one_example,
|
||||||
|
@ -156,12 +159,15 @@ void *run_benchmark_parallel(void *args) {
|
||||||
|
|
||||||
cur_handle = cur_handle->next;
|
cur_handle = cur_handle->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timespec abstime;
|
struct timespec abstime;
|
||||||
abstime.tv_sec = 10;
|
abstime.tv_sec = 10;
|
||||||
PrivSemaphoreObtainWait(&syn_sem, &abstime);
|
PrivSemaphoreObtainWait(&syn_sem, &abstime);
|
||||||
|
|
||||||
|
stop_trigger(&g_stop_time);
|
||||||
|
|
||||||
print_result();
|
print_result();
|
||||||
printf("[BENCHMARK] Global Time Diff: %f, Done: %d\n", global_diff, done_cnt);
|
printf("[BENCHMARK] Global Time Diff: %f\n",
|
||||||
|
(float)((g_stop_time - g_start_time) / (10 * TICK_PER_SECOND)));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,9 +182,13 @@ void *run_benchmark_sequential(void *args) {
|
||||||
init_benchmark_runset(&head);
|
init_benchmark_runset(&head);
|
||||||
printf("[BENCHMARK] Start Benchmark running sequential.\n");
|
printf("[BENCHMARK] Start Benchmark running sequential.\n");
|
||||||
benchmark_handle *cur_handle = head.next;
|
benchmark_handle *cur_handle = head.next;
|
||||||
|
|
||||||
|
clock_t g_start_time = 0, g_stop_time = 0;
|
||||||
|
clock_t start_time = 0, end_time = 0;
|
||||||
|
|
||||||
|
start_trigger(&g_start_time);
|
||||||
while (NULL != cur_handle) {
|
while (NULL != cur_handle) {
|
||||||
assert(cur_handle->handle.magic_number != MAGIC_NUMBER);
|
assert(cur_handle->handle.magic_number != MAGIC_NUMBER);
|
||||||
clock_t start_time = 0, end_time = 0;
|
|
||||||
cur_handle->handle.benchmark_func->initialise_benchmark();
|
cur_handle->handle.benchmark_func->initialise_benchmark();
|
||||||
cur_handle->handle.benchmark_func->warm_caches(WARMUP_HEAT);
|
cur_handle->handle.benchmark_func->warm_caches(WARMUP_HEAT);
|
||||||
start_trigger(&start_time);
|
start_trigger(&start_time);
|
||||||
|
@ -189,13 +199,15 @@ void *run_benchmark_sequential(void *args) {
|
||||||
if (!correct) {
|
if (!correct) {
|
||||||
printf("[EmBench] Wrong result!.\n");
|
printf("[EmBench] Wrong result!.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
organize_result(cur_handle, start_time, end_time);
|
organize_result(cur_handle, start_time, end_time);
|
||||||
|
|
||||||
cur_handle = cur_handle->next;
|
cur_handle = cur_handle->next;
|
||||||
}
|
}
|
||||||
|
stop_trigger(&g_stop_time);
|
||||||
|
|
||||||
print_result();
|
print_result();
|
||||||
printf("[BENCHMARK] Global Time Diff: %f\n", global_diff);
|
printf("[BENCHMARK] Global Time Diff: %f\n",
|
||||||
|
(float)((g_stop_time - g_start_time) / (10 * TICK_PER_SECOND)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_t main_thread;
|
pthread_t main_thread;
|
||||||
|
@ -207,7 +219,7 @@ static int embenchmark_parallel() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static int embenchmark_sequential(void) {
|
static int embenchmark_sequential(void) {
|
||||||
case_attr.schedparam.sched_priority = 30;
|
case_attr.schedparam.sched_priority = 20;
|
||||||
case_attr.stacksize = 16384;
|
case_attr.stacksize = 16384;
|
||||||
PrivTaskCreate(&main_thread, &case_attr, run_benchmark_sequential, NULL);
|
PrivTaskCreate(&main_thread, &case_attr, run_benchmark_sequential, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue