* compiler settings in AdaGIDE @ 2010-07-23 9:52 Ada novice 2010-07-23 11:56 ` Gautier write-only 2010-07-24 18:21 ` jonathan 0 siblings, 2 replies; 34+ messages in thread From: Ada novice @ 2010-07-23 9:52 UTC (permalink / raw) Hi, I'm using the AdaGIDE editor (version 7.45.2) together with the GNAT AdaCore libre compiler (release 2010) on a Win XP machine. I would like my codes to run as fast as possible and here is the content of a typical gnat.ago file that I use. Please let me know what improvements I can make in order for an Ada program to run in the minimum amount of time. I understand that setting the release mode makes a program bypass some checks and make it run faster. -gnatVa -O3 -gnatn -funroll-loops -gnatf -gnato WINDOWS_TARGET -- Begin compiler switches RELEASE <- active (current) build mode TRUE <- are gcc/gnatmake/main/target-dir of Release := these from Debug mode ? debug o2 false debug inlining false debug unroll_loops false debug suppress_all_checks false debug debug_info true debug integer_overflow_check true debug stack_check false debug trace_back false debug all_validity_checks false debug strip_all_symbols false debug profiling false debug verbose_details false debug all_warnings true debug build_in_place false release o2 true release inlining true release unroll_loops true release suppress_all_checks true release debug_info false release integer_overflow_check false release stack_check false release trace_back false release all_validity_checks false release strip_all_symbols true release profiling false release verbose_details true release all_warnings true release build_in_place false -- End compiler switches -- Begin Release mode commands -- End Release mode commands -- Begin run options prompt_arguments false ad_trace_back false -- End run options Thanks. YC ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 9:52 compiler settings in AdaGIDE Ada novice @ 2010-07-23 11:56 ` Gautier write-only 2010-07-23 14:23 ` Ada novice [not found] ` <f72678ba-23ce-4c9a-b17e-b33fbd45300d@l14g2000yql.googlegroups.com> 2010-07-24 18:21 ` jonathan 1 sibling, 2 replies; 34+ messages in thread From: Gautier write-only @ 2010-07-23 11:56 UTC (permalink / raw) In the "Compiler Options" box, you can add combinations of the following: -fpeel-loops -ftracer -funswitch-loops -fweb -frename-registers and look what happens. Also -O3 instead of -O2 is worth a look. For floating-point maths, you can try -mfpmath=sse -msse2 (or -msse3) If you look on the web for those switches, there are often ideas of other ones... In your sources, you can check (one at a time) the effects of the Inline pragma. HTH G. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 11:56 ` Gautier write-only @ 2010-07-23 14:23 ` Ada novice [not found] ` <f72678ba-23ce-4c9a-b17e-b33fbd45300d@l14g2000yql.googlegroups.com> 1 sibling, 0 replies; 34+ messages in thread From: Ada novice @ 2010-07-23 14:23 UTC (permalink / raw) Hi, Thanks for your kind help. As I mentioned earlier, I use -gnatVa -O3 -gnatn -funroll-loops -gnatf -gnato and so the -O3 is already there though the .ago file doesn't state it. But perhaps in AdaGIDE, the option -O3 is equivalent to: release o2 true release inlining true as written in the .ago file in my earlier message. I have tried to put all of your options at once so as to have: -gnatVa -O3 -gnatn -funroll-loops -gnatf -gnato -fpeel-loops -ftracer - funswitch-loops -fweb -frename-registers -mfpmath=sse -msse3 but I didn't see improvements in the execution time. For the sample program that I'm testing, the options that I used previously run the code in 1538 s and with the new options (combination of yours and mine), it took 1546 s. The problem is that there's not much information available on the compiler options on the web. But I shall investigate each of the option that you supplied and also it can be a good idea to not put all these options at the same time. For now I read that -mfpmath=sse - msse3 should be very suitable to increase the execution speed. Thanks again. YC ^ permalink raw reply [flat|nested] 34+ messages in thread
[parent not found: <f72678ba-23ce-4c9a-b17e-b33fbd45300d@l14g2000yql.googlegroups.com>]
* Re: compiler settings in AdaGIDE [not found] ` <f72678ba-23ce-4c9a-b17e-b33fbd45300d@l14g2000yql.googlegroups.com> @ 2010-07-23 14:54 ` Georg Bauhaus 2010-07-23 15:16 ` Robert A Duff 0 siblings, 1 reply; 34+ messages in thread From: Georg Bauhaus @ 2010-07-23 14:54 UTC (permalink / raw) On 23.07.10 16:17, Ada novice wrote: > Hi, > Thanks for your kind help. As I mentioned earlier, I use > > -gnatVa -O3 -gnatn -funroll-loops -gnatf -gnato -O3 may already trigger inlining an loop unrolling. The GNAT Guides, including GCC docs, explain this. They have been installed with GNAT on your computer. The versions installed with your compiler should match the software installed, perhaps more than any other version of these same docs you find on the net. Last time I checked the sections on optimization in the GNAT docs recommend -O2 -funroll-loops IIRC. One thing you could do---after showing that your program is correct---is remove numeric overflow checking (-gnato). Or turn off all checks (-gnatp). The program is no standard Ada program then, but since your program is correct... :-) Another thing is playing with object sizes. Lots of risk and disappointment ahead, though! Sometimes a definition of a type can be altered such that its representation uses only 32 bits on some 64 bit computer, which may or may not be good for your program. > and so the -O3 is already there though the .ago file doesn't state it. > I have tried to put all of your options at once so as to have: > > -gnatVa -O3 -gnatn -funroll-loops -gnatf -gnato -fpeel-loops -ftracer - > funswitch-loops -fweb -frename-registers -mfpmath=sse -msse3 Does your program use floating point types? Georg ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 14:54 ` Georg Bauhaus @ 2010-07-23 15:16 ` Robert A Duff 2010-07-23 15:22 ` Georg Bauhaus 0 siblings, 1 reply; 34+ messages in thread From: Robert A Duff @ 2010-07-23 15:16 UTC (permalink / raw) Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes: > On 23.07.10 16:17, Ada novice wrote: >> Hi, >> Thanks for your kind help. As I mentioned earlier, I use >> >> -gnatVa -O3 -gnatn -funroll-loops -gnatf -gnato If you want speed, then you don't want -gnatVa. > One thing you could do---after showing that your program > is correct---is remove numeric overflow checking > (-gnato). To clarify: -gnato turns overflow checking ON -- it's off by default. >...Or turn off all checks (-gnatp). The program is no > standard Ada program then, but since your program is correct... :-) It's still a standard Ada program. - Bob ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 15:16 ` Robert A Duff @ 2010-07-23 15:22 ` Georg Bauhaus 2010-07-23 16:51 ` sjw 0 siblings, 1 reply; 34+ messages in thread From: Georg Bauhaus @ 2010-07-23 15:22 UTC (permalink / raw) On 23.07.10 17:16, Robert A Duff wrote: >> ...Or turn off all checks (-gnatp). The program is no >> standard Ada program then, but since your program is correct... :-) > > It's still a standard Ada program. Without -gnato? ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 15:22 ` Georg Bauhaus @ 2010-07-23 16:51 ` sjw 2010-07-23 18:03 ` Robert A Duff 0 siblings, 1 reply; 34+ messages in thread From: sjw @ 2010-07-23 16:51 UTC (permalink / raw) On Jul 23, 4:22 pm, Georg Bauhaus <rm.dash-bauh...@futureapps.de> wrote: > On 23.07.10 17:16, Robert A Duff wrote: > > >> ...Or turn off all checks (-gnatp). The program is no > >> standard Ada program then, but since your program is correct... :-) > > > It's still a standard Ada program. > > Without -gnato? -gnato is one of the things you have to do to make GNAT a conforming Ada compiler. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 16:51 ` sjw @ 2010-07-23 18:03 ` Robert A Duff 2010-07-23 18:27 ` Ada novice ` (2 more replies) 0 siblings, 3 replies; 34+ messages in thread From: Robert A Duff @ 2010-07-23 18:03 UTC (permalink / raw) sjw <simon.j.wright@mac.com> writes: > On Jul 23, 4:22�pm, Georg Bauhaus <rm.dash-bauh...@futureapps.de> > wrote: >> On 23.07.10 17:16, Robert A Duff wrote: >> >> >> ...Or turn off all checks (-gnatp). �The program is no >> >> standard Ada program then, but since your program is correct... :-) >> >> > It's still a standard Ada program. >> >> Without -gnato? Sure. How could compiler switches affect some property ("standardness") of the text of an Ada program? > -gnato is one of the things you have to do to make GNAT a conforming > Ada compiler. Well, not really. If you don't say -gnato, then GNAT is implicitly assuming "pragma Suppress(Overflow_Check);". That's a standard feature of Ada, and the compiler writer gets to decide how source text is represented. If you don't want that text as part of your program, say "-gnato". Similarly, if you say "-gnatn", GNAT is implicitly including "pragma Suppress(All_Checks);" as part of your program text. I realize this argument is a bit of a cheat. And I think overflow checks should be turned on by default. But I don't think it's a conformance issue, formally speaking -- GNAT conforms with or without -gnatn or -gnato. Without -gnatE (dynamic elaboration checks), on the other hand, GNAT is nonconforming, because it rejects some legal programs, and you can't play the above "source representation" game. I think it's good that it's nonconforming in this case, because the default behavior (static elaboration checks) is better than the standard way, and it doesn't harm portability. - Bob ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 18:03 ` Robert A Duff @ 2010-07-23 18:27 ` Ada novice 2010-07-23 20:33 ` Simon Wright 2010-07-23 19:31 ` Dmitry A. Kazakov 2010-07-23 20:34 ` Simon Wright 2 siblings, 1 reply; 34+ messages in thread From: Ada novice @ 2010-07-23 18:27 UTC (permalink / raw) Thanks for all the reading! It seems that I better keep -gnato (as I don't want to remove any numeric overlfow checking). Georg: Yes, I'm using floating point types (Long_float). I'll take away the -gnatVa as Robert suggested. Quote from Georg: "Last time I checked the sections on optimization in the GNAT docs recommend -O2 -funroll-loops IIRC" What's IIRC? In AdaGIDE, the optimization is mentioned in Options > settings as level O2. But writing -O2 -funroll-loops implies O3. Am I right? So then writing -O3 -funroll-loops contains redundant information. YC ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 18:27 ` Ada novice @ 2010-07-23 20:33 ` Simon Wright 0 siblings, 0 replies; 34+ messages in thread From: Simon Wright @ 2010-07-23 20:33 UTC (permalink / raw) Ada novice <posts@gmx.us> writes: > What's IIRC? If I Remember Correctly. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 18:03 ` Robert A Duff 2010-07-23 18:27 ` Ada novice @ 2010-07-23 19:31 ` Dmitry A. Kazakov 2010-07-23 21:01 ` Robert A Duff 2010-07-23 20:34 ` Simon Wright 2 siblings, 1 reply; 34+ messages in thread From: Dmitry A. Kazakov @ 2010-07-23 19:31 UTC (permalink / raw) On Fri, 23 Jul 2010 14:03:19 -0400, Robert A Duff wrote: > sjw <simon.j.wright@mac.com> writes: > >> -gnato is one of the things you have to do to make GNAT a conforming >> Ada compiler. > > Well, not really. If you don't say -gnato, then GNAT is implicitly > assuming "pragma Suppress(Overflow_Check);". Objection. Ada compiler should not assume anything not explicitly specified. Example: what about assuming raise Program_Error; at each even source line? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 19:31 ` Dmitry A. Kazakov @ 2010-07-23 21:01 ` Robert A Duff 2010-07-23 22:32 ` Peter C. Chapin 2010-07-24 1:48 ` BrianG 0 siblings, 2 replies; 34+ messages in thread From: Robert A Duff @ 2010-07-23 21:01 UTC (permalink / raw) "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes: >> Well, not really. If you don't say -gnato, then GNAT is implicitly >> assuming "pragma Suppress(Overflow_Check);". > > Objection. Ada compiler should not assume anything not explicitly > specified. I agree 100%. Overflow checks should be on by default, and you should have to do something explicit to turn them off. But we were talking about standard conformance, which is not quite the same as what compilers "should" do. >... Example: what about assuming > > raise Program_Error; > > at each even source line? Well, so long as there's an option to turn that malfeature off, it's standard conforming. But it's not a good idea, and the users of that compiler (if there are any) will complain loudly. ;-) - Bob P.S. I work for AdaCore, so I should note that my opinion that overflow checks should be turned on by default is my own personal opinion. AdaCore disagrees. The reason is that they are fairly expensive. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 21:01 ` Robert A Duff @ 2010-07-23 22:32 ` Peter C. Chapin 2010-07-24 1:48 ` BrianG 1 sibling, 0 replies; 34+ messages in thread From: Peter C. Chapin @ 2010-07-23 22:32 UTC (permalink / raw) On 2010-07-23 17:01, Robert A Duff wrote: > P.S. I work for AdaCore, so I should note that my opinion > that overflow checks should be turned on by default is > my own personal opinion. AdaCore disagrees. The reason > is that they are fairly expensive. Isn't that hardware dependent (the expense, I mean)? My understanding was that one some architectures overflow checking could be done with minimal... even zero... impact on a correct program. Peter ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 21:01 ` Robert A Duff 2010-07-23 22:32 ` Peter C. Chapin @ 2010-07-24 1:48 ` BrianG 1 sibling, 0 replies; 34+ messages in thread From: BrianG @ 2010-07-24 1:48 UTC (permalink / raw) Robert A Duff wrote: > P.S. I work for AdaCore, so I should note that my opinion > that overflow checks should be turned on by default is > my own personal opinion. AdaCore disagrees. The reason > is that they are fairly expensive. I assume you mean that the checks are expensive? :-):-):-) (Sorry, I couldn't resist!) --I can learn to resist -- Anything but temptation --I can learn to co-exist -- With anything but pain --I can learn to compromise -- Anything but my desires --I can learn to get along -- With all the things I can't explain ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 18:03 ` Robert A Duff 2010-07-23 18:27 ` Ada novice 2010-07-23 19:31 ` Dmitry A. Kazakov @ 2010-07-23 20:34 ` Simon Wright 2010-07-23 20:52 ` Robert A Duff 2 siblings, 1 reply; 34+ messages in thread From: Simon Wright @ 2010-07-23 20:34 UTC (permalink / raw) Robert A Duff <bobduff@shell01.TheWorld.com> writes: > Similarly, if you say "-gnatn", GNAT is implicitly including > "pragma Suppress(All_Checks);" as part of your program text. -gnatp ? ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 20:34 ` Simon Wright @ 2010-07-23 20:52 ` Robert A Duff 2010-07-24 10:30 ` Ada novice 0 siblings, 1 reply; 34+ messages in thread From: Robert A Duff @ 2010-07-23 20:52 UTC (permalink / raw) Simon Wright <simon@pushface.org> writes: > Robert A Duff <bobduff@shell01.TheWorld.com> writes: > >> Similarly, if you say "-gnatn", GNAT is implicitly including >> "pragma Suppress(All_Checks);" as part of your program text. > > -gnatp ? Yeah, thanks for the correction. - Bob ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 20:52 ` Robert A Duff @ 2010-07-24 10:30 ` Ada novice 2010-07-24 12:03 ` Robert A Duff 0 siblings, 1 reply; 34+ messages in thread From: Ada novice @ 2010-07-24 10:30 UTC (permalink / raw) On Jul 23, 10:52 pm, Robert A Duff <bobd...@shell01.TheWorld.com> wrote: > Simon Wright <si...@pushface.org> writes: > > Robert A Duff <bobd...@shell01.TheWorld.com> writes: > > >> Similarly, if you say "-gnatn", GNAT is implicitly including > >> "pragma Suppress(All_Checks);" as part of your program text. > So removing -gnatn is a good thing if one wants to enable checks? YC ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-24 10:30 ` Ada novice @ 2010-07-24 12:03 ` Robert A Duff 2010-07-24 12:36 ` Ada novice 0 siblings, 1 reply; 34+ messages in thread From: Robert A Duff @ 2010-07-24 12:03 UTC (permalink / raw) Ada novice <posts@gmx.us> writes: > On Jul 23, 10:52�pm, Robert A Duff <bobd...@shell01.TheWorld.com> > wrote: >> Simon Wright <si...@pushface.org> writes: >> > Robert A Duff <bobd...@shell01.TheWorld.com> writes: >> >> >> Similarly, if you say "-gnatn", GNAT is implicitly including >> >> "pragma Suppress(All_Checks);" as part of your program text. > > So removing -gnatn is a good thing if one wants to enable checks? No. I meant -gnatp, not -gnatn. Sorry! - Bob ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-24 12:03 ` Robert A Duff @ 2010-07-24 12:36 ` Ada novice 0 siblings, 0 replies; 34+ messages in thread From: Ada novice @ 2010-07-24 12:36 UTC (permalink / raw) On Jul 24, 2:03 pm, Robert A Duff <bobd...@shell01.TheWorld.com> wrote: > > No. I meant -gnatp, not -gnatn. Sorry! > > - Bob Thanks for the clarifications. So I have the options -O3 -gnatn -funroll-loops -gnatf -gnato -fpeel-loops -ftracer - funswitch-loops -fweb -frename-registers -mfpmath=sse -msse3 to play with. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-23 9:52 compiler settings in AdaGIDE Ada novice 2010-07-23 11:56 ` Gautier write-only @ 2010-07-24 18:21 ` jonathan 2010-07-25 13:29 ` Ada novice ` (2 more replies) 1 sibling, 3 replies; 34+ messages in thread From: jonathan @ 2010-07-24 18:21 UTC (permalink / raw) On Jul 23, 10:52 am, Ada novice <po...@gmx.us> wrote: > Hi, > I'm using the AdaGIDE editor (version 7.45.2) together with the > GNAT AdaCore libre compiler (release 2010) on a Win XP machine. I > would like my codes to run as fast as possible and here is the content > of a typical gnat.ago file that I use. Please let me know what > improvements I can make in order for an Ada program to run in the > minimum amount of time. > > Thanks. > YC I wrote a quick benchmark using our favorite complex number eigen-routine, so now we can test some these things rather quickly. The benchmark does 100 calls to Complex_Eigenvalues.Eigen (P , W , V , FAIL); using 121 x 121 complex matrices. I compiled it with both the 2009 and 2010 GNAT GPL compilers and timed it on a fast Intel PC (Xeon X5460 @ 3.16GHz) with: time ./bench Let's look at the best results first, and compare the '09 and '10 GNAT GPL compilers: 2010 GNAT GPL: gnatmake bench.adb -gnatnp -O2 -march=native -ffast-math -funroll- loops 3.61 seconds 2009 GNAT GPL: gnatmake bench.adb -gnatnp -O2 -march=native -ffast-math -funroll- loops 4.57 seconds This came as a nice surprise to me! We can learn some more about the compiler switches by toggling them. I'll stick to the 2010 GNAT GPL from now on: change -O2 to -O3: (gnatmake bench.adb -gnatnp -O3 -march=native -ffast-math -funroll- loops) running time changes from 3.61 to 3.63 seconds remove -funroll-loops: (gnatmake bench.adb -gnatnp -O2 -march=native -ffast-math) running time changes from 3.61 to 3.66 seconds remove -ffast-math: (gnatmake bench.adb -gnatnp -O2 -march=native) running time changes from 3.61 to 4.35 seconds The -ffast-math had an amazing affect. I've never seen that before ... maybe an interaction with complex number arithmetic. Now let's check -gnato: add -gnato: (gnatmake bench.adb -gnatnp -O2 -march=native -ffast-math -funroll- loops -gnato) running time changes from 3.61 to 3.64 seconds (Good news again.) I suspect that the -mfpmath=sse is the default on Intel. If you are on an Intel processor, then you have the option of running on the 387 stack by using -mfpmath=387. The compiler even tries to use both sse and 387 if you use -mfpmath=387,sse, or so the man pages say. (-mfpmath=387,sse isn't very good yet .. usually slower.) Finally, I always use the more portable: type Real is digits 15; It will give you standard double precision without much loss in speed as far as I can tell. To get single precision: type Real is digits 6; Its not much faster than the 15 digit version in the present benchmark. My experience is that it is almost always a bad idea to do much arithmetic (especially something like eigenvalue calculations), in single precision ... maybe at best useful for minimizing data storage size if data is known to be inaccurate.) I wasn't planning to do any more benchmarking than this, but the 2009 vs 2010 results were so surprising and so welcome that I took the time to do one more test. You can find the code in the following public directory: http://web.am.qub.ac.uk/users/j.parker/bench_depository/ You might also want to look at some other math routines I keep at: http://web.am.qub.ac.uk/users/j.parker/miscellany/ On this set of floating point routines, by the way, here's the best I could come up with for maximum speed: gnatmake xxx.adb -gnatnp -O2 -march=native -ffast-math -funroll-loops I've never found anything much better .. I always start with this set of switches (-gnatnp -O2 -march=native -ffast-math -funroll-loops) and turn other switches on and off to see if they help. In the benchmark directory you can find some programs I've either collected or written over the years. I'll compare Ada and Fortran 90 versions of a jacobi iterative eigen- decomposition for symmetric real matrices. The Ada version has departed slightly from the fortran version over the years, but the two are still very close ... do almost the same amount of computation in the same way. Mostly I just want to compare the 2009 and the 2010 GNAT GPL though - here is a test on a 500 x 500 Moler's matrix: 2010 GNAT GPL: gnatmake jacobi_eigen_bench_1 -gnatnp -O2 -march=native -ffast-math -funroll-loops 2.036 seconds 2009 GNAT GPL: gnatmake jacobi_eigen_bench_1 -gnatnp -O2 -march=native -ffast-math -funroll-loops 2.676 seconds Again, I found this so surprising that I copied over the test routine jacobi_eigen_tst_1.adb from another directory, just to make sure that the jacobi packages were actually working. You may want to verify this. You'll need packages matrix_sampler_3.ads and matrix_sampler_3.adb. For testing I start with: gnatmake jacobi_eigen_tst_1.adb -gnato -gnatVa -gnata To make the Fortran comparison I used (1) jacobi_eigen.f90, (2) a recent version (11.0) of the the Intel Fortran compiler, and (3) a not very recent version of gfortran (based on gcc 4.3.2): ifort -fast jacobi_eigen.f90 gfortran jacobi_eigen.f90 -O3 -march=native -funroll-loops -ffast- math Results on a 500 x 500 matrix: 2.038 seconds (2010 GNAT GPL) 2.012 seconds (gfortran (based on gcc 4.3.2)) 1.824 seconds (ifort -fast, version 11.0) Actually, INTEL's ifort is usually 20% or more faster than than the gcc's. It can do miraculous things with nested loops but in this case I suspect that it may be doing some algebra on the Jacobi inner loops and then factoring out some constants (you get gcc speed if you suppress that kind of thing with the ifort -fp-model strict switch). J. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-24 18:21 ` jonathan @ 2010-07-25 13:29 ` Ada novice 2010-07-25 19:30 ` Jeffrey R. Carter ` (2 more replies) 2010-07-26 8:02 ` Making measurements (Was: compiler settings in AdaGIDE) Jacob Sparre Andersen 2010-07-27 15:11 ` compiler settings in AdaGIDE Colin Paul Gloster 2 siblings, 3 replies; 34+ messages in thread From: Ada novice @ 2010-07-25 13:29 UTC (permalink / raw) Many thanks for all these precious information. The settings -gnatnp -O2 -march=native -ffast-math -funroll-loops was only 1 s faster (1537 s) as compared to using -gnatVa -O3 -gnatn -funroll-loops -gnatf -gnato which took 1538 s. I have two questions: 1. I see that you use -gnatnp. Is this safe to do so i.e. to suppress all checks? 2. In the specification -march="machine architecture here", you use native for the machine architecture. Does this apply to Intel processors as well? And thank you very much for making accessible the programs on your website. This is indeed very generous on your part. I find some very useful codes there. YC ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-25 13:29 ` Ada novice @ 2010-07-25 19:30 ` Jeffrey R. Carter 2010-07-26 14:13 ` Ada novice 2010-07-25 22:57 ` jonathan 2010-07-25 23:40 ` jonathan 2 siblings, 1 reply; 34+ messages in thread From: Jeffrey R. Carter @ 2010-07-25 19:30 UTC (permalink / raw) On 07/25/2010 06:29 AM, Ada novice wrote: > > 1. I see that you use -gnatnp. Is this safe to do so i.e. to suppress > all checks? No, but it is a little faster. You asked about maximizing speed, not about safety. Of course, none of this is going to make a significant difference, as you found out yourself. Significant speed changes come about from improved algorithms. The correct approach is to implement correctly, clearly, and safely, then measure against your timing requirements (which are unspecified), and only make changes if the result fails to meet the timing requirements. -- Jeff Carter "I soiled my armor, I was so scared." Monty Python & the Holy Grail 71 ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-25 19:30 ` Jeffrey R. Carter @ 2010-07-26 14:13 ` Ada novice 2010-07-26 15:48 ` sjw 0 siblings, 1 reply; 34+ messages in thread From: Ada novice @ 2010-07-26 14:13 UTC (permalink / raw) On Jul 25, 9:30 pm, "Jeffrey R. Carter" <spam.jrcarter....@spam.acm.org> wrote: > On 07/25/2010 06:29 AM, Ada novice wrote: > > 1. I see that you use -gnatnp. Is this safe to do so i.e. to suppress > > all checks? > No, but it is a little faster. You asked about maximizing speed, not about > safety. Of course, none of this is going to make a significant difference, as > you found out yourself. Significant speed changes come about from improved > algorithms. The correct approach is to implement correctly, clearly, and safely, > then measure against your timing requirements (which are unspecified), and only > make changes if the result fails to meet the timing requirements. Thanks. I understand. I would prefer to keep the -gnatn just to be safe. YC ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-26 14:13 ` Ada novice @ 2010-07-26 15:48 ` sjw 2010-07-26 17:12 ` Dmitry A. Kazakov 2010-07-26 17:18 ` Ada novice 0 siblings, 2 replies; 34+ messages in thread From: sjw @ 2010-07-26 15:48 UTC (permalink / raw) On Jul 26, 3:13 pm, Ada novice <po...@gmx.us> wrote: > On Jul 25, 9:30 pm, "Jeffrey R. Carter" > > <spam.jrcarter....@spam.acm.org> wrote: > > On 07/25/2010 06:29 AM, Ada novice wrote: > > > 1. I see that you use -gnatnp. Is this safe to do so i.e. to suppress > > > all checks? > > No, but it is a little faster. You asked about maximizing speed, not about > > safety. Of course, none of this is going to make a significant difference, as > > you found out yourself. Significant speed changes come about from improved > > algorithms. The correct approach is to implement correctly, clearly, and safely, > > then measure against your timing requirements (which are unspecified), and only > > make changes if the result fails to meet the timing requirements. > > Thanks. I understand. I would prefer to keep the -gnatn just to be > safe. -gnatp to suppress checks. -gnatn is about inlining. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-26 15:48 ` sjw @ 2010-07-26 17:12 ` Dmitry A. Kazakov 2010-07-26 17:18 ` Ada novice 1 sibling, 0 replies; 34+ messages in thread From: Dmitry A. Kazakov @ 2010-07-26 17:12 UTC (permalink / raw) On Mon, 26 Jul 2010 08:48:58 -0700 (PDT), sjw wrote: > On Jul 26, 3:13�pm, Ada novice <po...@gmx.us> wrote: >> On Jul 25, 9:30 pm, "Jeffrey R. Carter" >> >> <spam.jrcarter....@spam.acm.org> wrote: >>> On 07/25/2010 06:29 AM, Ada novice wrote: >>> > 1. I see that you use -gnatnp. Is this safe to do so i.e. to suppress >>> > all checks? >>> No, but it is a little faster. You asked about maximizing speed, not about >>> safety. Of course, none of this is going to make a significant difference, as >>> you found out yourself. Significant speed changes come about from improved >>> algorithms. The correct approach is to implement correctly, clearly, and safely, >>> then measure against your timing requirements (which are unspecified), and only >>> make changes if the result fails to meet the timing requirements. >> >> Thanks. I understand. I would prefer to keep the -gnatn just to be >> safe. > > -gnatp to suppress checks. -gnatn is about inlining. The gentleman's set is: debug -gnatVa all validity checks on -gnatf show all errors messages -gnato integer overflow check -g add debug info -fstack-check check stack overflow release -gnatVa -gnatf -gnato -O2 medium level optimization -gnatn inline as defined by the user -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-26 15:48 ` sjw 2010-07-26 17:12 ` Dmitry A. Kazakov @ 2010-07-26 17:18 ` Ada novice 1 sibling, 0 replies; 34+ messages in thread From: Ada novice @ 2010-07-26 17:18 UTC (permalink / raw) On Jul 26, 5:48 pm, sjw <simon.j.wri...@mac.com> wrote: > > -gnatp to suppress checks. -gnatn is about inlining. Yes, sorry for the mix up. YC ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-25 13:29 ` Ada novice 2010-07-25 19:30 ` Jeffrey R. Carter @ 2010-07-25 22:57 ` jonathan 2010-07-26 14:12 ` Ada novice 2010-07-25 23:40 ` jonathan 2 siblings, 1 reply; 34+ messages in thread From: jonathan @ 2010-07-25 22:57 UTC (permalink / raw) On Jul 25, 2:29 pm, Ada novice <po...@gmx.us> wrote: > Many thanks for all these precious information. The settings > > -gnatnp -O2 -march=native -ffast-math -funroll-loops > > was only 1 s faster (1537 s) as compared to using > > -gnatVa -O3 -gnatn -funroll-loops -gnatf -gnato Interesting result. I repeated the 100 calls to COMPLEX_EIGENVALUES.Eigen ( P, W, V, FAIL) test on a 121 x 121 sized matrix. I still get the same big decrease in running time from the -ffast-math switch. Generic_Complex_Eigenvalues seems sensitive to -ffast-math, but I've never seen any other program care much about it. > 1. I see that you use -gnatnp. Is this safe to do so i.e. to suppress > all checks? If I remove the -gnatp then running time goes from 3.61 to 6.1 sec. If I remove the -gnatnp then running time goes from 3.61 to 6.7 sec. (I suspect that you know that -gnatnp is really -gnatn -gnatp). On a high percentage of ordinary problems (usually data analysis) I would not care at all about the increased running time, and I would not remove the checks. There is another class of program I write and these run for days or weeks. These I never stop optimizing and testing, and all checks are removed! > 2. In the specification -march="machine architecture here", you use > native for the machine architecture. Does this apply to Intel > processors as well? I just checked the gcc man pages and found nothing at all about -march=native. It helps a little on all the machines I've used and occasionally in the past it has helped enormously. Just now I removed -march=native from the Generic_Complex_Eigenvalues test and running time went from 3.61 sec to 3.58 sec. When I remove it from the Jacobi benchmark, the program slows down slightly. So the switch seems to do something on my intel machine, but all I can say now is that the difference is very small and unpredictable. J. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-25 22:57 ` jonathan @ 2010-07-26 14:12 ` Ada novice 0 siblings, 0 replies; 34+ messages in thread From: Ada novice @ 2010-07-26 14:12 UTC (permalink / raw) On Jul 26, 12:57 am, jonathan <johns...@googlemail.com> wrote: > On Jul 25, 2:29 pm, Ada novice <po...@gmx.us> wrote: > > > Many thanks for all these precious information. The settings > > > -gnatnp -O2 -march=native -ffast-math -funroll-loops > > > was only 1 s faster (1537 s) as compared to using > > > -gnatVa -O3 -gnatn -funroll-loops -gnatf -gnato > > Interesting result. I repeated the 100 calls to > COMPLEX_EIGENVALUES.Eigen ( P, W, V, FAIL) test on a > 121 x 121 sized matrix. > I still get the same big decrease in running time from the > -ffast-math switch. Maybe what I have in my code is not affected by the -ffast-math switch. > On a high percentage of ordinary problems (usually data > analysis) I would not care at all about the increased > running time, and I would not remove the checks. There > is another class of program I write and these run for days > or weeks. These I never stop optimizing and testing, and > all checks are removed! I would prefer to keep the -gnatn. > > 2. In the specification -march="machine architecture here", you use > > native for the machine architecture. Does this apply to Intel > > processors as well? > > I just checked the gcc man pages and found nothing at all about > -march=native. It helps a little on all the machines I've > used and occasionally in the past it has helped enormously. Just > now I removed -march=native from the Generic_Complex_Eigenvalues > test and running time went from 3.61 sec to 3.58 sec. When > I remove it from the Jacobi benchmark, the program slows down > slightly. So the switch seems to do something on my intel machine, > but all I can say now is that the difference is very small and > unpredictable. Thanks for this information. YC ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-25 13:29 ` Ada novice 2010-07-25 19:30 ` Jeffrey R. Carter 2010-07-25 22:57 ` jonathan @ 2010-07-25 23:40 ` jonathan 2 siblings, 0 replies; 34+ messages in thread From: jonathan @ 2010-07-25 23:40 UTC (permalink / raw) On Jul 25, 2:29 pm, Ada novice <po...@gmx.us> wrote: > 1. I see that you use -gnatnp. Is this safe to do so i.e. to suppress > all checks? I could not resist testing the -gnatp switch on my other benchmark, the Jacobi eigendecomposition. So I removed -gnatp and added -gnato, and running time went from 2.04 sec to 2.35 sec. Not bad at all! J. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Making measurements (Was: compiler settings in AdaGIDE) 2010-07-24 18:21 ` jonathan 2010-07-25 13:29 ` Ada novice @ 2010-07-26 8:02 ` Jacob Sparre Andersen 2010-07-26 9:57 ` jonathan 2010-07-27 15:11 ` compiler settings in AdaGIDE Colin Paul Gloster 2 siblings, 1 reply; 34+ messages in thread From: Jacob Sparre Andersen @ 2010-07-26 8:02 UTC (permalink / raw) Jonathan <johnscpg@googlemail.com> wrote: > 2010 GNAT GPL: > gnatmake bench.adb -gnatnp -O2 -march=native -ffast-math -funroll- > loops > 3.61 seconds I hope this is a average or median value from several measurements. Which of the two? Did you estimate the uncertaincy of your measurements? Jacob -- Jacob Sparre Andersen Research & Innovation Vesterbrogade 148K, 1. th. 1620 K�benhavn V Danmark Phone: +45 21 49 08 04 E-mail: jacob@jacob-sparre.dk Web-sted: http://www.jacob-sparre.dk/ ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: Making measurements (Was: compiler settings in AdaGIDE) 2010-07-26 8:02 ` Making measurements (Was: compiler settings in AdaGIDE) Jacob Sparre Andersen @ 2010-07-26 9:57 ` jonathan 2010-07-26 13:50 ` Making measurements Jacob Sparre Andersen 0 siblings, 1 reply; 34+ messages in thread From: jonathan @ 2010-07-26 9:57 UTC (permalink / raw) On Jul 26, 9:02 am, Jacob Sparre Andersen <ja...@jacob-sparre.dk> wrote: > Jonathan <johns...@googlemail.com> wrote: > > 2010 GNAT GPL: > > gnatmake bench.adb -gnatnp -O2 -march=native -ffast-math -funroll- > > loops > > 3.61 seconds > > I hope this is a average or median value from several measurements. > > Which of the two? Did you estimate the uncertaincy of your > measurements? > > Jacob > -- > Jacob Sparre Andersen Research & Innovation > Vesterbrogade 148K, 1. th. > 1620 København V > Danmark > > Phone: +45 21 49 08 04 > E-mail: ja...@jacob-sparre.dk > Web-sted:http://www.jacob-sparre.dk/ I did a few runs with the linux: time ./bench on an empty machine and got numbers like this: 0m3.612s 0m3.604s 0m3.620s 0m3.612s 0m3.620s 0m3.604s Some programs fluctuate hugely in running time .. never figured out why. J. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: Making measurements 2010-07-26 9:57 ` jonathan @ 2010-07-26 13:50 ` Jacob Sparre Andersen 0 siblings, 0 replies; 34+ messages in thread From: Jacob Sparre Andersen @ 2010-07-26 13:50 UTC (permalink / raw) Jonathan <johnscpg@googlemail.com> wrote: > I did a few runs with the linux: time ./bench > on an empty machine and got numbers like this: > > 0m3.612s 0m3.604s 0m3.620s 0m3.612s 0m3.620s 0m3.604s Looks like we have a nice symmetric case where the average and the median are the same. ;-) > Some programs fluctuate hugely in running time .. never figured out > why. It may be something as simple as which core the program happens to be running on. Or which operating system processes are running in the background. In general it is a good idea to report an average of at least three timing measurements and the standard deviation of the measurements. Jacob -- Jacob Sparre Andersen Research & Innovation Vesterbrogade 148K, 1. th. 1620 K�benhavn V Danmark Phone: +45 21 49 08 04 E-mail: jacob@jacob-sparre.dk Web-sted: http://www.jacob-sparre.dk/ ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-24 18:21 ` jonathan 2010-07-25 13:29 ` Ada novice 2010-07-26 8:02 ` Making measurements (Was: compiler settings in AdaGIDE) Jacob Sparre Andersen @ 2010-07-27 15:11 ` Colin Paul Gloster 2010-08-01 16:39 ` Ada novice 2 siblings, 1 reply; 34+ messages in thread From: Colin Paul Gloster @ 2010-07-27 15:11 UTC (permalink / raw) On Sat, 24 Jul 2010, Jonathan sent: |----------------------------------------------------------------------| |"[..] | | | | time ./bench | | | |Let's look at the best results first, and compare the | |'09 and '10 GNAT GPL compilers: | | | | 2010 GNAT GPL: | | gnatmake bench.adb -gnatnp -O2 -march=native -ffast-math -funroll- | |loops | | 3.61 seconds | | | | 2009 GNAT GPL: | | gnatmake bench.adb -gnatnp -O2 -march=native -ffast-math -funroll- | |loops | | 4.57 seconds | | | |This came as a nice surprise to me! | |We can learn some more about the compiler switches by | |toggling them. I'll stick to the 2010 GNAT GPL from now on: | | | | change -O2 to -O3: | | (gnatmake bench.adb -gnatnp -O3 -march=native -ffast-math -funroll-| |loops) | | running time changes from 3.61 to 3.63 seconds | | | | remove -funroll-loops: | | (gnatmake bench.adb -gnatnp -O2 -march=native -ffast-math) | | running time changes from 3.61 to 3.66 seconds | | | | remove -ffast-math: | | (gnatmake bench.adb -gnatnp -O2 -march=native) | | running time changes from 3.61 to 4.35 seconds | | | |The -ffast-math had an amazing affect. I've never seen that | |before ... maybe an interaction with complex number arithmetic. | | | |[..]" | |----------------------------------------------------------------------| The GNU Compiler Collection's -ffast-math switch used to provide a significant increase in speed for various frontends excluding GNAT. In my experience at least, this effect had no special relationship with complex numbers. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: compiler settings in AdaGIDE 2010-07-27 15:11 ` compiler settings in AdaGIDE Colin Paul Gloster @ 2010-08-01 16:39 ` Ada novice 0 siblings, 0 replies; 34+ messages in thread From: Ada novice @ 2010-08-01 16:39 UTC (permalink / raw) In this document: http://www.benchit.org/downloads/documents/comparing_gcc42_gcc43.pdf some guidelines are given for increased performance. Tow points worthy to note: 1. The -ftree-vectorize option is now on by default under -O3. 2. Tuning for Intel Core 2 processors is available via -mtune=core2 and -march=core2. Have anyone tried these options? YC ^ permalink raw reply [flat|nested] 34+ messages in thread
end of thread, other threads:[~2010-08-01 16:39 UTC | newest] Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-07-23 9:52 compiler settings in AdaGIDE Ada novice 2010-07-23 11:56 ` Gautier write-only 2010-07-23 14:23 ` Ada novice [not found] ` <f72678ba-23ce-4c9a-b17e-b33fbd45300d@l14g2000yql.googlegroups.com> 2010-07-23 14:54 ` Georg Bauhaus 2010-07-23 15:16 ` Robert A Duff 2010-07-23 15:22 ` Georg Bauhaus 2010-07-23 16:51 ` sjw 2010-07-23 18:03 ` Robert A Duff 2010-07-23 18:27 ` Ada novice 2010-07-23 20:33 ` Simon Wright 2010-07-23 19:31 ` Dmitry A. Kazakov 2010-07-23 21:01 ` Robert A Duff 2010-07-23 22:32 ` Peter C. Chapin 2010-07-24 1:48 ` BrianG 2010-07-23 20:34 ` Simon Wright 2010-07-23 20:52 ` Robert A Duff 2010-07-24 10:30 ` Ada novice 2010-07-24 12:03 ` Robert A Duff 2010-07-24 12:36 ` Ada novice 2010-07-24 18:21 ` jonathan 2010-07-25 13:29 ` Ada novice 2010-07-25 19:30 ` Jeffrey R. Carter 2010-07-26 14:13 ` Ada novice 2010-07-26 15:48 ` sjw 2010-07-26 17:12 ` Dmitry A. Kazakov 2010-07-26 17:18 ` Ada novice 2010-07-25 22:57 ` jonathan 2010-07-26 14:12 ` Ada novice 2010-07-25 23:40 ` jonathan 2010-07-26 8:02 ` Making measurements (Was: compiler settings in AdaGIDE) Jacob Sparre Andersen 2010-07-26 9:57 ` jonathan 2010-07-26 13:50 ` Making measurements Jacob Sparre Andersen 2010-07-27 15:11 ` compiler settings in AdaGIDE Colin Paul Gloster 2010-08-01 16:39 ` Ada novice
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox