다음을 통해 공유


/cgthreads (Code Generation Threads)

 

The latest version of this topic can be found at -cgthreads (Code Generation Threads).

Sets number of cl.exe threads to use for optimization and code generation.

Syntax

/cgthreads[1-8]  

Arguments

number
The maximum number of threads for cl.exe to use, in the range 1 to 8.

Remarks

The /cgthreads option specifies the maximum number of threads cl.exe uses in parallel for the optimization and code generation phases of compilation. Notice that there can be no space between /cgthreads and the number argument. By default, cl.exe uses four threads, as if /cgthreads4 were specified. If more processor cores are available, a larger number value can improve build times. This option is especially useful when it's combined with /GL (Whole Program Optimization).

Multiple levels of parallelism can be specified for a build. The msbuild.exe switch /maxcpucount specifies the number of MSBuild processes that can be run in parallel. The /MP (Build with Multiple Processes) compiler flag specifies the number of cl.exe processes that simultaneously compile the source files. The /cgthreads option specifies the number of threads used by each cl.exe process. Because the processor can only run as many threads at the same time as there are processor cores, it's not useful to specify larger values for all of these options at the same time, and it can be counterproductive. For more information about how to build projects in parallel, see Building Multiple Projects in Parallel.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Working with Project Properties.

  2. Select the Configuration Properties, C/C++ folder.

  3. Select the Command Line property page.

  4. Modify the Additional Options property to include /cgthreadsN, where N is a value from 1 to 8, and then select OK.

To set this compiler option programmatically

See Also

Compiler Options
Setting Compiler Options