[英]How to deal with SIGSEGV, Segmentation fault. while using Avx2
I've received segmentation fault wile called我收到了分段错误,称为
_mm256_load_pd
usage are as blew用法很糟糕
double * Val = malloc(sizeof(double)*4);
__m256d vecv = _mm256_load_pd(&Val[0]);
gdb shows gdb 显示
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7fc5017 in _mm256_load_pd (__P=0x555555559370)
at /usr/lib/gcc/x86_64-linux-gnu/9/include/avxintrin.h:862
862 return *(__m256d *)__P;
(gdb) frame 1
#1 gemv_d_lineProduct_4_avx2 (Val=0x555555559370, indx=0x5555555592f0,
Vector_X=0x5555555592c0, Vector_Y=0x555555559340)
at someThing.c:114
114 __m256d vecv = _mm256_load_pd(&Val[0]);
(gdb)
while I make Val bigger而我让 Val 更大
double * Val = malloc(sizeof(double)*4);
I found _mm256_load_pd works rightly but result in我发现_mm256_load_pd工作正常但导致
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7fc50e3 in _mm256_store_pd (__A=..., __P=0x555555559390)
at /usr/lib/gcc/x86_64-linux-gnu/9/include/avxintrin.h:868
868 *(__m256d *)__P = __A;
(gdb) frame 1
#1 gemv_d_lineProduct_4_avx2 (Val=0x5555555593e0, indx=0x555555559310,
Vector_X=0x5555555592c0, Vector_Y=0x555555559390)
at something.c:122
122 _mm256_store_pd(Vector_Y,vecY);
https://github.com/DevilInChina/gemv https://github.com/DevilInChina/gemv
mkdir build;cd build
cmake ..
make
cd ../bin
./line
#then might get some seg fault
change memory allocate function to将 memory 分配 function 更改为
void *aligned_alloc (size_t __alignment, size_t __size);
first parameter should be 1024 or something else.第一个参数应该是 1024 或其他。
According to the Intel reference , _mm256_load_pd()
requires 32-byte aligned pointer.根据Intel 参考资料,
_mm256_load_pd()
需要 32 字节对齐的指针。
Please, use aligned_alloc()
to allocate a memory chunk having the proper alignment.请使用
aligned_alloc()
分配具有正确alignment 的memory 块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.