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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,99210dd26e04d959 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!news2.glorb.com!usenet.stanford.edu!newsfeed.berkeley.edu!ucberkeley!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Loops and parallel execution Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <4d3eeef7$0$6879$9b4e6d93@newsspool2.arcor-online.net> Date: Tue, 25 Jan 2011 17:37:03 +0100 Message-ID: NNTP-Posting-Date: 25 Jan 2011 17:37:07 CET NNTP-Posting-Host: 3b5b3c44.newsspool1.arcor-online.net X-Trace: DXC=S<>O_M>@P[jg`45cDR8l?oic==]BZ:afn4Fo<]lROoRa<`=YMgDjhgbjT0RSF^oPHl[6LHn;2LCVn7enW;^6ZC`d\`mfM[68DCck^W>M1I^CAd X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:17653 Date: 2011-01-25T17:37:07+01:00 List-Id: On Tue, 25 Jan 2011 16:40:38 +0100, Georg Bauhaus wrote: > A quick idea. Assume that some subprogram Op from package P > is reentrant (and does not depend on global state). Then, > > with P; > ... > for K in all First .. Last loop > P.Op (K); > end loop; > > should have the effect of the following being permitted: > > (a) to pick K from First .. Last in any order > > (b) to execute P (J) in parallel with P (K) for J, K from > First .. Last > > The same would be allowed for sufficiently simple expressions: > > for K in all First .. Last loop > L(K) := Standard."*" (K, 3); > end loop; > > Can this be borrowed from HPF (IIUC)? > Is pragma Pure (P) sufficient to signal reentrance? No, it is not sufficient because it is wrong. P cannot be pure because all instances of P.Op must be synchronized at the end of the "loop." You need some frame, context relatively to which P might become pure. "Embedded task", thread, fiber, call it as you want. If you have that at the language level, then it becomes no matter whether the thing executed on such a context is pure or not. This is similar to proper Ada tasks, you can access shared data from a task as you wish. If you do this inconsistently that is your problem (erroneous execution). The point is, if you are going to somehow derive concurrency stuff from a sequentially written program using pragmas and a "mind reading" compiler, I doubt that could go anywhere. If you want to add light-weight embedded in code tasking constructs a-la Occam, that might go, but I don't think that they could be much useful. You need to map them onto OS services in order to gain something, because normally there is no direct access to the cores. That is not light-weight. Have you some certain OS in mind? This thing you wanted in present Ada: task type Worker (Do_Me : not null access procedure (K : Integer)) is entry Op (K : Integer); end Worker; task body Worker is I : Integer; begin accept Op (K : Integer) do I := K; end Op; Do_Me (I); end Worker; procedure Print (K : Integer) is begin Put_Line (Integer'Image (K)); end Print; ... declare Threads : array (1..20) of Worker (Print'Access); begin for K in Threads'Range loop Threads (K).Op (K); end loop; end; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de