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: a07f3367d7,8060bed478dfa9cd X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.83.101 with SMTP id p5mr9874294wiy.0.1356837414425; Sat, 29 Dec 2012 19:16:54 -0800 (PST) Path: i11ni337233wiw.0!nntp.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!85.12.40.131.MISMATCH!xlned.com!feeder3.xlned.com!news.astraweb.com!border6.a.newsrouter.astraweb.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Ada 2012 automatic concurrency? Date: Thu, 27 Dec 2012 00:55:11 +0200 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 X-Trace: individual.net Je8Sb0bY+MwLju6PYgoFGAU3vP6W2LktVcQ0oSllTYevrvjcfsRyzuoKTQhrMbw0UJ Cancel-Lock: sha1:6Tqfjj724OhY4AKkdvYNpS3aJZ4= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Date: 2012-12-27T00:55:11+02:00 List-Id: On 12-12-25 19:26 , charleshixsn@earthlink.net wrote: > In the RM I read (page 209): NOTES 1 Concurrent task execution may be > implemented on multicomputers, multiprocessors, or with interleaved > execution on a single physical processor. On the other hand, whenever > an implementation can determine that the required semantic effects > can be achieved when parts of the execution of a given task are > performed by different physical processors acting in parallel, it may > choose to perform them in this way. > > ---------------- Does this imply that if I use protected types, that > the code will automatically be run concurrently on a multiprocessor > system, or might automatically be run concurrently? I believe that the second sentence in your quote has a more general meaning: that an Ada compiler is allowed to generate code that uses several processors or cores in parallel just to implement a logically sequential (single-task) computation. For example, if your program contains the two statements: x := a + b; y := a - b; and the target computer has two processors or cores capable of addition and subtraction, the Ada compiler may generate code that uses these two processors in parallel, one to compute a+b and the other to compute a-b. This is allowed, since the semantic effects are the same as when using one processor for both computations (assuming that none of these variables is declared "volatile"). So I don't think that your use or non-use of protected types (or tasks) is relevant to this RM sentence. > If so, does Gnat do this? I think not, but it might be a feature of the GCC back-end rather than the GNAT Ada front-end. However, many high-performance processors today have multiple "functional units" per core, and the processor core itself can issue or execute several instructions in parallel, from the same program, even if the compiler intends or assumes sequential execution when it generates the instruction sequence. This multi-issue feature of modern processors means that there is less interest and profit in doing such fine-grain parallelization at compile-time. At most, the compiler should sequence instructions according to the data dependencies, to let the processor run several consecutive data-independent instructions in parallel. For large-grain parallelization, you should use tasks. I don't know of any Ada compiler, including GNAT, that does automatic large-grain parallelization. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .