MSVC10/MP不能跨项目中的文件夹构建多核 [英] MSVC10 /MP builds not multicore across folders in a project

查看:114
本文介绍了MSVC10/MP不能跨项目中的文件夹构建多核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人指出我们遇到的问题或解决方法.

I'm hoping someone points out something wrong or a workaround for what we are experiencing.

使用/MP编译项目时,似乎只同时编译同一文件夹中的文件.我使用了进程浏览器来擦拭命令行并确认行为.

When compiling a project with /MP it appears that only files in the same folder are compiled concurrently. I used process explorer to swipe the command line and confirm the behavior.

项目过滤器似乎对并发编译的内容没有任何影响.

Project filters seem to have all no impact on the what gets compiled concurrently.

磁盘上的项目结构:

Folder\
  project.vcxproj  
  source\  
    foo.cpp  
    foo1.cpp  
  other_folder\  
    bar.cpp
    bar1.cpp
    bar3.cpp

初始过程树:

MSBuild.exe
  cl.exe  ( passed: source\foo.cpp source\foo1.cpp )
    cl.exe  ( passed: source\foo.cpp )
    cl.exe  ( passed: source\foo1.cpp )

cl.exe的2个子实例完成后,父代关闭,并显示以下进程树:

After the 2 child instances of cl.exe complete the parent closes and the following process tree appears:

MSBuild.exe
  cl.exe  ( passed: other_folder\bar.cpp other_folder\bar1.cpp other_folder\bar2.cpp )
    cl.exe  ( passed: other_folder\bar.cpp )
    cl.exe  ( passed: other_folder\bar1.cpp )
    cl.exe  ( passed: other_folder\bar2.cpp )

我们的资源很好地组织在许多层次的嵌套文件夹中,这些文件夹与磁盘上标头的布局相匹配-我讨厌不得不放弃它来利用/MP.

Our source is nicely organized in many levels of nested folders that match the layout of the headers on disk - I would hate to have to give that up to take advantage of /MP.

推荐答案

项目在对象文件名"(在vcxproj XML中,在CL.exe命令行上为/Fo)中使用%(RelativeDir)导致msbuild更改为按目录将cpp文件批处理到cl.exe.这可能会对使用/MP获得的收益产生重大影响.

The use of %(RelativeDir) in "Object File Name" ( in the vcxproj XML, /Fo on the CL.exe command line ) project causes msbuild to batch the cpp files to cl.exe on a per directory basis. This can have a significant impact on the benefits gained from using /MP.

请注意,如果您的项目使用%(RelativeDir)作为目标文件,则其配置很可能会尝试避免与其他文件夹中具有相同名称的cpp文件中的.obj文件冲突.

Note that if your project uses %(RelativeDir) for object files its likely that the configuration is trying to avoid colliding .obj files that from cpp files with the same name in different folders.

/Fo命令行参数通常是编译器将obj文件转储到的文件夹-仅传递了一个,因此给定目录的所有cpp文件一次只能传递到CL.exe.

The /Fo command line parameter is typically a folder that the compiler dumps the obj files into - there is only ONE passed, so all of the cpp files for a given directory can only be passed to CL.exe at a time.

那是很痛苦的-但我很高兴有一个原因和解决方案.希望对您有所帮助.

That was a pain - but I'm glad there is a reason and a solution. Hope it helps.

更新

一个队友发现,每当将MSBuild参数发送到CL.exe时,它似乎都已损坏或严重限制了/MP.这很可能是因为/MP要正常工作,顶级CL.exe需要包含一堆cpp文件.

A team mate found that anytime an MSBuild parameter is sent to CL.exe it seems to break or severely limit /MP. This is most likely because for /MP to work well the top level CL.exe needs to have a bundle of cpp files.

我们的解决方案是对对象文件名"不使用任何msbuild参数(我认为其为%params%).这要求我们重命名一些cpp文件,以免它们冲突.

Our solution was to not use any msbuild params ( I think its the %params% ) for 'Object File Name'. This required that we rename some cpp files so they did not collide.

希望这在VS2012或VS2013中已更改.

Hope this has changed in VS2012 or VS2013.

这篇关于MSVC10/MP不能跨项目中的文件夹构建多核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆