RasUser1873
Posts: 1
Joined: Sun Sep 06, 2020 2:46 am

Thought 64 bit. Why only 32?

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 ?

ejolson
Posts: 5982
Joined: Tue Mar 18, 2014 11:47 am

Re: Thought 64 bit. Why only 32?

Sun Sep 06, 2020 4:39 am

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.

W. H. Heydt
Posts: 13604
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Thought 64 bit. Why only 32?

Sun Sep 06, 2020 5:03 am

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.

User avatar
kerry_s
Posts: 1557
Joined: Thu Jan 30, 2020 7:14 pm

Re: Thought 64 bit. Why only 32?

Sun Sep 06, 2020 5:14 am

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/

NimbUx
Posts: 273
Joined: Fri Jan 03, 2020 10:33 am

Re: Thought 64 bit. Why only 32?

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 ?

fruitoftheloom
Posts: 24489
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Thought 64 bit. Why only 32?

Sun Sep 06, 2020 10:21 am

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 !
Thinking outside the box is better than burying your head in the sand...

User avatar
jahboater
Posts: 6281
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Thought 64 bit. Why only 32?

Sun Sep 06, 2020 10:41 am

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.
Pi4 8GB running PIOS64 Lite

NimbUx
Posts: 273
Joined: Fri Jan 03, 2020 10:33 am

Re: Thought 64 bit. Why only 32?

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 ?

Heater
Posts: 16835
Joined: Tue Jul 17, 2012 3:02 pm

Re: Thought 64 bit. Why only 32?

Sun Sep 06, 2020 2:09 pm

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.
Memory in C++ is a leaky abstraction .

fruitoftheloom
Posts: 24489
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Thought 64 bit. Why only 32?

Sun Sep 06, 2020 2:14 pm

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
Thinking outside the box is better than burying your head in the sand...

User avatar
jahboater
Posts: 6281
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Thought 64 bit. Why only 32?

Sun Sep 06, 2020 2:46 pm

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.
Pi4 8GB running PIOS64 Lite

Kendek
Posts: 265
Joined: Thu Jul 25, 2019 4:39 pm
Location: Kaposvár, Hungary

Re: Thought 64 bit. Why only 32?

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

ejolson
Posts: 5982
Joined: Tue Mar 18, 2014 11:47 am

Re: Thought 64 bit. Why only 32?

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?

Kendek
Posts: 265
Joined: Thu Jul 25, 2019 4:39 pm
Location: Kaposvár, Hungary

Re: Thought 64 bit. Why only 32?

Sun Sep 06, 2020 4:22 pm

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.

User avatar
jahboater
Posts: 6281
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Thought 64 bit. Why only 32?

Sun Sep 06, 2020 6:51 pm

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.
Pi4 8GB running PIOS64 Lite

Return to “General discussion”