Linux   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了运行任何英特尔AVX函数后,数学函数需要更多周期大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

参见英文答案 > Using AVX instructions disables exp() optimization?                                    1个我注意到运行任何英特尔AVX功能后,数学函数(如ceil,round,...)需要更多的CPU周期.请参阅以下示例:#include <stdio.h&

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

请参阅以下示例:

#include <>dio.h>
#include < 32));="" }="" #define="" num_iterations="" 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 @R_146_10586@l cycles 1900864520 CPI 190

请指教.

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

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

大佬总结

以上是大佬教程为你收集整理的运行任何英特尔AVX函数后,数学函数需要更多周期全部内容,希望文章能够帮你解决运行任何英特尔AVX函数后,数学函数需要更多周期所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。