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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,103803355c3db607 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.220.230 with SMTP id pz6mr11280582pbc.3.1341250414765; Mon, 02 Jul 2012 10:33:34 -0700 (PDT) Path: l9ni10446pbj.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Keean Schupke Newsgroups: comp.lang.ada Subject: Re: GNAT (GCC) Profile Guided Compilation Date: Mon, 2 Jul 2012 10:26:58 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <38b9c365-a2b2-4b8b-8d2a-1ea39d08ce86@googlegroups.com> <982d531a-3972-4971-b802-c7e7778b8649@googlegroups.com> <520bdc39-6004-4142-a227-facf14ebb0e8@googlegroups.com> <4ff08cb2$0$6575$9b4e6d93@newsspool3.arcor-online.net> <4ff1d731$0$6582$9b4e6d93@newsspool3.arcor-online.net> NNTP-Posting-Host: 82.44.19.199 Mime-Version: 1.0 X-Trace: posting.google.com 1341250414 9269 127.0.0.1 (2 Jul 2012 17:33:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 2 Jul 2012 17:33:34 +0000 (UTC) In-Reply-To: <4ff1d731$0$6582$9b4e6d93@newsspool3.arcor-online.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=82.44.19.199; posting-account=T5Z2vAoAAAB8ExE3yV3f56dVATtEMNcM User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-07-02T10:26:58-07:00 List-Id: On Monday, 2 July 2012 18:15:28 UTC+1, Georg Bauhaus wrote: > On 02.07.12 00:57, Keean Schupke wrote: > > The real benefit (and performance gains) from profile guided compilatio= n come from correcting branch prediction. As such the gains will be most ap= parent when there is an 'if' statement in the inner loop of the code. Try s= omething where you are taking the sign of an int in the formula and have th= ree cases <0 =3D0 >0. >=20 >=20 > Thanks for your lucid words, I was mostly guessing at what profile > guided compilation might actually do. Indeed, now that I have started > playing with conditionals, the translations show very different effects > already, for variations of the procedure below, >=20 > procedure Compute_1D (A : in out Matrix_1D) is > begin > for K in A'First + Len + 1 .. A'Last - Len - 1 loop > case K mod Len is > when 0 | Len - 1 =3D> null; > when others =3D> > A (K) :=3D (A(K + 1) > + A(K - Len) > + A(K - 1) > + A(K + Len)) mod Num'Last; > end case; > if A (K) mod 6 =3D 0 then > A (K) :=3D (A (K) - 1) mod Num'Last; > else > A (K) :=3D K mod Num'Last; > end if; > end loop; > end Compute_1D; >=20 > Ada and C++ are mostly on a par without help from a profile > (the 2D approach is still better in the Ada case; perhaps mod 6 > isn't true for that many K). C++ gains 8%, Ada only 4%, though. >=20 >=20 > Cheers, > Georg As it happens, the branch predictor is quite good at predicting regular 'mo= d' patterns. See: http://en.wikipedia.org/wiki/Branch_predictor And look for the section on the two level adaptive predictor. I think Monte-Carlo techniques must be particularly sensitive to branch pre= dictor error, as each iteration the branching is controlled by a pseudo ran= dom number (and we hope the branch predictor cannot predict that). So if for each iteration you pick a random number, and that controls your b= ranch pattern in the inner loop, you should see a stronger effect from the = profile-guided optimisation. Cheers, Keean.