Fix comments.
[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      16         3 kB
19      64        48 kB
20     256       768 kB
21   1,024    12,288 kB
22   4,096   196,608 kB
23  16,384 3,145,728 kB */
24
25 #define Dim 1024
26
27 int A[Dim][Dim];
28 int B[Dim][Dim];
29 int C[Dim][Dim];
30
31 int
32 main (void)
33 {
34   int i, j, k;
35
36   /* Initialize the matrices. */
37   for (i = 0; i < Dim; i++)
38     for (j = 0; j < Dim; j++)
39       {
40         A[i][j] = i;
41         B[i][j] = j;
42         C[i][j] = 0;
43       }
44
45   /* Multiply matrices. */
46   for (i = 0; i < Dim; i++)     
47     for (j = 0; j < Dim; j++)
48       for (k = 0; k < Dim; k++)
49         C[i][j] += A[i][k] * B[k][j];
50
51   /* Done. */
52   exit (C[Dim - 1][Dim - 1]);
53 }