p12tic / libsimdpp

Portable header-only C++ low level SIMD library
Boost Software License 1.0
1.24k stars 129 forks source link

Are there any plans to implement more math functions? #83

Open invexed opened 7 years ago

invexed commented 7 years ago

Hi,

Are there any immediate plans to implement more math functions, such as log() and exp()? If not, is there a reason as to why they haven't been implemented?

Thanks.

p12tic commented 7 years ago

Hi,

There are plans to add both precise and approximate versions of various mathematical functions. The list of functions is at least what C++ provides in the cmath header, initially the C++98 subset, later C++11.

The reason why this hasn't been done already is lack of time. The projects that use libsimdpp and where I'm involved myself don't use most of these functions. The implementations of functions that are used are not rigorously tested and it's probably not a good idea to open source things that are possibly broken in some edge case :-)

Any contributions in this area are welcome. One possibility to reduce the effort needed is to port the code that boost.simd uses (at least used to use, before the recent purge of history), as the licenses are the same.

p12tic commented 7 years ago

Forgot to mention that there's several more people interested in math functions, though I don't know how much time they will be able contribute. To anyone who starts working on this feature, please create an issue for functions that you are working on, assign to yourself and don't close the issue until the implementation lands into the master branch.

invexed commented 7 years ago

Thanks for the quick reply.

Unfortunately I haven't got the time at the moment to attempt the implementation of further math functions, but I will have a go if/when I'm less busy.

Shall I leave this issue open for the time being?

p12tic commented 7 years ago

Yes, let's leave this issue open.

peabody-korg commented 7 years ago

In older projects we used Intel's amath for exp2(), sin(), cos(), and possibly some other similar functions. It would be nice to these in simdpp!

xugng commented 6 years ago

I am currently porting boost.simd math functions to libsimdpp. I will come up with some initial pull requests in the near future.

p12tic commented 6 years ago

@xugng That's great to hear. Could you do a preliminary PR as early as possible so that we can discuss changes? Even a single function would be enough at the beginning.

eriksjolund commented 6 years ago

The license for Gromacs (LGPL >= 2.1) prevents it from being included in libsimdpp but it contains some highly optimized SIMD code for mathematical functions. I haven't used it myself but I guess it might be useful outside the scope of libsimdpp. I just wanted to mention it because the Gromacs SIMD implementation of mathematical functions might not be so well-known.

https://github.com/gromacs/gromacs/blob/master/src/gromacs/simd/simd_math.h http://manual.gromacs.org/documentation/2016.4/doxygen/html-lib/simd__math_8h.xhtml https://stackoverflow.com/a/47951585/757777