On Sep 6, 10:51 am, "Nike Dattani" <dattani.n...@gmail.com> wrote:
> Hi!
>
> I have a function in which the dominant operation (i think) in two different lines is MatrixVector multiplication.
>
> In the first of these two lines, the result of the matrixvector multiplication is multiplied by a scalar (should take negligable time)
>
> In the second of these two lines, a vector is subtracted from the result, then I'm doing the absolute value of the answer and then finding the max element in the result.
>
> Both of these lines are called 7800000 times, and the sizes of the matrices and vectors are the exact same, yet the first line takes 138055 seconds and the second takes 24899 seconds.
>
> I used matlab's profiler and it gave me this output (line 57 is the first line mentioned above, and line 61 is the second):
>
> http://bayimg.com/gaOlAAAcM
>
> Is this not a surprising result ? I would like to read what others think about why there is such a big difference.
>
> My only guess is that perhaps the matrix A is stored in the cache while the matrix Cinv is not stored in the cache, simply because A is constant throughout this program, and Cinv changes 5200 times. But this theory is weak because dividing 7800000 by 5200, we get that each new value of Cinv is reused 1500 times, so if the JIT compiler was smart it would store Cinv in the cache as well. Also, since both A and Cinv are about 6MB in size, I doubt they would even fit in the L3 cache.
>
> Looking forward to figuring this out,
> Nike
Of course, alpha and beta have been preallocated, right?
