运行任何英特尔AVX函数后,数学函数需要更多周期

参见英文答案 > Using AVX instructions disables exp() optimization?                                    1个
我注意到运行任何英特尔AVX功能后,数学函数(如ceil,round,…)需要更多的cpu周期.

请参阅以下示例:

#include dio.h>
#include teraTIONS 10000000

void run_round()
{
    unsigned long int t1,t2,res,i;
    double d = 3.2;

    t1 = get_rdtsc();
    for (i = 0 ; i < NUM_IteraTIONS ; ++i) {
        res = round(d*i);
    }
    t2 = get_rdtsc();

    printf("round res %lu total cycles %lu CPI %lu\n",t2 - t1,(t2 - t1) / NUM_IteraTIONS);
 }

int main ()
{
    __m256d a;

    run_round();

    a = _mm256_set1_pd(1);

    run_round();

    return 0;
}

编译:gcc -Wall -lm -mavx foo.c

输出是:

round res 31999997总周期224725952 CPI 22

round res 31999997 total cycles 1900864520 CPI 190

请指教.

最佳答案
反汇编生成代码.

我的猜测是会有额外的寄存器保存/恢复,或类似的东西.

相关文章

1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...
如何抑制stable_secret读取关键的“net.ipv6.conf.all.stabl...
1 删除0字节文件 find -type f -size 0 -exec rm -rf {} ...
## 步骤 1:安装必要的软件包 首先,需要确保系统已安装 `dh...