Opened 8 years ago

Last modified 3 years ago

#3963 new enhancement

Split C source code in more files for more efficient parallel compilation

Reported by: Francesco Casella Owned by: Lennart Ochel
Priority: high Milestone:
Component: Code Generation Version:
Keywords: Cc:

Description

The MSL and ScalableTestSuite coverage logs

https://test.openmodelica.org/libraries/ModelicaTest_trunk/BuildModelRecursive.html

https://test.openmodelica.org/libraries/ScalableTestSuite_Experimental/BuildModelRecursive.html

reveal that the C compile time is always a significant fraction of the overall build time, and in many cases the bottleneck of the entire process.

Recently, the large header file that prevented the splitting of the C source files into much smaller chunks was removed by Martin S., but the number of C files is still the same. We should avoid very large files and split them into a larger number of smaller ones, e.g. by putting an upper bound to the number of functions contained in each .c file.

I guess the effort/gain ratio of this improvement would be extremely high, even if a comparatively crude splitting strategy was undertaken. Any volunteers?

Thanks!

Change History (15)

comment:1 by crupp@…, 8 years ago

This is actually a big problem in some cases. As an example, I have a moderately sized model with only 432 states, but 9k variables, 12k alias variables, and 12k parameters. The 06inz.c and 08bnd.c files are ~100k in size. On linux, they compile fine, but use a couple GB of RAM each. On Windows 64-bit, gcc fails with a seg fault when the memory used exceeds ~4GB. This may be a different issue (gcc seg faulting), but could be remedied by reducing the number of functions in each of these files.

I upvote this improvement.

comment:2 by Adrian Pop, 8 years ago

You can use the 64bit version of OpenModelica from the nightly-builds to access more memory:
https://build.openmodelica.org/omc/builds/windows/nightly-builds/
In the 1.9.6 release we only have 32bit version of gcc and executables which can only access 4G.

comment:3 by crupp@…, 8 years ago

Sorry, I didn't mean to hijack this ticket. My point was more that the compilers shouldn't need to use 4GB of memory to compile a file, regardless of whether the compiler can handle it or not.

FYI, I am using the nightly 64-bit version. It was clearly a compiler issue since an "internal compiler error: segmentation fault" was returned. I even tried changing the stack size of the cc1.exe program. It may also be coincidence that it happened at 4GB.

comment:4 by Adrian Pop, 8 years ago

@crupp: no worries, if this issue happened with 64bit GCC then we learned something valuable. Can you confirm that this is the case?

Of course we should try to split the C files. We would need to use some heuristics as compilation time will go down but link time will go up, so is an optimization problem.

comment:5 by crupp@…, 8 years ago

Sub-topic moved to #3968.

comment:6 by Martin Sjölund, 8 years ago

Some work has been done on this, splitting 06_inz into multiple parts based on the flag --equationsPerFile. But there are more files that need to be split in order to actually help the scalability of the compilation time. The default flag is set to 2000 equations per file.

Last edited 8 years ago by Francesco Casella (previous) (diff)

comment:7 by Martin Sjölund, 8 years ago

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:8 by Martin Sjölund, 8 years ago

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:9 by Francesco Casella, 7 years ago

Milestone: 1.12.01.13.0

Milestone moved to 1.13.0 due to 1.12.0 already being released.

comment:10 by Francesco Casella, 7 years ago

See also #4851

comment:11 by Francesco Casella, 6 years ago

Milestone: 1.13.01.14.0

Rescheduled to 1.14.0 after 1.13.0 releasee

comment:12 by Francesco Casella, 5 years ago

Milestone: 1.14.01.16.0

Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0

comment:13 by Francesco Casella, 4 years ago

Milestone: 1.16.01.17.0

Retargeted to 1.17.0 after 1.16.0 release

comment:14 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:15 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.