[fpc-pascal] Common OpenMP syntax?

Andreas Berger Andreas at TheBergerClan.org
Wed Jul 26 12:05:53 CEST 2006


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;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20060726/21992ab9/attachment.html>


More information about the fpc-pascal mailing list