From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1a44c40a66c293f3 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news.glorb.com!newsfeed2.telusplanet.net!newsfeed.telus.net!edtnps89.POSTED!023a3d7c!not-for-mail Sender: blaak@METROID Newsgroups: comp.lang.ada Subject: Re: PAR (Was: Embedded languages based on early Ada) References: <1172192349.419694.274670@k78g2000cwa.googlegroups.com> <1172239820.896603.222120@k78g2000cwa.googlegroups.com> <113ls6wugt43q$.cwaeexcj166j$.dlg@40tude.net> <1i3drcyut9aaw.isde6utlv6iq.dlg@40tude.net> <1c61jqeqo68w$.2irtg70stnsa.dlg@40tude.net> <1vdieyr16h7ct$.1vuvfmghy8dzo$.dlg@40tude.net> <1l5727owshrjf$.uuylbc4ek430.dlg@40tude.net> From: Ray Blaak Organization: The Transcend Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 07 Mar 2007 20:17:40 GMT NNTP-Posting-Host: 208.66.252.228 X-Trace: edtnps89 1173298660 208.66.252.228 (Wed, 07 Mar 2007 13:17:40 MST) NNTP-Posting-Date: Wed, 07 Mar 2007 13:17:40 MST Xref: g2news2.google.com comp.lang.ada:9760 Date: 2007-03-07T20:17:40+00:00 List-Id: "Dmitry A. Kazakov" writes: > 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; This is also bad programming. The assignments are in parallel, overwriting each other, and it is not clear in a given statement what initial value of Sum is being worked with. As shown, this example looks like it is after a sequential summation, and that contradicts what the concurreny execution will do. A better program would be: declare Partial1 : Numeric; Partial2 : Numeric; Partial3 : Numeric; Sum : Numeric; begin begin in parallel Partial1 := Integrate (Series (1..N); Partial2 := Integrate (Series (N+1..2*N); Partial2 := Integrate (Series (2*N+1..3*N); end; Sum := Partial1 + Partial2 + Partial3; ... end; > > Ada already has synchronization constructs that need to be used to allow > > dependent concurrent items to coordinate properly. > > If so, then what would be the contribution of PAR? A syntactic convenience to tediously writing task bodies explicitly. Consider the immediate example above written out explicitly. > One important > proposition is that there is no any use in PAR running absolutely > independent code. So the question arise, what *exactly* PAR does with: > > 1. ":=" x 2 times > 2. "+" > 3. "-" > 4. "I" x 4 times The short answer is nothing. PAR spawns some tasks and waits for them to complete, nothing more or less. Parallel programing is hard. Relying on implicit optimization is what I recommend against, since in general it is a fiendishly complex problem as to how to sort out the interdependencies. Keep PAR simple, and leave it to the programmer to figure out the synchronization. -- Cheers, The Rhythm is around me, The Rhythm has control. Ray Blaak The Rhythm is inside me, rAYblaaK@STRIPCAPStelus.net The Rhythm has my soul.