V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Contextualist
V2EX  ›  问与答

Makefile 中需要占用多个进程的 target 如何合理并行?

  •  
  •   Contextualist · 2022-08-23 15:20:43 +08:00 · 676 次点击
    这是一个创建于 614 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Makefile 的 -j 选项的计算方式是默认每个 target 占用一个进程,但有时候一个 target 下的某条指令使用多进程,make 就管不了了。

    具体情况:为 nvcc 指定多个计算架构时,各架构的编译是可以并行的,比如
    nvcc -t2 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_80,code=sm_80 实际上会同时跑两个进程。现在希望并行编译所有 .cu 文件的同时不超过 -j 的进程数限制。

    注:不考虑 make --max-load

    第 1 条附言  ·  2022-08-24 03:32:13 +08:00
    2 条回复    2022-08-24 00:47:11 +08:00
    lixile
        1
    lixile  
       2022-08-23 20:45:55 +08:00
    何以解忧 唯有 cmake
    友情提示 cmake 的并行 也是基于 make 的 jobserver
    但是写 cmake 真的心智负担比 makefile 低太多了
    Contextualist
        2
    Contextualist  
    OP
       2022-08-24 00:47:11 +08:00
    @lixile 主要是老项目迁移有些麻烦,我们新项目都用 CMake 了。不过你也算是提醒我了,搜了一下 Makefile 的 jobserver 好像是提供接口的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4336 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 05:32 · PVG 13:32 · LAX 22:32 · JFK 01:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.