Recent

Recent Posts

Pages: 1 ... 8 9 [10]
91
FPC development / Compiler raised internal error when compiling RISCV and LoongArch
« Last post by TYDQ on May 18, 2025, 06:00:10 pm »
These days I have tried to compile my DIY efi app(Absolutely efi app,can only be executed in UEFI Firmware)(compiled elf file Will be translated to efi file,fpc compile the elf file and it will be translated to efi app by my elf2efi) as my app.
However, compiler terminated compiling when compiling elf file for RISCV64 or LoongArch64 and give a error like this(LoongArch64 is same when using bash build.sh loongarch64,RISCV64 is using bash build.sh riscv64):
(To build it easily,I write the build.sh,And my efi app source code and builds.sh in zip file is stubbed in this topic)
Code: Bash  [Select][+][-]
  1. Error: Compilation raised exception internally
  2. An unhandled exception occurred at $0000000000465BB7:
  3. EListError: List index exceeds bounds (0)
  4. $0000000000465BB7
  5. $0000000000465BF2
  6. $00000000006222D9
  7. $00000000006BA8EE
  8. $00000000006235A1
  9. $00000000006A6CA4
  10. $00000000006235A1
  11. $00000000006B5FD5
  12. $00000000006B7688
  13. $00000000006B90EE
  14. $00000000006B7655
  15. $00000000006B7D34
  16. $00000000006235A1
  17. $00000000005E994D
  18. $00000000006235A1
  19. $00000000006A1EEA
  20. $00000000006235A1
  21. fpintres.pas(3,10) Fatal: Internal error 2006012304
  22. Fatal: Compilation aborted
  23. sysinit.pas(3,10) Fatal: Internal error 2006012304
  24. Fatal: Compilation aborted
  25. si_prc.pas(3,10) Fatal: Internal error 2006012304
  26. Fatal: Compilation aborted
  27. kernel.pas(1,16) Fatal: Internal error 2006012304
  28. Fatal: Compilation aborted
These error occurs when compiling RISCV and LoongArch ELF which FPC already supported,other platform cannot occur this problem,this error is architectures-specfic.
I don't know whether my code is wrong or the fpc source code is wrong,I have compile the fpc source code by myself and git clone the fpc source code newest trunk.If my code is wrong,you should point out where.
92
The command

gcc --print-libgcc-file-name

prints the path for the actual gcc installation.
On opensuse tumbleweed (64 bit) it gives:
/usr/lib64/gcc/x86_64-suse-linux/14/libgcc.a

The -Fl option in the fpc.cfg needs only the path without libgcc.a .
93
General / Re: FPC for high-performance computing
« Last post by Martin_fr on May 18, 2025, 05:54:13 pm »
Code: Text  [Select][+][-]
  1. FPC 3.2.2 Unrolled  2578 ms
  2. verify = 17398848
  3. 397.21 MB/s

I tested his code with trunk / O3 and {$Optimization noLOOPUNROLL} to make sure trunk hadn't simply done more unroll already. But that made no difference.

Btw Core I7-8700K




I was actually surprised of the huge improvement. I know trunk had some work done. But in other tests, the gains were around 4% to 5%.

From what I have seen (commits / mail list) a lot of work went into the peephole optimizer. That are usually local optimizations (register usages over short bits of code, avoid storing to mem, change 2 statements to avoid wait cycles...)

I don't know if there was any work on other optimization parts such as DFA and the overall register allocation.
94
General / Re: FPC 3.2.2 - compilerproc problem with fpc_ansistr_unique
« Last post by Thaddy on May 18, 2025, 05:48:02 pm »
Hello,
I am faced with a problem that I can not solve:
when I use this source code (without SetLength), I get the message:
Strutils should not even touch that. (but you are always on the wrong side of the border of what is sensible)
It should use UniqueString instead,
95
General / Re: FPC 3.2.2 - compilerproc problem with fpc_ansistr_unique
« Last post by marcov on May 18, 2025, 05:44:03 pm »
Do you also declare it in the interface of the system unit?
96
BGRABitmap and LazPaint / Re: BGRAGtkBitmap
« Last post by TRon on May 18, 2025, 05:31:27 pm »
I am not sure that you have seen my previous post.
No, I indeed missed that post. But it doesn't really matter much as it is unrelated.

Quote
Tried Lazarus 4.0rc3 - still the same).
With the exception of unchecking the fpgui package after the selection of BGRABitmap in OPM and just before pressing the install button the result for me in attached picture (same as for 4.0 release btw).
97
Everything does work but I get two error messages. Screenshot attached shows the errors. How do I make them go away?
In the fpc.cfg used by the compiler is an entry that looks something like:
Code: [Select]
# path to the gcclib
#ifdef cpui386
-Fl/usr/lib/gcc/x86_64-linux-gnu/12
#endif
#ifdef cpux86_64
-Fl/usr/lib/gcc/x86_64-linux-gnu/12
#endif

Note the number at the end. This number as well as the location of the gcc dependencies might be located in another directory on your system. I am not that familiar with gcc to know if there is a default way to determine the exact location (there probably is one).

If not mistaken then usually package build-essential (debian based distros at least) takes care of retrieving these dependencies.
98
General / Re: FPC for high-performance computing
« Last post by LV on May 18, 2025, 05:27:17 pm »
@Martin_fr, could you run chacha20's code with loop unrolling using the fpc trunk compiler? Thanks.

Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. uses sysutils, strutils;
  4.  
  5. type
  6.   chacha20state = record
  7.     state: array[0..15] of dword;
  8.     keystream: array[0..15] of dword;
  9.     position: dword;
  10.   end;
  11.  
  12. procedure chacha20_set_counter(var state: chacha20state; counter: dword);
  13. begin
  14.   state.state[12] := counter;
  15.   state.position := 64;
  16. end;
  17.  
  18. procedure chacha20_init(var state: chacha20state; key, nonce: string; counter: dword=0);
  19. const
  20.   magic = 'expand 32-byte k';
  21. begin
  22.   fillchar(state, sizeof(state), 0);
  23.   move(magic[1], state.state[0], 16);
  24.   if length(key) > 32 then setlength(key, 32);
  25.   if key <> '' then move(key[1], state.state[4], length(key));
  26.   chacha20_set_counter(state, counter);
  27.   if length(nonce) > 12 then setlength(nonce, 12);
  28.   if nonce <> '' then move(nonce[1], state.state[13], length(nonce));
  29. end;
  30.  
  31. function rotl32(x, n: dword): dword; inline;
  32. begin
  33.   result := (x shl n) or (x shr (32-n));
  34. end;
  35.  
  36. procedure chacha20_quarterround(p: pdword; a, b, c, d: integer); inline;
  37. var
  38.   a_val, b_val, c_val, d_val: dword;
  39. begin
  40.   a_val := p[a];
  41.   b_val := p[b];
  42.   c_val := p[c];
  43.   d_val := p[d];
  44.  
  45.   a_val += b_val;
  46.   d_val := rotl32(d_val xor a_val, 16);
  47.   c_val += d_val;
  48.   b_val := rotl32(b_val xor c_val, 12);
  49.   a_val += b_val;
  50.   d_val := rotl32(d_val xor a_val, 8);
  51.   c_val += d_val;
  52.   b_val := rotl32(b_val xor c_val, 7);
  53.  
  54.   p[a] := a_val;
  55.   p[b] := b_val;
  56.   p[c] := c_val;
  57.   p[d] := d_val;
  58. end;
  59.  
  60. procedure chacha20_next_block(var state: chacha20state);
  61. var
  62.   i: integer;
  63. begin
  64.   move(state.state, state.keystream, 64);
  65.   for i := 1 to 10 do begin
  66.     // Column rounds
  67.     chacha20_quarterround(@state.keystream, 0, 4, 8, 12);
  68.     chacha20_quarterround(@state.keystream, 1, 5, 9, 13);
  69.     chacha20_quarterround(@state.keystream, 2, 6, 10, 14);
  70.     chacha20_quarterround(@state.keystream, 3, 7, 11, 15);
  71.     // Diagonal rounds
  72.     chacha20_quarterround(@state.keystream, 0, 5, 10, 15);
  73.     chacha20_quarterround(@state.keystream, 1, 6, 11, 12);
  74.     chacha20_quarterround(@state.keystream, 2, 7, 8, 13);
  75.     chacha20_quarterround(@state.keystream, 3, 4, 9, 14);
  76.   end;
  77.   for i := 0 to high(state.keystream) do
  78.     state.keystream[i] += state.state[i];
  79.   state.state[12] += 1;
  80.   state.position := 0;
  81. end;
  82.  
  83. procedure chacha20_xor(var state: chacha20state; data: pointer; len: dword);
  84. var
  85.   p: PByte;
  86.   remain, block_count, i: dword;
  87.   pData, pKey: PDWord;
  88. begin
  89.   p := data;
  90.   remain := 64 - state.position;
  91.  
  92.   if remain > 0 then begin
  93.     if remain >= 4 then begin
  94.       pData := PDWord(p);
  95.       pKey := @state.keystream[state.position div 4];
  96.       for i := 0 to (remain div 4) - 1 do begin
  97.         pData[i] := pData[i] xor pKey[i];
  98.       end;
  99.       inc(p, (remain div 4) * 4);
  100.       dec(len, (remain div 4) * 4);
  101.       inc(state.position, (remain div 4) * 4);
  102.       remain := remain mod 4;
  103.     end;
  104.  
  105.     if remain > 0 then begin
  106.       if remain > len then remain := len;
  107.       for i := 0 to remain - 1 do
  108.         p[i] := p[i] xor pbyte(@state.keystream[state.position + i])^;
  109.       inc(p, remain);
  110.       dec(len, remain);
  111.       inc(state.position, remain);
  112.     end;
  113.   end;
  114.  
  115.   block_count := len div 64;
  116.   if block_count > 0 then begin
  117.     pData := PDWord(p);
  118.     for i := 0 to block_count - 1 do begin
  119.       if state.position >= 64 then
  120.         chacha20_next_block(state);
  121.       pKey := @state.keystream[0];
  122.  
  123.       pData[0] := pData[0] xor pKey[0];
  124.       pData[1] := pData[1] xor pKey[1];
  125.       pData[2] := pData[2] xor pKey[2];
  126.       pData[3] := pData[3] xor pKey[3];
  127.       pData[4] := pData[4] xor pKey[4];
  128.       pData[5] := pData[5] xor pKey[5];
  129.       pData[6] := pData[6] xor pKey[6];
  130.       pData[7] := pData[7] xor pKey[7];
  131.       pData[8] := pData[8] xor pKey[8];
  132.       pData[9] := pData[9] xor pKey[9];
  133.       pData[10] := pData[10] xor pKey[10];
  134.       pData[11] := pData[11] xor pKey[11];
  135.       pData[12] := pData[12] xor pKey[12];
  136.       pData[13] := pData[13] xor pKey[13];
  137.       pData[14] := pData[14] xor pKey[14];
  138.       pData[15] := pData[15] xor pKey[15];
  139.  
  140.       inc(pData, 16);
  141.       state.position := 64;
  142.     end;
  143.     len := len mod 64;
  144.     p := PByte(pData);
  145.   end;
  146.  
  147.   if len > 0 then begin
  148.     if state.position >= 64 then
  149.       chacha20_next_block(state);
  150.     if len >= 4 then begin
  151.       pData := PDWord(p);
  152.       pKey := @state.keystream[state.position div 4];
  153.       for i := 0 to (len div 4) - 1 do begin
  154.         pData[i] := pData[i] xor pKey[i];
  155.       end;
  156.       inc(p, (len div 4) * 4);
  157.       dec(len, (len div 4) * 4);
  158.       inc(state.position, (len div 4) * 4);
  159.     end;
  160.     for i := 0 to len - 1 do
  161.       p[i] := p[i] xor pbyte(@state.keystream[state.position + i])^;
  162.     inc(state.position, len);
  163.   end;
  164. end;
  165.  
  166. const
  167.   size = 1024*1024*1024;
  168.  
  169. var
  170.   cc: chacha20state;
  171.   data: pointer;
  172.   start, end_: qword;
  173.  
  174. begin
  175.   chacha20_init(cc, DupeString('a', 32), DupeString('b', 12));
  176.   data := getmem(size);
  177.   start := GetTickCount64;
  178.   chacha20_xor(cc, data, size);
  179.   end_ := GetTickCount64;
  180.   writeln('FPC 3.2.2 Unrolled  ',end_-start, ' ms');
  181.   writeln('verify = ', pint32(@cc.keystream)^);
  182.   writeln(Format('%.2f MB/s', [(size/(1024*1024))/((end_-start)/1000)]));
  183.   readln;
  184. end.
  185.  
100
I faced this by using the gcc.exe - the gnu proxy to cc.exe when the path's not set (maybe on -nostdlib, too).

Check, if you use a clean/valid fpc.ini.
Pages: 1 ... 8 9 [10]

TinyPortal © 2005-2018