-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_performance1.c
75 lines (69 loc) · 1.75 KB
/
test_performance1.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
74
75
#include <stdio.h>
int n = 1000;
int a[1000][1000];
int b[1000][1000];
int c[1000][1000];
int matrix_mul(int *arg,int p, int nn, int mm)
{
int i, j, k;
for (i = p; i < mm; i++)
{
for (j = 0; j < nn; j++)
{
c[i][j]=0;
for (k = 0; k < nn; k++)
{
c[i][j] += a[i][k] * b[k][j];
}
}
}
*arg=1;
}
int test1()
{
int selfPriority; /* priority of this task */
int taskId[4]; /* taskId of spawned task */
int i;
int countflag[4] = {0};
int before,after;
int ff,dd;
int j;
for(i = 0; i < n; i++)
for(j = 0; j < n; j++)
{
a[i][j] = b[i][j] = 1;
}
/* setup */
taskPriorityGet (0, &selfPriority);
before = tick_ulong_get();
/* create a new task */
for (i = 0; i < 4; i++)
{
ff = (n/4) * i;
dd = (n/4) * (i+1);
taskId[i] = taskSpawn ("task", selfPriority + 1 + i, 0, 0x8000,
(void *)matrix_mul,&countflag[i],ff,n,dd, 0L, 0L, 0L, 0L, 0L, 0L);
if (taskId[i] == -1)
{
printf("Failed to create the task%d",i);
return -1;
}
}
while( !(countflag[0] && countflag[1] && countflag[2] && countflag[3]) )
{
taskDelay(1);
}
after = tick_ulong_get();
printf("%d\t%d\t%d\t%d\n",countflag[0],countflag[1],countflag[2],countflag[3]);
printf("before = %d\n",before);
printf("after = %d\n",after);
printf("during time = %d\n",after - before);
for(i = 0; i < 20; i++)
{
for(j = 0; j < 20; j++)
{
printf("%d\t",c[i][j]);
}
printf("\n");
}
}