Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Jaap Schellekens <schj@geo.vu.nl>
To: axp-list@redhat.com
Subject: Binary search speed in Alpha
Date: Fri, 27 Nov 1998 11:07:37 +0100 (MET)	[thread overview]
Message-ID: <13918.31089.348053.439622@flow.geo.vu.nl> (raw)


Hello all,

I have a model of unsaturated flow which I try to optimize
speedwise. I'm asking you this becuase we are in the process
of getting one ore two new workstation for modelling and I would
love to get an Alpha. 

From profiling I concluded that most of the time is not spend
in the matrix solving, but in the functions to construct the matrix.
Basically I'm now looking at a method for searching a sorted table
that has a better performance on an Alpha. I suspect the 
memory access pattern of the binary search I use does not
favour the Alpha architecture a lot. Some numbers (seconds):

Arch				TimeA	     TimeB    TimeC
----------------------------------------------------------
pentium 293MMX (used to be 233):  19.1       37.1       -
Alpha XL300:			  19.4	     100.7     26.1
SPARC Ultra 170:		  30.3	     91.5       -

TimeA: run time with look-up tables 
TimeB: run time original function 
TimeB: run time original function using libfm and libffm


From this i conclude:
 1) libfm  and libffm are a Good Thing Indeed!!
 2) Somehow the binary search is not well optimized
    for the Alpha architecture


I have tried several things, including changing the size of the look up
tables but that has very little influence on the results. The same for
changing the type of the tables from double to float.

Any suggestions (also pointers to books on this subject) are welcome,


Jaap


The code (based on an old -- freeware -- pascal version of numerical recipies):

double getval_short(TBL *tab, double xval)
{
	unsigned long index,mid,lo,up,n;
	int ascnd;
	double top,bott,rico;

	/* first check high and low points */	
	if (xval <= tab->x[0])
		return tab->y[0];
	else if (xval >= tab->x[(tab->points) - 1])
		return tab->y[(tab->points) - 1];

	/* Find position in array: x[index] < xval < x[index +1]*/
	n = tab->points;
	lo = -1; up = n;

	ascnd = (tab->x[n - 1] >= tab->x[0]);
	while (up - lo > 1){
		mid = (up + lo) >> 1;
		if (xval >= tab->x[mid] == ascnd)
			lo = mid;
		else
			up = mid;
	}
	if ( xval == tab->x[0])  index = 0;
	else if (xval == tab->x[n-1]) index =  n - 2;
	else index = lo;

	/* linear interpolation */
	top = (tab->y[index + 1] - tab->y[index]);
	bott = (tab->x[index + 1] - tab->x[index]);
	rico =  top/bott;
	return (rico * (xval - tab->x[index])) + tab->y[index];
}

-- 
--------------------------------------------------------------
Jaap Schellekens                E-mail:         schj@geo.vu.nl
Hydro(geo)logy Dept.            Fax:            ++31 20 6462457
Inst. of Earth Sc.              Voice:          ++31 20 4447287
Vrije Universiteit
De Boelelaan 1085               use finger schj@flow.geo.vu.nl
                                for extra information
1081 HV Amsterdam NL            See also:   http://flow.geo.vu.nl


             reply	other threads:[~1998-11-27 10:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-27 10:07 Jaap Schellekens [this message]
1998-11-27  8:58 ` Binary search speed in Alpha Matti Aarnio
1998-11-27 13:27   ` Jaap Schellekens
1998-11-28 19:12     ` Bibek Sahu
1998-11-28 19:36       ` Jaap Schellekens
1998-11-28 20:46         ` Dave Gilbert
1998-11-29 16:54           ` Jaap Schellekens
1999-05-26 13:05       ` ElectricFence/Alpha Jaap Schellekens
1999-05-26 14:03         ` ElectricFence/Alpha Uncle George
1999-05-26 14:52           ` ElectricFence/Alpha Jaap Schellekens
1999-05-26 14:06         ` ElectricFence/Alpha Alvin Starr
1999-05-26 14:24         ` ElectricFence/Alpha Maciej W. Rozycki
1999-05-26 14:45         ` ElectricFence/Alpha Giuliano Procida
1999-05-26 14:56         ` ElectricFence/Alpha Mark Probst
  -- strict thread matches above, loose matches on Subject: below --
1998-11-27 13:58 Binary search speed in Alpha Wessels, Hans
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