Re: PAR (Was: Embedded languages based on early Ada)



Dmitry A. Kazakov a écrit :

Why is it bad programming? Consider this:

declare
Sum : Numeric := 0.0;
begin in parallel
Sum := Sum + Integrate (Series (1..N);
Sum := Sum + Integrate (Series (N+1..2*N);
Sum := Sum + Integrate (Series (2*N+1..3*N);
...
end;

task type Integrate is
entry Run (Series : in Series_Type);
entry Result (Value : in out Numeric);
end Integrate;

Max : constant := 30;
T : array (1 .. Max) of Integrate;

declare
Sum : Numeric := 0.0;
S : Numeric;
begin
for K in T'Range loop
T (K).Start (Series ((K-1) * N + 1 .. K * N));
end loop;

for K in S'Range loop
T (K).Result (S);
Sum := Sum + S;
end loop;
end;

Typed directly from my mail client, sorry if it is not compiling :)

I don't see the point of PAR which create dynamically threads all the
time. A waste of time! The T tasks above can be reused during all the
application lifetime if necessary.

Pascal.

--

--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
.



Relevant Pages

  • Re: Need a Sanity Check
    ... I believe the calls to Text_IO may be potentially blocking. ... > task type Three_Entries_Type is ... > entry Start; ... > end loop; ...
    (comp.lang.ada)
  • Re: Tasks and Calendar
    ... ' Declare the variable. ... Dim oAppt as Outlook.AppointmentItem ... >> function returns an Items collection which you can loop through. ... >> For Each AnyObj in AnyCollection ...
    (microsoft.public.outlook.program_vba)
  • RE: Creating a que
    ... and entry count in a collection. ... if eo.Count> 0 then bMoreData = True ... At the beginning of the loop you assume this is the last time through the ... Then you go through each item in the Entries ...
    (microsoft.public.excel.programming)
  • Re: perl newbie: leaner code ideas
    ... > To learn Perl, I have written a bit of code that needs to do the following: ... Don't declare variables prematurely. ... if the foreach loop contriol variable has already been ... variable as a foreach loop contriol variable without an explicit "my". ...
    (comp.lang.perl)
  • Re: Spreadsheet::WriteExcel & worksheet->write
    ... Paul Lalli wrote: ... Do not double-quote variables without reason. ... Here you declare a brand new variable, within this loop. ...
    (comp.lang.perl.misc)