Recent

Author Topic: Optimization on Linux RpiOS aarch64 ?  (Read 3124 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Optimization on Linux RpiOS aarch64 ?
« on: October 08, 2021, 02:49:57 am »
Hello.

I noted that, on RPiOS (64 bit) aarch64, for some applications that access audio libraries or use BGRABitmap, using any fpc optimization (even O1) crash the application at init.

I noted too that Raspberry Pi OS (64 bit) still do no have hardware accelerated for Chromium or VLC.
https://forums.raspberrypi.com/viewtopic.php?t=275370#p1761738

Is it related?

And, more generally, does it exist a documentation with details of optimizations done for each level (O1, O2, O3, O4) ?

PS: Raspberry Pi OS (64 bit) is far to be usable because infinitely slower than Pi OS (32 bit) on the same machine, but this is a other story.

Thanks.

Fre;D
« Last Edit: October 08, 2021, 03:00:22 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Optimization on Linux RpiOS aarch64 ?
« Reply #1 on: October 08, 2021, 05:38:08 am »
https://www.freepascal.org/docs-html/prog/progsu58.html (the manual) sheds some light on optimization.

I have no real speed issues with RPi AARCH, on the contrary, I see considerable speed increase in some apps, but the system itself is still in its infancy, so many libraries need to mature. And indeed hardware audio and video acceleration is still not available for VLC and Chromium. I run AARCH64 on an RPi 4, just to test, but the brink of my work is still 32 bit on my other Pi's (ranging from 1 to 4, except 2)

BTW I can't get some of my own audio libraries (based on VC6) to work on 64 bit, but that is likely for lack of effort. Nowadays I am quite lazy. Pensionado syndrom...  I am considering to build an LLVM version of FPC if at all possible.
What does work, and really fast, is the number crunching on audio buffers. (Filters, delays, reverb, convolution, synthesis, not relying on external libraries) But I am stuck on audio output for now. Currently test with saving/loading wav. Cumbersome.

Can you show some of the crashing code in a full program?
« Last Edit: October 08, 2021, 06:08:47 am by Thaddy »
Specialize a type, not a var.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Optimization on Linux RpiOS aarch64 ?
« Reply #2 on: October 08, 2021, 06:27:29 am »
Hello Thaddy.

I used rpi 3 B with last Rpi OS aarch64, mainly to test msegui applications.
I do not have yet a rpi4.

I have good result with msegui + uos audio application (but the latency is worst than with the Rpi OS 32 bit):
https://github.com/fredvs/strumpract/releases/

Quote
Can you show some of the crashing code in a full program?
Huh, not yet, because it is all the Rpi OS aarch64 that refuse to boot now, I have to re-install it.

Fre;D

I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: Optimization on Linux RpiOS aarch64 ?
« Reply #3 on: October 08, 2021, 01:26:27 pm »
I run AARCH64 on an RPi 4, just to test, but the brink of my work is still 32 bit on my other Pi's (ranging from 1 to 4, except 2)

I used rpi 3 B with last Rpi OS aarch64, [snip], but the latency is worst than with the Rpi OS 32 bit)

It's interesting. I will need to install a RasbPi 4 (Raspbian OS): it seems - today - that your reviews are biased towards still installing a 32 bits OS rather than a 64 bits one, for stability and speed reasons.

« Last Edit: October 08, 2021, 01:28:25 pm by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Optimization on Linux RpiOS aarch64 ?
« Reply #4 on: October 08, 2021, 03:20:11 pm »
Hello Eric.

Both the Rpi3 b and Rpi4 have a ARM aarch64 CPU.

So it is possible to install on both a 32 or 64 bit OS.

But the Rpi4 is much more powerful and (following docs) is capable to fluently run the Rpi OS 64 (like Thaddy noted).

Anyway, it seems to me that, even for the Rpi4, it is safer to use the Rpi OS 32 because Rpi OS 64 is still in beta state.

Concerning MSEgui on the Rpi, it is working like charm and is, imho, the perfect widgetset for that machine.

And if you have a "Pure X" os (os without ténor widgetset installed, like GTK or Qt) MSEgui has no concurrent (but, of course, MSEgui can run also on os with ténor widgetset installed).

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Optimization on Linux RpiOS aarch64 ?
« Reply #5 on: October 08, 2021, 03:41:54 pm »
It's interesting. I will need to install a RasbPi 4 (Raspbian OS): it seems - today - that your reviews are biased towards still installing a 32 bits OS rather than a 64 bits one, for stability and speed reasons.
Well yes and no:
I would still - as of today recommend Raspberry Pi OS - as it now called - 32 bit for stability, but for some applications AARCH64 is much (about 30%) faster. Heey... Pi's are for experimenting... As I wrote this morning, I just have one (1) Pi with the beta. And that is just for testing.

Just to give an insight of what I tested for audio (including rant  ;D ):
Frederic VanMol's FFT/IFFT gets about 320 channels. Still used in FL studio, formerly FrutiyLoops.
My translation of Freeverb 3, C code by Jezar,  (mine is the one that is "borrowed" by Christian without due source mentioning, I wrote it 18 years ago. I wrote it for TobyBear) gives also a similar image: about 25%. Christian, when you are reading this, give proper due and restore the header after so many years. And mention that the VST host itself is based on MY code....You did much good for Pascal and audio, but you still claim code written by me and you know that!  It still makes me angry (somewhat.  8-) O:-))
In the case of Freeverb 3 I am not talking about the 32 bit float Intel version I made, but the pure Pascal version I made. And that is much faster than the 32 bit version compared to  AARCH64.

(FYI: The reverb is "borrowed" ad verbatim, the VST host is much improved and adapted by Christian and Tobias. I am not reaaaaally too angry.. >:D O:-) since I forgot who wrote the C version of the VST host originally. Mea Culpa....But at least the reference should be in my sources: I have always been very, very precise with that)
« Last Edit: October 08, 2021, 04:33:02 pm by Thaddy »
Specialize a type, not a var.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Optimization on Linux RpiOS aarch64 ?
« Reply #6 on: October 08, 2021, 04:03:22 pm »
Well yes and no:
I would still - as of today recommend Raspberry Pi OS - as it now called - 32 bit for stability, but for some applications AARCH64 is much (about 30%) faster.

Did you test also GUI applications?
Maybe on the Rpi4 some applications are faster but, trust me, on the Rpi3 the system is not stable.
Most of the case I have only 1 boot working, after playing a few and close+reboot the boot fails and I have to re-install with rpi-imager all the Rpi OS 64.
Also, with  Rpi OS 64 on Rpi3, after a "sudo apt-get update" the system crash.

A contrario, on the Rpi3 with Rpi OS 32, all is working like charm.

But I dont know about the behavior on Rpi4.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Optimization on Linux RpiOS aarch64 ?
« Reply #7 on: October 08, 2021, 04:07:12 pm »
Yes, Fred, and indeed there is some instability (well, a lot, but not directly related to your original question). That is also documented.
I suggest to follow the RaspBerry Pi website and the kernel beta's for that.

Oh, this may be important, I have no Pi 3's that run AARCH - only a single 4 -running 64 bits, alongside may others (about 7).
I will give it a try and report back. Will take  some days though.
« Last Edit: October 08, 2021, 04:22:19 pm by Thaddy »
Specialize a type, not a var.

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: Optimization on Linux RpiOS aarch64 ?
« Reply #8 on: October 08, 2021, 04:58:28 pm »
I use Manjaro ARM (for aarch64). It works on RPi 4. But sometimes OS shows the message that "disk space is low" so I suggest to delete the LibreOffice.

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Optimization on Linux RpiOS aarch64 ?
« Reply #9 on: October 08, 2021, 07:06:43 pm »
Quote from: Alextp link=topic=56636.msg421020#ymsg421020 date=1633705108
I use Manjaro ARM (for aarch64). It works on RPi 4. But sometimes OS shows the message that "disk space is low" so I suggest to delete the LibreOffice.
Well, depending on model: do you have a 2,4 or 8Gb model? With the 2 G I would simply add swap space. And are you really running a 8 G  card?
Specialize a type, not a var.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: Optimization on Linux RpiOS aarch64 ?
« Reply #10 on: October 09, 2021, 08:17:20 pm »
Hello.

After reinstalling many time Rpi OS 64 on the Rpi3 ( sometime the os crash after 2 minutes, sometime after a few more ) I have the chance to have once enough time to debug the problem.

To resume: without any optimization, all ok, the program runs like charm.
But with -O1 the program crash at loading.

gdb point to this:

 
Code: Pascal  [Select][+][-]
  1.  result:= defaultfunctional[longword(value) - longword(cl_functional)].name;

where defaultfunctional is defined with this:

Code: Pascal  [Select][+][-]
  1. const
  2. cl_functional = colorty($80000000);
  3. cl_lastfunctional =           cl_functional + 9;
  4.  
  5.  functionalcolorcount = integer(cl_lastfunctional)-integer(cl_functional);
  6.  
  7.  defaultfunctional: array[0..functionalcolorcount-1]
  8.                      of colorinfoty =
  9.    (
  10.     (name: 'cl_invalid';  rgb:               (blue: $ff; green: $ff; red: $ff; res: $00)), //0
  11.     (name: 'cl_default'; rgb:                (blue: $ff; green: $ff; red: $ff; res: $00)), //1
  12.     (name: 'cl_parent';  rgb:                (blue: $ff; green: $ff; red: $ff; res: $00)), //2
  13.     (name: 'cl_transparent'; rgb:            (blue: $ff; green: $ff; red: $ff; res: $00)), //3
  14.     (name: 'cl_brush';  rgb:                 (blue: $ff; green: $ff; red: $ff; res: $00)), //4
  15.     (name: 'cl_brushcanvas'; rgb:            (blue: $ff; green: $ff; red: $ff; res: $00)), //5
  16.     (name: 'cl_none';  rgb:                  (blue: $ff; green: $ff; red: $ff; res: $00)), //6
  17.     (name: 'cl_font';  rgb:                  (blue: $ff; green: $ff; red: $ff; res: $00)), //7
  18.     (name: 'cl_normal';  rgb:                (blue: $ff; green: $ff; red: $ff; res: $00))  //8
  19.    );
  20.  
 
What is not ok for -O1 in this code?

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018