This forum has been archived. All content is frozen. Please use KDE Discuss instead.

bounds checking only in expensive operations

Tags: None
(comma "," separated)
max.b
Registered Member
Posts
7
Karma
0
Is there an option in Eigen that would make it check the bounds in BLAS-1 and more expensive functions, while leaving element-level access unsafe and fast?

For large arrays, checking that their sizes agree before operating on them adds a negligible overhead, while for element-level access the overhead can be dramatic. During development/debugging, I like to check things as much as possible, but for "Release", only where it costs little.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Bounds checking are disabled in "Release" mode, that is when compiling with -DNDEBUG or -DEIGEN_NO_DEBUG.
max.b
Registered Member
Posts
7
Karma
0
Right. My question is if it's possible to partially enable it, i.e. make
Code: Select all
some_mat(i, j)
fast/unsafe, but catch problems with
Code: Select all
mat1 * mat2
having incompatible sizes.

I work with largish matrices, so the above would be a better "Release" mode than not checking anything anywhere (equally fast, but safer).
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
I see. We do have this subtle difference for internal debugging but not for operator(). In Eigen's own code we use some_mat.coeff(i,j) and some_mat.coeffRef(i,j) for which no bound checking are performed (they are performed once before starting the computation). However for internal debugging we can enable bound checking for them by compiling with -DEIGEN_INTERNAL_DEBUGGING=1.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Yahoo [Bot]