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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Everything You Know Is Wrong Date: Tue, 29 Dec 2015 15:58:24 -0600 Organization: JSA Research & Innovation Message-ID: References: NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1451426305 6753 24.196.82.226 (29 Dec 2015 21:58:25 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 29 Dec 2015 21:58:25 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:28929 Date: 2015-12-29T15:58:24-06:00 List-Id: "Dmitry A. Kazakov" wrote in message news:n5ugbf$fqr$1@speranza.aioe.org... > On 2015-12-29 17:57, G.B. wrote: > >> The point is that, since order does not matter among these parallel >> computations, and since parallel loops are not just fantasy, >> the possibility of postponement follows from parallel loops. > > Ada does not have parallel loops. The job is done! But Ada 202x most likely will. >> Consider F1 and F2 from a Pure package, X a variable of type T >> and T without progenitors: >> >> declare >> A : T := F1 (1,2,3); >> B : T := F2 (X); >> begin >> G (A, B); >> end; >> >> Is it impossible for a compiler to see that the initializing parts of >> the declarations of A and B are independent? > > No, because initialization of T may have side effects. Ada mandates B > initialized after A. Again, the "optimization" you wanted is done. Irrelevant - the compiler knows if any side-effects are possible (T is known to the compiler). That is going to be a conservative determination, but it will be true for many types (there is no side-effect for elementary types, for instance). Similarly, the compiler could know that other side-effects aren't possible, either by inspecting the code or by a declaration (many compilers have mechanisms for this, and Ada 202x is likely to get one as well). In any case, optimization is a very important part of compilation. Pretty much all Ada compilers make decisions like the one shown here every time you compile anything - the results would be terrible if they did not. For Janus/Ada, it makes a difference of up to 25% in time and space (compared to the unoptimized code). And of course one can optimize for many different things, including power usage -- I'm pretty sure the compilers used for mobile platforms do such optimizations as a matter of course. And that's for C -- Ada provides many more optimization possibilities because it has far more information about the program and the programmers intentions. Randy. > BTW, why do you believe that the same amount of computation performed > consecutively should require less energy or (not quite same) less battery > drain? It is no obvious. In any case it might depend on the specifics of > the battery, the board, the memory controller, the number of cores etc. > You cannot optimize for these, it would lead a combinatoric explosion of > targets. All that mess to save 0.1% drain? > > -- > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de