schedule the highest priority thread,overP1
[monosproject.git] / src / examples / matmult.c
blob4f0615fa06fa642a531309dd0644fe60cccf9d44
1 /* matmult.c
3 Test program to do matrix multiplication on large arrays.
5 Intended to stress virtual memory system.
7 Ideally, we could read the matrices off of the file system,
8 and store the result back to the file system!
9 */
11 #include <stdio.h>
12 #include <syscall.h>
14 /* You should define DIM to be large enough that the arrays
15 don't fit in physical memory.
17 Dim Memory
18 ------ --------
19 16 3 kB
20 64 48 kB
21 128 192 kB
22 256 768 kB
23 512 3,072 kB
24 1,024 12,288 kB
25 2,048 49,152 kB
26 4,096 196,608 kB
27 8,192 786,432 kB
28 16,384 3,145,728 kB */
29 #define DIM 128
31 int A[DIM][DIM];
32 int B[DIM][DIM];
33 int C[DIM][DIM];
35 int
36 main (void)
38 int i, j, k;
40 /* Initialize the matrices. */
41 for (i = 0; i < DIM; i++)
42 for (j = 0; j < DIM; j++)
44 A[i][j] = i;
45 B[i][j] = j;
46 C[i][j] = 0;
49 /* Multiply matrices. */
50 for (i = 0; i < DIM; i++)
51 for (j = 0; j < DIM; j++)
52 for (k = 0; k < DIM; k++)
53 C[i][j] += A[i][k] * B[k][j];
55 /* Done. */
56 exit (C[DIM - 1][DIM - 1]);