2
$\begingroup$

I have 2 complex, non-symmetric, matrices $A_{1000\times1000}$, $B_{1000\times1000}$ and I am using Matlab to get it's eigenvalues (functions like eig or eigs). Both matrices are different - one is denser and the other one has more complex values. To compare the complexity of the eigenvalue solving process for both matrices I would like to calculate the number of FLOPs needed for this procedure. Of course, it is possible to calculate the time need for the eigenvalue solver to complete its task, but this is highly unstable since a lot of background processes might be creating some noise.

In Matlab, there is no function that would allow me to get FLOPs for eigs but I might use another software, since I only need these matrices $A, B$ which can be exported. Does anyone have an Idea how I could reach my goal?

$\endgroup$
10
  • 3
    $\begingroup$ Is there any specific reason for you wanting the number of FLOPs? In general, eigenvalue problems are solved iteratively and then the number of operations is not fixed. $\endgroup$
    – nicoguaro
    Commented Jun 20, 2019 at 16:23
  • $\begingroup$ sure, I am comparing two similar methods which are solved via eigenvalue problem. Both methods, depending on their configuration produce different matrices. Sometime these matrices are even hermitian. I need to compare the cost of calculation for both methods - the right way to do it is by counting FLOPs. $\endgroup$
    – Kosha Misa
    Commented Jun 20, 2019 at 16:47
  • 3
    $\begingroup$ "the right way to do it is by counting FLOPs": I beg to differ, for various reasons, some of which are discussed here $\endgroup$
    – GoHokies
    Commented Jun 20, 2019 at 20:32
  • $\begingroup$ Thanks @GoHokies, I've read through this very interesting discussion. As Matt Knepley and other point out, FLOPs are important for the efficiency analysis, but admitted, not alone - memory-ops should also be taken into account. In my case counting flops makes sense, because I am performing a relative comparison of matrices on the same hardware. $\endgroup$
    – Kosha Misa
    Commented Jun 21, 2019 at 5:48
  • $\begingroup$ if you really want to count FLOPs four your two test cases (again, I believe this is not a good idea, even if you're doing a relative comparison on the same hardware, as memory bandwidth / arithmetic intensity does play a role), you'll have to get much closer to the hardware - perhaps with CPU event counters or a hardware emulator. $\endgroup$
    – GoHokies
    Commented Jun 21, 2019 at 6:08

1 Answer 1

3
$\begingroup$

The solution would be using PAPI (performance API) library http://icl.cs.utk.edu/papi/. There is a Windows and Linux Version. In order to use it on MATLAB or Octave code, you would have to add the mPAPI written by quepas on github : https://github.com/quepas/mPAPI. This however needs PAPI version >= 5.5.1 and since Windows version of PAPI was not continued after version 3.x, you will have to use Linux.

Now it works really fine and counts FLOPs. PAPI has got a lot of predefined events for this.

$\endgroup$
1
  • 1
    $\begingroup$ while I am not entirely sure if counting FLOPs is the right way (not arguing, not the point), it's quite an interesting find of mPAPI/PAPI. I was certainly not aware of it, and it can be very valuable. Definite upvote. $\endgroup$
    – Anton Menshov
    Commented Jul 4, 2019 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.