Numerics: Visual C++ vs. g++
- From: Evgenii Rudnyi <usenet@xxxxxxxxx>
- Date: Thu, 22 May 2008 02:16:04 -0700 (PDT)
I have been working for long time with g++ but for some internal
matter I have to use Visual C++ Express Edition now. I have made quick
tests with my code in C and C++ that implements the naive
multiplication of matrices
http://matrixprogramming.com/MatrixMultiply/code/2direct/
with the goal to see how the compiler optimizes the loops. My commands
to compile and run tests are in the make file compare and
make –f compare
compiles and runs tests with GCC and Visual C++. Below there are
results with gcc 3.3 under Cygwin and Visual C++ Express Edition 2005
at my HP notebook
$ make -f compare
gcc -s -O3 -Wl,--stack=50000000 direct1.c -o direct1-gcc.exe
direct1-gcc.exe
time for C(1000,1000) = A(1000,1000) B(1000,1000) is 2.453000 s
cl -O2 -nologo direct1.c -link -STACK:50000000 -out:direct1-vc.exe
direct1.c
direct1-vc.exe
time for C(1000,1000) = A(1000,1000) B(1000,1000) is 1.984000 s
gcc -s -O3 -Wl,--stack=50000000 direct2.c -o direct2-gcc.exe
direct2-gcc.exe
time for C(1000,1000) = A(1000,1000) B(1000,1000) is 2.047000 s
cl -O2 -nologo direct2.c -link -STACK:50000000 -out:direct2-vc.exe
direct2.c
direct2-vc.exe
time for C(1000,1000) = A(1000,1000) B(1000,1000) is 1.985000 s
g++ -s -O3 direct.cc -o direct-gcc.exe
direct-gcc.exe 1000
time for C(1000,1000) = A(1000,1000) B(1000,1000) is 2 s
cl -EHsc -O2 -nologo -DUSECLOCK direct.cc -link -out:direct-vc.exe
direct.cc
direct-vc.exe 1000
time for C(1000,1000) = A(1000,1000) B(1000,1000) is 6.969 s
One sees that for the C code VC produces a slightly faster code but in
the case of C++ code it is slower more than 3 times. I am new to VC++
and I guess that there are some specific flags to optimize the C++
code. I am searching now in Help but so far unsuccessfully. I would
appreciate any hint in this respect, as it is quite painful to loose a
factor of 3 in a simple loop.
Best wishes,
Evgenii
.
- Follow-Ups:
- Re: Numerics: Visual C++ vs. g++
- From: user923005
- Re: Numerics: Visual C++ vs. g++
- Prev by Date: Re: Quartic vs. Cubic Solutions
- Next by Date: Re: Quartic vs. Cubic Solutions
- Previous by thread: Hibbeler Mechanics of Materials 7th edition || Solution Manual
- Next by thread: Re: Numerics: Visual C++ vs. g++
- Index(es):
Relevant Pages
|