Comments (20)
Thanks for the feedback. I am currently busy with work on a different package. I expect to get back to CppAD in the middle of May and will work on this then.
from cppad.
I have begun work on this bug in the directory
https://github.com/coin-or/CppAD/tree/master/test_more/debug_rel
The idea is that the debug.cpp file (release.cpp file) will be compiler for debugging (release) that the debug_rel.cpp program use both. I will then create tests cases that fail and then fix them one at a time; i.e., a test driven development approach.
from cppad.
The with NDEBUG and without NDEBUG versions of CppAD are not compatible. They assume all the rest of CppAD is compiled the same way. For example, the CppAD memory allocator does some tracking between function calls when NDEBUG is defined and it needs to be done for all allocations for it to work. What I do is to have two separate build and install directories.
build.debug
build.release
prefix/package.debug
prefix/package.release
Then I use a soft link from
build -> build.debug
prefix/package -> prefix/packabge.debug
to get the debug version.
Would this work for you ?
from cppad.
I create a Debian package for the library and then install it in the system.
It is not common to have multiple versions of the same library for different compilation flags installed in Debian/Ubuntu.
Nonetheless, I will try to create different versions of the library in the Debian package and then load the correct one for the executable using CMake.
Thank you!
from cppad.
Perhaps I should can put a separate flag on the things that make the Debug and Release version incompatible. I have put it on the CppAD wish list; see
f7f04b6
Thanks.
from cppad.
Thank you!
Note: I just realized that I will have to create different library versions for extra 4/5 libraries that also depend on that library :(
from cppad.
I've looked in CppAD sources and it appears that the only reason why ADFun changes size/structure is due to the following lines in class player:
# ifndef NDEBUG
/// Flag indicating that a special function must be called before next
bool special_before_next_;
# endif
I've removed the # ifndef NDEBUG
and #endif
and left the member variable be always defined (even if it is not used) and I am able to generate my models but it then fails during destruction.
from cppad.
I am busy right now with other things, but I can help a little, if you want to try and do this.
I suggest adding the flage CPPAD_EXTRA_DEBUG to the file
cppad/configure.hpp.in
Do not worry about setting it using cmake (I can do that later).
Next I would do a
git grep special_before_next_
and change all the NDEBUG guards to use CPPAD_EXTRA_DEBUG as a guard.
I think you will also have to make this change for the NDEBUG that appear in
cppad/utility/thread_alloc.hpp
from cppad.
I've compared both versions of my library with and without NDEBUG using https://lvc.github.io/abi-compliance-checker/ and found that there are many issues...
I cannot identify the root cause for many of the reported differences.
For instance, it says:
namespace CppAD
[−] old_atomic<cg::CG<double> >::forward ( size_t p, size_t q, vector<bool>const& vx, vector<bool>& vy, vector<cg::CG<double> >const& tx, vector<cg::CG<double> >& ty ) 1
Change Effect
1 The parameter ty became passed at the different offset on the stack (0 instead of -48). Violation of the calling convention. This may result in crash or incorrect behavior of applications.
I think I might be safer to go the way of making different packages for the library.
from cppad.
Thanks for trying. It has helped me to see the problems you have run into. I need to come up with a way to determine which NDEBUG statements are causing the difficulty.
from cppad.
I just came across the same problem and would be interested in a solution as well.
I'm working on a library that internally uses CppAD and that I share with other people. If someone just wants to use the library and not modify it, that person will most likely build it with 'Release' type setting in CMake. Unfortunately, CMake then automatically sets the -DNDEBUG compiler flag for library compilation.
If the users executable linking to the library is then compiled as a Debug project, errors are thrown when destructors of the library are called and the user has no idea what this is :)
from cppad.
I have found an interesting article on this for gcc; see
Link- and run-time coexistence of release- and debug-mode components
on
https://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode_design.html#methods.coexistence.link
from cppad.
I am working on the debug_rel branch; see
https://github.com/coin-or/CppAD/commits/debug_rel
from cppad.
I have added random selection of debug versus release to many of the cppad tests and they all seem to work (in the debug_rel branch). Please try this version and see if you have any problems mixing debug and release. Add the following flag, when you compile your tests:
-DCPPAD_DEBUG_AND_RELEASE
I will continue trying to find a case that fails. If you and I do not find any problems, I plan to merge debug_rel into the master branch.
from cppad.
If I use the clang compiler, and set random_choice_0123 to 0, make check_example_general is failing. I am tracking this down.
There was a problem with the test
example/general/compare_change.cpp
when mixing debug and release. This was fixed in
4876d14
from cppad.
When I type in the following commands
git clone https://github.com/coin-or/CppAD.git
cd CppAD
git checkout debug_rel
mkdir build && cd build
cmake ..
then in the end Cmake reports that several tests are available
-- make check_example_optimize: available
-- make check_example_print_for: available
-- make check_example_sparse: available
-- make check_example_utility: available
-- make check_example: available
-- make check_introduction: available
-- make check_det_by_minor_c: available
-- make check_det_by_minor_cpp: available
-- make check_test_more_compare_c: available
-- make check_test_more_debug_rel: available
-- make check_test_more_general: available
-- make check_test_more: available
-- make check_speed_cppad: available
-- make check_speed_double: available
-- make check_speed_example: available
-- make check_speed: available
-- make check: avialable
However, when I try and run a test with make check
, then the output is
Scanning dependencies of target speed_example
[ 0%] Building CXX object speed/example/CMakeFiles/speed_example.dir/example.cpp.o
clang: error: no such file or directory: 'NOTFOUND'
make[3]: *** [speed/example/CMakeFiles/speed_example.dir/example.cpp.o] Error 1
make[2]: *** [speed/example/CMakeFiles/speed_example.dir/all] Error 2
make[1]: *** [CMakeFiles/check.dir/rule] Error 2
make: *** [check] Error 2
How do you run the tests and where exactly do you have to specify the -DCPPAD_DEBUG_AND_RELEASE
flag? If I do cmake -DCPPAD_DEBUG_AND_RELEASE ..
in my build directory, the output is
Parse error in command line argument: -DCPPAD_DEBUG_AND_RELEASE
Should be: VAR:type=value
CMake Error: No cmake script provided.
CMake Error: Problem processing arguments. Aborting.
from cppad.
I merged the debug_rel branch into the master yesterday, so you can now use the master branch for this purpose. Coin should have built the documentation (from the master branch) this morning, but the Coin web site is down, so i will point you to the source code for the documentation.
See
https://github.com/coin-or/CppAD/blob/master/omh/preprocessor.omh
See
https://github.com/coin-or/CppAD/blob/master/omh/install/cmake.omh
I also suggest using verbose make files to see the compilation mode being use;
see
https://github.com/coin-or/CppAD/blob/master/omh/install/cmake.omh
from cppad.
My testing (with the current master branch) has not indicated any problems mixing debug and release when
-DCPPAD_DEDBUG_AND_RELEASE
is specified on the compile command line. If you have a case that is not working, please re-open this bug.
from cppad.
from cppad.
If you would like to run the CppAD tests of this feature; see debug_odd and debug_even under the heading debug_which on
https://www.coin-or.org/CppAD/Doc/cmake.htm#cppad_debug_which
from cppad.
Related Issues (20)
- Computing the Jacobian of an ODE HOT 2
- CPPAD_DISCRETE_FUNCTION does not work through base2ad HOT 2
- Eigen::NumTraits does not define infinity() or quiet_NaN() HOT 3
- How to add self defined functions to AD<Base>? HOT 8
- Using C++ conditional operators HOT 5
- AD<double> not working in Eigen with some complex function HOT 4
- Computing Derivatives of solutions of optimization Problems HOT 9
- Working with CppAD::ipopt::solve and CppADCodeGen HOT 4
- Leppov case missing in local/optimize/get_op_usage.hpp HOT 3
- Discrete coefficient sets for polynomial vary as a function of dependent variable HOT 16
- How to write the `.lp` file of a Ipopt model? HOT 6
- Linking error "undefined reference to `CppAD::local::temp_file()'" HOT 4
- solution vector is empty HOT 10
- Undefined reference to temp_file HOT 2
- ipopt and cppad tests HOT 11
- Problem to Link with CppAD and Ipopt HOT 16
- CppAD::cg::CGException: what(): GreaterThanZero cannot be called for non-parameters HOT 5
- Compiler warnings from use of bitwise '|' and '&' for bool arguments HOT 5
- Potential build mistake in third party tool in use of NDEBUG flag - CppAD compiled in Release HOT 13
- Static library for non-windows builds HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cppad.