https://www.cnblogs.com/bbqzsl/p/15510377.html

近期在做优化时,对一些函数分别在不同编译平台上进行bench测试。发现了不少问题。

现在拿其中一个问题来分享。

 1 typedef float MAFloat;
 2
 3 MAFloat sma(const MAFloat* seq, const int cnt, const int N, const int M)
 4 {
 5     const MAFloat C1 = (MAFloat)M/N;
 6     const MAFloat C2 = (MAFloat)(N-M)/N;
 7     MAFloat result = 0.f;
 8     int total = cnt;
 9
10 #pragma nounroll
11     for (int i = 0; i < total; ++i)
12     {
13         result = result * C2 + seq[i] * C1;
14     }
15
16     return result;
17 }
11-05 04:26