From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <9605021558.AA08556@nova.tat.physik.uni-tuebingen.de> Date: Thu, 2 May 1996 17:54:24 +0200 (MET DST) From: Harald Koenig Subject: Re: ev4sched---here it is In-Reply-To: > > gcc -O3 1556.99 secs > > cc -O3 824.56 secs > > > > this almost a factor of TWO:-( > > Have you tried to profile this? The difference might be partly in the > libraries, so if the "cc" version is also using DEC libraries (likely), then it > might be due to that. very unlikely since this program only reads a ~300k ASCII data file, then does 10-30min linear matrix solving/optimization and finally prints a ~100k report. for most of the time libraries aren't needed at all as far as I can see. but anyhow, I tried to profile this program (always being curious ;-) and got a lot of new problems: - profiling only works with "-O0". using "-O1" or higher will give an endless loop for the first subroutine called (when executing "return" the subroutine is reentered immediately according to "stepi"s in gdb when compiling everything with "-O1 -g -pg". I've tried using "-p" too which gives the same problems (endless loop and alignment traps for anythying but "-O0"). - when using anything higher as "-O0" I get two alignment traps at the start of this program: unaligned trap at 00000001200748a8: 00000001405ec02c 2d 14 unaligned trap at 00000001200748b4: 00000001405ec034 2d 13 from gdb x/i: 0x1200748a8 : b5cc0000 stq s5, 0(s3) 0x1200748b4 : b5ac0008 stq s4, 8(s3) which is located in libgmon.a: 0x29c : c3e00055 br 0x3f4 0x2a0 : 47ff0410 clr a0 0x2a4 : a53d80a0 ldq s0, -32608(gp) 0x2a8 : a77d8070 ldq t12, -32656(gp) 0x2ac : 6b5b4000 jsr ra, (t12), 0x2b0 0x2b0 : 27ba0001 ldah gp, 65536(ra) 0x2b4 : 23bd8740 lda gp, -30912(gp) 0x2b8 : a42b0000 ldq t0, 0(s2) 0x2bc : b4090000 stq v0, 0(s0) 0x2c0 : 40221401 addq t0, #16, t0 0x2c4 : 4420d103 bic t0, #6, t2 0x2c8 : a4430000 ldq t1, 0(t2) 0x2cc : a4bd8020 ldq t4, -32736(gp) 0x2d0 : 44203101 bic t0, #1, t0 0x2d4 : a49d8018 ldq t3, -32744(gp) 0x2d8 : 48410242 mskwl t1, t0, t1 0x2dc : b4430000 stq t1, 0(t2) 0x2e0 : b5850000 stq s3, 0(t4) 0x2e4 : b1440000 stl s1, 0(t3) 0x2e8 : b5cc0000 stq s5, 0(s3) 0x2ec : b14c0010 stl s1, 16(s3) 0x2f0 : 4143152a subq s1, #24, s1 0x2f4 : b5ac0008 stq s4, 8(s3) [ ... ] 0x3f4 : 45ef041e or fp, fp, sp 0x3f8 : a75e0000 ldq ra, 0(sp) 0x3fc : a53e0008 ldq s0, 8(sp) 0x400 : a55e0010 ldq s1, 16(sp) 0x404 : a57e0018 ldq s2, 24(sp) 0x408 : a59e0020 ldq s3, 32(sp) 0x40c : a5be0028 ldq s4, 40(sp) 0x410 : a5de0030 ldq s5, 48(sp) 0x414 : a5fe0038 ldq fp, 56(sp) 0x418 : 43cc141e addq sp, #96, sp 0x41c : 6bfa8001 ret zero, (ra), 1 End of assembler dump. the following program, when compiled with "cc -pg -O1 demo.c" or higher won't output anything but loop (forever? didn't want to wait that long) but "cc -pg -O0 demo.c" is fine: int sub() { return 1; } main() { int i; i = sub(); printf("%d\n",i); } - gprof 2.6 from Red Hat doesn't honor HZ=1000, all timing values in seconds are divided by 10 anyway, here is the start of gprof output with "-O0" for a small data set (15 sec runtime with profiling, ~5.2 cpu secs with gcc -O2, ~2.6 secs with cc -O2): % cumulative self self total time seconds seconds calls ms/call ms/call name 62.28 0.91 0.91 1 906.26 960.37 sx3b_ 19.93 1.20 0.29 1 290.04 291.29 sx3a_ 8.39 1.32 0.12 648 0.19 0.19 sxdx_ 3.42 1.37 0.05 2 24.90 26.57 sxop_ 1.74 1.39 0.03 23 1.10 1.11 sxpn_ 1.21 1.41 0.02 1 17.58 1271.81 MAIN__ 1.07 1.43 0.02 352 0.04 0.04 sxdu_ 0.54 1.43 0.01 1278 0.01 0.01 sxas_ 0.54 1.44 0.01 __start 0.47 1.45 0.01 6283 0.00 0.00 sxus_ 0.20 1.45 0.00 400 0.01 0.01 sxlp_ 0.13 1.45 0.00 done 0.07 1.46 0.00 434 0.00 0.00 sxps_ 0.00 1.46 0.00 100358 0.00 0.00 _IO_sputbackc 0.00 1.46 0.00 100358 0.00 0.00 _IO_ungetc 0.00 1.46 0.00 36324 0.00 0.00 Binit 0.00 1.46 0.00 21844 0.00 0.00 sxpv_ 0.00 1.46 0.00 21840 0.00 0.00 sxsv_ 0.00 1.46 0.00 19982 0.00 0.00 _IO_default_xsputn 0.00 1.46 0.00 14034 0.00 0.00 _IO_padn 0.00 1.46 0.00 9540 0.00 0.00 sxlz_ 0.00 1.46 0.00 8358 0.00 0.00 _IO_setb 0.00 1.46 0.00 8305 0.00 0.00 _IO_init 0.00 1.46 0.00 8287 0.00 0.00 _IO_sprintf 0.00 1.46 0.00 8287 0.00 0.00 _IO_str_init_static 0.00 1.46 0.00 8287 0.00 0.00 _IO_vsprintf ^^^^ 14.6 secs! all sx* routines are fortran subroutines, _IO_sputbackc is the first (f2c) library routine... > Admittedly gcc is pretty bad at some things, and floating point is not the > strongest point of gcc, so it _may_ be due to just compilers.. of course this program was *not* compiled using "-mieee" which would cost another factor 1.5-2. I'll try some C (integer) code next time to see if this isn't that bad for non floating point code... one more performance note I just got today are the "xstones" for the XF86_S3 with a S3 Trio64V+ card I've tested in both a alpha XL266 machine (21064/266 with 2MB cache) and my PC with Pentium OverDrive 83MHz with 256k cache and 32bit data bus (486 board; ASUS SP3G): machine | line | fill | blt | text | arc | cmplx | xstones --------+---------+---------+---------+---------+-----------+---------+-------- PODP83 | 680251 | 251101 | 184931 | 270446 | 10170423 | 375542 | 293210 XL266D | 385344 | 239787 | 183127 | 281627 | 7627608 | 512581 | 276883 note that the cpu intensive line- and arc-stones are much lower for the alpha than for the i586 whereas I/O or graphics engine intensive tests are about the same (fill, blt, test). Harald -- All SCSI disks will from now on ___ _____ be required to send an email notice 0--,| /OOOOOOO\ 24 hours prior to complete hardware failure! <_/ / /OOOOOOOOOOO\ \ \/OOOOOOOOOOOOOOO\ \ OOOOOOOOOOOOOOOOO|// Harald Koenig, \/\/\/\/\/\/\/\/\/ Inst.f.Theoret.Astrophysik // / \\ \ koenig@tat.physik.uni-tuebingen.de ^^^^^ ^^^^^