From nobody@FreeBSD.org  Wed Jul 17 18:44:03 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 2CB8537B400
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 17 Jul 2002 18:44:03 -0700 (PDT)
Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id DF9E443E31
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 17 Jul 2002 18:44:02 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g6I1i2OT096589
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 17 Jul 2002 18:44:02 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.4/8.12.4/Submit) id g6I1i25M096588;
	Wed, 17 Jul 2002 18:44:02 -0700 (PDT)
Message-Id: <200207180144.g6I1i25M096588@www.freebsd.org>
Date: Wed, 17 Jul 2002 18:44:02 -0700 (PDT)
From: Si-Liang Chang <slchang@csie.nctu.edu.tw>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Functions with more than 1 arguments Gets More Executing Time.
X-Send-Pr-Version: www-1.0

>Number:         40714
>Category:       kern
>Synopsis:       Functions with more than 1 arguments Gets More Executing Time.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          wish
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 17 18:50:01 PDT 2002
>Closed-Date:    Mon Jul 29 02:48:59 PDT 2002
>Last-Modified:  Mon Jul 29 02:48:59 PDT 2002
>Originator:     Si-Liang Chang
>Release:        4.6-Release
>Organization:
Institute of Physics, National Chiao-Tung Univ., Taiwan, R.O.C
>Environment:
FreeBSD orchid 4.6-RELEASE FreeBSD 4.6-RELEASE #0: Tue Jun 11 06:14:12 GMT 2002     murray@builder.freebsdmall.com:/usr/src/sys/compile/GENERIC  i386      
>Description:
When running my molecule dynamics simulation programs on FreeBSD, they are always about 33% slower than those (with the same conditions) run on a Linux box or Solaris. In order to simplify the problem, we run several testing programs. Finally, we conclude that, functions with more than 1 arguments spend much executing time.
>How-To-Repeat:
In Program 1, it spends about 7.534u on our PPro FreeBSD 4.6R mechine.
In Program 2, it spends about 2.904u on our PPro FreeBSD 4.6R mechine.

In the meanwhile,
In Program 1, it spends about 2.56u on our PPro Solaris 8 mechine.
In Program 2, it spends about 2.66u on our PPro Solaris 8 mechine.

Of course, the problem exist for mechines with higher speed such as AMD XP 1G and XP+ 1.8G.

Program 1------------------------------

#include <stdio.h>

double Fun(double,double,double);

int main(void) {
    double x,y,z,s;
    
    s=0.0;
    for(x=0.0;x<1.0;x=x+0.001) {
        for(y=0.0;y<1.0;y=y+0.001) {
            for(z=0.0;z<1.0;z=z+0.1) {
                s=Fun(x,y,z);
            }
        }
    }
}
double Fun(double x,double y,double z) {
    return(x+y+z);
}


Program 2 ---------------------------------

#include <stdio.h>

double Fun(double);

int main(void) {
    double x,y,z,s;
    
    s=0.0;
    for(x=0.0;x<1.0;x=x+0.001) {
        for(y=0.0;y<1.0;y=y+0.001) {
            for(z=0.0;z<1.0;z=z+0.1) {
                s=Fun(x)+Fun(y)+Fun(z);
            }
        }
    }
}
double Fun(double x) {
    return(x+1.0);
}

>Fix:
      
>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: Si-Liang Chang <slchang@csie.nctu.edu.tw>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: kern/40714: Functions with more than 1 arguments Gets More
 Executing Time.
Date: Thu, 18 Jul 2002 16:37:04 +1000 (EST)

 On Wed, 17 Jul 2002, Si-Liang Chang wrote:
 
 > >Description:
 > When running my molecule dynamics simulation programs on FreeBSD, they are always about 33% slower than those (with the same conditions) run on a Linux box or Solaris. In order to simplify the problem, we run several testing programs. Finally, we conclude that, functions with more than 1 arguments spend much executing time.
 > >How-To-Repeat:
 > In Program 1, it spends about 7.534u on our PPro FreeBSD 4.6R mechine.
 > In Program 2, it spends about 2.904u on our PPro FreeBSD 4.6R mechine.
 >
 > In the meanwhile,
 > In Program 1, it spends about 2.56u on our PPro Solaris 8 mechine.
 > In Program 2, it spends about 2.66u on our PPro Solaris 8 mechine.
 
 I think this is actually a stack alignment problem (partly in FreeBSD,
 partly in gcc).  It is not present in -current.  Try using gcc-3.1 from
 ports for time-critical floating-point applications.
 
 Bruce
 
State-Changed-From-To: open->feedback 
State-Changed-By: dwmalone 
State-Changed-When: Sun Jul 28 06:31:06 PDT 2002 
State-Changed-Why:  
Can you try Bruce's suggestion of testing gcc 3.1? The old behaviour 
is a well known interaction between FreeBSD not aligning the stack 
and gcc assuming the stack is already aligned rather than aligning 
it itself. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40714 

From: "Si-Liang Chang" <slchang.ep87g@nctu.edu.tw>
To: <freebsd-gnats-submit@FreeBSD.org>, <slchang@csie.nctu.edu.tw>
Cc:  
Subject: Re: kern/40714: Functions with more than 1 arguments Gets More Executing Time.
Date: Mon, 29 Jul 2002 10:43:52 +0800

 This is a multi-part message in MIME format.
 
 ------=_NextPart_000_0008_01C236EC.D4B2E1F0
 Content-Type: text/plain;
 	charset="big5"
 Content-Transfer-Encoding: quoted-printable
 
 Yes, I have install gcc 3.0.4. After compiling with -malign-double, it =
 seems that it doesn't work on my molecular dynamics programs.
 
     Si-Liang Chang
 
 ------=_NextPart_000_0008_01C236EC.D4B2E1F0
 Content-Type: text/html;
 	charset="big5"
 Content-Transfer-Encoding: quoted-printable
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <HTML><HEAD>
 <META http-equiv=3DContent-Type content=3D"text/html; charset=3Dbig5">
 <META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
 <STYLE></STYLE>
 </HEAD>
 <BODY bgColor=3D#ffffff>
 <DIV><FONT size=3D2>Yes, I have install gcc 3.0.4. After =
 compiling&nbsp;with=20
 -malign-double, it seems that it doesn't work on my molecular dynamics=20
 programs.</FONT></DIV>
 <DIV><FONT size=3D2></FONT>&nbsp;</DIV>
 <DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; Si-Liang =
 Chang</FONT></DIV></BODY></HTML>
 
 ------=_NextPart_000_0008_01C236EC.D4B2E1F0--
 
State-Changed-From-To: feedback->closed 
State-Changed-By: dwmalone 
State-Changed-When: Mon Jul 29 02:47:54 PDT 2002 
State-Changed-Why:  
Stack alignment problem fixed with gcc 3 port. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40714 
>Unformatted:
