Main Page   Compound List   File List   Compound Members   File Members  

matmult.c

Go to the documentation of this file.
00001 /* matmult.c 
00002  *    Test program to do matrix multiplication on large arrays.
00003  *
00004  *    Intended to stress virtual memory system.
00005  *
00006  *    Ideally, we could read the matrices off of the file system,
00007  *      and store the result back to the file system!
00008  */
00009 
00010 #include "syscall.h"
00011 
00012 #define Dim     20      /* sum total of the arrays doesn't fit in 
00013                          * physical memory 
00014                          */
00015 
00016 int A[Dim][Dim];
00017 int B[Dim][Dim];
00018 int C[Dim][Dim];
00019 
00020 int
00021 main()
00022 {
00023     int i, j, k;
00024 
00025     for (i = 0; i < Dim; i++)           /* first initialize the matrices */
00026         for (j = 0; j < Dim; j++) {
00027              A[i][j] = i;
00028              B[i][j] = j;
00029              C[i][j] = 0;
00030         }
00031 
00032     for (i = 0; i < Dim; i++)           /* then multiply them together */
00033         for (j = 0; j < Dim; j++)
00034             for (k = 0; k < Dim; k++)
00035                  C[i][j] += A[i][k] * B[k][j];
00036 
00037     Exit(C[Dim-1][Dim-1]);              /* and then we're done */
00038 }

Generated on Mon Feb 10 09:54:46 2003 for nachos by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002
The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees