[Lazarus] Lazarus server back online

2021-12-28 Thread Marc Weustink via lazarus
Hi all, It took a bit longer than expected, but I'm happy to inform you that the Lazarus services are back online. For those interested in why it took longer, I'll explain at the end of the message. Marc On 24-12-2021 08:30, Marc Weustink wrote: Hi, On Monday 27 December 9.00 CET (8.00 GMT

Re: [Lazarus] Lazarus server back online

2021-12-28 Thread Mattias Gaertner via lazarus
On Tue, 28 Dec 2021 09:41:03 +0100 Marc Weustink via lazarus wrote: >[...] > To be continued... Oh dear. Thanks for the all the work! Mattias -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus

Re: [Lazarus] Lazarus server back online

2021-12-28 Thread Michael Van Canneyt via lazarus
On Tue, 28 Dec 2021, Marc Weustink via lazarus wrote: Hi all, It took a bit longer than expected, but I'm happy to inform you that the Lazarus services are back online. For those interested in why it took longer, I'll explain at the end of the message. [snip] Meanwhile it was 24:00 an

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Juha Manninen via lazarus
On Tue, Dec 28, 2021 at 3:29 AM Noel Duffy via lazarus < lazarus@lists.lazarus-ide.org> wrote: > So it appears to me that an unsigned pointer type is required in > UTFLengthFast. > Can you please create a patch for UTFLengthFast. You can upload it here or create a merge request in GitLab or anyth

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Martin Frb via lazarus
On 28/12/2021 11:52, Juha Manninen via lazarus wrote: On Tue, Dec 28, 2021 at 3:29 AM Noel Duffy via lazarus wrote: So it appears to me that an unsigned pointer type is required in UTFLengthFast. Can you please create a patch for UTFLengthFast. You can upload it here or create a mer

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Bart via lazarus
On Tue, Dec 28, 2021 at 11:52 AM Juha Manninen via lazarus wrote: > Can you please create a patch for UTFLengthFast. You can upload it here or > create a merge request in GitLab or anything. @Juha: can you please comment on my possible improvement using PopCnt instead of a multiplication with O

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Juha Manninen via lazarus
On Tue, Dec 28, 2021 at 1:45 PM Bart via lazarus < lazarus@lists.lazarus-ide.org> wrote: > @Juha: can you please comment on my possible improvement using PopCnt > instead of a multiplication with ONEMASK. > I confess I didn't remember what PopCnt does. I checked from the net. FPC implements it as

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Bart via lazarus
On Tue, Dec 28, 2021 at 12:08 PM Martin Frb via lazarus wrote: > I would like to see the generates assembler on M1, if that is possible? (for > code with optimization off, as well as code with whatever optimization was > used so far) @Noel: Here's example code (standalone) you can use to tes

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Bart via lazarus
On Tue, Dec 28, 2021 at 1:09 PM Juha Manninen via lazarus wrote: > I confess I didn't remember what PopCnt does. I checked from the net. > FPC implements it as internproc. > function PopCnt(Const AValue : QWord): QWord;[internproc:fpc_in_popcnt_x]; > I guess it translates to one x86_64 instruct

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Bart via lazarus
On Tue, Dec 28, 2021 at 1:09 PM Juha Manninen via lazarus wrote: >> I will patch the function using unsigned types where applicable. >> I will keep the loop variables unsigned though. > > > Yes, thank you. Done. Should that be merged to fixes? -- Bart -- _

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Marco van de Voort via lazarus
Op 12/28/2021 om 1:53 PM schreef Bart via lazarus: I just tested PopCnt vs Multiplication on win32 and win64. The version with PopCnt is appr. 3 times slower on both 32 and 64 bit! You need an appropriate minimal CPU with -Cp Try e.g. -Cpcoreavx  for core 3000 series and higher -- _

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Bart via lazarus
On Tue, Dec 28, 2021 at 2:46 PM Marco van de Voort via lazarus wrote: > You need an appropriate minimal CPU with -Cp > > > Try e.g. -Cpcoreavx for core 3000 series and higher Thanks for that. Up to PENTIUMM: PopCnt slower COREI : approximately equally fast COREAVX PopCnt slightly faster COREA

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Florian Klämpfl via lazarus
Am 28.12.2021 um 15:01 schrieb Bart via lazarus: On Tue, Dec 28, 2021 at 2:46 PM Marco van de Voort via lazarus wrote: You need an appropriate minimal CPU with -Cp Try e.g. -Cpcoreavx for core 3000 series and higher Thanks for that. Up to PENTIUMM: PopCnt slower COREI : approximately eq

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Marco van de Voort via lazarus
Op 12/28/2021 om 3:01 PM schreef Bart via lazarus: -Cpcoreavx for core 3000 series and higher Thanks for that. Up to PENTIUMM: PopCnt slower COREI : approximately equally fast COREAVX PopCnt slightly faster COREAVX2 PopCnt slightly faster On what machine did you test? The settings if for t

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Bart via lazarus
On Tue, Dec 28, 2021 at 3:31 PM Florian Klämpfl via lazarus wrote: > For X86, check for the define CPUX86_HAS_POPCNT (compile time!). Thanks. -- Bart -- ___ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Bart via lazarus
On Tue, Dec 28, 2021 at 3:39 PM Marco van de Voort via lazarus wrote: > On what machine did you test? The settings if for the generated code, > but the actual processor determines the effective speed. I have a Intel i5 7th generation on my Win10-64 laptop from approx. 2017 (so, it's really old f

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Florian Klämpfl via lazarus
Am 28.12.2021 um 15:50 schrieb Bart via lazarus: On Tue, Dec 28, 2021 at 3:39 PM Marco van de Voort via lazarus wrote: On what machine did you test? The settings if for the generated code, but the actual processor determines the effective speed. I have a Intel i5 7th generation on my Win10-6

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Bart via lazarus
On Tue, Dec 28, 2021 at 3:56 PM Florian Klämpfl via lazarus wrote: > > Crash at run time with sigill. Popcnt was introduced with Nehalem, so >10 > years ago. Thanks. Any other CPU's support something like this? -- Bart -- ___ lazarus mailing list

[Lazarus] Improved FPC JSON-RPC support

2021-12-28 Thread Michael Van Canneyt via lazarus
Hello, Thanks to the magic of RTTI and Invoke(), creating a JSON-RPC server has just become significantly easier ! Given an interface definition: IMyOtherInterface = interface ['{4D52BEE3-F709-44AC-BD31-870CBFF44632}'] Function SayHello : string; function Echo(args : TStringArray) :

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Marc Weustink via lazarus
On 27-12-2021 22:10, Noel Duffy via lazarus wrote: On 28/12/21 01:47, Juha Manninen via lazarus wrote: On Mon, Dec 27, 2021 at 1:44 AM Noel Duffy via lazarus < lazarus@lists.lazarus-ide.org> wrote: I need some help getting to the root of a problem with incorrect results on Apple hardware (M1,

Re: [Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

2021-12-28 Thread Noel Duffy via lazarus
On 29/12/21 01:26, Bart via lazarus wrote: fpc -al ulen.pas > This will produce the file ulen.s > You can attach or copy that here. File is attached. The output from running this program is: % ./ulen Signed version Len = -100663283 Unsigned version Len = 1 To add another wrinkle to this, th

[Lazarus] fpc bug with M1 [[was: Re: UTF8LengthFast returning incorrect results on AARCH64 (MacOS)]]

2021-12-28 Thread Martin Frb via lazarus
On 28/12/2021 22:05, Noel Duffy via lazarus wrote: On 29/12/21 01:26, Bart via lazarus wrote: fpc -al ulen.pas > This will produce the file ulen.s > You can attach or copy that here. File is attached. Thanks. And I think there is a bug in FPC This is the signed version # [43] Result += (p

Re: [Lazarus] fpc bug with M1 [[was: Re: UTF8LengthFast returning incorrect results on AARCH64 (MacOS)]]

2021-12-28 Thread Noel Duffy via lazarus
On 29/12/21 10:47, Martin Frb via lazarus wrote: On 28/12/2021 22:05, Noel Duffy via lazarus wrote: On 29/12/21 01:26, Bart via lazarus wrote: fpc -al ulen.pas > This will produce the file ulen.s > You can attach or copy that here. File is attached. Thanks. And I think there is a bug in FP

[Lazarus] Faster than popcnt [[Re: UTF8LengthFast returning incorrect results on AARCH64 (MacOS)]]

2021-12-28 Thread Martin Frb via lazarus
On 28/12/2021 15:50, Bart via lazarus wrote: On Tue, Dec 28, 2021 at 3:39 PM Marco van de Voort via lazarus wrote: On what machine did you test? The settings if for the generated code, but the actual processor determines the effective speed. I have a Intel i5 7th generation on my Win10-64 lap

Re: [Lazarus] fpc bug with M1 [[was: Re: UTF8LengthFast returning incorrect results on AARCH64 (MacOS)]]

2021-12-28 Thread Martin Frb via lazarus
On 28/12/2021 23:18, Noel Duffy via lazarus wrote: The assembler produced by 3.2.2 looks like this: # [43] Result += (pn8^ shr 7) and ((not pn8^) shr 6); ldr    x0,[sp] ldrsb    w0,[x0] mvn    w0,w0 mvn => bitwise not. And that applies to the whole register. So I guess "eor    w0

Re: [Lazarus] Faster than popcnt [[Re: UTF8LengthFast returning incorrect results on AARCH64 (MacOS)]]

2021-12-28 Thread Bart via lazarus
On Tue, Dec 28, 2021 at 11:35 PM Martin Frb via lazarus wrote: > I have a core I7-8600 > The diff between the old code and popcnt is less significant. > > old: 715 > pop: 695 > > But there is a 3rd way, that is faster. > add: 610 Not surprising that you should come up with a faster solution. IIR

Re: [Lazarus] Faster than popcnt [[Re: UTF8LengthFast returning incorrect results on AARCH64 (MacOS)]]

2021-12-28 Thread Marco van de Voort via lazarus
On 28-12-2021 23:35, Martin Frb via lazarus wrote: "nx" has a single "1" in each of the 8 bytes in a Qword (based on 64bit). If we regard each of this bytes as an entity of its own, then we can keep adding those "1". I also was thinking in that direction, but more about how to optimize tha