You are not logged in.

#51 2008-06-09 14:10:28

fallening
Member
From: PRC
Registered: 2007-11-26
Posts: 25

Re: C++ program, Arch took 14 secs while PCLOS, Ubuntu, Mandriva only 8-9.

$ cat time.cc
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>

using namespace std;

const unsigned char SIZE = 15;
unsigned long long result;

void count(unsigned char i, unsigned char j)
{
    if(!i && !j) {
        ++result;
        return;
    }
    
    if(i) {
        count(i - 1, j);
    }
    if(j) {
        count(i, j - 1);
    }
}
 
int main()
{
    clock_t start, finish;
    long double duration;


    //system("date");
    result = 0;
    start = clock();
    count(SIZE, SIZE);
    finish = clock();
    cout << result << endl;

    duration = static_cast<long double>( finish - start ) / CLOCKS_PER_SEC;

    cout << fixed;
    cout << endl << setprecision(10) << duration << " second(s).";

    //cout << "\n" << 
    //system("date");
    return 0;
}
[feng@enlightenment tmp]$ g++ -o time time.cc  -O2 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
[feng@enlightenment tmp]$ ./time
155117520

5.9900000000 second(s).[feng@enlightenment tmp]$ time ./time
155117520

6.0100000000 second(s).
real    0m6.241s
user    0m5.993s
sys     0m0.030s
[feng@enlightenment tmp]$ g++ -o time time.cc  -O3 -march=pentium-m -pipe -fomit-frame-pointer -msse2 -mmmx -mfpmath=sse
[feng@enlightenment tmp]$ time ./time
155117520

3.2900000000 second(s).
real    0m3.381s
user    0m3.296s
sys     0m0.007s

載瞻星辰
載歌幽人
流水今日
明月前身

Offline

#52 2008-06-14 07:26:41

Mr_Shameless
Member
Registered: 2008-05-20
Posts: 19

Re: C++ program, Arch took 14 secs while PCLOS, Ubuntu, Mandriva only 8-9.

Hi, i guess this topic is over. But i just tried the OpenSUSE live KDE4 CD, and found some interesting facts. I just want to present them here, for your information.

These binaries were all compiled under Archlinux, then run on OpenSUSE.

-march=i586 -O2: 6 seconds
-march=686 -O2: 5 seconds
-march=native -O2: 5 seconds
-march=native -O3: 3 seconds

So, OpenSUSE was even faster than Ubuntu, wow. I forgot to check what version of OpenSUSE that was, not sure 10.3 or 11. I was directed to that from the KDE site.

Offline

#53 2008-08-06 17:12:26

cjpembo
Member
Registered: 2008-08-06
Posts: 105

Re: C++ program, Arch took 14 secs while PCLOS, Ubuntu, Mandriva only 8-9.

System:  2.33 GHz  64-bit Archlinux

g++ -march=x86-64 -O3 -msse3 -pipe -fomit-frame-pointer main.cpp -o main

time ./main

real    0m1.686s
user    0m1.670s
sys     0m0.013s

Offline

#54 2008-08-06 18:56:32

czar
Member
Registered: 2008-03-08
Posts: 115

Re: C++ program, Arch took 14 secs while PCLOS, Ubuntu, Mandriva only 8-9.

Asgaroth wrote:

but the posts with just the execution time for their machines only tested on Arch and nothing else is not really helpful.

cjpembo wrote:

System:  2.33 GHz  64-bit Archlinux

g++ -march=x86-64 -O3 -msse3 -pipe -fomit-frame-pointer main.cpp -o main

time ./main

real    0m1.686s
user    0m1.670s
sys     0m0.013s

excellent month and a half bump

Last edited by czar (2008-08-06 18:57:52)

Offline

#55 2008-08-06 20:31:41

cjpembo
Member
Registered: 2008-08-06
Posts: 105

Re: C++ program, Arch took 14 secs while PCLOS, Ubuntu, Mandriva only 8-9.

All results use the same compile settings:

g++ -march=x86-64 -O3 -msse3 -pipe -fomit-frame-pointer main.cpp -o main

Results:

Kubuntu 8.04 64-bit Live CD:         2.229 seconds
ArchLinux 64-bit installed system:  1.686 seconds
LFS 64-bit Live CD:                       1.543 seconds

Arch is fast, but it should be faster.

Chris

Offline

#56 2008-08-17 08:52:01

SyXbiT
Member
Registered: 2008-06-28
Posts: 152
Website

Re: C++ program, Arch took 14 secs while PCLOS, Ubuntu, Mandriva only 8-9.

1.6 seconds with following compile flags:
g++ -O3 -fomit-frame-pointer -march=core2 test.cpp -o core2_O3.o
(also posted -O2 for comparison's sake)

Intel Core2Quad (Penryn) 2.53GHZ. 12MB L2 Cache 4GB DDR2 RAM

syxbit@SyXbiT-D:~/code$ time ./core2_O2.o 
real    0m3.833s
user    0m3.830s
sys     0m0.003s


syxbit@SyXbiT-D:~/code$ time ./core2_O3.o 
real    0m1.607s
user    0m1.550s
sys     0m0.007s

and just so you all know, you can use -march=native (as of GCC 4.2.2)
this will pick the right option for you (in my case 'core2')


also tested on my laptop with same compile flags:
Intel Santa Rosa Core2Duo T7500 w/ 4GB DDR2 RAM

syxbit@SyXbiT-L:~/code$ time ./core2_O2.o 
real    0m4.676s
user    0m4.663s
sys     0m0.007s


syxbit@SyXbiT-D:~/code$ time ./core2_O3.o 
real    0m2.129s
user    0m2.007s
sys     0m0.050s

Last edited by SyXbiT (2008-08-17 09:01:40)

Offline

#57 2008-08-17 09:10:54

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: C++ program, Arch took 14 secs while PCLOS, Ubuntu, Mandriva only 8-9.

SyXbiT wrote:

1.6 seconds with following compile flags:
g++ -O3 -fomit-frame-pointer -march=core2 test.cpp -o core2_O3.o
(also posted -O2 for comparison's sake)

How does that have anything to do with this thread?


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#58 2008-08-17 18:59:45

SyXbiT
Member
Registered: 2008-06-28
Posts: 152
Website

Re: C++ program, Arch took 14 secs while PCLOS, Ubuntu, Mandriva only 8-9.

shining wrote:
SyXbiT wrote:

1.6 seconds with following compile flags:
g++ -O3 -fomit-frame-pointer -march=core2 test.cpp -o core2_O3.o
(also posted -O2 for comparison's sake)

How does that have anything to do with this thread?

wow. how friendly.

Offline

#59 2008-08-17 23:55:34

czar
Member
Registered: 2008-03-08
Posts: 115

Re: C++ program, Arch took 14 secs while PCLOS, Ubuntu, Mandriva only 8-9.

Its about comparing the speed between two distros not "omgz my puter is uber fast". "1.6 seconds" is an arbitrary number until you do the same on another distro.

Offline

#60 2008-08-18 05:38:57

Intrepid
Member
Registered: 2008-06-11
Posts: 254

Re: C++ program, Arch took 14 secs while PCLOS, Ubuntu, Mandriva only 8-9.

@Mr_Shameless: This could be offset not just by distro problems, but by kernel problems.  Are you sure there isn't some problem with hardware detection in your arch kernel?  Are your cores running at full frequency?  Is SMP properly working in your kernel?

For a while, I had a problem with detection of both cores in arch due to a bios/kernel communication problem.  ACPI was also delayed due to incompatible BIOS settings.  This could be a weirdo problem like that.

To deduce this scientifically, you need to ensure all of the hurdles are ironed out. E.g. right now I am using an older (relatively) kernel for hardware compatibility (2.6.25).

Last edited by Intrepid (2008-08-18 05:39:53)


Intrepid (adj.): Resolutely courageous; fearless.
Specs: AMD Phenom II X3 720 BE unlocked, Asus Radeon HD 4870 Dark Knight, Lite-On lightscribe SATA drive, Western Digital Caviar Black HD. 4GB DDR3 1600

Offline

#61 2010-03-10 13:10:47

akurei
Member
From: Bochum, NRW, Germany
Registered: 2009-05-25
Posts: 141
Website

Re: C++ program, Arch took 14 secs while PCLOS, Ubuntu, Mandriva only 8-9.

14:07 akurei@matt:lol $ g++ lol.cpp -o notoptimized
14:08 akurei@matt:lol $ g++ -O2 -Wall -fomit-frame-pointer -march=native lol.cpp -o optimized
14:08 akurei@matt:lol $ time ./notoptimized 
Mi 10. Mär 14:09:10 CET 2010
155117520
Mi 10. Mär 14:09:23 CET 2010

real    0m13.534s
user    0m13.412s
sys     0m0.030s
14:09 akurei@matt:lol $ time ./optimized 
Mi 10. Mär 14:09:30 CET 2010
155117520
Mi 10. Mär 14:09:40 CET 2010

real    0m9.888s
user    0m9.796s
sys     0m0.013s
14:09 akurei@matt:lol $ cat /proc/cpuinfo 
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 28
model name      : Intel(R) Atom(TM) CPU N270   @ 1.60GHz
stepping        : 2
cpu MHz         : 800.000
cache size      : 512 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 xtpr pdcm movbe lahf_lm
bogomips        : 3193.62
clflush size    : 64
cache_alignment : 64
address sizes   : 32 bits physical, 32 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 28
model name      : Intel(R) Atom(TM) CPU N270   @ 1.60GHz
stepping        : 2
cpu MHz         : 800.000
cache size      : 512 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1
apicid          : 1
initial apicid  : 1
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 xtpr pdcm movbe lahf_lm
bogomips        : 3193.34
clflush size    : 64
cache_alignment : 64
address sizes   : 32 bits physical, 32 bits virtual
power management:

14:10 akurei@matt:lol $ uname -a
Linux matt 2.6.32-ARCH #1 SMP PREEMPT Tue Feb 23 19:24:08 UTC 2010 i686 Intel(R) Atom(TM) CPU N270 @ 1.60GHz GenuineIntel GNU/Linux

Oh, and by the way:

14:10 akurei@matt:lol $ g++ -O3 -Wall -fomit-frame-pointer -march=native lol.cpp -o optimized
14:12 akurei@matt:lol $ time ./optimized 
Mi 10. Mär 14:17:11 CET 2010
155117520
Mi 10. Mär 14:17:17 CET 2010

real    0m5.596s
user    0m5.486s
sys     0m0.017s

Last edited by akurei (2010-03-10 13:18:05)

Offline

#62 2010-03-10 13:24:13

Allan
Developer
From: Brisbane, AU
Registered: 2007-06-09
Posts: 9,939
Website

Re: C++ program, Arch took 14 secs while PCLOS, Ubuntu, Mandriva only 8-9.

Offline

Board footer

Powered by FluxBB