当我想对编译器的性能进行基准测试时,我需要使用多少个内核?

How many cores do I need to use when I want to benchmark the performance of my compiler?

我重新排序编译器优化。

我想用 gcc O3 比较输出的性能。

我有一个测试套件。

基准测试需要使用多少个内核?

我确定它们的可执行文件是不同的。

而且我用单核测了他们运行的时间,时间也差不多。

但我不限制核心数量来衡量 运行 时间,我编译器的可执行文件比 gcc O3 快。

如何确定哪个编译器更好?


问题

当我想对编译器的性能进行基准测试时,我需要使用多少个内核?


嗯,越多越好。您提到的 Single-core 绝对 推荐。既然你提到了 gcc,你就得看看 GCC benchmarks.

但是,在前面提到的“越多越好”的背景下,请注意下面 answer 正确表述的“递减法则 return”:

In the benchmark wars the individual manufacturers will will throw as many cores/processors/CPUs at the problem as they can be effective with. But there's always (except in some very weird circumstances) a "law of diminishing return" -- the second core will only add 60-80%, the third core less than that, etc. (And this assumes a problem that is sufficiently multi-threaded to actually make use of the added cores.) So you can't look at a given benchmark and assume that twice as many cores will provide twice the performance. In fact, in some cases you could double the number of cores and actually reduce performance. Achieving good performance in a highly multi-threaded application is somewhere between an art and black magic.