小编use*_*218的帖子

使用AVX内在函数代替SSE并不能提高速度 - 为什么?

我已经使用英特尔的SSE内在函数已经有一段时间了,性能有了很好的提升.因此,我期望AVX内在函数能够进一步加速我的程序.不幸的是,直到现在情况并非如此.可能我犯了一个愚蠢的错误,所以如果有人能帮助我,我将非常感激.

我使用Ubuntu 11.10和g ++ 4.6.1.我编写了我的程序(见下文)

g++ simpleExample.cpp -O3 -march=native -o simpleExample
Run Code Online (Sandbox Code Playgroud)

测试系统配有Intel i7-2600 CPU.

这是代表我的问题的代码.在我的系统上,我得到输出

98.715 ms, b[42] = 0.900038 // Naive
24.457 ms, b[42] = 0.900038 // SSE
24.646 ms, b[42] = 0.900038 // AVX
Run Code Online (Sandbox Code Playgroud)

注意,仅选择计算sqrt(sqrt(sqrt(x)))以确保内存带宽不限制执行速度; 这只是一个例子.

simpleExample.cpp:

#include <immintrin.h>
#include <iostream>
#include <math.h> 
#include <sys/time.h>

using namespace std;

// -----------------------------------------------------------------------------
// This function returns the current time, expressed as seconds since the Epoch
// -----------------------------------------------------------------------------
double getCurrentTime(){
  struct timeval curr;
  struct timezone tz;
  gettimeofday(&curr, &tz);
  double tmp = …
Run Code Online (Sandbox Code Playgroud)

c++ performance gcc sse avx

44
推荐指数
4
解决办法
2万
查看次数

标签 统计

avx ×1

c++ ×1

gcc ×1

performance ×1

sse ×1