Thread: Matrix Multiplication

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    27
    thanks for your response.
    I was able to reduce the operation time to about 10% of the original time by manualy unrolling the loops in steps of three for the middle loop and steps of 16 for the inner loop. I also set gcc to optimization level 3, but I haven't tried just using fun loops yet( I don't know gcc that well).

    I know of another algothrim (strasson or something like that), that is suppose to be really fast, but I don't know how to implement it.

    There are also a few different way to format the loop that will make have less cache misses, but you have to do another store instuction in the inner loop, depending on the machine this can make it faster or slower. I did some simple test and found that it seems to make it faster for the pentium III.

    Code:
    for(i = 0; i<512; i++){
    
         for(k = 0; k<512; k++){
    
              r = a[i][k];
    
              for(j = 0; j<512; j++)
    
                   c[i][j] += r * b[k][j];
    
         }
    }
    Last edited by samps005; 12-04-2002 at 09:39 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C - access violation
    By uber in forum C Programming
    Replies: 2
    Last Post: 07-08-2009, 01:30 PM
  2. *operator overloading: scalar matrix multiplication
    By gemini_shooter in forum C++ Programming
    Replies: 4
    Last Post: 06-08-2009, 01:14 PM
  3. Matrix Multiplication ( Accessing data from a file ) HELP
    By six_degreez in forum C Programming
    Replies: 2
    Last Post: 07-24-2008, 05:21 PM
  4. Matrix Help
    By HelpmeMark in forum C++ Programming
    Replies: 27
    Last Post: 03-06-2008, 05:57 PM