From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,80f21c0575c616e8,start X-Google-Attributes: gid111c93,public From: Alex Rhomberg Subject: fast array calculation in C Date: 1999/10/07 Message-ID: <37FCEB06.5F23041F@ife.ee.ethz.ch>#1/1 X-Deja-AN: 534015377 Content-Transfer-Encoding: 7bit X-Trace: 7 Oct 1999 20:48:38 +0100, beethoven.ee.ethz.ch Organization: Electronics Lab, ETH Zurich, Switzerland Content-Type: text/plain; charset=us-ascii MIME-Version: 1.0 Newsgroups: comp.os.linux.alpha Hi I'm trying to do fast arrays/matrixes/vectors in C Not easy I've found that looking at the produces assembler is important. In my case, the Compaq ccc compiler produces nearly three times faster code than gcc. It gets dependencies much better. I've found that the biggest difference in code efficience comes if the compiler thinks that lvalue and rvalue accesses could be the same address or not. By feeding the produced assembler into a short Perl script, I was able to identify ugly code, optimize it and shave 30% of the execution time of a 700 line function by optimizing 4 lines. I'll post the perl-script for those who are interested. It finds the lines where the target of a ldt/addt/mult/subt function appears in the following line, which means pipeline stalls: - Alex **************Listing of find_stalls *************** #!/usr/bin/perl -wlp # usage: #objdump -d myobject.o | find_stalls|more #then search for UGLY! use strict; use vars qw/$target/; BEGIN {$target = "alotta garbaga"} chomp; $_ .= "\t\t#UGLY!!" if /\Q$target,/; $target = "allotta garbaga"; $target = $1 if /ldt\s+(\$f\d+),/; #target is first arg of ldt $target = $1 if /(?:mult|subt|addt)\s+.*(\$f\d+)/; #target is last arg of mlt, subt and add