SIMD backends for math functions - #3
Conversation
- don't install gtest when tests are enabled - Bump cmake min version to 3.23 - Use file sets - Use configure_file to pass the macros for selecting sleef or svml
PaulGannay
left a comment
There was a problem hiding this comment.
Why are some of the file name in all caps (CEXA_SIMD_AOCLLIBM.hpp, ...)?
| #define CEXA_IMPL_SIMD_AOCL_AVX2_UNARY_FUNCTION(func) \ | ||
| CEXA_IMPL_SIMD_AOCL_AVX2_S4_UNARY_FUNCTION(func) \ | ||
| CEXA_IMPL_SIMD_AOCL_AVX2_S8_UNARY_FUNCTION(func) \ | ||
| CEXA_IMPL_SIMD_AOCL_AVX2_D4_UNARY_FUNCTION(func) |
There was a problem hiding this comment.
Is there a reason why unary macro are defined as 3 separate macro merged in a fourth one while the binary macro are all defined in a single macro?
There was a problem hiding this comment.
Because AOCL LibM doesn't support every function for every vector type, CEXA_IMPL_SIMD_AOCL_AVX2_UNARY_FUNCTION is used when the function is implemented for fp32x8, fp32x4 and fp64x4, otherwise I use one or more of the three separate macros, for example cbrt is only defined for fp32x4, so I use CEXA_IMPL_SIMD_AOCL_AVX2_S4_UNARY_FUNCTION(cbrt).
We only use the binary macro for pow which is supported on all vector types, which is why there is a single macro for binary functions.
| #cmakedefine CEXA_SIMD_ENABLE_SLEEF | ||
| #cmakedefine CEXA_SIMD_ENABLE_SVML |
There was a problem hiding this comment.
Shouldn't AOCL-libm also be in this file?
There was a problem hiding this comment.
I haven't figured out yet how to link AOCL cleanly through CMake, the libm examples rely on a user provided variable with the path to an aocl-libm install instead of doing a find_package or using pkg-config, they mention .deb/.rpm packages which don't seem to exist so I cannot look at this either to see if they export CMake files which could be used with a find_package
| option( | ||
| CEXA_SIMD_ENABLE_SLEEF | ||
| "Use the sleef library to implement the simd math functions" | ||
| OFF | ||
| ) | ||
| option(CEXA_SIMD_ENABLE_SVML "Use the svml to implement the simd math functions" OFF) | ||
| option(CEXA_SIMD_ENABLE_TESTS "Enable accuracy tests" OFF) | ||
| option(CEXA_SIMD_ENABLE_INSTALL "Enable installation of the library" ON) | ||
|
|
||
| if(CEXA_SIMD_ENABLE_SLEEF AND CEXA_SIMD_ENABLE_SVML) | ||
| message(FATAL_ERROR "Only one backend can be enabled at a time") | ||
| endif() | ||
|
|
Co-authored-by: Paul Gannay <paul.gannay@cea.fr>
- update the CI to test with kokkos 4.6 and 5.1
I can try to setup a CI job running the Kokkos simd perf tests with and without the sleef backend and compare the results, assuming that running inside a github runner doesn't introduce too much noise |
By "small cap only" do you mean something like |
There was a problem hiding this comment.
What about other headers CEXA_SIMD_SVML, CEXA_SIMD_AOCLLIBM ?
There was a problem hiding this comment.
Good catch, I didn't notice that sleef was duplicated. For AOCLLIBM, I don't support it through CMake yet, they don't seem to export files to enable find_package, so I will probably have to implement a FindAOCLLIBM file myself.
Co-authored-by: Thomas Padioleau <thomas.padioleau@cea.fr>
|
Removed the AOCL Libm header for now, I will add it back in another PR once I figure out how to include it with CMake |
This PR adds Kokkos SIMD compatible wrappers for simd math libraries. A user can use this as a cmake project, and include
CEXA_SIMD_Backends.hppin their program, or directly includeCEXA_SIMD_{SLEEF,SVML,AOCLLIBM}.hpp.Currently, only sleef and svml are supported in the CMake, I will add aocl libm later as the support for vectorized functions is not complete at the moment (users can still use the standalone header)
I also added a basic accuracy test to ensure that the functions give a reasonable (<=4ulp) difference from the exact value