为什么KISS_FFT的正反基数4的计算不同,第二部分? [英] Why is the kiss_fft's forward and inverse radix-4 calculation different, part 2?
本文介绍了为什么KISS_FFT的正反基数4的计算不同,第二部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Part 1 - why the code below checks st_inverse in the first place
KISS_FFT代码在循环内有此分支:
do {
if(st->inverse) {
Fout[m].r = scratch[5].r - scratch[4].i;
Fout[m].i = scratch[5].i + scratch[4].r;
Fout[m3].r = scratch[5].r + scratch[4].i;
Fout[m3].i = scratch[5].i - scratch[4].r;
}else{
Fout[m].r = scratch[5].r + scratch[4].i;
Fout[m].i = scratch[5].i - scratch[4].r;
Fout[m3].r = scratch[5].r - scratch[4].i;
Fout[m3].i = scratch[5].i + scratch[4].r;
}
++Fout;
} while (--k); // Fout[] has k*4 elements.
稍微重新排序:
if(st->inverse) {
Fout[m].r = scratch[5].r - scratch[4].i;
Fout[m].i = scratch[5].i + scratch[4].r;
Fout[m3].r = scratch[5].r + scratch[4].i;
Fout[m3].i = scratch[5].i - scratch[4].r;
}else{
Fout[m3].r = scratch[5].r - scratch[4].i;
Fout[m3].i = scratch[5].i + scratch[4].r
Fout[m].r = scratch[5].r + scratch[4].i;
Fout[m].i = scratch[5].i - scratch[4].r;;
}
这两个代码块真正的不同之处在于它们对m
和m3
的使用。但m
和m3
在循环内不变。我可以通过交换m
和m3
来简单地消除此内循环分支吗?
if(st->inverse) { swap(&m, &m3); }
do {
Fout[m].r = scratch[5].r - scratch[4].i;
Fout[m].i = scratch[5].i + scratch[4].r;
Fout[m3].r = scratch[5].r + scratch[4].i;
Fout[m3].i = scratch[5].i - scratch[4].r;
++Fout;
} while (--k);
推荐答案
我确实可以使用该优化。然而,对于可以使用AVX的当前一代的编译器来说,这并不是必需的。他们还将使用vpcmpeqd
删除该分支
和vblendvps
。
这篇关于为什么KISS_FFT的正反基数4的计算不同,第二部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文