OS/2, eCS & ArcaOS - Technical > Programming
i686 vs Pentium 4
Dave Yeo:
So anyways, my next idea is to benchmark the differences in optimizing for different CPU architectures. I found this, https://www.eembc.org/coremark/index.php a benchmark designed to test integer and pipeline speed on various CPU's see the Details part of the above page.
So I downloaded the source and built it and now share it, it is attached and includes the logs I generated.
Ideally to test, it needs to be rebuilt with different flags, make clean and then make, or make XCFLAGS="options" such as -march=pentium4. The -march targets an architecture. I tested no flags, seems our GCC now targets i686, Pentium 4, and native, in my case I5 as well as -march=pentium4 -mtune=generic. The -mtune parameter affects the instruction ordering with generic being for the common CPU's available and used when GCC was released.
The results showed most tests resulting in about 16200 Iterations/Sec with the best results actually for -march=pentium4 -mtune=generic, 16241 Iterations/Sec with most of the others being close enough that it may be background processes affecting the results (should really run 3-5 times and average). The exception being plain old -march=pentium4 which gave 13162 Iterations/Sec, bigger numbers are better and it seems P4 has close to a 20% performance hit on my CPU and likely on all Intel CPU's besides Netburst and likely similar on AMD. AMD should be tested.
By uncommenting the LFLAGS_END line in os2/core_portme.mak and using make XCFLAGS="-DMULTITHREAD=4 -DUSE_PTHREAD" can test 4 threads, where my results were Iterations/Sec : 59947.545897 with no flags and for P4, Iterations/Sec : 50128.454164, once again a performance hit of about 15%.
My idea is for the RPM packagers to simply add CFLAGS+= -mtune=generic to their future P4 builds which should result in a performance boost in most cases for everyone except the few P4 users left without having to switch architectures and rebuild everything.
Anyways source is included, requirements to build are simply GCC and make, pthread-dev for multi-threading. "make XCFLAGS="-march=amdfam10" for newer AMD chips if others want to check out the differences. Don't forget to make clean in between compilations.
Now I should find a floating point benchmark and test that.
Edit: XCFLAGS="-march=native" is a simple way to test on your CPU
Dariusz Piatkowski:
Dave, everyone...
--- Quote from: Dave Yeo on March 08, 2022, 03:28:46 am ---So anyways, my next idea is to benchmark the differences in optimizing for different CPU architectures. I found this, https://www.eembc.org/coremark/index.php a benchmark designed to test integer and pipeline speed on various CPU's see the Details part of the above page.
So I downloaded the source and built it and now share it, it is attached and includes the logs I generated...
--- End quote ---
Nice!!! Thank you...
Here are the results for my Phenom II X6 running at 3.8GHz:
--- Code: ---2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 17587
Total time (secs): 17.587000
Iterations/Sec : 17058.054245
Iterations : 300000
Compiler version : GCC9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00)
Compiler flags : -O2 -DPERFORMANCE_RUN=1
Memory location : Please put data memory location here
(e.g. code in flash, data on heap etc)
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0xcc42
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 17058.054245 / GCC9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00) -O
2 -DPERFORMANCE_RUN=1 / Heap
--- End code ---
I'll play around with the different optimization flags Dave which you discussed in your post next. Also, the above is a result when executed on my system in as-is state, so various CPU spikes, etc...not quieted by any means! lol
Dave Yeo:
So for testing floating point, I found this, https://github.com/shaswata56/BenchUtil simple programs to test 32 bit and 64 bit Gigaflops.
Testing by editing the makefile's CFLAG's, surprisingly using -march=pentium4 produced slightly better numbers then anything else I tried.
--- Code: ---K:\work\BenchUtil>flops32.exe
Number of CPU cores to run Benchmark: 4
Benchmarking for 32 Bit Floating point operations per second
1| Tr 1: 166771296 Tr 2: 171153429 Tr 3: 180760710 Tr 4: 168050527 FLOPS = 686735962
Maximum CPU Throughput: 0.686736 Gigaflops.
Maximum Single Core Throughput: 0.180761 Gigaflops.
K:\work\BenchUtil>flops64.exe
Number of CPU cores to run Benchmark: 4
Benchmarking for 64 Bit Floating point operations per second
1| Tr 1: 177902634 Tr 2: 168180220 Tr 3: 182884650 Tr 4: 173335942 FLOPS = 702303446
Maximum CPU Throughput: 0.702303 Gigaflops.
Maximum Single Core Throughput: 0.182885 Gigaflops.
--- End code ---
Then I realized there was no optimization happening, so I added -O2 (and others) which surprisingly resulted in 0 Gigaflops, seemed the compiler had optimized the floating point math away :).
Then it occurred to me to test SSE, so I added "-msse2 -mfpmath=sse" to the CFLAGS and got a huge speedup,
--- Code: ---K:\work\BenchUtil>flops32.exe
Number of CPU cores to run Benchmark: 4
Benchmarking for 32 Bit Floating point operations per second
1| Tr 1: 1456272991 Tr 2: 1465967192 Tr 3: 1418616653 Tr 4: 3770445355 FLOPS = 8111302191
Maximum CPU Throughput: 8.111302 Gigaflops.
Maximum Single Core Throughput: 3.770445 Gigaflops.
K:\work\BenchUtil>flops64.exe
Number of CPU cores to run Benchmark: 4
Benchmarking for 64 Bit Floating point operations per second
1| Tr 1: 4119103170 Tr 2: 4128738432 Tr 3: 4097239406 Tr 4: 4144496382 FLOPS = 16489577390
Maximum CPU Throughput: 16.489578 Gigaflops.
Maximum Single Core Throughput: 4.144496 Gigaflops.
--- End code ---
Then also adding -march=pentium4, the speedup was smaller,
--- Code: ---K:\work\BenchUtil>flops32.exe
Number of CPU cores to run Benchmark: 4
Benchmarking for 32 Bit Floating point operations per second
1| Tr 1: 1373982585 Tr 2: 1404198986 Tr 3: 1382572280 Tr 4: 3279735363 FLOPS = 7440489214
Maximum CPU Throughput: 7.440489 Gigaflops.
Maximum Single Core Throughput: 3.279735 Gigaflops.
K:\work\BenchUtil>flops64.exe
Number of CPU cores to run Benchmark: 4
Benchmarking for 64 Bit Floating point operations per second
1| Tr 1: 4136387606 Tr 2: 4130490416 Tr 3: 4147691444 Tr 4: 4125981262 FLOPS = 16540550728
Maximum CPU Throughput: 16.540550 Gigaflops.
Maximum Single Core Throughput: 4.147692 Gigaflops.
--- End code ---
So you can see why to use SSE for floating point math. Seems the 32 bit math was slower compiled for a P4 and the 64 bit math was about the same. Once again really should have done the measurements 3-5 times and averaged.
Dariusz Piatkowski:
--- Quote from: Dariusz Piatkowski on March 08, 2022, 02:04:27 pm ---I'll play around with the different optimization flags Dave which you discussed in your post next...
--- End quote ---
Hmm...so a bit of a surprise actually, I did not anticipate this.
1) tune & arch = amdfam10
--- Code: ---2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 13914
Total time (secs): 13.914000
Iterations/Sec : 57496.047147
Iterations : 800000
Compiler version : GCC9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00)
Compiler flags : -O2 -DMULTITHREAD=4 -DUSE_PTHREAD -DPERFORMANCE_RUN=1 -lpthread
Parallel PThreads : 4
--- End code ---
2) arch=amdfam10, tune=generic
--- Code: ---2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 17822
Total time (secs): 17.822000
Iterations/Sec : 67332.510380
Iterations : 1200000
Compiler version : GCC9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00)
Compiler flags : -O2 -DMULTITHREAD=4 -DUSE_PTHREAD -DPERFORMANCE_RUN=1 -lpthread
Parallel PThreads : 4
--- End code ---
3) same config as #2 above, but running the full 6 cores
--- Code: ---2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 21224
Total time (secs): 21.224000
Iterations/Sec : 84809.649453
Iterations : 1800000
Compiler version : GCC9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00)
Compiler flags : -O2 -DMULTITHREAD=6 -DUSE_PTHREAD -DPERFORMANCE_RUN=1 -lpthread
Parallel PThreads : 6
--- End code ---
4) same #3 above, but with arch=pentium4, tune=generic
--- Code: ---2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 21252
Total time (secs): 21.252000
Iterations/Sec : 84697.910785
Iterations : 1800000
Compiler version : GCC9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00)
Compiler flags : -O2 -DMULTITHREAD=6 -DUSE_PTHREAD -DPERFORMANCE_RUN=1 -lpthread
Parallel PThreads : 6
--- End code ---
The GCC architecture specific tune option produced WORSE performance than the GENERIC option, which at least to me is not intuitive, quite the opposit actually.
..and while I focused in the above tests on multi-threaded performance, the single-threaded runs matched the tune results that I saw here (same conclusion).
Dave Yeo:
That is strange, is it repeatable? I also notice the 2nd run had more Iterations for some reason as well as your log not showing all the compiler flags. I get this,
--- Code: ---2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 13073
Total time (secs): 13.073000
Iterations/Sec : 61194.829037
Iterations : 800000
Compiler version : GCC9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00)
Compiler flags : -O2 -DMULTITHREAD=4 -DUSE_PTHREAD -march=native -mtune=generic -DPERFORMANCE_RUN=1 -lpthread
Parallel PThreads : 4
--- End code ---
some crc's
--- Code: ---Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 61194.829037 / GCC9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00) -O2 -DMULTITHREAD=4 -DUSE_PTHREAD -march=native -mtune=generic -DPERFORMANCE_RUN=1
-lpthread / Heap / 4:PThreads
--- End code ---
Looking at [url]https://www.eembc.org/coremark/scores.php[/code] and filtering for AMD Phenom II X6 1090T I see someone else got 73233.25
Always a possibility of a compiler bug. Also if you don't specify -mtune, you get it tuned for -march
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version