Usenet comp.os.linux.alpha (1997-2013)
 help / color / mirror / Atom feed
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: fast array calculation in C
Date: 1999/10/13	[thread overview]
Message-ID: <38044C2C.C06F699B@ife.ee.ethz.ch> (raw)
In-Reply-To: 877lksab9h.fsf@gmx.de

Eberhard Burr wrote:
> 
> Alex Rhomberg <rhomberg@ife.ee.ethz.ch> writes:
> 
> Would you care posting an example?  I am not a computer scientist but
> I'm always interested in speedy calculations ;-) I guess from looking
> at an example of what you did, I can learn much more than from
> following the discussion about aliasing (honestly, I don't even know
> what that is).

Sure

here is the code I posted to the alpha-c mailing list (for compaq ccc):
#define FAST or not and look at the speed differences.
I used the perl script at the bottom to find bad lines in the assembler
code
- Alex

===========snip example code follows

void subroutine(double *fmat_lin, const double __restrict x,
        const double __restrict dhdX0_loc)
{
#ifdef FAST
    double fmat_li[9];
#else
    double *fmat_li = fmat_lin;
#endif
    
    fmat_li[0+3*0] = x[0]*dhdX0_loc[0];
    fmat_li[0+3*1] = x[0]*dhdX0_loc[1];
    fmat_li[0+3*2] = x[0]*dhdX0_loc[2];
    fmat_li[1+3*0] = x[1]*dhdX0_loc[0];
    fmat_li[1+3*1] = x[1]*dhdX0_loc[1];
    fmat_li[1+3*2] = x[1]*dhdX0_loc[2];
    fmat_li[2+3*0] = x[2]*dhdX0_loc[0];
    fmat_li[2+3*1] = x[2]*dhdX0_loc[1];
    fmat_li[2+3*2] = x[2]*dhdX0_loc[2];
    for (k = 1;k < 8;k++) {
      fmat_li[0+3*0] += x[3*k+0]*dhdX0_loc[3*k+0];
      fmat_li[0+3*1] += x[3*k+0]*dhdX0_loc[3*k+1];
      fmat_li[0+3*2] += x[3*k+0]*dhdX0_loc[3*k+2];
      fmat_li[1+3*0] += x[3*k+1]*dhdX0_loc[3*k+0];
      fmat_li[1+3*1] += x[3*k+1]*dhdX0_loc[3*k+1];
      fmat_li[1+3*2] += x[3*k+1]*dhdX0_loc[3*k+2];
      fmat_li[2+3*0] += x[3*k+2]*dhdX0_loc[3*k+0];
      fmat_li[2+3*1] += x[3*k+2]*dhdX0_loc[3*k+1];
      fmat_li[2+3*2] += x[3*k+2]*dhdX0_loc[3*k+2];
    }
#ifdef FAST
    memcpy(fmat_lin, fmat_li, sizeof(double)*9);
#endif
}

============== perl code follows

#!/usr/bin/perl -wp
# usage if this script is named find_stalls
#objdump -d myobject.o | find_stalls | more
#then search for UGLY!
use strict;
use vars qw/$t/;

$t &&  /\Q$t,/ && s/$/\t\t#UGLY!!/; #append UGLY if target is seen
$t = (/(?:mult|subt|addt|ldt).*(\$f\d+)/)[0];
   #new target is last floating register arg



  reply	other threads:[~1999-10-13  4:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-10-07  4:00 fast array calculation in C Alex Rhomberg
1999-10-09  4:00 ` Greg Lindahl
1999-10-11  4:00   ` Alex Rhomberg
1999-10-11  4:00     ` Greg Lindahl
1999-10-11  4:00       ` memore0
1999-10-11  4:00         ` Greg Lindahl
1999-10-12  4:00         ` Alex Rhomberg
1999-10-12  4:00           ` memore0
1999-10-12  4:00             ` Alex Rhomberg
1999-10-12  4:00           ` Eberhard Burr
1999-10-13  4:00             ` Alex Rhomberg [this message]
1999-10-13  4:00               ` Robert Harley
1999-10-12  4:00       ` Alex Rhomberg
     [not found] <3809E64D.85BDCAFC@ife.ee.ethz.ch>
     [not found] ` <7ud6gc$2o94@news2.newsguy.com>
1999-10-18  4:00   ` Alex Rhomberg
1999-10-18  4:00     ` Greg Lindahl
1999-10-18  4:00       ` Alex Rhomberg
1999-10-18  4:00   ` Emil Briggs
1999-10-18  4:00     ` Greg Lindahl
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox