Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

huge object file / compile time #159

Open
hiokazaki opened this issue Feb 7, 2025 · 1 comment
Open

huge object file / compile time #159

hiokazaki opened this issue Feb 7, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@hiokazaki
Copy link

hiokazaki commented Feb 7, 2025

I have a function with the following signature:

double F(double, double, double, std::array<double, 100>)

and contains about 3000 lines of code, each of which has a few (on average, close to 1) arithmetic operations (only + and *) which take some mix of one of the 103 arguments, one of about 80 temporary (stack) variables, and floating point constants.

In forward mode, the file compiles in a second or two and creates a 50kB object (including debug info etc.)

However, templating the function and attempting to compute its adjoint took clang ~25 minutes to compile (at -O2), and resulted in a 55MB object. Adding #undef XAD_USE_STRONG_INLINE reduced the compile time to ~23 minutes, and the resulting object to ~30MB.

In any case, it seems that both the compile time and object size have increased by about 1000x - is that expected?

I am able to manually break up this function into about 12 smaller functions each emitting a scalar, which are then assembled by another ~100 or so operations into the final scalar. Would that help?

To Reproduce
I think that any (non-degenerate) random with this signature and this number of intermediate operations will experience the same issue.

Perhaps a test to validate compile time, object size, and runtime performance scaling as a function of input function size/complexity is worth writing?

Expected behaviour
I was expecting compile and runtime to increase by 10x or so, not 1000x.

Environment (please complete the following information):

  • OS: Ubuntu 24.04 LTS
  • Compiler: Clang 20, -O2 -g
  • CMake Configuration (if not default): Not using CMake (just including/linking to xad separately); xad was built with the default CMake configuration.
@hiokazaki hiokazaki added the bug Something isn't working label Feb 7, 2025
Copy link

boring-cyborg bot commented Feb 7, 2025

Thanks for opening your first issue here. We'll look into it and get back in due time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant