[Issue 3661] ^^ not supported in array operations.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 21 18:05:23 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3661



--- Comment #9 from Witold Baryluk <baryluk at smp.if.uj.edu.pl> 2010-11-21 18:04:00 PST ---
> > I don't know many methods which use them personally, but it doesn't mean that
> > they shouldn't be provided. Actually any formula which have exponent (ie.
> > Stirling's approximation) can be used to compute multiple values in parallel,
> > so it should be possible to "vectorize" them easly.
> 
> The problem is that they're not going to be efficiently vectorized. It'd be
> possible to have x[] ^^ y[] become arrayPow(x, y); but array pow would just be
> a for-loop of calls to pow().
> I guess what I'm saying is that there'd be no performance benefit.

Now I see. I had no idea that SSE do not have nacassary instructions for this
(log,exp,pow). But this is limitation of hardware vector unit. Language should
not make such limitations. It is possible that new hardware will support more
transcendental functions.

Acutely there are some simple vector libraries, which implements missing
SSE/AVX/AltiVec functions (sin/cos/sincos/exp/log/pow), and can be found in
approximated, precise or strict versions. And even then (with software
emulation) they are faster than just using scalar unit 4 times (and even faster
for AVX with 8 single precision float operands) - just benchmarked some code
from http://gruntthepeon.free.fr/ssemath/ on Intel Core2.

When talking about ^^ operation, it is known that x ^^ y == exp(y * log(x)),
and this is how this operation is implemented most often. Additionally if x is
constant (like few of my examples), log(x) can be precomputed in compile-time.

I'm not only fighting here about performance, but about clear and orthogonal
usage of syntax. It should just work.

Thanks.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list