質問

I am trying to optimise the compilation time of a large VC++ project. My processor is a Core i7 950 (4 Cores, 8 Threads since it supports Intel Hyper-Threading Technology).

In Microsoft Visual Studio 2010, if you go to Tools>Options>Projects and Solutions>VC++ Project Settings>Maximum Concurrent C++ complilations

you can select the maximum of CPU cores to use for parallel C++ compilation. I select 0 there (so that all my cores are used), which produces exactly the same results as when using 4 or 8.

Now, if I open the Task Manager whilst compiling the project, I can see that 4 parallel compilation threads are running (Under processes they have the description: Microsoft C/C++ Compiler Driver), and that the total CPU usage is a bit less than 50% all the time.

So my question is:

Is it possible to have 8 parallel compilation threads in a quad core, hyper-threaded processor? If this is not possible, then is it possible somehow to use near 100% the processor power whilst compiling?

This is will save me a huge amount of time.

Thank you very much in advance,

Nicholas

役に立ちましたか?

解決

This is will save me a huge amount of time.

No, it wouldn't. Hyperthreading is useful when you have different sorts of tasks to run which use complementary resources inside the CPU. For example, one thread uses a lot of floating-point and the other doesn't. While the first is doing floating-point math, the rest of the CPU is available to the other thread.

For obvious reasons, a bunch of compile threads want the same internal CPU resources. All you'd achieve is having twice as many threads fighting over the CPU cache and resources. More cache contention would make life slower, not faster.


Well, the above explains why you won't get BIG gains from Hyperthreading and homogenous code. The conventional wisdom for parallel make is to set the number of jobs one greater than the number of cores, the assumption being that 1/N processes is probably doing disk I/O. Of course, that's for Unix make where a job does a lot of makefile processing in addition to actual compilation.

If you turned the knob up to 8 and didn't see any change (note, it could be a negative change in throughput for reasons explained above) in Task Manager reported CPU usage, it's probably because interdependencies in your solution are forcing certain compile tasks to run sequentially. If one task relies on the output of another (precompiled headers often cause this) then that limits the number of simultaneous jobs -- even if you had a 16 core system, you'd still not get more parallelism than what the project structure permits.

他のヒント

Could be that you're just disk limited instead of CPU limited.

I think this is a problem with visual studio. Try to run your makefiles with "jom" the parallel nmake clone. You should see a 35% increase when using it over msvc called to compile with 4 cores.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top