2006/7/27, Vinzent Hoefler <[EMAIL PROTECTED]>:
On Wednesday 26 July 2006 10:05, Andreas Berger wrote:
> Steve Williams wrote:
> > Michael Van Canneyt wrote:
> >> Which is why I think that it's better to have them as local
> >> functions, instead of having to introduce a lot of new functions.
> >>
> >> Local functions are very pascal-ish. C doesn't have it, which is
> >> why they can't use it.
> >> Let's use the language features to their full extent.
> >
> >    *procedure* SubTask(*var* x : *array of* Float);
> >    *var*
> >      /// Variables declared here have /|*private*|/ context./
> >      iam     : Integer;
> >      nt      : Integer;
> >      ipoints : Integer;
> >    *parallel*
> >      iam := OMP.Get_Thread_Num;  /// OMP library calls./
> >      nt  := OMP.Get_Num_Threads;
> >             ipoints := Length (x) *div* nt; /// size of partition/
> >      istart  := iam * ipoints;     /// starting array index/
> >             *if* iam = Pred (nt) *then*
> >        ipoints := Length (x) - istart; /// last thread may do more/
> >             SubDomain (x, istart, ipoints);
> >    *end*;
>
> Wouldn't it be better to write it like this:
>     procedure SubTask(var x: array of Float); *parallel*;
>     var
>        ...
>     begin
>        ...
>     end;

Actually no. I thought about it, but I didn't get through all that stuff
yesterday evening or else I would have updated the WiKi already. The
problem I see is that the parallel directive has more meanings
(basically it is the main directive). For that reason, I wouldn't want
to put in on the callee, but rather on the caller.

I think it would also be easier for the compiler then to detect alls
those parallel regions.

Let's see. Anyway, there was already more response I would have expected
after the days of silence. :)

What about the same approach as the class procedures?

Actually we have in a class the possibility to:
class procedure MyProc;
class function MyFunc: Integer;

Then we could very simply have:
parallel procedure ParallelBlock;
parallel function ParallelFunction; //if this can happen...


Also, I read that in example 1: "Variables declared here should have
shared context." In fact by default they have private context and to
me it looks like more normal. Maybe we should have a way to do the
contrary: specify that a variable has shared context... What others
think?

--
Alexandre Leclerc
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to