![]() |
| [[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]] |
|
|
#1 |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,145
|
Hi all,
I'm looking for the Intel Approximate Math Library. It used to be at www.intel.com/design/Pentium4/devtools/ but that page moved and I couldn't locate the library. So, does anyone know where to find it, or can send me a copy? That would be much appreciated. I'm also interested in other approximation libraries/functions. The more options between precision and performance the better...Thanks a lot, Nick |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Aug 2004
Location: Århus, Denmark
Posts: 769
|
I have never heard of this library, but AMD has a library of their. I'm sure you know this already, but I'll post it anyway just in case: http://developer.amd.com/acml.jsp
___________________________________________
"Stupid bug! You go squish now!!" - Homer Simpson |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,145
|
AMD's library doesn't really have what I'm looking for. I seek fast implementations of transcendental functions (exp, log, sin, etc). Thanks anyway, it was worth checking out.
So the Intel Approximate Math Library contains approximations of transcendental functions, optimized for SSE. For some time I have used my own implementations (sin/cos) but now I'm looking for more precision with minimal performance impact... |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Aug 2004
Location: Århus, Denmark
Posts: 769
|
The CRT has a few functions implemented using SSE2 (see here), but they are most likely built for precision. The CRT source does however come with VS2005, so you could dig up those files and enhance them for speed
![]()
___________________________________________
"Stupid bug! You go squish now!!" - Homer Simpson |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,145
|
Interesting! It seems pretty hard to derive a faster (single-precision) version from it, but it's always good to have a reference.
|
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,145
|
Since the Intel library is still nowhere to be found, I started writing my own approximations. Here's a 2^x implementation (first attempt):
Code:
All ideas to make it more accurate and/or faster are welcome! |
|
|
|
|
|
#7 |
|
DevMaster Staff
Join Date: Oct 2004
Location: Seattle, WA
Posts: 4,095
|
What are ulps? (Couldn't find the term with google...)
___________________________________________
Currently working at Sucker Punch reedbeta.com - OpenGL demos and other projects Luabridge - a lightweight, dependency-free C++/Lua binding library. CD Lite - an unobtrusive, minimal CD player application for Windows. |
|
|
|
|
|
#8 |
|
DevMaster Staff
Join Date: Jan 2003
Posts: 1,200
|
|
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,145
|
The accuracy/performance balance of the Intel library failed to impress me. At least for the exp2 implementation...
Here's my own vector implementation: Code:
It has a relative accuracy of 2-22.33. It returns infinity on overflow, 0.0 on underflow, and keeps it accracy with denormals. For NaN inputs it returns infinity. Last edited by Nick : 01-20-2007 at 12:08 PM. |
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,145
|
For those interested:
Here's a version with a weighted minimax polynomial of order four, yielding 2-18.54 relative precision: Code:
Code:
Code:
Last edited by Nick : 01-20-2007 at 11:58 AM. |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Jan 2003
Location: Switzerland
Posts: 1,331
|
Hehe, looks cool. If i would work currently in C++, I'd sure plug this into my code directly and look how it affects the image, depending on the quality of the function
![]() But I don't think I'll touch C++ in the sooner time at all anymore... And I don't have my code lying around, else, it would be a simple copy-paste. But I'll remember ![]()
___________________________________________
davepermen.net -Loving a Person is having the wish to see this Person happy, no matter what that means to yourself. -No matter what it means to myself.... |
|
|
|
|
|
#13 | |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,145
|
Quote:
![]() |
|
|
|
|
|
|
#14 |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,145
|
A log2 implementation (first attempt):
Code:
![]() |
|
|
|
|
|
#15 |
|
Senior Member
Join Date: Aug 2004
Location: Århus, Denmark
Posts: 769
|
Any benchmarks to go with that? Not that I'm doubting it will be faster, but it's always nice to know how much faster it is.
![]()
___________________________________________
"Stupid bug! You go squish now!!" - Homer Simpson |
|
|
|
|
|
#16 | |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,145
|
Quote:
Anyway, I'm considering making it an article for the 'Daily Code Gem', including benchmark results. I can't promise when I have the time for it though... |
|
|
|
|
|
|
#17 | |
|
Senior Member
Join Date: Jan 2003
Location: Switzerland
Posts: 1,331
|
Quote:
Yes. You and you're work are the only reason to regret this... But sorry, thats not enough... ![]()
___________________________________________
davepermen.net -Loving a Person is having the wish to see this Person happy, no matter what that means to yourself. -No matter what it means to myself.... |
|
|
|
|
|
|
#18 | |
|
Valued Member
Join Date: Nov 2004
Location: Milan -ITALY-
Posts: 298
|
There's one thing I don't understand.
I'll quote from "AMaths.pdf", page 5: Quote:
Regards, Ciao ciao : )
___________________________________________
-Nautilus 1.551640271931635485e+1292913986 ? Why, that's: 2 ^ ((2 ^ (2 ^ ((2 ^ 2) + (2 ^ (2 - 2))))) - (2 ^ (2 - 2))). Now verify, please... |
|
|
|
|
|
|
#19 | |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,145
|
Quote:
A native C# compiler with inline assembly would convince me in a second though... |
|
|
|
|
|
|
#20 | |
|
Senior Member
Join Date: Aug 2004
Location: Ghent, Belgium
Posts: 1,145
|
Quote:
|
|
|
|
|
|
|
#21 |
|
Valued Member
Join Date: Nov 2004
Location: Milan -ITALY-
Posts: 298
|
Thank you very much, Nick
![]()
___________________________________________
-Nautilus 1.551640271931635485e+1292913986 ? Why, that's: 2 ^ ((2 ^ (2 ^ ((2 ^ 2) + (2 ^ (2 - 2))))) - (2 ^ (2 - 2))). Now verify, please... |
|
|
|
|
|
#22 |
|
New Member
Join Date: Dec 2007
Location: Ottawa, Canada
Posts: 1
|
Hi Nick,
I'm a novice at SSE programming -- I'm teaching myself SSE by using a mix of SSE and FP to implement a linear algebra algorithm. I'm using FP because the algorithm involves the logarithm function. I've determined that this is the main bottleneck (according to gprof, I spend 86% of the time in the logarithm function), so I'm looking for ways to implement the logarithm function in pure SSE. I'm reluctant to reuse your log2 code verbatim; I think that by redesigning the algorithm with my particular application in mind (for example, my required interval of convergence, precision, etc.), I can better optimize the overall performance of my application. Do you have any pointers on how to design a logarithm approximator? From what I can see in your code, you're extracting the exponent field and approximating the logarithm of the mantissa using a 5th-order polynomial. How did you arrive at the coefficients? I would either use 5 terms of the Taylor series expansion for log, or pick 5 points (perhaps evenly-spaced) on the interval of interest and obtain a 5th-order polynomial that passes through those points (and perhaps visibly verify that the error between those points is acceptable). Anyway, I'm not very experienced in this domain, which is why I'm hoping you could provide some pointers. Thanks, Catalin Patulea |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|