Research Article

Inastemp: A Novel Intrinsics-as-Template Library for Portable SIMD-Vectorization

Code 8

Templatized function example.
(1) template <class VecType>
(2) double ScalarProduct(const VecType& v1, const VecType& v2)
(3) return (v1 v2).horizontalSum();
(4)
(5)
(6) // Possible usage
(7) double res_1 = ScalarProduct<InaVecAVX2<double>>(…);
(8) double res_1 = ScalarProduct<InaVecAVX512KNL<double>>(…);