gpt4 book ai didi

bash - 如何: make -j x//where x is automatically determined

转载 作者:行者123 更新时间:2023-11-29 09:02:01 29 4
gpt4 key购买 nike

看完这个问题的答案后: Make "make" default to "make -j 8"

我想知道是否有办法让 -j 选项自动使用正确数量的编译线程?

所以我说制作make 命令本身根据硬件使用 6、4 或 8 个线程?

最佳答案

如果您只使用 make -j

make 不会自行查找核心数——相反,它会并行化到最大值。但是,您应该能够通过以下方式确定核心数

grep -c "^processor" /proc/cpuinfo

或(根据 Azor-Ahai 的评论,如果您的系统可用)

nproc

因此:

make -j $(nproc)

有关详细信息,请参阅“如何 How to obtain the number of CPUs/cores in Linux from the command line?”。另请参阅 GNU make: should the number of jobs equal the number of CPU cores in a system?

关于bash - 如何: make -j x//where x is automatically determined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10945370/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com