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>
Hi Justin, I think having .bc math libraries for different backends makes perfect sense! For example, in case of NVPTX backend we have the following problem: many math functions that are only available as CUDA C++ headers could not be easily used in, for instance, GPU program written in Fortran. On our end we are currently doing exactly what you proposed: generating math.bc module and then link it at IR-level with the target application. There is no need for SIMD, but having .bc math library would still be very important! - D. 2013/1/27 Justin Holewinski <justin.holewinski at gmail.com>> 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 > > _______________________________________________ > 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/20130127/293f4342/attachment.html>
----- Original Message -----> From: "Dmitry Mikushin" <dmitry at kernelgen.org> > To: "Justin Holewinski" <justin.holewinski at gmail.com> > Cc: "Hal Finkel" <hfinkel at anl.gov>, "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu> > Sent: Sunday, January 27, 2013 10:19:42 AM > Subject: Re: [LLVMdev] SIMD trigonometry/logarithms? > > Hi Justin, > > I think having .bc math libraries for different backends makes > perfect sense! For example, in case of NVPTX backend we have the > following problem: many math functions that are only available as > CUDA C++ headers could not be easily used in, for instance, GPU > program written in Fortran. On our end we are currently doing > exactly what you proposed: generating math.bc module and then link > it at IR-level with the target application. There is no need for > SIMD, but having .bc math library would still be very important!I agree. I think that, essentially, all we need is some infrastructure for finding standard bc/ll include files (much like clang can add its own internal include directory). -Hal> > - D. > > > 2013/1/27 Justin Holewinski < justin.holewinski at gmail.com > > > > > 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 > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > >
I think that a bc library could be quite flexible. For example it should be possible to create a wrapper in bc that calls libsvml functions. paul On 2013-01-27, at 9:22 AM, Justin Holewinski wrote: 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<mailto:hfinkel at anl.gov>> wrote: ----- Original Message -----> From: "Dimitri Tcaciuc" <dtcaciuc at gmail.com<mailto:dtcaciuc at gmail.com>> > To: llvmdev at cs.uiuc.edu<mailto: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<mailto:LLVMdev at cs.uiuc.edu> http://llvm.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<mailto:LLVMdev at cs.uiuc.edu> http://llvm.cs.uiuc.edu<http://llvm.cs.uiuc.edu/> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -- Thanks, Justin Holewinski _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu<mailto:LLVMdev at cs.uiuc.edu> http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Additionally, I think this relates to my suggestion to transform library calls into intrinsics. Early on you want to canonicalize math library calls into intrinsics. The vectorizers trivially widen the intrinsics and before codegen you replace the intrinsics with calls. If you insert calls to the bc math library too early you won't benefit from intrinsic aware optimizations. Basically I think what you need is a module that provides intrinsic implementations for various vector widths. paul On 2013-01-27, at 9:22 AM, Justin Holewinski wrote: 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<mailto:hfinkel at anl.gov>> wrote: ----- Original Message -----> From: "Dimitri Tcaciuc" <dtcaciuc at gmail.com<mailto:dtcaciuc at gmail.com>> > To: llvmdev at cs.uiuc.edu<mailto: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<mailto:LLVMdev at cs.uiuc.edu> http://llvm.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<mailto:LLVMdev at cs.uiuc.edu> http://llvm.cs.uiuc.edu<http://llvm.cs.uiuc.edu/> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -- Thanks, Justin Holewinski _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu<mailto:LLVMdev at cs.uiuc.edu> http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev