问题描述
在Docker映像中(即在dockerfile中)进行编译时,三月
和 mtune
应该是什么
When compiling in a docker image (i.e. in the dockerfile), what should march
and mtune
be set to?
请注意,这不是在正在运行的容器中进行编译,而是在构建容器时进行编译(例如,在编译容器时从源代码构建工具)。图像运行)。
Note this is not about compiling in a running container, but compiling when the container is being built (e.g. building tools from source when the image is run).
例如,当前我运行 docker build
并从源代码安装R包时, (可能是 g ++ / gcc / f95
...)的负载:
For example, currently when I run docker build
and install R packages from source I get loads of (could be g++/gcc/f95
...):
g++ -std=gnu++14 [...] -O3 -march=native -mtune=native -fPIC [...]
如果我在Dockerhub构建的映像中使用 native
,我想这将使用Dockerhub使用的机器规格,并且这会影响可下载的图像二进制文件吗?
If I use native
in an image built by Dockerhub, I guess this will use the spec of the machine used by Dockerhub, and this will impact the image binary available for download?
这与
For reference, check this detailed benchmark comparison by Phoronix:
GCC Compiler Tests At A Variety Of Optimization Levels Using Clear Linux
它使用不同的优化标志比较了十几个使用GCC 6.3的基准测试。基准运行在Intel Core-I7 6800K计算机上,该计算机支持现代Intel指令集,包括SSE,AVX,BMI等(请参阅(完整列表)。具体来说, -O3
与 -O3 -march = native
是有趣的指标。
您可能会看到,在大多数基准测试中, -O3 -march = native
优于 -O3
几乎可以忽略不计(在一种情况下, -O3
获胜...)。
It compares about a dozen benchmarks with GCC 6.3 using different optimization flags. Benchmarks run on an Intel Core-I7 6800K machine, which supports modern Intel instruction sets including SSE, AVX, BMI, etc. (see here for the complete list). Specifically, -O3
vs. -O3 -march=native
is the interesting metric.You could see that in most benchmarks, the advantage of -O3 -march=native
over -O3
is minor to negligible (and in one case, -O3
wins...).
最后, -march = x86-64 -mtune = generic
是Docker映像的不错选择,应该提供良好的可移植性,并且通常会对性能造成较小的影响。
To conclude, -march=x86-64 -mtune=generic
is a decent choice for Docker images and should provide good portability and a typically minor performance hit.
这篇关于在docker映像中编译时进行调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!