-
Notifications
You must be signed in to change notification settings - Fork 26
/
demo_nice.c
73 lines (53 loc) · 2.23 KB
/
demo_nice.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// See LICENSE for license details.
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include "hbird_sdk_soc.h"
#include "insn.h"
int main(void)
{
int i=100;
int arr[4]={1,2,3,4};
unsigned int array[ROW_LEN][COL_LEN]=
{{10,20,30},
{20,30,40},
{30,40,50}
};
unsigned int begin_instret, end_instret, instret_normal, instret_nice;
unsigned int begin_cycle, end_cycle, cycle_normal, cycle_nice;
printf("**********************************************\n");
printf("** begin to sum the array using ordinary add sum\n");
begin_instret = __get_rv_instret();
begin_cycle = __get_rv_cycle();
normal_case(array);
end_instret = __get_rv_instret();
end_cycle = __get_rv_cycle();
instret_normal = end_instret - begin_instret;
cycle_normal = end_cycle - begin_cycle;
printf("\n\n");
printf("**********************************************\n");
printf("** begin to sum the array using nice add sum\n");
begin_instret = __get_rv_instret();
begin_cycle = __get_rv_cycle();
nice_case(array);
end_instret = __get_rv_instret();
end_cycle = __get_rv_cycle();
instret_nice = end_instret - begin_instret;
cycle_nice = end_cycle - begin_cycle;
printf("**********************************************\n");
printf("** performance list \n");
printf("\t normal: \n");
printf("\t instret: %d, cycle: %d \n", instret_normal, cycle_normal);
printf("\t nice : \n");
printf("\t instret: %d, cycle: %d \n", instret_nice , cycle_nice );
printf("**********************************************\n\n");
printf("* * * * ***** * ******* *** \n");
printf("** * * * * * * * * \n");
printf("* * * * * * * * * \n");
printf("* * * * * * * ***** * \n");
printf("* * * * * * * * * \n");
printf("* ** * * * * * * * \n");
printf("* * ***** ***** ******* ******* *** \n");
printf("\n\n**********************************************");
return 0;
}