From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24186 invoked by alias); 8 Mar 2007 12:30:57 -0000 Received: (qmail 24173 invoked by uid 22791); 8 Mar 2007 12:30:52 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 08 Mar 2007 12:30:49 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.1/8.13.1) with ESMTP id l28CUlp7017241 for ; Thu, 8 Mar 2007 07:30:47 -0500 Received: from zebedee.littlepinkcloud.COM (vpn-14-8.rdu.redhat.com [10.11.14.8]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l28CUc2x015944; Thu, 8 Mar 2007 07:30:40 -0500 Received: from littlepinkcloud.COM (localhost.localdomain [127.0.0.1]) by zebedee.littlepinkcloud.COM (8.13.8/8.13.5) with ESMTP id l28CUbWa004769; Thu, 8 Mar 2007 12:30:37 GMT Received: (from aph@localhost) by littlepinkcloud.COM (8.13.8/8.13.5/Submit) id l28CUarF004766; Thu, 8 Mar 2007 12:30:36 GMT MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17904.492.460648.266863@zebedee.pink> Date: Thu, 08 Mar 2007 15:01:00 -0000 From: Andrew Haley To: "Shane R" Cc: gcc-help@gcc.gnu.org Subject: Re: Linux c++ opmization--- linux runs at half the speed of windows? In-Reply-To: References: X-Mailer: VM 7.19 under Emacs 22.0.93.1 X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2007-03/txt/msg00108.txt.bz2 Shane R writes: > I hope this is the appropriate forum. Please direct me to the correct one if > it is not. > > I am trying to optimize a c++ application that I ported from a windows > system to Linux. OK. > The app is a terminal based application that does some one time file io at > the start then runs completely in memory. After the one time io the app runs > successive timed epochs on the same data in Windows as Linux. The app is a > program that runs some code for doing non-linear optmization (math stuff). > > The reason why I am posting is that I timed the time it takes for the > application to complete an epoch. It take twice as long in Linux as > windows?!?! That is fairly unusual. > My system is an Intel Centrino Duo with 2gigs of ram. The application is > only using a fraction of available memory in windows and linux. The > application is single-threaded in both. > > I am using Visual Studio 2003 in Windows and when I type gcc -v I get: > Target: i486-linux-gnu > Configured with: ../src/configure -v > --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr > --enable-shared --with-system-zlib --libexecdir=/usr/lib > --without-included-gettext --enable-threads=posix --enable-nls > --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu > --enable-libstdcxx-debug --enable-mpfr --enable-checking=release > i486-linux-gnu > Thread model: posix > gcc version 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5) > > > > I am currently using these g++ options: > > CFLAGS = -o3 -O3 -march=pentium4 -ffast-math -funroll-loops -Wall > -Wno-return-type > > But I have tried every permutation of the above options to virtually no > effect > > The average run time of an epoch in windows is about 3000 milliseconds while > the average run time of an epoch in Linux is 6000! > > I don't know if it matters but I am doing calls to the rand() function in > both my windows and linux apps. It might matter, yes. I suspect that the right approach is to do some profiling. Make sure oprofile is installed, then sudo opcontrol --init sudo opcontrol --start sudo opcontrol --stop opreport -l Let us know how you get along. You might be surprised where the time goes. Andrew.