Handmade Hero»Forums»Code
11 posts
Friendly old programmer from the days of the BBC and Amiga
Multithreaded builds?
After speeding up my builds with some tricks learned here I wondered if we couldn't speed things up some more by using a multi-threaded build.
One way to do this is to use START to run a command on a new thread from a batch file.
So you can just stick START before calling CL.EXE.
But this has some problems associate with it.
Firstly if you have a meta pre-processor "project", you need that to build & run first. That OK as you can just build that without the START.
Then you can build both your EXE and your DLLs multi-threaded with START.
The Other problem which is more troublesome is getting the output back from the threaded CL calls.. you can pipe the output to files but that's not ideal.

What do people think? Is it worth it? any ideas?


Mārtiņš Možeiko
2562 posts / 2 projects
Multithreaded builds?
Edited by Mārtiņš Možeiko on
If you have multiple translation units then use /MP argument to cl.exe:
1
cl.exe /MP ...(other args)... file1.cpp file2.cpp fileN.cpp

This will make cl.exe to compile each file in separate process. This is available since VS2005.

If you have only one translation unit use /cgthreads argument. It will use 4 threads for code generation and optimizations. You can use number 1 to 8 to specify exactly how many threads to use. This is available since VS2013.

You can use both switches together.
11 posts
Friendly old programmer from the days of the BBC and Amiga
Multithreaded builds?
Oh that's a much better solution,
thanks mmozeiko