Recent

Author Topic: FPC for ARM CPU with NEON?  (Read 9986 times)

ZXDunny

  • New member
  • *
  • Posts: 7
FPC for ARM CPU with NEON?
« on: June 14, 2011, 12:05:59 am »
Hi all - my first topic, please be gentle!

I'm habitually a windows user... well, I was until I got a shiny new Open Pandora handheld console and decided I really, really wanted to port my Delphi apps to it. I'm now running Debian Squeeze in a VirtualBox machine on my Win7 host. Given that I've not been using linux for long, I was very pleased to get be able to use the installation tutorial on the wiki relatively easily.

The result is that my most complex app, a BASIC interpreter builds and runs very nicely on the ARM-powered Pandora! Yay, go me :) I was very careful when writing the app to make it as non-Delphi/Windows dependent as possible, and it's paid off.

But anyway, onto my question.

The Pandora's CPU is quite a recent ARM and supports NEON floating-point operations. As my interpreter relies heavily on floating point, I'd like to build it with NEON floating point operations enabled. This doesn't seem to be available as a default. I tried inserting the parameters into the command line when building (-Cfneon, iirc) which doesn't appear to work on FPC 2.4.2.

I surmised that maybe these options were not available in that version of FPC, so I'm just reinstalling Debian - I have no idea how to uninstall FPC - and having a bash at installing Lazarus/FPC for ARM using FPC 2.5.1, which from the information I've read should support NEON. My question (finally) is this:

How do I modify the "Lazarus_first_time" script to build a NEON capable FPC/Lazarus build, and enable NEON in my application?

Bear in mind that although I'm not averse to modifying and running scripts in a terminal, I'm only a windows user starting out in linux, and will need very explicit instructions.

Can anyone help me please?

Cheers,

D.

Laksen

  • Hero Member
  • *****
  • Posts: 614
    • J-Software
Re: FPC for ARM CPU with NEON?
« Reply #1 on: June 14, 2011, 07:31:27 am »
Since FPC doesn't really support vector extensions currently it doesn't have an NEON mode. NEON is mostly the SIMD part of new ARM coprocessors

Just select VFPv2/VFPv3 instead. If your processor has NEON then it probably has VFP too

ZXDunny

  • New member
  • *
  • Posts: 7
Re: FPC for ARM CPU with NEON?
« Reply #2 on: June 14, 2011, 04:52:12 pm »
Since FPC doesn't really support vector extensions currently it doesn't have an NEON mode. NEON is mostly the SIMD part of new ARM coprocessors

Just select VFPv2/VFPv3 instead. If your processor has NEON then it probably has VFP too

The Pandora does have VFP3, so I suppose I'll have to use that - I'm going to have a go at modifying the script now. From what I can tell, it sets up a script that calls "as" to inject the -meabi=5 parameter, so I should be able to add -mfpu=vfpv3 to that and then instruct FPC to (hopefully) use vfp3 with the -Cfvfp3 parameter... In theory :)

I think I read somewhere that the assembler might support NEON, but if FPC doesn't emit NEON opcodes then I think that might be somewhat redundant. We'll see :)

Thanks,

D.

Laksen

  • Hero Member
  • *****
  • Posts: 614
    • J-Software
Re: FPC for ARM CPU with NEON?
« Reply #3 on: June 14, 2011, 07:21:09 pm »
NEON is mostly just like SSE on x86. FPC inline assembler probably supports the instructions, but the compiler can't vectorize loops and stuff like that automatically. That was what I meant with it. If you add -CfVFPv3 to the fpc command line it should automatically instruct the linker to use vfp. the meabi=5 injection is the only thing needed to be injected to gas

ZXDunny

  • New member
  • *
  • Posts: 7
Re: FPC for ARM CPU with NEON?
« Reply #4 on: June 14, 2011, 09:54:23 pm »
NEON is mostly just like SSE on x86. FPC inline assembler probably supports the instructions, but the compiler can't vectorize loops and stuff like that automatically. That was what I meant with it. If you add -CfVFPv3 to the fpc command line it should automatically instruct the linker to use vfp. the meabi=5 injection is the only thing needed to be injected to gas

I see. Unfortunately, my current install of Lazarus (FPC 2.4.2) doesn't seem to recognise the -CfVFP3 argument - where should it be specified in the UI? I tried in project options, other, custom options and I just get an error when I try to build my app.

I tried updating to FPC 2.5.1, but the lazarus_first_time script tries to download
Code: [Select]
ftp://ftp.freepascal.org/pub/fpc/dist/2.5.1/i386-linux/rpm/fpc-2.5.1-1.i686.rpmwhich doesn't exist :(

Have you any tips on how to "upgrade" my current FPC to a newer build? I'm afraid that I'm quite at sea trying to do this by myself - I even tried doing it manually as detailed here but although I managed to track down a 2.5.1 zip file, lazarus complains that "as" cannot be found. I tried manually running "as" from the terminal, and it just hangs indefinitely - this is using the version of binutils used by the script, too :(

Cheers,

D.