使用Intel MKL在700fps高帧率下多次执行正反FFT崩溃,求排查方案
高速相机FFT运算崩溃问题排查
我们有一台帧率≥700fps的高速相机,需要对采集的图像执行FFT计算及后续处理。但FFT运算在处理若干帧后会崩溃,10fps低帧率下则无此问题。
为定位问题,我编写了一个循环执行FFT的测试程序,该程序同样会崩溃。
更新1:我用-g参数编译后通过lldb运行,仍未获取到有效堆栈跟踪:
➜ cmake-build-debug lldb IntelTest (lldb) target create "IntelTest" Current executable set to '/Users/harshmathur/CourseworkRepo/IntelTest/cmake-build-debug/IntelTest' (x86_64). (lldb) run Process 13947 launched: '/Users/harshmathur/CourseworkRepo/IntelTest/cmake-build-debug/IntelTest' (x86_64) DftiGetValue DFTI_PACKED_FORMAT : 57 Process 13947 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x111844100) frame #0: 0x0000000110568a4c libmkl_avx2.2.dylib`mkl_dft_avx2_ipps_cFFTfwd_64_64fc + 2428 libmkl_avx2.2.dylib`mkl_dft_avx2_ipps_cFFTfwd_64_64fc: -> 0x110568a4c <+2428>: vmovupd %ymm2, (%rsi) 0x110568a50 <+2432>: vmovupd %ymm7, 0x200(%rsi) 0x110568a58 <+2440>: vaddpd %ymm13, %ymm6, %ymm2 0x110568a5d <+2445>: vsubpd %ymm13, %ymm6, %ymm6
更新2:另外,当NN设为32时,以下代码可正常运行无报错;仅当NN>32时,程序会突然终止。
相关代码如下:
#include <iostream> #include <mkl.h> #define NN 128 #define NPIXFFT NN * (1 + NN / 2) using namespace std; typedef struct { double re; double im; } mkl_double_complex; int getFFTWPlans(DFTI_DESCRIPTOR_HANDLE *descHandle); int main() { int i; MKL_LONG status; DFTI_DESCRIPTOR_HANDLE descHandle; getFFTWPlans(&descHandle); double *image = (double*)malloc(sizeof(double) * NN * NN); double *recoveredImage = (double*)malloc(sizeof(double) * NN * NN); mkl_double_complex *imageFT = (mkl_double_complex*) mkl_malloc( NPIXFFT * sizeof(mkl_double_complex),64); for (i=0; i < NN * NN; i++) { image[i] = i * 2 + 1; } while (1) { status = DftiComputeForward(descHandle, image, imageFT); if (status != 0) { cout <<"DftiComputeForward Failed: " << status << endl; break; } status = DftiComputeBackward(descHandle, imageFT, recoveredImage); if (status != 0) { cout <<"DftiComputeBackward Failed: " << status << endl; break; } } return 0; } int getFFTWPlans(DFTI_DESCRIPTOR_HANDLE *descHandle){ MKL_LONG lengths[2]; lengths[0] = NN; lengths[1] = NN; MKL_LONG status = DftiCreateDescriptor(descHandle, DFTI_DOUBLE, DFTI_REAL, 2, lengths); if (status != 0) { cout << "DftiCreateDescriptor failed : " << status << endl; return -1; } status = DftiSetValue(*descHandle, DFTI_PLACEMENT, DFTI_NOT_INPLACE); if (status != 0) { cout << "DftiSetValue DFTI_PLACEMENT failed : " << status << endl; return -2; } status = DftiSetValue(*descHandle, DFTI_THREAD_LIMIT, 1); if (status != 0) { cout << "DftiSetValue DFTI_THREAD_LIMIT failed : " << status << endl; return -2; } MKL_LONG format; status = DftiGetValue(*descHandle, DFTI_PACKED_FORMAT, &format); if (status != 0) { cout << "DftiGetValue DFTI_PACKED_FORMAT failed : " << status << endl; return -3; } cout << "DftiGetValue DFTI_PACKED_FORMAT : " << format << endl; status = DftiCommitDescriptor(*descHandle); if (status != 0) { cout << "DftiCommitDescriptor failed : " << status << endl; return -4; } return status; }
内容的提问来源于stack exchange,提问作者Harsh M
相关产品推荐
相关产品推荐

