Contextualist
V2EX  ›  问与答

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

  •  
  •   Contextualist · Aug 23, 2022 · 1422 views
    This topic created in 1361 days ago, the information mentioned may be changed or developed.

    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

    2 replies    2022-08-24 00:47:11 +08:00
    lixile
        1
    lixile  
       Aug 23, 2022
    何以解忧 唯有 cmake
    友情提示 cmake 的并行 也是基于 make 的 jobserver
    但是写 cmake 真的心智负担比 makefile 低太多了
    Contextualist
        2
    Contextualist  
    OP
       Aug 24, 2022
    @lixile 主要是老项目迁移有些麻烦,我们新项目都用 CMake 了。不过你也算是提醒我了,搜了一下 Makefile 的 jobserver 好像是提供接口的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2979 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 04:41 · PVG 12:41 · LAX 21:41 · JFK 00:41
    ♥ Do have faith in what you're doing.