Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (32 sloc) 1017 Bytes
#include "include/CBaseMath.h"
%{ import sys; sys.path.append('../..'); from mathfuncs import * }%
#include <cmath>
using namespace std;
% for t,s in zip(ctypes,['f','']):
OVERLOADABLE ${t} smSum(const ${t}* __restrict__ pSrc, const int len) {
${t} r = 0;
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += pSrc[i]; }
return r;
}
OVERLOADABLE ${t} smSum_sqr(const ${t}* __restrict__ pSrc, const int len) {
${t} r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += pSrc[i]*pSrc[i]; }
return r;
}
% for f in unaryfs:
OVERLOADABLE ${t} smSum_${f}(const ${t}* __restrict__ pSrc, const int len) {
${t} r = 0;
#pragma ivdep
#pragma clang loop interleave_count(8)
for (int i=0; i<len; ++i) { r += ${f}(pSrc[i]); }
return r;
}
OVERLOADABLE void sm_${f}(const ${t}* __restrict__ pSrc, ${t}* __restrict__ pDst, const int len) {
#pragma ivdep
for (int i=0; i<len; ++i) { pDst[i] = ${f}(pSrc[i]); }
}
% end # f
% end # t