Page 1 of 1

Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 2:49 am
by RasUser1873
Hello,

Maybe I am missing something here but thought that the new Pi 4 could do 64 bit OS but the only ones I see for download are all 32 bit... what am I missing here ?

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 4:39 am
by ejolson
The standard OS is 32-bit to retain full compatibility across the product line from the original Pi to the Zero to the latest 4B. If you download a 64-bit OS, then you can use the 4B in 64-bit mode.

I've had pretty good luck with Gentoo Linux and the beta release of 64-bit Raspberry Pi OS 64. I think many people like Ubuntu as well. I expect others will have further recommendations.

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 5:03 am
by W. H. Heydt
The Pi2Bv1.2, Pi3B, Pi3B+ and Pi3A+ can all do 64-bit. 64-bit capability isn't new with the Pi4B...though enough memory to make effective use of is. The prior Pis are limited 1GB, and the Pi3A+ has only 512MB.

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 5:14 am
by kerry_s
RasUser1873 wrote:
Sun Sep 06, 2020 2:49 am
Hello,

Maybe I am missing something here but thought that the new Pi 4 could do 64 bit OS but the only ones I see for download are all 32 bit... what am I missing here ?
64 bit is still beta, work in progress.
viewtopic.php?f=117&t=275370

64bit lite version.
https://downloads.raspberrypi.org/raspi ... 020-08-24/

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 9:56 am
by NimbUx
In your opinions, do the added capabilities of 64-bit (instructions, register set...) compensate
for the higher memory consumption vs. 32-bit Linux on the R-Pi-4B used as a "desktop" PC ?
Will your answers be different across the range of RAM sizes : 1 , 2, 4, 8, ( 16 ?) gigabytes ?

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 10:21 am
by fruitoftheloom
RasUser1873 wrote:
Sun Sep 06, 2020 2:49 am
Hello,

Maybe I am missing something here but thought that the new Pi 4 could do 64 bit OS but the only ones I see for download are all 32 bit... what am I missing here ?

What model of 4B ? if 1GB or 2GB you may not notice much difference between ARMHF or ARM64 Operating Systems.

Also you do not state where you only find ARMHF 32bit Operating Systems suitable for your 4B !

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 10:41 am
by jahboater
NimbUx wrote:
Sun Sep 06, 2020 9:56 am
In your opinions, do the added capabilities of 64-bit (instructions, register set...) compensate
for the higher memory consumption vs. 32-bit Linux on the R-Pi-4B used as a "desktop" PC ?
Will your answers be different across the range of RAM sizes : 1 , 2, 4, 8, ( 16 ?) gigabytes ?
You will get a range of different answers.

These 64-bit OS's are free and only take a few minutes to install.
So why not try Raspberry Pi OS 64-bit (beta), Gentoo64, and Ubuntu, say, on a spare SD card and see what you think. Measure the memory usage (if you can) for your work loads.
I would start with the Raspberry Pi OS personally. There is a new Lite version here by the way:
https://downloads.raspberrypi.org/raspi ... 64/images/

Code I write in C uses the exact width data types, so that only pointers take more memory in 64-bit mode.
The code itself tends to be more compact. Having twice the number of registers (31 general purpose integer registers and 32 128 bit SIMD registers in NEON (floating-point)) means a lot less memory references (more often functions don't need to spill registers to the stack for example. Temporary values may be saved in registers to be re-used later etc etc).
YMMV :)

The 64-bit instruction set is more modern and is streamlined for the new out-of-order, speculative execution, register renaming, CPU's (like the Pi4's Cortex-A72). The legacy 32-bit mode has all sorts of slow instructions that don't work well with these recent CPU's.

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 1:10 pm
by NimbUx
jahboater wrote:
Sun Sep 06, 2020 10:41 am
Code I write in C uses the exact width data types, so that only pointers take more memory in 64-bit mode.
The code itself tends to be more compact. Having twice the number of registers (31 general purpose integer registers and 32 128 bit SIMD registers in NEON (floating-point)) means a lot less memory references (more often functions don't need to spill registers to the stack for example. Temporary values may be saved in registers to be re-used later etc etc).
YMMV :)

The 64-bit instruction set is more modern and is streamlined for the new out-of-order, speculative execution, register renaming, CPU's (like the Pi4's Cortex-A72). The legacy 32-bit mode has all sorts of slow instructions that don't work well with these recent CPU's.
Interesting points ! The question then turns into : do the standard compilers make a good job using these more modern capabilities of the 64-bit ARM binary programming interface ? Are the apps in the standard repository, and the Raspi-OS-64 itself, optimised for the instruction set - or do you need hand crafted ASM in your own programmes to gain the benefits you mentionned above ?

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 2:09 pm
by Heater
I'm very sure that GCC and Clang are doing a good job of generating optimal code for 64 bit ARM now a days. They have been at it for a while.

It seems very unlikely the guys building Raspi-OS-64 would not be using the relevant compiler options to produce the best code for the 64 bit Raspi SoC.

It's all but impossible to produce better code by hand in assembler than the compiler optimizers do now a days.

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 2:14 pm
by fruitoftheloom
NimbUx wrote:
Sun Sep 06, 2020 1:10 pm
jahboater wrote:
Sun Sep 06, 2020 10:41 am
Code I write in C uses the exact width data types, so that only pointers take more memory in 64-bit mode.
The code itself tends to be more compact. Having twice the number of registers (31 general purpose integer registers and 32 128 bit SIMD registers in NEON (floating-point)) means a lot less memory references (more often functions don't need to spill registers to the stack for example. Temporary values may be saved in registers to be re-used later etc etc).
YMMV :)

The 64-bit instruction set is more modern and is streamlined for the new out-of-order, speculative execution, register renaming, CPU's (like the Pi4's Cortex-A72). The legacy 32-bit mode has all sorts of slow instructions that don't work well with these recent CPU's.
Interesting points ! The question then turns into : do the standard compilers make a good job using these more modern capabilities of the 64-bit ARM binary programming interface ? Are the apps in the standard repository, and the Raspi-OS-64 itself, optimised for the instruction set - or do you need hand crafted ASM in your own programmes to gain the benefits you mentionned above ?

RaspiOS64 is Debian ARM64 base which has had a decade of development:

https://wiki.debian.org/Arm64Port

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 2:46 pm
by jahboater
NimbUx wrote:
Sun Sep 06, 2020 1:10 pm
Interesting points ! The question then turns into : do the standard compilers make a good job using these more modern capabilities of the 64-bit ARM binary programming interface ?
Yes of course. They have been supporting Aarch64 for many years now.
Study some code produced by the compiler using these options:

Code: Select all

gcc program.c -S -fverbose-asm -Os -march=armv8-a -mcpu=cortex-a72 -mtune=cortex-a72 -o program.s
See if you can do any better by hand! The compiler knows all the intricacies of the scheduling for these new OOO CPU's, which instructions are best kept together (like mov/movk), and so on.

Use GCC 10.2 for the best performance at the time of writing.

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 3:03 pm
by Kendek
jahboater wrote:
Sun Sep 06, 2020 2:46 pm
Study some code produced by the compiler using these options:

Code: Select all

gcc program.c -S -fverbose-asm -Os -march=armv8-a -mcpu=cortex-a72 -mtune=cortex-a72 -o program.s
-march=armv8-a+crc

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 3:50 pm
by ejolson
Kendek wrote:
Sun Sep 06, 2020 3:03 pm
jahboater wrote:
Sun Sep 06, 2020 2:46 pm
Study some code produced by the compiler using these options:

Code: Select all

gcc program.c -S -fverbose-asm -Os -march=armv8-a -mcpu=cortex-a72 -mtune=cortex-a72 -o program.s
-march=armv8-a+crc
Do you have an example when those crc instructions are generated while building a standards-compliant C or C++ code?

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 4:22 pm
by Kendek
ejolson wrote:
Sun Sep 06, 2020 3:50 pm
Kendek wrote:
Sun Sep 06, 2020 3:03 pm
jahboater wrote:
Sun Sep 06, 2020 2:46 pm
Study some code produced by the compiler using these options:

Code: Select all

gcc program.c -S -fverbose-asm -Os -march=armv8-a -mcpu=cortex-a72 -mtune=cortex-a72 -o program.s
-march=armv8-a+crc
Do you have an example when those crc instructions are generated while building a standards-compliant C or C++ code?
ARMv8.1 enables +crc extension by default, but the Pi4 is only ARMv8 with hardware CRC32. So the +crc is necessary if we want to be precise. But I'm sorry, I don't know a good example source code that you could analyze.

Re: Thought 64 bit. Why only 32?

Posted: Sun Sep 06, 2020 6:51 pm
by jahboater
Kendek wrote:
Sun Sep 06, 2020 4:22 pm
ARMv8.1 enables +crc extension by default, but the Pi4 is only ARMv8 with hardware CRC32. So the +crc is necessary if we want to be precise. But I'm sorry, I don't know a good example source code that you could analyze.
I would be surprised if the compiler recognized the CRC code in the C/C++ source using that exact polynomial (0x04C11DB7) and emitted one the CRC32 instructions. Its very specific.