【x86向量化】三种不同方式的AGC算法代码运行速度对比

前言

在使用通用处理器如x86-64开发软件无线电算法的过程中,充分利用cpu的simd指令集(mmx/sse/avx/neon等)对于性能是至关重要的。现代的x86-64处理器能够支持很大的浮点向量运算,例如intel haswell(2011年发布)平台支持的avx指令集,ymm 0 ~ ymm15寄存器宽度为256bit,每条指令能实现8个单精度浮点数乘法或加法,4GHz主频运行linpack实测速度可达100Gflops。

AGC(自动增益控制)是软件无线电处理中最基本的算法之一。其目的是保持输出信号幅度基本稳定,以方便后续算法处理。AGC算法的工作流程可以总结为三步:

1. 放大信号。乘法运算,调整信号的幅度;

2. 检测信号幅度。对输出信号使用功率检波或者有效值检波,测量信号的实际幅度;

3. 调整增益。比较设定值与实际幅度的偏差,据此调整增益设置。

为了能够尽可能充分利用处理器的运算能力,编译器会对代码进行自动向量化,将多个浮点操作打包在一起,生成simd指令。因此,编写合适的代码结构对于性能是至关重要的。本文将对3种不同结构的AGC算法代码进行性能对比测试,以找出最优的方案。

算法实现方案

其中x y为float complex,pwr reference gain为float,全部对齐到16字节地址

<code class="hljs glsl"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">for</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(i=<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">0</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>;i<n;i++) { step1: y="gain" * x; <span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//MUL=2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
    step2: pwr = y.re * y.re + y.im * y.im;   <span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//MUL=2 ADD=1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
}
step3: <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">if</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(pwr > reference) gain *= <span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">0.99</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>; <br>       <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">else</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> gain *= <span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">1.01</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>;  <span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//CMP=1 MUL=1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></n;i++)></span></code>

Total FLOPS = n * 5 + 2;

根据gcc编译器自动向量化的说明 (https://gcc.gnu.org/projects/tree-ssa/vectorization.html) 编写了相应的测试代码。

其中算法1使用libvolk()库的avx2实现,算法2和算法3使用c语言编写

<code class="hljs bash">//算法1<br><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">for</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> (i=0; i<*_num_iterations; i++) {   volk_32<span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in">fc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>_s32<span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in">fc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>_multiply_32<span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in">fc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y, x, gain, n);
    volk_32<span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in">fc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>_magnitude_squared_32f(pwry, y, n);
    *pwr = 0;<br>    volk_32f_accumulator_s32f(pwr, pwry, n);
    *pwr /= n;
    <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">if</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(*pwr > d_reference) gain *= a1;
    <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">else</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> gain *= a2;<br>}</*_num_iterations;></span></code>
<code class="hljs verilog"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//算法2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-comment"><br><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">*pwr = 0;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">for</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">int</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> i = <span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">0</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>; i < n; i++)
{
    y[i] = x[i] * gain;<span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//step1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
    pwry[i] = <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i])*<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i]) + imag(y[i])*imag(y[i]);<span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//step2.1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
}
<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">for</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">int</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> i = <span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">0</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>; i < n; i++)
{
    *pwr += pwry[i];<span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//step2.2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
}
*pwr /= n;
<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">if</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(*pwr > d_reference) gain *= a1;
<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">else</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> gain *= a2;<br><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//备注:经过测试, step1和step2.1放在同个循环,step2.2放在另外的循环中,速度最快。</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//step1 2.1 2.2分开三个循环,或者step1 2.1 2.2放在一起,或者step1分开step2.1 2.2放在一起,速度都会减慢</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//不使用pwry中间变量,直接累加到pwr,速度也会减慢</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br></span></code>
<code class="hljs verilog"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//算法3,手动展开循环,其中n是8的倍数</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">*pwr = 0;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">for</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">int</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> i = <span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">0</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>; i < n; i+=<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">8</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>)
{
    y[i] = x[i] * gain;
    pwry[i] = <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i])*<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i]) + imag(y[i])*imag(y[i]);
    y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = x[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] * gain;
    pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]) + imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]);
    y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = x[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] * gain;
    pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]) + imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]);
    y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">3</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = x[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">3</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] * gain;
    pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">3</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">3</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">3</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]) + imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">3</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">3</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]);
    y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">4</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = x[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">4</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] * gain;
    pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">4</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">4</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">4</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]) + imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">4</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">4</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]);
    y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">5</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = x[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">5</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] * gain;
    pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">5</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">5</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">5</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]) + imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">5</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">5</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]);
    y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">6</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = x[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">6</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] * gain;
    pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">6</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">6</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">6</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]) + imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">6</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">6</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]);
    y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">7</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = x[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">7</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] * gain;
    pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">7</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] = <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">7</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">real</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">7</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]) + imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">7</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>])*imag(y[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">7</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]);
}
<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">for</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">int</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> i = <span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">0</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>; i < n; i+=<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">8</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>)
{
    *pwr += pwry[i]    + pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] + pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] + pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">3</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] 
          + pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">4</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>]  + pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">5</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] + pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">6</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>] + pwry[i+<span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">7</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>];
}
*pwr /= n;
<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">if</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>(*pwr > d_reference) gain *= a1;
<span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">else</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> gain *= a2;</code>

以上测试代码分别循环iter次,其中iter=256*1048576/n,即测试的数据总长度不变。

使用getrusage函数得到循环的执行时间,进而计算出每秒处理的数据个数。

编译时,算法2和3均成功向量化

<code class="hljs less">gcc 7<span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class">.4</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class">.0</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//算法2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">agc_gr_bench.cc:105:20: note: loop vectorized</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">agc_gr_bench</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class">.cc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:105</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:20</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">note</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">loop</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">versioned</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">for</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">vectorization</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">because</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">of</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">possible</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">aliasing</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">agc_gr_bench</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class">.cc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:105</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:20</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">note</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">loop</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">turned</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">into</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">non-loop</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>; it never loops.
<span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">agc_gr_bench</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class">.cc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:105</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:20</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">note</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">loop</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">with</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">7</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">iterations</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">completely</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">unrolled</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">agc_gr_bench</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class">.cc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:110</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:20</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">note</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">loop</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">unrolled</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">7</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">times</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">agc_gr_bench</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class">.cc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:105</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:20</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">note</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">loop</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">unrolled</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">3</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">times</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">agc_gr_bench</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class">.cc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:108</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:12</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">note</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">loop</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">unrolled</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">times</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//算法3</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">agc_gr_bench.cc:139:20: note: loop vectorized</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">agc_gr_bench</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class">.cc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:139</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:20</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">note</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">loop</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">versioned</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">for</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">vectorization</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">because</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">of</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">possible</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">aliasing</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">agc_gr_bench</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class">.cc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:159</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:20</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">note</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">loop</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">unrolled</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">3</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">times</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">agc_gr_bench</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class"><span class="hljs-selector-class">.cc</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:142</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo"><span class="hljs-selector-pseudo">:12</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">note</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>: <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">loop</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">unrolled</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">1</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag"><span class="hljs-selector-tag">times</span></span></span></span></span></span></span></span></span></span></span><br></span></span></span></span></code>

备注: 作为对比,导入了gnuradio feed_forward_agc中的快速开平方拟合算法, 仅执行检波算法

<code class="hljs cpp"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//算法: agc_gr </span></span></span></span></span></span></span></span></span><br><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">//测试方法:循环执行该函数iter*n次 </span></span></span></span></span></span></span></span></span></span><br><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment"><span class="hljs-comment">inline static float envelope(gr_complex x)</span></span></span></span></span></span></span></span></span></span>
{
    <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">float</span></span></span></span></span></span></span></span></span></span> r_abs = <span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in">std</span></span></span></span></span></span></span></span></span></span>::<span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in">fabs</span></span></span></span></span></span></span></span></span></span>(x.real());
    <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">float</span></span></span></span></span></span></span></span></span></span> i_abs = <span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in">std</span></span></span></span></span></span></span></span></span></span>::<span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in"><span class="hljs-built_in">fabs</span></span></span></span></span></span></span></span></span></span>(x.imag());

    <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">if</span></span></span></span></span></span></span></span></span></span>(r_abs > i_abs)
        <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">return</span></span></span></span></span></span></span></span></span></span> r_abs + <span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">0.4</span></span></span></span></span></span></span></span></span></span> * i_abs;
    <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">else</span></span></span></span></span></span></span></span></span></span>
        <span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword"><span class="hljs-keyword">return</span></span></span></span></span></span></span></span></span></span> i_abs + <span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number"><span class="hljs-number">0.4</span></span></span></span></span></span></span></span></span></span> * r_abs;
}</code>

测试环境

i7-4770k 2.6GHz

DDR3 2400 8GB

ubuntu 16.04 LTS

gcc 7.4.0 (备注: gcc 5.4.0速度减少10-15%,clang 3.8速度减少50%)

libvolk 1.4 (备注:未使用volk_modtool生成配置文件,使用默认的算法选择逻辑。)

存在问题:使用过volk_modtool之后最高可损失40%性能,架构选择a_sse3 u_sse3 a_avx u_avx均有此问题,原因不明。

测试结果

bench.png

 volk库速度最快,在向量长度n=1024时,处理速率1.75Gsps;

其次是手动展开循环的c代码(算法3),n=32时,处理速率1.24Gsps;

最慢的是简单循环(算法2),n=16时,处理速率0.85Gsps;

总结

若算法允许每次迭代处理多个数据(n值较大),应该优先使用libvolk库。

若算法要求迭代周期尽可能短(小的n值),应该用c语言自行编写展开的循环。

保持n值不要太大(使得数据能放入L1或L2缓存),否则性能会快速下降

源代码

attachment icon agc_bench.tar.gz 31.88KB GZ 31次下载

[修改于 1 年前 - 2019-01-03 17:57:01]

来自:计算机科学 / 软件综合
 
4
2019-1-2 14:53:53
1楼

SDR的算法有并行化加速的空间吗

折叠评论
加载评论中,请稍候...
折叠评论
2019-1-3 14:33:14
2楼

现在正在学编代码的同学前来膜拜。

折叠评论
加载评论中,请稍候...
折叠评论

想参与大家的讨论?现在就 登录 或者 注册

warmonkey
专家 学者 机友 笔友
文章
320
回复
6462
学术分
17
2008/10/11注册,1 小时前活动

科创航天主席

插入资源
全部
图片
视频
音频
附件
全部
未使用
已使用
正在上传
空空如也~
上传中..{{f.progress}}%
处理中..
上传失败,点击重试
{{f.name}}
空空如也~
(视频){{r.oname}}
{{selectedResourcesId.indexOf(r.rid) + 1}}
插入表情
我的表情
共享表情
Emoji
上传
注意事项
最大尺寸100px,超过会被压缩。为保证效果,建议上传前自行处理。
建议上传自己DIY的表情,严禁上传侵权内容。
点击重试等待上传{{s.progress}}%处理中...已上传
空空如也~
草稿箱
加载中...
此处只插入正文,如果要使用草稿中的其余内容,请点击继续创作。
{{fromNow(d.toc)}}
{{getDraftInfo(d)}}
标题:{{d.t}}
内容:{{d.c}}
继续创作
删除插入插入
{{forum.displayName}}
{{forum.countThreads}}
篇文章,
{{forum.countPosts}}
条回复
{{forum.description || "暂无简介"}}
ID: {{user.uid}}
学术分隐藏
{{submitted?"":"投诉"}}
请选择违规类型:
{{reason.description}}
支持的图片格式:jpg, jpeg, png