Article View: comp.sys.mac.programmer.help
Article #58Re: [Altivec Newbie] optimizing current code?
From: Dan Gordon
Date: Thu, 18 Jan 2001 14:32
Date: Thu, 18 Jan 2001 14:32
39 lines
2979 bytes
2979 bytes
Dave Howell wrote: > > > Personally, I try to keep things to one AltiVec instruction per line. > > > It helps me optimize later, but there's no reason you have to do it > > > that way. > > > > CodeWarrior does a reasonable job at scheduling if you write in C, so I am > > curious how keeping things one per line helps you optimize. > > Ian, you misunderstood. He didn't say it helps CodeWarrior to optimize, > but that it helped HIM to optimize. If your code is written one > instruction per line, it's easier from an editing standpoint to reorder > operations later, than if you have to edit complex vector expressions. > > Dave Hi, I'm curious about the qualifier "if you write in C" CW will schedule the instructions effectively. What I have done is to write a C++ class called "vec4" so I can do things like vec4 a(1,2,3,4); vec4 b(2,3,4,5); vec4 c; c = a + b; via operator overloading and inlining the c = a+b should resolve to c = vec_add(a,b); The vec4 is a union between a vector float and an array of four floats. For the moment, I deal with vec_madd and vec_nmsub by wrapping them in equivalent functions that operate on a vec4. via inlining, the wrapper should have no effect on the final code. However, I observe that I take a modest performance hit by doing this as opposed to just writing out the vector instructions explicitly. Is there some reason the compiler should optimize differently in the two cases? Dan Gordon
Technical Details
Message-ID:
<3A66FE75.86226B62@sarkomand.com>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!news-out.cwix.com!newsfeed.cwix.com!europa.netcrusader.net!199.45.45.8!cyclone1.ba-dsg.net!typhoon2.ba-dsg.net.POSTED!not-for-mailReferences:
<943r3l$hn2$1@nnrp1.deja.com> <170120011731277716%dcardani@buena.spamfree.com> <Pine.SGI.4.30.0101171735050.41019-100000@helix2.caltech.edu> <180120010242044690%dave@noreturnaddress.nulldev>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 101ec9,a6671d8e4f3ed02f
X-Google-Attributes: gid101ec9,public
X-Google-Thread: 10bcce,a6671d8e4f3ed02f
X-Google-Attributes: gid10bcce,public
X-Google-Thread: f635e,a6671d8e4f3ed02f
X-Google-Attributes: gidf635e,public
X-Google-ArrivalTime: 2001-01-18 06:35:14 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!news-out.cwix.com!newsfeed.cwix.com!europa.netcrusader.net!199.45.45.8!cyclone1.ba-dsg.net!typhoon2.ba-dsg.net.POSTED!not-for-mail
Message-ID: <3A66FE75.86226B62@sarkomand.com>
From: Dan Gordon <dfgordon@sarkomand.com>
X-Mailer: Mozilla 4.73C-CCK-MCD {C-UDP; EBM-APPLE} (Macintosh; U; PPC)
X-Accept-Language: en,pdf
MIME-Version: 1.0
Newsgroups: comp.sys.mac.programmer.help,comp.sys.mac.programmer.codewarrior,codewarrior.mac
Subject: Re: [Altivec Newbie] optimizing current code?
References: <943r3l$hn2$1@nnrp1.deja.com> <170120011731277716%dcardani@buena.spamfree.com> <Pine.SGI.4.30.0101171735050.41019-100000@helix2.caltech.edu> <180120010242044690%dave@noreturnaddress.nulldev>
Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D4F5353"
Content-Transfer-Encoding: 7bit
Lines: 43
Date: Thu, 18 Jan 2001 14:32:17 GMT
NNTP-Posting-Host: 138.88.37.45
X-Complaints-To: newsadmin@bellatlantic.net
X-Trace: typhoon2.ba-dsg.net 979828337 138.88.37.45 (Thu, 18 Jan 2001 09:32:17 EST)
NNTP-Posting-Date: Thu, 18 Jan 2001 09:32:17 EST