问题描述
它可以利用多核吗?在多核32位计算机上并行运行?
在32位计算机上64位运行速度要慢多少?
Can it utilise mulitple cores in parallel when on a Multi-Core 32bit machine?
How much slower are 64bit operations on a 32bit machine?
推荐答案
它可能使用多个内核来运行不同的线程,但是对于64位计算,它不会并行使用它们。 64位长基本上存储为两个32位int。为了添加它们,需要两个添加,以跟踪进位。乘法类似于将两个两位数字相乘,除了每个数字的基数为2 ^ 32而不是基数10。对其他算术运算如此。
It may use multiple cores to run different threads, but it does not use them in parallel for 64 bit calculations. A 64 bit long is basically stored as two 32 bit ints. In order to add them, two additions are needed, keeping track of the carry bit. Multiplication is kind of like multiplying two two-digit numbers, except each digit is in base 2^32 instead of base 10. So on for other arithmetic operations.
编辑速度:我只能猜测速度差。加法需要两个加法而不是一个,而乘法(我认为)需要四个乘法而不是一个。但是,我怀疑如果所有内容都可以保存在寄存器中,那么实际的计算时间将比两次访问内存和两次写入内存所需的时间相形见,,所以我的猜测大约是大多数情况下的两倍。操作。我想这将取决于处理器,特定的JVM实现,月相等等。除非您进行大量运算,否则我不会担心。大多数程序会花费大部分时间来等待IO往返磁盘或网络。
Edit about speed: I can only guess about the speed difference. An addition requires two adds instead of one, and a multiplication would (I think) require four multiplies instead of one. However, I suspect that if everything can be kept in registers then the actual time for the computation would be dwarfed by the time required to go to memory twice for the read and twice for the write, so my guess is about twice as long for most operations. I imagine that it would depend on the processor, the particular JVM implementation, the phase of the moon, etc. Unless you are doing heavy number crunching, I wouldn't worry about it. Most programs spend most of their time waiting for IO to/from the disk or network.
这篇关于Java:VM如何在32位处理器上处理64位`long`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!