使-j4或-j8 [英] make -j4 or -j8

查看:201
本文介绍了使-j4或-j8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4个处理器和我编译处理器饿应用,我读到使用使与-j4开关被推荐为OpenCV的,我宁愿用-j8,什么是做多处理器的优势在哪里?

I have 4 processors and am compiling processor hungry application, I read that using make with the -j4 switch was recommended for OpenCV, should I rather use -j8 and what is the advantage of making for multiple processors?

推荐答案

至于你说的 -j 标志告诉make它允许产卵的所提供的金额线程。理想的情况是每个线程自身的核心/ CPU上执行,所以你多核心/ CPU的环境来充分发挥其

As you say the -j flag tells make that it is allowed to spawn the provided amount of 'threads'. Ideally each thread is executed on its own core/CPU, so your multi-core/CPU environment is used to its fullest.

制作本身不编译源文件。这是通过一编译器(GCC)完成。 Makefile的(输入制作)包含了一系列的目标。每个目标都有一组依赖(其他目标)和规则如何构建目标。 制作读取Makefile文件(S)和管理所有的目标,依赖性和构建规则。除了编译源文件,你可以使用制作来执行,可以通过shell命令来描述的任何任务。

make itself does not compile the source files. This is done by a compiler (gcc). The Makefile (input for make) contains a set of targets. Each target has a set of dependencies (on other targets) and rules how to build the target. make reads the Makefile(s) and manages all targets, dependencies and build rules. Besides compiling source files you can use make to perform any task that can be described by shell commands.

如果设置线程过高的允许数量,它是不可能安排在它自己的核心的每个线程。附加调度(上下文)交换机,因此让所有的线程中执行。这种额外的资源使用率明显导致性能降低。

If you set the allowed number of threads too high, it is not possible to schedule each thread on its own core. Additional scheduling (context) switches are required to let all threads execute. This additional resource usage obviously result in lower performance.

有多个规则经验法则,但我想这要设置总金额<芯&GT的数量; + 1 是最常见的。这背后的想法是,所有芯具有其自己的线程并且有一个处理目标和一个附加管理线程是下一个要构建

There are multiple rules-of-thumb, but I guess that setting to total amount to <number of cores> + 1 is the most common. The idea behind this is that all cores have their own thread and there is one additional managing thread that handles the targets and which is next to be build.

这篇关于使-j4或-j8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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