C/C++、Windows 控制台应用程序的速度是否取决于目标是 32 位还是 64 位?

发布于 2024-09-05 22:00:49 字数 130 浏览 9 评论 0原文

假设内存不是问题,针对 64 位操作系统是否会使 C/C++ Windows 控制台应用程序运行得更快?

更新:在一些评论/答案的提示下,该应用程序涉及统计算法(例如,线性代数、随机数抽取等)。

Supposing that memory is not an issue does targeting a 64 bit OS make a C/C++ Windows console application run faster?

Update: Prompted by a few comments/answers the application involves statistical algorithms (e.g., linear algebra, random number draws etc).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

深者入戏 2024-09-12 22:00:52

如果大部分执行时间都花在数学上,那么您可能会受益。在大多数情况下,情况并非如此。如果您正在对核反应堆进行蒙特卡洛模拟或光线追踪渲染或类似的东西,您可能会看到很大的好处。我的SWAG“没有多大好处”

If most of the execution time is spent doing math then you might get a benefit. In most cases this is not true. If you're doing monte carlo simulations of nuclear reactors or raytracing renders or something similar you're probably going to see a big benefit. My SWAG is "not much benefit"

明媚殇 2024-09-12 22:00:52

可能会更慢 - 你刚刚有效地将 CPU 缓存的大小减半

当然 Intel 和 AMD 的工程师知道这一点,因此内存管理器做了很多工作来减少仅使用低 32 位的 64 位宽指针和整数的影响

Possibly slower - you have just effectively halved the size of the CPU cache

Of course Intel and AMD's engineers know this so the memory manager does a lot of work to reduce the impact of 64bit wide pointers and integers where only the low 32bits are used

桃酥萝莉 2024-09-12 22:00:51

主要回复编辑内容,而不是最初的问题:我已经移植了一个大量依赖统计数据和(尤其是)线性代数的应用程序,以作为 64 位代码运行。对于该代码,我们的工作量很小,而且速度提高了大约 3:1。

我怀疑大多数认为不会出现这种情况的想法(通常是间接的)来自那些拥有不易移植代码的公司,并且正在尽力告诉客户为什么继续购买是个好主意他们的程序,尽管它仍然是 32 位代码。在我移植的(或者在大多数情况下只是“重新编译”)的代码中,没有比 64 位代码慢,而且大多数代码至少快一点。

Replying mostly to the edit, not the original question: I've ported one application that's heavy on statistics and (especially) linear algebra to run as 64-bit code. For that code, the effort was minimal, and we got about a 3:1 improvement in speed.

I suspect that the majority of the notion that there often won't be comes (usually indirectly) from companies who have code that won't be easy to port, and are doing their best to tell customers why it's a good idea to continue buying their program, even though it's still 32-bit code. Of the code I've ported (or just "recompiled" in most cases) none has come out any slower as 64-bit code, and most has come out at least a little faster.

不打扰别人 2024-09-12 22:00:51

答案是也许。你必须测量。

使用 64 位目标允许使用更多寄存器,这意味着对内存的访问更少,从而执行速度更快。

另一方面,使用 64 位目标会强制所有指针和地址都为 64 位,从而增大内存占用并减慢执行速度。

The answer is maybe. You have to measure.

Using a 64 bits target allows the use of more registers, which implies less accesses to memory, and thus faster execution.

On the other hand, using a 64 bits target forces all pointers and addresses to be 64 bits, enlarging the memory footprint, and slowing the execution.

请爱~陌生人 2024-09-12 22:00:51

答案是一个很大的“也许”。

当您对应用程序进行重大更改时,针对不同的平台肯定会对您的应用程序的性能产生影响。它对于类型、操作和非常不同的操作系统具有不同的大小语义进行交互。

这些因素和许多其他因素肯定会导致应用程序的性能发生变化。无论它是微妙的、巨大的、更好的、更差的等等……都将高度特定于您正在编写的应用程序的类型。如果没有更多细节,不可能在这里给出一般性答案。

The answer is a big Maybe.

Targeting a different platform will certainly have a performance impact on your application as you're making a substantial change to the application. It has different size semantics for types, operations and very different operating system to interact.

These factors and many others will certainly lead to a performance change in your application. Whether it is subtle, huge, better, worse, etc ... will be highly specific to the type of application you are writing. It's not possible to give a general answer here without more details.

在巴黎塔顶看东京樱花 2024-09-12 22:00:51

在其他条件相同(这不太可能)的情况下,64 位的额外数据大小(处理指针时要移动的数据量的两倍)将导致预期它会变慢。

但其他因素(例如 WOW 开销)可能会主导事情......

唯一的方法是在您的目标硬件上测试您的应用程序。

Everything else being equal (which is unlikely) the extra data size of the 64bit (twice as much data to move around when dealing with pointers) would lead to expecting it to be slower.

But other factors (e.g. WOW overhead) could dominate things...

The only way would be to test your application on the hardware you are targeting.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文