标签: simd

任何Yeppp上的分段错误!api电话

说实话,这是我第一次使用像Yeppp!这样的任何类型的库,我的意思是SIMD库具有动态运行时选择,或者他们会说出来.最终结果是库应该选择最佳的SIMD汇编代码,以便在运行的任何平台和硬件上运行.

这似乎是在我的项目中使用的一个很好的工具,但是,正如标题所述,我不能称之为任何Yeppp!功能没有发生分段故障.我能够获得的调试信息也没有帮助.

我的系统配置是:

Xubuntu 13.04 'raring' with Linux 3.8.0-31-generic x86_64

GCC 4.8.1 --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu .... etc, there were many more, but I chose the important ones

Code::Blocks IDE and GDB 7.5.91.20130417-cvs-ubuntu debugger through Code::Blocks

Intel Pentium(R) Dual-Core CPU T4400 @ 2.20GHz with SIMD instruction sets MMX, SSE, SSE2, SSSE3
Run Code Online (Sandbox Code Playgroud)

我列出了CPU等等,因为它对Yeppp来说可能很重要!选择正确的运行时,这可能是问题.

下面是我正在使用的简单测试代码,虽然我尝试了其他的Yeppp!具有各种数据类型的函数,都是相同的分段错误.我也尝试了各种对齐方式,如32和64,但我怀疑这是问题所在.

YEP_ALIGN(16) int32_t a[100], b[100], c[100];
//just test values
for( int x = 0; x < 100; x++ ) {
    a[x] = x + …
Run Code Online (Sandbox Code Playgroud)

c++ linux simd segmentation-fault yeppp

3
推荐指数
1
解决办法
359
查看次数

SSE:reinterpret_cast <__ m128*>而不是_mm_load_ps

我正在使用C++编写一个简单的卷积函数,从基本的"滑动窗口"卷积开始,使用常规产品(目前没有FFT内容),直到SEE,AVX和可能的OpenCL.我遇到了SSE的问题.我的代码看起来像这样:

for (x = 0; x < SIZEX - KSIZEX + 1; ++x)
{
    for (y = 0; y < SIZEY - KSIZEY + 1; ++y)
    {           
        tmp = 0.0f;

        float fDPtmp = 0.0f;
        float *Kp = &K[0];


        for (xi = 0; xi < KSIZEX; ++xi, Kp=Kp+4)
        {                               
            float *Cp = &C[(x+xi)*SIZEY + y];

            __m128 *KpSSE = reinterpret_cast<__m128*>(&K);
            __m128 *CpSSE = reinterpret_cast<__m128*>(&C[(x + xi)*SIZEY + y]);
            __m128 DPtmp = _mm_dp_ps(*KpSSE, *CpSSE, 0xFF);
            _mm_store_ss(&fDPtmp, DPtmp);

            tmp += fDPtmp;
        }

        R[k] = …
Run Code Online (Sandbox Code Playgroud)

c++ x86 sse simd

3
推荐指数
1
解决办法
1493
查看次数

为什么在某些CPU上SSE对齐的读取+随机播放比未对齐的读取要慢?

在尝试优化有限差分代码所必需的未对齐读取时,我更改了未对齐负载,如下所示:

__m128 pm1 =_mm_loadu_ps(&H[k-1]);
Run Code Online (Sandbox Code Playgroud)

到此对齐的读取+随机代码中:

__m128 p0   =_mm_load_ps(&H[k]);
__m128 pm4  =_mm_load_ps(&H[k-4]);
__m128 pm1  =_mm_shuffle_ps(p0,p0,0x90);   // move 3 floats to higher positions
__m128 tpm1 =_mm_shuffle_ps(pm4,pm4,0x03); // get missing lowest float
       pm1  =_mm_move_ss(pm1,tpm1);        // pack lowest float with 3 others
Run Code Online (Sandbox Code Playgroud)

其中H是16字节对准; H[k+1],H[k±3]和movlhps&的movhlps优化也有类似的变化H[k±2](这是循环的完整代码)。

我发现在Core i7-930上阅读的优化H[k±3]似乎很有效,同时添加了下一个优化以±1减慢循环速度(以百分比为单位)。在±1和±3优化之间切换不会改变结果。

同时,在Core 2 Duo 6300和Core 2 Quad上启用两项优化(针对±1和±3)都可以提高性能(提高百分之十),而对于Core i7-4765T,这两项都降低了性能(降低百分之百)。

在Pentium 4上,所有尝试优化未对齐读取的尝试,包括那些带有movlhps/ movhlps导致读取速度减慢的读取。 …

optimization performance x86 sse simd

3
推荐指数
1
解决办法
1218
查看次数

英特尔SIMD-如何检查__m256 *是否包含任何非零值

我正在使用Microsoft Visual Studio编译器。我试图找出256位向量是否包含任何非零值。我已经尝试过,res_simd = ! _mm256_testz_ps(*pSrc1, *pSrc1);但是没有用。

c++ simd intrinsics avx

3
推荐指数
1
解决办法
1302
查看次数

SSE2内在函数 - 比较无符号整数

我有兴趣在添加无符号8位整数时识别溢出值,并将结果饱和到0xFF:

__m128i m1 = _mm_loadu_si128(/* 16 8-bit unsigned integers */);
__m128i m2 = _mm_loadu_si128(/* 16 8-bit unsigned integers */);

__m128i m3 = _mm_adds_epu8(m1, m2);
Run Code Online (Sandbox Code Playgroud)

我会感兴趣的是执行比这些无符号整数更少的比较,类似于_mm_cmplt_epi8签名:

__m128i mask = _mm_cmplt_epi8 (m3, m1);
m1 = _mm_or_si128(m3, mask);
Run Code Online (Sandbox Code Playgroud)

如果"epu8"等效可用,mask必须0xFF在那里m3[i] < m1[i](溢出!) 0x00 otherwise,我们将能够饱和m1使用"或",所以m1将持有另外的结果,其中有效的,0xFF它溢出.

问题是,_mm_cmplt_epi8执行符号比较,因此,例如,如果m1[i] = 0x70和m2[i] = 0x10,然后m3[i] = 0x80和mask[i] = 0xFF,这显然不是我的要求.

使用VS2012.

我希望采用另一种方法来执行此操作.谢谢!

c++ x86 sse simd intrinsics

3
推荐指数
2
解决办法
3380
查看次数

memcpy在linux中移动128位

我正在linux中为PCIe设备编写设备驱动程序.此设备驱动程序执行多次读写操作以测试吞吐量.当我使用memcpy时,TLP的最大有效载荷是8个字节(在64位架构上).在我看来,获得16字节有效载荷的唯一方法是使用SSE指令集.我已经看到了这个,但代码没有编译(AT&T/Intel语法问题).

  • 有一种方法可以在linux中使用该代码吗?
  • 有谁知道我在哪里可以找到一个移动128位的memcpy的实现?

c linux assembly sse simd

3
推荐指数
2
解决办法
2001
查看次数

AVX固有的_mm256_cmp_ps应该为true时返回NaN吗?

当我尝试:

__m256 a = _mm256_set_ps(1, 1, 1, 1, 1, 1, 1, 1);
__m256 b = _mm256_set_ps(0, 0, 0, 0, 0, 0, 0, 0);

__m256 c = _mm256_cmp_ps(a, b, _CMP_LT_OQ);
Run Code Online (Sandbox Code Playgroud)

我得到的输出是<b:

[0, 0, 0, 0, 0, 0, 0, 0]
Run Code Online (Sandbox Code Playgroud)

但是当尝试:

__m256 a = _mm256_set_ps(1, 1, 1, 1, 1, 1, 1, 1);
__m256 b = _mm256_set_ps(0, 0, 0, 0, 0, 0, 0, 0);

__m256 c = _mm256_cmp_ps(b, a, _CMP_LT_OQ);
Run Code Online (Sandbox Code Playgroud)

要么

__m256 a = _mm256_set_ps(1, 1, 1, 1, 1, 1, 1, 1);
__m256 …
Run Code Online (Sandbox Code Playgroud)

c++ simd avx

3
推荐指数
1
解决办法
1212
查看次数

大型阵列上的SSE性能较低

我是SSE编程的新手,所以我希望有人可以帮助我.我最近使用GCC SSE内在函数实现了一个函数来计算32位整数数组的总和.我的实现代码如下.

int ssum(const int *d, unsigned int len)
{
  static const unsigned int BLOCKSIZE=4;
  unsigned int i,remainder;
  int output;
  __m128i xmm0, accumulator;
  __m128i* src;

  remainder = len%BLOCKSIZE;
  src = (__m128i*)d;
  accumulator = _mm_loadu_si128(src);

  output = 0;
  for(i=BLOCKSIZE;i<len-remainder;i+=BLOCKSIZE){
    xmm0 = _mm_loadu_si128(++src);
    accumulator = _mm_add_epi32(accumulator,xmm0);
  }

  accumulator = _mm_add_epi32(accumulator, _mm_srli_si128(accumulator, 8));
  accumulator = _mm_add_epi32(accumulator, _mm_srli_si128(accumulator, 4));
  output = _mm_cvtsi128_si32(accumulator);


  for(i=len-remainder;i<len;i++){
    output += d[i];
  }
  return output;
}
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,这是一个相当简单的实现,我使用扩展的xmm寄存器一次对数组4求和,然后通过将剩余元素相加来最后清理.

然后,我将此SIMD实现的性能与简单的for循环进行了比较.这个实验的结果可以在这里找到:

SIMD与for循环

正如您所看到的,与for循环相比,此实现确实显示输入大小(意味着数组的长度)的约60%加速,大约为5M元素.但是,对于较大的输入尺寸值,与for循环相比,性能会急剧下降并且仅产生大约20%的加速.

我无法解释这种性能急剧下降的原因.我或多或少地通过内存线性地步进,因此对于两种实现,缓存未命中和页面错误的影响应该大致相同.我在这里错过了什么?有什么办法可以让这条曲线变平吗?任何想法将不胜感激.

c performance sse simd intrinsics

3
推荐指数
1
解决办法
563
查看次数

What is the reason for different performance of the same implementation using icc, gcc and clang?

I have implemented a program for a[i]=a[i-1]+c and I represent it her. I use begin_rdtsc and end_rdtsc to read and store the rdtsc to measure the speedup.

The program is as follows, I use x86intrin.h

#define MAX1 512
#define LEN MAX1*MAX1  //array size for time measure ments
int __attribute__(( aligned(32))) a[LEN];

int main(){

    singleCore // It's a macro to assign the program to a single core of the processor
    int i, b, c;

    begin_rdtsc

    // b=1 and c=2 in this …
Run Code Online (Sandbox Code Playgroud)

x86 assembly gcc simd icc

3
推荐指数
1
解决办法
280
查看次数

是否可以对数组中的每3个相邻元素求和,并使用向量指令使它们中的每一个等于和?

在我的程序中,我有一个很大的32位整数数组.我必须对它进行以下操作:

sum = array[i] + array[i+1] + array[i+2]
array[i] = sum
array[i+1] = sum
array[i+2] = sum
i+=3
Run Code Online (Sandbox Code Playgroud)

或者,正如我在汇编中写的那样:

loop: ;R12 - address of the array, R11 - last element, R10 - iterator

mov eax, [R12 + R10]
add eax, [R12 + R10 + 4]
add eax, [R12 + R10 + 8]

mov [R12 + R10], eax
mov [R12 + R10 + 4], eax
mov [R12 + R10 + 8], eax

mov rax, 0
mov rdx, 0

add R10, 12 …
Run Code Online (Sandbox Code Playgroud)

x86 assembly simd avx

3
推荐指数
1
解决办法
162
查看次数

标签 统计

simd ×10

c++ ×5

sse ×5

x86 ×5

assembly ×3

avx ×3

intrinsics ×3

c ×2

linux ×2

performance ×2

gcc ×1

icc ×1

optimization ×1

segmentation-fault ×1

yeppp ×1