ARM64 Vs ARM32 -- What's Different For Linux Programmers? (edn.com) 102
New submitter DebugN writes: When ARM introduced 64-bit support to its architecture, it aimed for Linux application compatibility with prior 32-bit software on its architecture. But for Linux programmers, there remain some significant differences that can affect code behavior. If you are a Linux programmer working with — or will soon be working with — 64-bit, you might want to know what those differences are, and this useful EDN article says it all.
ARM32? ARM64? (Score:1)
Re: (Score:2, Funny)
Vegeta, what does the scouter stay about his ARM level?
Re: ARM32? ARM64? (Score:3)
[goku@dragonball]$ scouter -h
It's over
Segmentation fault
[goku@dragonball]$
Re: (Score:3, Funny)
I'm wrestling with how to answer all these ARM questions.
Re: (Score:1)
You can buy a MS Surface really cheap if you are interested in that.
I'm not a programmer... (Score:1)
But if the answer isn't "32bit exactly", i will be really confused...
Re:I'm not a programmer... (Score:5, Informative)
The instruction set for ARM64 is a bit more like MIPS than ARM. I don't think it would matter to an end user, but this new 64-bit mode has made for a lot of extra work for compiler developers as many of the optimizations developed over the years are no longer effective for 64-bit code. And the bits of operating system and library code that was written for 32-bit or Thumb has to be rewritten as if ARM64 was a totally alien architecture.
It came as a big surprise really, because years ago when ARM Thumb was added as an extension it was somewhat compatible with the old instruction set, at least in the assembler syntax. That made it relatively easy to port between the two modes. Thumb mode instructions that are half as big, but still operate on 32-bit values, but those instructions are more limited in terms of what they can do and what arguments they will accept. On the Game Boy Advance, the thumb operations could run twice as fast as the non-thumb operations because the 16-bit bus for cartridges was relatively slow compared to the CPU performance.
ps - I prefer to call it aarch64 or ARMv8.
Re: (Score:2)
The instruction set for ARM64 is a bit more like MIPS than ARM
That's not really true. MIPS has no condition codes, has branch delay slots, has no PC-relative addressing and no complex addressing modes. About the only thing where AArch64 is more like MIPS than AArch32 is in having a non-architectural PC, which is a decision made by most modern architectures as making the PC a possible destination register complicates a lot of things microarchitecturally. A few similarities between AArch32 and AArch64 that are not shared with MIPS:
Re: (Score:2)
The instruction set for ARM64 is a bit more like MIPS than ARM
That's not really true. MIPS has no condition codes, has branch delay slots, has no PC-relative addressing and no complex addressing modes.
I think that OrangeTide meant that the experience of porting to ARM64 is like the experience of porting to MIPS. He mentions specifically that there are major code changes (i.e. in optimizations) that need to be done which weren't necessary when porting to i.e. Thumb. Those code changes make the port experience similar to porting to another architecture altogether, i.e. MIPS.
Re: (Score:2)
Right. A lot of the conditional instructions have been dropped. And a lot of the semantics of existing instructions have changed. It is true that operations still modify status flags to handle conditions, versus MIPS which has branches that perform the comparisons themselves. Obviously the new architecture is not like MIPS, SPARC or POWER, but I'd argue it's not much like ARM either. Aarch r31 is a bit like MIPS r0 though, in that it is a zero value if you read it (rsp). Although it's a bit overloaded on AR
Re: (Score:1, Offtopic)
lisaparratt is right on and your comment shows so.
I live in Denmark, you know, among one of the first democratic countries in the world (besides the original democracy Greece), and our feet crumble when we see and hear the US talk about human rights, equal rights, and your so called democracy (which is a republic which is not a democracy which many people in and form the US claims).
Re:Trump vs Clinton -- Whats different for voters (Score:5, Funny)
Hang on, I think I'm getting it. Usually people use car analogies on /. but you're talking about the US and Denmark, right? So in this case, Denmark is 64-bit and the US is only 32-bit? Or are you talking about ARMs as in "the right to keep and bear ARM [chips]"?
Re: (Score:1)
live in Denmark, you know, among one of the first democratic countries in the world (besides the original democracy Greece), and our feet crumble when we see and hear the US talk about human rights, equal rights, and your so called democracy (which is a republic which is not a democracy which many people in and form the US claims).
This is the dumbest thing people talk about. A republic is not democratic? Spoken by a poster who hails to his king (queen), baby?
The US is a liberal democracy. It is THE liberal democracy. Calling it "not a democracy" is fucking retarded. You're a poster living in a kingdom claiming that his democracy is one of the oldest in the world despite it actually being a monarchy and almost a century younger than the USA. Sure thing, guy!
I'm just going to go on with the rest of my day thinking that democracy must h
Re: (Score:3)
Re: (Score:2)
We're perfectly aware what it means. People on your side of the pond use it to mean anything you don't like. If I was you, right now I'd be cursing Craig Joubert, the neighbour's dog and the weather for being socialists.
Greenland literally means "A country that is green". Doesn't alter the fact that it's predominantly white.
There is a connection, anybody know what it is?
Re: (Score:2)
It looks about that way from here in the states as well.
tl;dr; (Score:3)
It's mostly nothing to do with ARM and much to do with "Moving to a later Linux kernel", implying ARM 32bit CPU's don't run on the latest kernels. But they do.
Re:tl;dr; (Score:5, Interesting)
It's mostly nothing to do with ARM and much to do with "Moving to a later Linux kernel",
You're thinking of the third item in their list.
The first item in their list does have to do with ARM; its register set is different, and OS APIs for debugging have platform dependencies - in particular, the Linux kernel handled A64 differently from A32 - and those particular developers happen to be using ptrace() and had to handle A64 differently.
The second item in their list has to do with the C library doing more atomic load/store operations on A64 for some reason; they speculate that it's "to better support multiprocessor systems."
The problem here is that the article had a misleading title; it was "ARM64 vs ARM32 -- What's different for Linux programmers" when it should have been "ARM64 vs ARM32 -- What's different for people working at a company whose core technology is a record and replay engine, which works by recording all non-deterministic input to a program and uses just-in-time compilation (JIT) to keep track of the program state". What Undo Software [undo-software.com] are doing is rather specialized and system-softwareish, and they run into issues that wouldn't affect the majority of programmers; those are the issues they're talking about.
Re: (Score:2)
Of course the title is misleading! For a user-space programmer, the ISA is completely hidden by the compiler and the system libraries (for example, synchronization). Still, the document makes interesting points, such as different behaviour of the compiler (which apparently removes locks in ARM32 but not in ARM64) which could impact performance, especially for highly concurrent applications.
Re: (Score:3)
Of course the title is misleading! For a user-space programmer, the ISA is completely hidden by the compiler and the system libraries (for example, synchronization).
Unless you're one of the user-space programmers writing the compiler or the system libraries. :-)
The programmers at Undo are programmers like that, not typical user-space programmers writing code for which the ISA doesn't matter.
(And a fair bit of kernel programming is done with the ISA hidden by the compiler and lower-level kernel code, for that matter.)
Re: (Score:2)
For a user-space programmer, the ISA is completely hidden by the compiler and the system libraries
There are a few places where it might matter. For example, AArch64 can do atomic operations on pairs of pointers. This is particularly important for some of the RCU code in the Linux kernel, but will be similarly important for some userspace atomic operations. If you're writing a userspace threading library (fairly niche) then the different structure of ucontext_t will be important. It can also be important if you're looking at the ucontext_t that's delivered as an argument to signal handlers (though m
Re: (Score:2)
I'm starting to wonder what really makes an architecture 32- or 64-bit. So far as I can tell, it's just the pointer size. 32-bit architectures can have 64-bit word sizes (double-word); the processor can internally carry 256-bit cache lines and have enormous data buses and still be an 8-bit 6502.
Seriously, you could make that: a 6502 with pin-outs for 256-bit data buses, but 8-bit addressing. Prefetches 32 words at once through one cycle into CPU cache. It would be nonsense. The Athlon 64 architectur
Re: (Score:3, Interesting)
Only people who don't actually use processors at the instruction set level are uncertain about whether or not a processor is "32 bit" or "64 bit". If you look at the architecture, it is usually very easily apparent. Not always, but usually.
Does it take more than one instruction to shift a 64-bit value? It probably isn't a 64-bit processor.
Re: (Score:2)
Now that was funny, first sentence making some kind of absolute statement about people's understanding, but then you hedge in later sentences with "usually" and then "probably".
the i860 was marketed by intel as a 64 bit processor because of the 64 bit graphics registers, but it had 32 of the 32 bit general purpose registers and 32 bit bus.
Re: (Score:3)
There are many instructions in x86 that operate on values larger than 32 bits.
MMX comes with 8 64bit registers
The movq instruction can move a 64bit value between memory and the MM registers.
Re: (Score:1)
How would you classify a CPU like the Z80?
It has an 8-bit databus and 8/16-bit registers but internally it is performing all instructions through a 4-bit ALU.
That why even a register-register addition takes 4 cycles, not counting the memory refresh.
It can do 16-bit additions (or left-shift if you so wish) with a single instruction, but I sure wouldn't call it a 16-bit CPU.
Re: (Score:2)
Re: (Score:2)
With 8-bit and 16-bit systems, this was the width of the data bus, while memory was mostly limited to 64Kbytes, but there were all sorts of funky paging that could swap in and out 16K blocks. With 32-bit and 64-bit systems, it's the theoretical maximum amount of uniquely addressable memory; 32-bit = 4 Gbytes, 64-bit = 1 Exabyte of storage. But CPU performance is being improved by using 128-bit and 256-bit wide data bus architectures to support SIMD instruction sets like AVX and 3Dnow!
Re: (Score:2)
Unless your 32bit CPU supports PAE, then it can address 36 bits of memory.
Re: (Score:2)
Seriously, you could make that: a 6502 with pin-outs for 256-bit data buses, but 8-bit addressing
I'm not seeing what you're saying here. How would you be able to address that memory from within the 6502 instruction set, with 8-bit addressing?
Re: (Score:2)
You'd say, "Get the memory at 0x0c00".
It would load the memory at 0x0c00-0x0c0F into CPU cache, and copy the 0x0c00 address into a register. If you then tried to add 0x0c0A to that register, it would read it from cache.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Which also doesn't make much sense, since there's not much advantage and a lot of disadvantage to 64-bit ISA.
The primary advantage for consumer devices is that you can access more RAM.
The x86-64 ISA adds extra registers and other instructions which would be useful to 16-bit processors
That's true, they should have been added years ago.
but it also makes word-sized values 64-bits wide by default.
Kind of......for a lot of instructions, the default is actually 16 bits. For a mov command, the default is to move 64bits, but you can also specify 8/16/32 bits. I'm not sure it matters too much practically what the 'default' is, though.
The x86-64 is indeed a hybrid monstrosity, whose only redeeming feature is backwards compatibility.
Re: (Score:2)
Ofcourse the other architecture in the embedded space is MIPS, and MIPS64 support has been around for a long long time... The move to 64bit was a perfect opportunity for MIPS to expand their market share as MIPS64 was tried and tested while ARM64 was completely new.
Re: (Score:2)
Re: (Score:2, Interesting)
Will people *please* stop saying that hardware "runs on" software: it's the other way round!
(If you want to say that a piece of hardware "runs" some software, that's perfectly acceptable -- but not "runs on".)
That's easy (Score:5, Funny)
One has a lot more arms.
Re: (Score:2)
One has a lot more arms.
Are you suggesting that an arms race is imminent?
So in summary (Score:4, Interesting)
There are no changes for programmers in general. Only the compiler writers need to care. (as usually happens with new cpu architectures)
Re: (Score:1)
Can we have that in writing, please?
Re: (Score:1)
worse, Perl
C Programmers on Linux, not "Linux Programmers" (Score:3, Informative)
This will have absolutely no effect to the majority of programmers that use a higher level language such as Java or Objective-C.
As the article shows examples, only Assembly and C have changes from the 32 bit version, which are to be expected. Not a big surprise for anyone. I am sure my Python code will run the same as it did on ARM32.
Re: (Score:1)
I am sure my Python code will run the same as it did on ARM32.
Unless the guys who write CPython get tripped by these differences
Re: (Score:2)
Guys that assume sizeof(int) as 32 bits, instead of using "sizeof(int)" explicitly will have a bad time.
And believe me, they're at loose even nowadays.
Re: (Score:2)
Re: (Score:2)
Didn't Microsoft go full retard and make 'long' a 32-bit type on 64-bit Windows?
Re: (Score:2)
Re: (Score:1)
You do know that MS Windows has existed longer than the int32_t typedef, right?
Re: (Score:2)
Re: (Score:2)
> Wow! Really sorry to say that sizeof(int) is 32 bits even on a 64-bit architecture.
Really, it's not. "int" varies depending on compiler and architecture. See below from www.unix.org.
http://www.unix.org/whitepaper... [unix.org]
It's precisely your kind of assumption from limited experience that breaks cross-compilation and multi-platform work.
Re: (Score:2)
Wow! Really sorry to say that sizeof(int) is 32 bits even on a 64-bit architecture.
Q.,E.D. :-)
The size of the int is a compiler decision, not architectural one. On my old 8 bits time, the sizeof(int) was 16 bits.
Re: (Score:1)
That should be (sizeof (int) * CHAR_BIT). POSIX requires CHAR_BIT to be 8, so you can reasonably choose to also make that assumption on Unix-ish systems. But on some architectures CHAR_BIT can be 16 or greater, e.g. on a DSP which only has floating point arithmetic. It could emulate 8-bit chars, but it'd be quite slow.
Portable C programming is actually quite easy, but you just have to stay mindful. It helps if you stick to unsigned arithmetic when practical, which is usually the case because unsigned is the
Re: (Score:2)
OMG, what drivel. Objective C is a superset of C, and as such shares all of C's characteristics.
Re: (Score:2)
Does ARM64 matter? (Score:1)
ARM64 has been coming for so long one wonders if it really matters anymore.
Yes, it has reached cell phones and tablets - but nobody is running anything but iOS or Android on those.
ARM64 was supposed to bring us standard motherboards with a standard, documented boot system so that Linux could treat ARM64 just like AMD64 for booting purposes - one standard bootloader instead of custom stuff for every board that quickly becomes a support nightmare.
Yet years after announcing, just like Power8's move to the mass
Re: (Score:2)
The market for mobile devices which might run ARM is far bigger than the market for laptops and desktops.
Re: (Score:1)
Perhaps, but also less profitable.
Re: (Score:2)
Every modern car with lane detection, pedestrian detection, sign detection, break assistance, collision detection (and in ten ears that will be "state of the art" and become mandatory for every car by law, just like ABS and ESB(? ESS?) became a year ago) has a dozen of ARMs and a few DSPs.
So yes: the simple idea of that Lady in the late 1980s is now the most sold high level processor on the planet.
Nevertheless there are still odd 8 bit and 16 bit processors sold as well. After all if you save 1$ in a device
Re: (Score:2)
This one goes to 64 (Score:1)
It's not 32. You see, most blokes, you know, will be playing at 32. You're on 32 here, all the way up, all the way up, all the way up, you're on 32 on your arm. Where can you go from there? Where?
- Nigel Tufnel
Details (Score:5, Funny)
You see, when you have ARM32 vs ARM64 you have to remember that 64 is at least twice as much as 32. So you're going to need to use larger instructions in your program or you're going to have a lot of empty space. Because your functions can go twice as far, you're going to need more data highways to get there without all the congestion. It's like moving from a crowded boulevard to an expressway.
When it comes to mobile apps, which is where you're going to be programming the ARM, these wider highways occupy valuable space on your mobile board, but it's worth it to reduce congestion by at least a half. Also, because you have larger bits, you can get more numbers in your apps without having to stress the fixed point unit. This means fonts take up less space and as such you can use more serifed typefaces.
This answer brought to you by That Guy Who Clearly Bullshitted Through His Interview and Got Promoted To Manager Last Week.
Re: (Score:2)
You see, when you have ARM32 vs ARM64 you have to remember that 64 is at least twice as much as 32. So you're going to need to use larger instructions in your program
You're joking, but that's actually true. Most AArch32 code these days uses Thumb-2, where most common instructions are 16 bits, a few are 32 bits. There's no Thumb-3 (yet) for AArch64, so all instructions are 32 bits. There almost certainly will be Thumb-3 at some point, though it is likely to be a little while coming and involve profiling a lot of code to determine what the most common instructions are (and there's no point in doing that until the compiler back ends have stabilised a bit).
Re: (Score:3)
Re: (Score:2)
Thanks, but doesn't quite change what I implied. Be it the instruction set or the peripheral set, iPhones, iPads and iPods use the same CPU from Apple's former Palo Alto Semi division. And likely the same peripheral interfaces. Going into different SPI/I2C/USB mode settings ain't trivial, and involves repeated low level programming. Whereas if it's done once on Apple's platforms, it can be reused, since Apple ain't gonna change those things in its processors to the point that it cripples the effort req
Re: (Score:2)
Been around for a couple years now
Undo Software now supports 64-bit ARM (Score:1)