I'm working on a project that requires the calculation of a Jacobian and Hessian matrix of a complex function. To generate the correct mathematical expression, I use symbolic differentiation and Python's SymPy module to generate the corresponding C++ code. It results in a single C++ Header-File with three functions (the function itself, jacobian, and hessian). The hessian, for example, has 11x11 expressions of the following form:
hessian(0,0) = <long-long-mathematical-function-with-abs-and-tanh-etc>;
Furthermore, these functions/expressions are template-functions as I need to pass different types (Scalars, Intervals) to them.
When I compile the program, it requires up to 70 GB RAM with g++ (GCC) 10.2.1 20201016 (Red Hat 10.2.1-6). Initially, I got a warning g++ note: variable tracking size limit exceeded
I added the -fno-var-tracking
flag, but it did not reduce the required memory in any significant way.
Could the problem be originated in the size of the right-hand-side of the individual expressions?
Is there any way (maybe compiler flags or sorts of) that might reduce the memory usage during compilation?
I use Eigen3 with custom scalar types to perform mathematical operations.