From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 20669 invoked from network); 27 Nov 1998 10:59:55 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 27 Nov 1998 10:59:55 -0000 Received: from mea.tmt.tele.fi (root@mea.tmt.tele.fi [194.252.70.2]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id FAA01509 for ; Fri, 27 Nov 1998 05:59:14 -0500 Received: by mea.tmt.tele.fi id <92268-18653>; Fri, 27 Nov 1998 10:58:31 +0200 Subject: Re: Binary search speed in Alpha In-Reply-To: <13918.31089.348053.439622@flow.geo.vu.nl> from Jaap Schellekens at "Nov 27, 98 11:07:37 am" To: axp-list@redhat.com Date: Fri, 27 Nov 1998 10:58:31 +0200 (EET) From: Matti Aarnio Phone: +358-20402082 (office, with redirection to cellular) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <19981127085841Z92268-18653+2@mea.tmt.tele.fi> > 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): How large is the table ? ... > 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. Alpha's memory subsystem is very good at pulling in (and also writing) large amounts of *sequential* data, in fact so good, that you can get at least 10-20 sequential data entries in within the time you do a *single* random walk step. (And you may get even more dramatic boosts with SDRAM based 21164 systems, I don't remember what the XL300 has in it.) Consider: CPU is clocking at 500+ MHz, it issues two integer instructions and one or two float instructions in parallel in every cycle. The memory subsystem runs at 60 to 100 million cycles per second during the SDRAM burst (128 to 2048 cycles per burst). With wide busses (128 bits) the memory can barely stay in par with processing speed. (Usually the CPU pipeline is running idle waiting for data...) So yes, surprisingly you could perhaps get best performance by doing simple linear search. Of course the log(N) is better when the N is very large, but up to N=100 (?) that might not be the case. When you know that you are reading in large amounts of data, you could perhaps sprinkle in assembly statements ordering the memory subsystem to do pre-load of a burst of data into the cache. The amount of data does exceed the amount of L1 cache at the CPU ? Then timely preloads will help. (So if you can't avoid blowing the cache away, do it at least in a smart way.. You could even use loads which don't cache at all, but getting them to burst properly is nightmarish..) That preload trick is not quite simple, nor I have my reference books with me now. But essentially: preload(srcaddr) for (...) { preload(srcaddr+preload_stride) scan_blob(srcaddr) srcaddr += preload_stride } The scan processing must handle the amount of data given in preload_stride, which in turn must be some power-of-2 given to the preload instruction, if I remember correctly. These tricks should work with all processors, I think. > Any suggestions (also pointers to books on this subject) are welcome, > Jaap > -- > Jaap Schellekens E-mail: schj@geo.vu.nl /Matti Aarnio