Reputation: 80
What is the core working behind the speed-up compilation process on the SMP machine?
Upvotes: 0
Views: 132
Reputation: 37212
Typically things like compilers and linkers are really bad at using multiple CPUs themselves.
However; often a large project will be broken up into many files that are compiled separately and then linked. For example; with 16 CPUs you could compile 16 separate files in parallel without much trouble (and then link all the object files after) and get the project built a lot faster (even though each instance of the compiler only uses one CPU itself).
For an added bonus; sometimes compilers will stall (e.g. have to wait for disk IO to read a source file or header or something). Using more processes (compiling more files in parallel) means that when one process/compiler stalls other processes may be able to continue, so there's less chance of a CPU being idle (doing nothing and not helping the project build faster).
In practice; this often ends up being controlled by whatever controls the building. For example, if you use make
to figure out which pieces need to be compiled, then you might use make -j=16
to tell the utility to try to run 16 jobs in parallel.
Upvotes: 1