Tuesday, August 18, 2009

Eigen2 Debug mode

Eigen's main page claims "Disabling asserts, by defining -DNDEBUG or -DEIGEN_NO_DEBUG, improves performance in some cases."
What they mean is that we need to call g++ with the -DEIGEN_NO_DEBUG option.

In this post, we test the effect of disabling asserts on a few test scenes. The first scene is a 512x512 render of a refractive sphere with reflective cornell room walls. The second scene is the same room, but 9 refractive spheres. The third scene is obtained by rendering the second scene at 1024x1024 with shadow rays. All scenes have 2 light sources.

Average running times with default settings (eigen in debug mode), were 3.6 seconds for the first scene, 4.3 seconds for the 2nd scene and 47 seconds for the third scene.



This reduces code run times pretty drastically (2.4, 2.8 and 33 seconds approximately for the three scenes described above). There is a clear 30% and above performance improvement when debug mode is disabled. Anyway, debugging with eigen is a nightmare (way too much boilerplate to sift through), and I use my own Vector library while doing serious debugging.

5 comments:

  1. So sort of like

    #ifdef __mydebug__
    sriram_vec3 vector;
    #elseif
    EIGEN_NEW_MACRO
    Vector3f vector;
    #endif

    ???

    Sounds cool.

    ReplyDelete
  2. Yes, Something like that... but at the header file level, so the meaning of Vector3f changes.

    #ifdef USE_EIGEN
      #include<Eigen/Core>
      #include<Eigen/Array>
      #include<Eigen/Geometry>
    #else
      #include"VectorMath.h"
    #endif

    ReplyDelete
  3. Then what about the eigen's aligned allocator?

    ReplyDelete
  4. That is handled by some more nested #ifdef statements. There is a #USE_SSEVECTOR etc...

    ReplyDelete
  5. That is handled by some more nested #ifdef statements. There is a #USE_SSEVECTOR etc...

    ReplyDelete