Hi everyone, I was looking at loop vectorizer code and wondered if there was any current or planned effort to introduce SIMD implementations of sin/cos/exp/log intrinsics (in particular for x86-64 backend)? Cheers, Dimitri. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130127/ab8ce011/attachment.html>
----- Original Message -----> From: "Dimitri Tcaciuc" <dtcaciuc at gmail.com> > To: llvmdev at cs.uiuc.edu > Sent: Sunday, January 27, 2013 3:42:42 AM > Subject: [LLVMdev] SIMD trigonometry/logarithms? > > > > Hi everyone, > > > I was looking at loop vectorizer code and wondered if there was any > current or planned effort to introduce SIMD implementations of > sin/cos/exp/log intrinsics (in particular for x86-64 backend)?Ralf Karrenberg had implemented some of these as part of his whole-function vectorization project: https://github.com/karrenberg/wfv/blob/master/src/utils/nativeSSEMathFunctions.hpp https://github.com/karrenberg/wfv/blob/master/src/utils/nativeAVXMathFunctions.hpp Opinions on pulling these into the X86 backend? -Hal> > > Cheers, > > > > > Dimitri. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
I'm wondering if it makes sense to instead supply a bc math library. I would think it would be easier to maintain and debug, and should still give you all of the benefits. You could just link with it early in the optimization pipeline to ensure inlining. This may also make it easier to maintain SIMD functions for multiple backends. On Sun, Jan 27, 2013 at 8:49 AM, Hal Finkel <hfinkel at anl.gov> wrote:> ----- Original Message ----- > > From: "Dimitri Tcaciuc" <dtcaciuc at gmail.com> > > To: llvmdev at cs.uiuc.edu > > Sent: Sunday, January 27, 2013 3:42:42 AM > > Subject: [LLVMdev] SIMD trigonometry/logarithms? > > > > > > > > Hi everyone, > > > > > > I was looking at loop vectorizer code and wondered if there was any > > current or planned effort to introduce SIMD implementations of > > sin/cos/exp/log intrinsics (in particular for x86-64 backend)? > > Ralf Karrenberg had implemented some of these as part of his > whole-function vectorization project: > > https://github.com/karrenberg/wfv/blob/master/src/utils/nativeSSEMathFunctions.hpp > > https://github.com/karrenberg/wfv/blob/master/src/utils/nativeAVXMathFunctions.hpp > > Opinions on pulling these into the X86 backend? > > -Hal > > > > > > > Cheers, > > > > > > > > > > Dimitri. > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130127/5fd485c4/attachment.html>
On 28/01/2013 12:49 AM, Hal Finkel wrote:> Ralf Karrenberg had implemented some of these as part of his > whole-function vectorization project: > https://github.com/karrenberg/wfv/blob/master/src/utils/nativeSSEMathFunctions.hpp > https://github.com/karrenberg/wfv/blob/master/src/utils/nativeAVXMathFunctions.hpp > Opinions on pulling these into the X86 backend? -HalI've actually been considering doing the same as these for our project (using the same reference implementation by Julien Pommier). We use math functions a lot in our code so any performance gain would be useful. However, accuracy is quite important in our case, so we would want any implementation to at least match the accuracy of the current implementation. On X86 (at least in LLVM 2.8 which we currently use), the sin/cos intrinsics end up using the X87 fpsin instruction. On Win32, the system provided sin function also ends up using the same assembly instruction. Peter N
FWIW, llvmpipe has C-binding code that generates (inlines) log/exp/pow/sin/cos functions of the fly, for an arbitrary number of elements (in most cases), and uses sse/avx intrinsics as available: http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/auxiliary/gallivm/lp_bld_arit.c The precision is 20bits, which is enough for 3D. But it wouldn't be difficult to have more (or even variable) precision, by using higher degree approximating functions were appropriate. The code is in a permissible license. Jose ----- Original Message -----> Hi everyone,> I was looking at loop vectorizer code and wondered if there was any current > or planned effort to introduce SIMD implementations of sin/cos/exp/log > intrinsics (in particular for x86-64 backend)?> Cheers,> Dimitri.> _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130214/fe71b8dc/attachment.html>
Hi, Looks interesting, but the codebase appears to only do SSE*/AVX (no ARM NEON -- which obviously makes me sad -- , or other architectures). It might be useful if some of the tests which are "optimized" into things like "has_avx, because that implies we're capable of 256-bit vectorization" were deoptimized to first test in "generic terms" and only tested for a specific instruction set is being used at the point when the string for an actual intrinsic is needed. Cheers, Dave From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Jose Fonseca Sent: 14 February 2013 14:49 To: Dimitri Tcaciuc Cc: llvmdev at cs.uiuc.edu Subject: Re: [LLVMdev] SIMD trigonometry/logarithms? FWIW, llvmpipe has C-binding code that generates (inlines) log/exp/pow/sin/cos functions of the fly, for an arbitrary number of elements (in most cases), and uses sse/avx intrinsics as available: http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/auxiliary/gallivm/lp_bld_arit.c The precision is 20bits, which is enough for 3D. But it wouldn't be difficult to have more (or even variable) precision, by using higher degree approximating functions were appropriate. The code is in a permissible license. Jose _____ Hi everyone, I was looking at loop vectorizer code and wondered if there was any current or planned effort to introduce SIMD implementations of sin/cos/exp/log intrinsics (in particular for x86-64 backend)? Cheers, Dimitri. _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130214/b2cad63d/attachment.html>