Define NO_BOUNDS by default
schuhschuh opened this issue · 10 comments
The preprocessor macro NO_BOUNDS
is used to disable costly boundary checks which slow down the execution. These index boundary checks should possibly only be done in Debug configuration.
Yes we should probably have a Release
(default) and a Debug
build type, each of them defining or not their relevant macros, like NO_BOUNDS. Sounds appropriate to you ?
Are you aware of any other macros than NO_BOUNDS that should be affected by usage of different build types ?
The (unconditional) preprocessor macros that were defined in the previous IRTKInclude.cmake
are:
ADD_DEFINITIONS(-DIMPERIAL -DANSI -DHAS_CONTRIB -DNO_BOUNDS)
Occurrences of IMPERIAL or HAS_CONTRIB should be removed from the code if their are still some. IMPERIAL is to my knowledge only used in the rview
source files.
What is ANSI
needed for ?
I have no idea.
Ok I'll figure this one out. Thanks for the pointers.
The problem with this is that it won't work for IDE generators. Only for Makefile, Ninja, et al.
I suggest the use of the new generator expressions. Before, I would have set some configuration specific properties (e.g., COMPILE_DEFINITIONS_DEBUG
...). But CMake now recommends generator expressions.
I don't have much experience yet with these, but something along the lines of:
add_definitions("-DIRTK_BOUNDS_CHECK=$<CONFIG:Debug>")
which requires changing all occurrences of #ifndef NO_BOUNDS
to
#if IRTK_BOUNDS_CHECK
// boundary checks
#endif
which is also much easier to read then the double negation of #if !defined(NO_BOUNDS)
.
If you want sth without code changes, the following should work, too:
set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_RELEASE NO_BOUNDS)
it won't work for IDE generators
That's a separate issue though, feel free to open one.
If you want sth without code changes, the following should work
I won't be the one validating it, since I don't use an IDE personally. Can someone verify this for whatever IDE is supposed to support these things? I suspect XCode, Visual...And submit a PR with a tested and validated solution? Thanks.
You could still validate it by setting CMAKE_BUILD_TYPE
for your Makefile generator.
EDIT: I assume... but yes, of course it's best to test in an IDE such as Xcode.