Re: [fpc-pascal] code optimization

2010-09-23 Thread Adrian Veith
On 23.09.2010 17:03, Jonas Maebe wrote: > > On 23 Sep 2010, at 16:59, Adrian Veith wrote: > >> I analyzed your code - I think the problem is the array element address >> calculation of the fpc compiler. You have a lot of code like >> Bar[MinValley] etc. The delphi compile uses the lea assembler c

Re: [fpc-pascal] code optimization

2010-09-23 Thread Paulo Costa
On 23/09/2010 18:09, stefan...@web.de wrote: Eduardo wrote: Can you try optimize for size? In some cases, it reduces L2 / L3 cache miss and runs faster than O3. It happens in other compilers and languages too. I just tried it: The code gets even slightly larger and much slower (almost a f

Re: [fpc-pascal] code optimization

2010-09-23 Thread stefan077
> Eduardo wrote: > >Can you try optimize for size? In some cases, it reduces L2 / L3 cache >miss and runs faster than O3. It happens in other compilers and >languages too. > I just tried it: The code gets even slightly larger and much slower (almost a factor of 2). __

Re: [fpc-pascal] code optimization

2010-09-23 Thread Jonas Maebe
On 23 Sep 2010, at 16:59, Adrian Veith wrote: I analyzed your code - I think the problem is the array element address calculation of the fpc compiler. You have a lot of code like Bar[MinValley] etc. The delphi compile uses the lea assembler code for this, whereas fpc calculates the address of

Re: [fpc-pascal] code optimization

2010-09-23 Thread Adrian Veith
Hi Stefan, I analyzed your code - I think the problem is the array element address calculation of the fpc compiler. You have a lot of code like Bar[MinValley] etc. The delphi compile uses the lea assembler code for this, whereas fpc calculates the address of one element with imul which is much s

[fpc-pascal] RichMemo in shared SO library - relocation error

2010-09-23 Thread Dibo
Hi, I have no problem with LCL and Richmemo in DLL, but on linux I can't build SO library with TRichMemo. I get this error: /usr/bin/ld: /home/dibo/Programowanie/Lazarus/components/richmemo/lib/x86_64-linux/richmemo.o: relocation R_X86_64_32S against `TC_RICHMEMO_RTFLOADSTREAM' can not be used

Re: [fpc-pascal] code optimization

2010-09-23 Thread stefan077
wrote: >My 2 cents: >looking at the code, i would assume that you can gain by using linked lists >with pointers instead of arrays and working with the index. This would reduce >the number of offset calculations. However, it means quite a rewrite. So, do >you really need more speed? My experi

Re: [fpc-pascal] Questions regarding arrays

2010-09-23 Thread Graeme Geldenhuys
On 23 September 2010 11:50, Michael Van Canneyt wrote: > > [ Snip: I'll see about what I can add to make it more clear ] Thanks. I just want the docs to be all that they can be. :-) > Take care that in this case you should not use a dynamic array to refer to > the memory allocated by the C API:

Re: [fpc-pascal] Questions regarding arrays

2010-09-23 Thread Michael Van Canneyt
On Thu, 23 Sep 2010, Graeme Geldenhuys wrote: On 23 September 2010 09:46, Michael Van Canneyt wrote: my FPC Language Reference docs with what you mentioned, or see if Michael van Canneyt could add that info into the official docs so others can benefit too. What do you want added ? I haven't

Re: [fpc-pascal] Questions regarding arrays

2010-09-23 Thread Graeme Geldenhuys
On 23 September 2010 09:50, Honza wrote: > > AFAIK yes as long as you don't break (it's possible using some wild > casting) the ref counting mechanism and handle the zero length case. In my case [working with the Xlib library], I will never have the case of a zero length array. So that I don't nee

Re: [fpc-pascal] Questions regarding arrays

2010-09-23 Thread Graeme Geldenhuys
On 23 September 2010 09:46, Michael Van Canneyt wrote: >> my FPC Language Reference docs with what you mentioned, or see if >> Michael van Canneyt could add that info into the official docs so >> others can benefit too. > > What do you want added ? I haven't seen anything which isn't already > ment

Re: [fpc-pascal] Questions regarding arrays

2010-09-23 Thread Honza
2010/9/23 Graeme Geldenhuys : > Out of interest. Do you know if dynamic array elements are in sequence > (storage area in memory) too - like static arrays? So could I do the > same as above, but instead of using a static array, use a dynamic > array, and pass the address of the first element to the

Re: [fpc-pascal] Questions regarding arrays

2010-09-23 Thread Michael Van Canneyt
On Thu, 23 Sep 2010, Graeme Geldenhuys wrote: Hi Michael, On 23 September 2010 00:49, Michael Müller wrote: So when the array memory is allocated by the calling function and freed by another function and you only what to be able to access the elements using the array braces you should use t

Re: [fpc-pascal] Questions regarding arrays

2010-09-23 Thread Graeme Geldenhuys
Hi Michael, On 23 September 2010 00:49, Michael Müller wrote: > > So when the array memory is allocated by the calling function and freed > by another function and you only what to be able to access the elements > using the array braces you should use the static array approach. But I > would defin