Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Rapsberry PI - cpu dilemma
Rapsberry PI - cpu dilemma [message #53840] Fri, 08 May 2020 16:36 Go to next message
mirek is currently offline  mirek
Messages: 14154
Registered: November 2005
Ultimate Member
There is an interesting issue. Original PI had Armv6 CPU, since PI 2, it is Armv7.

However, all binaries are still compiled for PI 1.

There two major differences between those 2 CPUs:

- Armv7 allows unaligned memory access, which is quite useful to optimize some things (e.g. Stream::Get32 method)
- Armv7 supports thumb 2, which results in significantly reduced code size

It is possible to activate compilation for Armv7 with clang (and GCC) using compiler flags and the code is really quite better, on platform where every bit of performance matters.

So it makes me think we should react to this somehow. I can definitely detect that I am running on RPI with armv7 and add those flags to default build methods. But that would make resulting binaries not work on original PI and on PI zero....

So I can:

- ignore armv7, leave it to user
- ignore PI 1 / 0 and the fact that resulting binary will not work on them, simply add damned flags
- create CLANG method for armv7 and CLANG_armv6 for backward compatibility with PI 1 / 0 (*)
- create CLANG method for armv6 and optimized CLANG_armv7

(*) is my currently the prefered plan...

Any ideas? Smile

(also posting it here for future documentation reference).

Re: Rapsberry PI - cpu dilemma [message #53845 is a reply to message #53840] Sat, 09 May 2020 06:11 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1377
Registered: December 2006
Ultimate Contributor
IMHO,
1) create CLANG method for armv7 and CLANG_armv6 for backward compatibility (maximum performance)
2) cross-compilation for Pi (nobody really wants to compile on Pi itself)
3) optimize code for small platform the way game developers do that (no exceptions, no RTTI). There is plenty of other stuff which can be optimized.

Basically, game developers have been doing this for decades. Just follow their steps ... Cool


Regards,
Novo

[Updated on: Sat, 09 May 2020 06:14]

Report message to a moderator

Re: Rapsberry PI - cpu dilemma [message #53846 is a reply to message #53840] Sat, 09 May 2020 06:29 Go to previous messageGo to next message
amrein is currently offline  amrein
Messages: 278
Registered: August 2008
Location: France
Experienced Member
It's just an opinion: completely useless complexity. If someone want to optimize their final binaries, they will add the correct flags themselves according to their c++ compiler.

We don't do this for amd, amd rizen of intel, so why bother?

Note: Raspberry Pi 2 Model B v1.2 and several other Raspberry Pi are ARM8 and you can boot some of them with the 64 kernel (available in the default Rasbian distribution). So, do we need to enable 64 bit support too?

https://en.wikipedia.org/wiki/Raspberry_Pi

To much complexity for small return on investment.
Re: Rapsberry PI - cpu dilemma [message #53847 is a reply to message #53846] Sat, 09 May 2020 07:08 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1377
Registered: December 2006
Ultimate Contributor
amrein wrote on Sat, 09 May 2020 00:29

We don't do this for amd, amd rizen of intel, so why bother?

Do you mean why somebody wants to compile code without exception support?
For the same reason why Sony removed exception support from Clang for their PlayStation 4, which is based on amd rizen.
Exception support is a complicated thing, especially on 32-bit platforms.
World of small devices is very different from regular PCs. People do care about instruction cache misses there.


Regards,
Novo
Re: Rapsberry PI - cpu dilemma [message #53848 is a reply to message #53847] Sat, 09 May 2020 07:32 Go to previous messageGo to next message
amrein is currently offline  amrein
Messages: 278
Registered: August 2008
Location: France
Experienced Member
What I mean is: we don't need to bother because if a developer needs to (say, he wants to gain 1 ms on his embedded application for x reasons), he will find his way himself.

We don't need to do anything.

[Updated on: Sat, 09 May 2020 07:34]

Report message to a moderator

Re: Rapsberry PI - cpu dilemma [message #53849 is a reply to message #53845] Sat, 09 May 2020 10:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14154
Registered: November 2005
Ultimate Member
Novo wrote on Sat, 09 May 2020 06:11
IMHO,
2) (nobody really wants to compile on Pi itself)


Actually, it is not as bad. Yes, it is about 5-10 times slower, but it reached my usability limit.

Mirek
Re: Rapsberry PI - cpu dilemma [message #53850 is a reply to message #53849] Sat, 09 May 2020 10:23 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14154
Registered: November 2005
Ultimate Member
Unfortunately, I have just found that CLANG crashes when compiling theide for armv7, so the whole thing is sort of pointless now...
Re: Rapsberry PI - cpu dilemma [message #53856 is a reply to message #53850] Sat, 09 May 2020 17:16 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1377
Registered: December 2006
Ultimate Contributor
mirek wrote on Sat, 09 May 2020 04:23
Unfortunately, I have just found that CLANG crashes when compiling theide for armv7, so the whole thing is sort of pointless now...

Clang crashes when compiling BenchmarkTess on Intel. This is not a reason to stop supporting Intel/AMD. Rolling Eyes
Eventually, Clang will be fixed and ARM will become a major platform.
It is good to be ready for that, IMHO.


Regards,
Novo
Re: Rapsberry PI - cpu dilemma [message #53857 is a reply to message #53848] Sat, 09 May 2020 17:25 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1377
Registered: December 2006
Ultimate Contributor
amrein wrote on Sat, 09 May 2020 01:32
What I mean is: we don't need to bother because if a developer needs to (say, he wants to gain 1 ms on his embedded application for x reasons), he will find his way himself.

We don't need to do anything.

It is not just "1 ms". All these optimizations are about running code several times faster and using several times less memory.
Compiler is not a magic wand. -O3 enables almost all optimizations, but you still need to tell your compiler in the code that a particular data structure is moveable ...
The same story is with aliasing ...


Regards,
Novo
Re: Rapsberry PI - cpu dilemma [message #53858 is a reply to message #53850] Sat, 09 May 2020 18:05 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1377
Registered: December 2006
Ultimate Contributor
mirek wrote on Sat, 09 May 2020 04:23
Unfortunately, I have just found that CLANG crashes when compiling theide for armv7, so the whole thing is sort of pointless now...

Most likely, cross-compiler won't crash Rolling Eyes


Regards,
Novo
Re: Rapsberry PI - cpu dilemma [message #53863 is a reply to message #53857] Sat, 09 May 2020 20:55 Go to previous message
mirek is currently offline  mirek
Messages: 14154
Registered: November 2005
Ultimate Member
Novo wrote on Sat, 09 May 2020 17:25
amrein wrote on Sat, 09 May 2020 01:32
What I mean is: we don't need to bother because if a developer needs to (say, he wants to gain 1 ms on his embedded application for x reasons), he will find his way himself.

We don't need to do anything.

It is not just "1 ms". All these optimizations are about running code several times faster and using several times less memory.


Several times is gross exaggeration. So far I have seen about 20% speedup in single particular benchmark (basically Stream::Get32 loop).

That said, I think this is definitely worth investigating, for various reasons.

Mirek

Previous Topic: memcpy() and memmove() optimization
Next Topic: Optimizing DrawImage across platforms
Goto Forum:
  


Current Time: Tue Dec 03 00:31:51 CET 2024

Total time taken to generate the page: 0.02238 seconds