Re: [fpc-devel] weird syntax

2007-12-11 Thread Florian Klaempfl
Vinzent Hoefler schrieb:
> On Tuesday 11 December 2007 10:04, Michael Schnell wrote:
>> Andrew Haines wrote:
>>> Hi,
>>>
>>>
>>> Is it possible to make this work:
>>>
>>> if X > 3 or < 10 then ...
>>>
>>> of course it would be shorthand for: if (X>3) or (X<10) then
>> The "or" operator is stronger than the "<" operator by definition.
>> This can't be changed.
> 
> Neither needs to be. There is no operand, but two operators ("or <") in 
> the second expression, so you wouldn't even be able to apply precedence 
> rules.

Actually, the shorthand for this expression is
if true then
...
;)
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] weird syntax

2007-12-11 Thread Vinzent Hoefler
On Tuesday 11 December 2007 10:04, Michael Schnell wrote:
> Andrew Haines wrote:
> > Hi,
> >
> >
> > Is it possible to make this work:
> >
> > if X > 3 or < 10 then ...
> >
> > of course it would be shorthand for: if (X>3) or (X<10) then
>
> The "or" operator is stronger than the "<" operator by definition.
> This can't be changed.

Neither needs to be. There is no operand, but two operators ("or <") in 
the second expression, so you wouldn't even be able to apply precedence 
rules.


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


Re: [fpc-devel] Parallel Computing

2007-12-11 Thread Mattias Gaertner
On Tue, 11 Dec 2007 19:24:59 +0100 (CET)
Daniël Mantione <[EMAIL PROTECTED]> wrote:

> 
> 
> Op Tue, 11 Dec 2007, schreef Mark Morgan Lloyd:
> 
> > Florian Klaempfl wrote:
> > 
> > > > It is common in the scientistware I benchmark daily. The evil
> > > > geniuses parallelize their applications by placing a some OpenMP
> > > > hints in their source code.
> > > 
> > > Yes, but only some loops. But just imagine how OpenMP could help
> > > in parallelization of the compiler? It can't imo.
> > 
> > But in fairness a compiler is neither more nor less specialist than
> > heavy numbercrunching code. OpenMP parallel procedures should, as
> > one particular simple example, be able to improve Mandelbrot speed
> > significantly since there is minimal interaction between the areas
> > being calculated.
> > 
> > There's lots more people running big finite difference or TLM
> > models than are doing systems programming. Getting them interested
> > in a language that is more friendly than C or FORTRAN would be to
> > everybody's advantage.
> > 
> > I've got some cellular automaton stuff that I want to look at, and
> > while explicit threads are probably the way to go having implicit
> > parallelisation would be a very interesting alternative.
> 
> Manual threading is not very comfortable, that is not the point. The
> point is, if we were to spend a lot of time on a parallelization
> feature, we want to spend it well.
> 
> OpenMP is just one way and has its limitations.

True.
Maybe it would be good to first start the OpenMP library part - a unit
providing some functions to easily use light weight threads.


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


Re: [fpc-devel] Parallel Computing

2007-12-11 Thread Daniël Mantione


Op Tue, 11 Dec 2007, schreef Mark Morgan Lloyd:

> Florian Klaempfl wrote:
> 
> > > It is common in the scientistware I benchmark daily. The evil
> > > geniuses parallelize their applications by placing a some OpenMP
> > > hints in their source code.
> > 
> > Yes, but only some loops. But just imagine how OpenMP could help in
> > parallelization of the compiler? It can't imo.
> 
> But in fairness a compiler is neither more nor less specialist than heavy
> numbercrunching code. OpenMP parallel procedures should, as one particular
> simple example, be able to improve Mandelbrot speed significantly since there
> is minimal interaction between the areas being calculated.
> 
> There's lots more people running big finite difference or TLM models than are
> doing systems programming. Getting them interested in a language that is more
> friendly than C or FORTRAN would be to everybody's advantage.
> 
> I've got some cellular automaton stuff that I want to look at, and while
> explicit threads are probably the way to go having implicit parallelisation
> would be a very interesting alternative.

Manual threading is not very comfortable, that is not the point. The point 
is, if we were to spend a lot of time on a parallelization feature, we 
want to spend it well.

OpenMP is just one way and has its limitations.

Daniël___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Parallel Computing

2007-12-11 Thread Mark Morgan Lloyd

Florian Klaempfl wrote:

It is common in the scientistware I benchmark daily. The evil geniuses 
parallelize their applications by placing a some OpenMP hints in their 
source code.


Yes, but only some loops. But just imagine how OpenMP could help in
parallelization of the compiler? It can't imo.


But in fairness a compiler is neither more nor less specialist than heavy 
numbercrunching code. OpenMP parallel procedures should, as one particular 
simple example, be able to improve Mandelbrot speed significantly since there 
is minimal interaction between the areas being calculated.


There's lots more people running big finite difference or TLM models than are 
doing systems programming. Getting them interested in a language that is more 
friendly than C or FORTRAN would be to everybody's advantage.


I've got some cellular automaton stuff that I want to look at, and while 
explicit threads are probably the way to go having implicit parallelisation 
would be a very interesting alternative.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] weird syntax

2007-12-11 Thread Bram Kuijvenhoven

Michael Schnell wrote:

Andrew Haines wrote:

Is it possible to make this work:

if X > 3 or < 10 then ...

of course it would be shorthand for: if (X>3) or (X<10) then
  
The "or" operator is stronger than the "<" operator by definition. This 
can't be changed.
In C we have a logical or ("||") and a binary or ("|"), as there is no 
boolean type. In Delphi language there is only one operator "or", as the 
type defines the makeup of the operation. While this is nice, it 
prevents the "<" operator from being stronger that "or", as the "or" 
might be bitwise.


In C the operators &, |, && and || *all* have lower precedence than ==, !=, <, >, <= 
and >=. (As a consequence, in C you probably want to use parenthesis in an expression like (mask & 
0xF38A) == 0xF080.)

Though I also don't like the parenthesis in (X>3) or (X<10), I think it is not 
really a good plan to change the precedence of operators in FPC, since it encourages 
writing code that is not compatible with Pascal standards.

Regards,

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


Re: [fpc-devel] Parallel Computing

2007-12-11 Thread Florian Klaempfl
Daniël Mantione schrieb:
> 
> Op Tue, 11 Dec 2007, schreef Florian Klaempfl:
> 
>> Mattias Gärtner schrieb:
>>> Zitat von Michael Schnell <[EMAIL PROTECTED]>:
>>>
> Think about the alternative: It is much harder to implement the same
> parallel loop with TThread. So OpenMP makes parallel loops much easier
> to implement. For me this is the 'Delphi' way: Makes things easy and
> readable.
>
 Of course you are right. In the example of "parallel" loops It's _a_lot_
 easier to to use for the programmer. "Lightweight-threaded" stuff like
 parallel loops was not the original aim of ThreadEvents. The original
 target was a more "standard" use of threads. But it _can_ be used for
 parallel loops, too, and it follows the "Delphi-language-paradigms" a
 lot tighter than using TThread.

 I don't suppose that anybody will start implementing real parallel loops
 like suggested on the wiki page any time soon.
>>> The examples are very artificial to demonstrate the problems.
>>> Some real world examples / tutorials should be added on a new page. Parallel
>>> algorithms are seldom taught in books/schools/university, so programmers are
>>> not used to them. This is slowly improving.
>> For me the whole OpenMP approach is really artifical, I don't see a real
>> use in real world code for it honestly.
> 
> It is common in the scientistware I benchmark daily. The evil geniuses 
> parallelize their applications by placing a some OpenMP hints in their 
> source code.

Yes, but only some loops. But just imagine how OpenMP could help in
parallelization of the compiler? It can't imo.

> 
> However, MPI is de facto the standard for parallelization and this is most 
> used. There are people who believe OpenMP is more efficient than MPI 
> (directly reading from another threads its data is more efficient than 
> sending messages between processes). However, modern MPI implementations 
> use shared memory and RDMA between processes to counter this; I have 
> seen little practical evidence that OpenMP is faster than MPI.
> 
> Daniël
> 
> 
> 
> 
> ___
> fpc-devel maillist  -  fpc-devel@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel

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


[fpc-devel] IsMultiThread variable

2007-12-11 Thread Graeme Geldenhuys
Hi,

Do I need to set IsMultiThread variable or does it get done
automatically by FPC?


Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Parallel Computing

2007-12-11 Thread Michael Schnell



For me the whole OpenMP approach is really artifical, I don't see a real
use in real world code for it honestly
IMHO, it _would_ be nice to do a matrix multiplication like this (or 
according to proposal 2 with "parallel for"):


procedure MultMatrix(const mr, m1, m2: TMatrix;);
var 
 ll: integer;


 procedure MultLine (l: integer); parallel;
 var 
   i, j: Integer;

   sum: TMatrixElement;
 begin
   for i := 0 to length(m1)-1 do begin
 sum := 0;
 for j := 0 to length(m2)-1 do begin
   sum := sum + m1[l, j] * m2[j, i];
 end;
 mr[l, i] := sum;
   end;
 end;

begin
   for l = 0 to length(m1)-1 do begin
 MultLine(l);

   end;
end;


But as said, I suppose implementation of a compiler that can handle this 
might be too much work for anybody to start with that project.


-Michael

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


Re: [fpc-devel] Parallel Computing

2007-12-11 Thread Daniël Mantione


Op Tue, 11 Dec 2007, schreef Florian Klaempfl:

> Mattias Gärtner schrieb:
> > Zitat von Michael Schnell <[EMAIL PROTECTED]>:
> > 
> >>> Think about the alternative: It is much harder to implement the same
> >>> parallel loop with TThread. So OpenMP makes parallel loops much easier
> >>> to implement. For me this is the 'Delphi' way: Makes things easy and
> >>> readable.
> >>>
> >> Of course you are right. In the example of "parallel" loops It's _a_lot_
> >> easier to to use for the programmer. "Lightweight-threaded" stuff like
> >> parallel loops was not the original aim of ThreadEvents. The original
> >> target was a more "standard" use of threads. But it _can_ be used for
> >> parallel loops, too, and it follows the "Delphi-language-paradigms" a
> >> lot tighter than using TThread.
> >>
> >> I don't suppose that anybody will start implementing real parallel loops
> >> like suggested on the wiki page any time soon.
> > 
> > The examples are very artificial to demonstrate the problems.
> > Some real world examples / tutorials should be added on a new page. Parallel
> > algorithms are seldom taught in books/schools/university, so programmers are
> > not used to them. This is slowly improving.
> 
> For me the whole OpenMP approach is really artifical, I don't see a real
> use in real world code for it honestly.

It is common in the scientistware I benchmark daily. The evil geniuses 
parallelize their applications by placing a some OpenMP hints in their 
source code.

However, MPI is de facto the standard for parallelization and this is most 
used. There are people who believe OpenMP is more efficient than MPI 
(directly reading from another threads its data is more efficient than 
sending messages between processes). However, modern MPI implementations 
use shared memory and RDMA between processes to counter this; I have 
seen little practical evidence that OpenMP is faster than MPI.

Daniël___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Parallel Computing

2007-12-11 Thread Florian Klaempfl
Mattias Gärtner schrieb:
> Zitat von Michael Schnell <[EMAIL PROTECTED]>:
> 
>>> Think about the alternative: It is much harder to implement the same
>>> parallel loop with TThread. So OpenMP makes parallel loops much easier
>>> to implement. For me this is the 'Delphi' way: Makes things easy and
>>> readable.
>>>
>> Of course you are right. In the example of "parallel" loops It's _a_lot_
>> easier to to use for the programmer. "Lightweight-threaded" stuff like
>> parallel loops was not the original aim of ThreadEvents. The original
>> target was a more "standard" use of threads. But it _can_ be used for
>> parallel loops, too, and it follows the "Delphi-language-paradigms" a
>> lot tighter than using TThread.
>>
>> I don't suppose that anybody will start implementing real parallel loops
>> like suggested on the wiki page any time soon.
> 
> The examples are very artificial to demonstrate the problems.
> Some real world examples / tutorials should be added on a new page. Parallel
> algorithms are seldom taught in books/schools/university, so programmers are
> not used to them. This is slowly improving.

For me the whole OpenMP approach is really artifical, I don't see a real
use in real world code for it honestly.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] weird syntax

2007-12-11 Thread Michael Schnell

Andrew Haines wrote:

Hi,


Is it possible to make this work:

if X > 3 or < 10 then ...

of course it would be shorthand for: if (X>3) or (X<10) then
  
The "or" operator is stronger than the "<" operator by definition. This 
can't be changed.
In C we have a logical or ("||") and a binary or ("|"), as there is no 
boolean type. In Delphi language there is only one operator "or", as the 
type defines the makeup of the operation. While this is nice, it 
prevents the "<" operator from being stronger that "or", as the "or" 
might be bitwise.

if X > 3 or < -1 or = 4000 or = 100 then...
  

for me
 a  or = 100;
should mean a := a or 100;

:)


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


Re: [fpc-devel] Parallel Computing

2007-12-11 Thread Michael Schnell



I don't suppose that anybody will start implementing real parallel loops
like suggested on the wiki page any time soon.



The examples are very artificial to demonstrate the problems.
Some real world examples / tutorials should be added on a new page. Parallel
algorithms are seldom taught in books/schools/university, so programmers are
not used to them. This is slowly improving.
  
By "implement" I mean the creation of the _FP_compiler_. Of course for 
FP _users_ it would be _great_ to be be able to use parallel sections 
and I do suppose there are very decent applications for this. But I 
don't suppose that anybody any time soon has enough spare time to update 
the compiler to be able to automatically create parallel code. That is 
why IMHO "thread events" are more likely to be born.



Everywhere. :)

For example search for 'thread' and add at the bottom or in between a short
sentence with a link, like 'Another approach is ...' or 'Threads can
communicate via TEventThreads too, see ...'.
  

OK. I'll try to do this.
I had _hoped_ for a more automated feature of the wiki software :(. 


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


Re: [fpc-devel] weird syntax

2007-12-11 Thread Vincent Snijders

Andrew Haines schreef:

Hi,


Is it possible to make this work:

if X > 3 or < 10 then ...

of course it would be shorthand for: if (X>3) or (X<10) then


One way to write this (assuming x is an integer type):
if x in [4..9] then ...



I suppose also it would be possible then to do:

if X > 3 or < -1 or = 4000 or = 100 then...


if x in [4..high(integer), low(integer)..-1, 4000, 100] then


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


Re: [fpc-devel] weird syntax

2007-12-11 Thread Marco van de Voort
> Is it possible to make this work:
> 
> if X > 3 or < 10 then ...
> 
> of course it would be shorthand for: if (X>3) or (X<10) then
> 
> I suppose also it would be possible then to do:
> 
> if X > 3 or < -1 or = 4000 or = 100 then...

Not likely. See e.g. the FAQ about extensions:

http://www.freepascal.org/faq.var#extensionselect

"The extension must have real value. Anything that is only a shorter
notation does not apply, unless it is out of compatibility with an existing
Pascal/Delphi codebase. Practically it means it must make something possible
that can't be done otherwise or be a compability item"

The main reason is that typing is never limiting (and typing optimization can be
better solved with editor templates)
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel