Revise makefile structure.
[pintos-anon] / src / tests / userprog / matmult.c
1 /* matmult.c 
2
3    Test program to do matrix multiplication on large arrays.
4  
5    Intended to stress virtual memory system.
6    
7    Ideally, we could read the matrices off of the file system,
8    and store the result back to the file system!
9  */
10
11 #include <syscall.h>
12
13 /* You should define this to be large enough that the arrays
14    don't fit in physical memory.
15
16    Dim    Memory
17    ---  --------
18     20     93 kB
19     30    316 kB
20     40    750 kB
21     50  1,464 kB
22     60  2,531 kB
23     70  4,019 kB
24     80  6,000 kB
25     90  8,542 kB
26    100 11,718 kB */
27 #define Dim 20
28
29 int A[Dim][Dim];
30 int B[Dim][Dim];
31 int C[Dim][Dim];
32
33 int
34 main (void)
35 {
36   int i, j, k;
37
38   /* Initialize the matrices. */
39   for (i = 0; i < Dim; i++)
40     for (j = 0; j < Dim; j++)
41       {
42         A[i][j] = i;
43         B[i][j] = j;
44         C[i][j] = 0;
45       }
46
47   /* Multiply matrices. */
48   for (i = 0; i < Dim; i++)     
49     for (j = 0; j < Dim; j++)
50       for (k = 0; k < Dim; k++)
51         C[i][j] += A[i][k] * B[k][j];
52
53   /* Done. */
54   exit (C[Dim - 1][Dim - 1]);
55 }