Search code examples
c++sseintel-mklparse-tree

C/C++ library for lazy evaluation of SIMD/SSE expressions


Libraries such as intel-MKL or amd-ACML provide easier interface to SIMD operations on vectors, but I want to chain several functions together. Are there readily available libraries where I can register a parse tree for an expression like

log( tanh(x) + exp(x) )

and then evaluate it on all members of an array ? What I want to avoid is to make a temporary arrays of tanh(x), exp(x) and tanh(x) + exp(x) by calling the mkl or acml functions for tanh(), exp() and +.

I can unroll the loop by hand and use the sse instructions directly, but was wondering if there are C++ libraries which does this for you, i.e.

1. Handles SIMD/SSE functions  
2. Allows building of parse trees out of SIMD/SSE functions.  

I am very much a newbie and have never used SSE or MKL/ACML before, just venturing out into new territory.


Solution

  • It may not do exactly what you want, but I suggest you take a look at macstl. It's a SIMD valarray implementation which uses template metaprogramming, and which can combine expressions into a single loop. You may be able to use this as is or perhaps as a basis for something closer to what you need.