[fpc-pascal] TComObject support

2005-05-31 Thread Sebastian Schuberth

Hi,

I'm trying to compile some Delphi 5 / 6 source code (a Windows Explorer 
shell extension) with FPC which derives a class from TComObject and uses 
a unit ComServ. Both seem to be not available under FPC, nor under 
Lazarus. Is there still a way to get support for these in FPC?


Thanks.

--
Sebastian Schuberth


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Optimizer in 2.0

2005-05-31 Thread Adrian Veith

Hi,

I am newbie with fpc (but not with pascal, which I use more than 20y now).
We have lot of existing delphi code, which some of it, I want to port to 
new platforms - and fpc looks like the right tool for it. But I am 
concerned about the speed. I did some basic benchmarks and it seems, 
that the optimizers has no effect in the 2.0 compiler (or the code even 
get's slower).


With the 1.9.8 compiler, the same code executes 4 times quicker - what 
happend (or what do I wrong) ?


For optimizing I use the -OG3rp3 switch  - is it still valid ?

Thanks,

Adrian.



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Optimizer in 2.0

2005-05-31 Thread Florian Klaempfl
Adrian Veith wrote:

> Hi,
> 
> I am newbie with fpc (but not with pascal, which I use more than 20y now).
> We have lot of existing delphi code, which some of it, I want to port to
> new platforms - and fpc looks like the right tool for it. But I am
> concerned about the speed. I did some basic benchmarks and it seems,
> that the optimizers has no effect in the 2.0 compiler (or the code even
> get's slower).

This shouldn't be the case in general, can you give examples or post the
benchmark? And don't try with useless code, we don't care about optimziations
which test only useless code which never happens in real programs.

> 
> With the 1.9.8 compiler, the same code executes 4 times quicker - what
> happend (or what do I wrong) ?
> 
> For optimizing I use the -OG3rp3 switch  - is it still valid ?
> 
> Thanks,
> 
> Adrian.
> 
> 
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] TObjectList in Contnrs in FCL (doc, usage)?

2005-05-31 Thread Tom Verhoeff
I would like to use TObjectList from Contnrs (because it occurs in
some Delphi application that I wish to compile with FreePascal).

There are two problems:

  (1)  The compiler does not find the unit Contnrs.  It turns out
   that this unit resides in

/usr/lib/fpc/2.0.1/units/i386-linux/fcl/contnrs.*

   which the compiler does not find by itself (it does find Classes in
   .../rtl/classes.*).
   Of course, I can change my fpc.cfg, but shouldn't this just work?
   Or should I do something else to use FCL units?

  (2)  The FCL (RTL?) documentation does not mention Contnrs (it does mention
   Classes).

It would be useful to include a link on "FCL - Free Component Library"
(fcl/fcl.html) to the online documentation



However, it is not completely clear to me where the boundary is between
RTL and FCL.  Classes is listed under FCL, and is documented under RTL.

Thanks,

Tom
-- 
E-MAIL: T.Verhoeff @ TUE.NL | Fac. of Math. & Computing Science
PHONE:  +31 40 247 41 25| Eindhoven University of Technology
FAX:+31 40 247 54 04| PO Box 513, NL-5600 MB Eindhoven
http://www.win.tue.nl/~wstomv/  | The Netherlands

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TObjectList in Contnrs in FCL (doc, usage)?

2005-05-31 Thread Peter Vreman
> I would like to use TObjectList from Contnrs (because it occurs in
> some Delphi application that I wish to compile with FreePascal).
>
> There are two problems:
>
>   (1)  The compiler does not find the unit Contnrs.  It turns out
>that this unit resides in
>
>   /usr/lib/fpc/2.0.1/units/i386-linux/fcl/contnrs.*
>
>which the compiler does not find by itself (it does find Classes in
>.../rtl/classes.*).
>Of course, I can change my fpc.cfg, but shouldn't this just work?
>Or should I do something else to use FCL units?

It is part of the default fpc.cfg. The * includes all subdirs. The
compiler does not know all paths by default. That is a design decission.
Because it is unknown which other packages the fcl depends on since that
is different per target.

-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl




___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Optimizer in 2.0

2005-05-31 Thread Adrian Veith
It shows with useless code like simple nested for .. to loops, but also 
with some more useful code like the attached RSA_Angriff from the C'T 
magazine.


My results are with:

fpc -Sd -OG3rp3 -XX RSA_Angriff_D5.dpr

5266 ms

with:

fpc -Sd -XX RSA_Angriff_D5.dpr

4844 ms

The unoptimized code is faster than the optimized code.

(BTW. I choosed an example where the Delphi compiler is really worse ;-) 
: 65953 ms)


Same picture with the whet.pas (whether or not the whetstone benchmark 
is useful) from your source distribution.


With optimization on:  7393.72 MIPS

With optimization off:  8368.20 MIPS

cheers,

Adrian.

Florian Klaempfl schrieb:


Adrian Veith wrote:

 


Hi,

I am newbie with fpc (but not with pascal, which I use more than 20y now).
We have lot of existing delphi code, which some of it, I want to port to
new platforms - and fpc looks like the right tool for it. But I am
concerned about the speed. I did some basic benchmarks and it seems,
that the optimizers has no effect in the 2.0 compiler (or the code even
get's slower).
   



This shouldn't be the case in general, can you give examples or post the
benchmark? And don't try with useless code, we don't care about optimziations
which test only useless code which never happens in real programs.

 


With the 1.9.8 compiler, the same code executes 4 times quicker - what
happend (or what do I wrong) ?

For optimizing I use the -OG3rp3 switch  - is it still valid ?

Thanks,

Adrian.



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
   




___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

 

program RSA_Angriff_D5;
(* Benchmarkversion testet Laufzeitverhalten primitiver Datentypen.
 *  - Konsolenprogramm
 *  - Auswahl zwischen bitorientierter Routine mit aufwändiger Rekursion 
DoPrim2()
 *und BruteForce-Routine DoPrimBruteForce() schlicht durch Auskommentieren 
in main()
 *  - zu zerlegende Zahl als BigNumber definiert.
 *
 *  Anmerkung: DoPrimBruteForce() findet auch kleine Primfaktoren,
 * DoPrim2() ignoriert diese, da RSA-Paare immer große Primfaktoren 
haben
 * (thats a bug, but also a feature)
*)

{$APPTYPE CONSOLE}
uses
SysUtils,
Windows;

const
  BigNumber: int64 = 34571237124234713;

procedure DoPrimBruteForce(NumberToCrunch: int64);
var i, j, UBound: int64; UBoundC: Comp;
begin
  i := 3;
  // ohne den Umweg über eine Gleitkommazahl
  // schafft Delphi das nicht
  UBoundC := NumberToCrunch;
UBound := Round(Sqrt(UBoundC));
while i < UBound do
  begin
if NumberToCrunch mod i = 0 then
begin
  j := NumberToCrunch div i;
  Writeln(i, ' * ', j, ' = ', j * i);
end;
Inc(i,2);
  end;
end;

procedure DoPrim2(NumberToCrunch: int64);
var UBound, z: int64;

  procedure Prim(
n: Integer;   // Bitmaske bis m-te Stelle, also 2^m - 1
m: Integer;   // Stelle (Zweierpotenz)
i,// 1. Kandidat für Primzahl
j,// 2. Kandidat für Primzahl
res: int64);   // bisher auf m Stellen synthetisiertes Produkt
  var
product: int64;
z0: int64;
m1, n1: Integer;
im, jm: int64;
  begin
product := i * j;   // Überlauf? dann Ende der Rekursion

// Rekursion bricht ab, wenn
//   - 1. Kandidat größer als Wurzel der Zahl
//   - Produkt zu groß
//   - m wegen überlauf negativ wird
if (i < UBound) and (product < z) and (m > 0) then
begin
z0 := z and n;   // Ausfiltern der relevanten 
Stellen
m1 := m shl 1; // nächste Stelle
n1 := n or m1; // Bitmaske erweitern

// Tiefensuche rekursiv!
// Es gibt vier mögliche Fälle, je zwei pro Kandidat
// zwei davon gehen in die Rekursion
// relevant sind nur m Stellen

if (res and n) = z0// +0, +0 (i, j 
unverändert)
then Prim(n1, m1, i, j, res);

im := i or m; // m-tes Bit der Kandidaten 
setzen
jm := j or m;
// Testen ob die letzten m Stellen des Kandidatenprodukts stimmen
res := im * j;
if (res and n) = z0// +1, +0 (m-tes Bit von i gesetzt)
  then Prim(n1, m1, im, j, res);
res := jm * i; // +0, +1 (m-tes Bit von j gesetzt)
if (res and n) = z0
then Prim(n1, m1, i, jm, res);
res := im * jm;// +1, +1 (m-tes Bit von i,j gesetzt)
if (res and n) = z0
then Prim(n1, m1, im, jm, res);
end else
begin // Rekursion bricht ab. Stimmt das Produkt etwa?
if (i 

Re: [fpc-pascal] TObjectList in Contnrs in FCL (doc, usage)?

2005-05-31 Thread Michael Van Canneyt



On Tue, 31 May 2005, Tom Verhoeff wrote:


I would like to use TObjectList from Contnrs (because it occurs in
some Delphi application that I wish to compile with FreePascal).

There are two problems:

 (1)  The compiler does not find the unit Contnrs.  It turns out
  that this unit resides in

/usr/lib/fpc/2.0.1/units/i386-linux/fcl/contnrs.*

  which the compiler does not find by itself (it does find Classes in
  .../rtl/classes.*).
  Of course, I can change my fpc.cfg, but shouldn't this just work?
  Or should I do something else to use FCL units?

 (2)  The FCL (RTL?) documentation does not mention Contnrs (it does mention
  Classes).

It would be useful to include a link on "FCL - Free Component Library"
(fcl/fcl.html) to the online documentation



However, it is not completely clear to me where the boundary is between
RTL and FCL.  Classes is listed under FCL, and is documented under RTL.


Classes is RTL. I will update the web page.

All non-visual VCL components (or their equivalents) will end up in the
FCL. The classes unit is an exception, since it is tightly integrated
with the Compiler/RTL. The division is compatible to Kylix/Delphi 7 or
higher.

Michael.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Optimizer in 2.0

2005-05-31 Thread Peter Vreman
> It shows with useless code like simple nested for .. to loops, but also
> with some more useful code like the attached RSA_Angriff from the C'T
> magazine.
>
> My results are with:
>
> fpc -Sd -OG3rp3 -XX RSA_Angriff_D5.dpr
>
> 5266 ms
>
> with:
>
> fpc -Sd -XX RSA_Angriff_D5.dpr
>
> 4844 ms
>
> The unoptimized code is faster than the optimized code.

Try without regvars. It is a known issue that register variables don't
produce better code on intel cpus because it increase register pressure.






___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal