This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
slow execution speed when compared against visual c++
- From: Marco Satyro <marco at virtualmaterials dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 03 Jan 2003 23:43:06 -0700
- Subject: slow execution speed when compared against visual c++
Dear GCC Help
I am considering converting a very large project from Visual C++ to GCC.
This project does lots of scientific computations and therefore the
execution speed is very important. I am doing the development on a
Pentium 4 running Windows XP, and I wrote a little program to test the
execution speed. I installed gcc using cygwin and wrote the program
using the bloodshed IDE. The program and makefile are attached
I set the optimization flag to -O3, but I am getting an execution speed
480 times slower than when I use Visual C++. It seems like gcc is using
some kind of floating point emulation instead of using the actual
hardware math.
Could you provide me with any clues about this problem?
Thanks in advance,
Marco
--
Marco A. Satyro, Ph.D., P.Eng.
403 241 3929 (phone)
403 241 8018 (fax)
Virtual Materials Group, Inc.
www.virtualmaterials.com
// test speed for floating point calcs
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
clock_t start, finish;
start = clock();
printf("\n start...\n");
for (double i = 0; i < 1e7; i++)
{
double val = (double)i + 0.01;
val = log(val);
val = exp(val);
val = sin(val);
val = cos(val);
val = tan(val);
val = log10(val);
val = i;
val = sqrt(val);
val = pow(val, 4.567);
}
finish = clock();
double duration = (double)(finish - start) / CLOCKS_PER_SEC;
printf( "Elapsed time = %12.5e", duration);
getchar();
return 0;
}
# Project: Project1
# Makefile created by Dev-C++ 4.9.7.0
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
RES =
OBJ = ../speed/speedtest.o $(RES)
LIBS = -L"e:/Dev-Cpp/lib"
INCS = -I"e:/Dev-Cpp/include" -I"e:/Dev-Cpp/include/c++" -I"e:/Dev-Cpp/include" -I"E:/SeappCode/Include" -I"E:/Seappprj/SeaPkg"
BIN = speed.exe
CXXFLAGS = $(INCS) -O3
CFLAGS = $(INCS) -O3
.PHONY: all all-before all-after clean clean-custom
all: all-before speed.exe all-after
clean: clean-custom
rm -f $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CPP) $(OBJ) -o "speed.exe" $(LIBS) $(CXXFLAGS)
../speed/speedtest.o: ../speed/speedtest.cpp
$(CPP) -c ../speed/speedtest.cpp -o ../speed/speedtest.o $(CXXFLAGS)