I have some data of Complex Values of size N, and would like to compute the FFT of this data using the Intel OneAPI. Here is my code:
# Connectivity
#include <bits/stdc++.h>
#include "mkl_dfti.h"
#include <complex.h>
using namespace std;
float pi = 2*acos(0.0);
int main(){
long long int N; cin >> N
float _Complex c2c_data[N];
DFTI_DESCRIPTOR_HANDLE my_desc1_handle = NULL;
DFTI_DESCRIPTOR_HANDLE my_desc2_handle = NULL;
MKL_LONG status;
// data is inserted here
status = DftiCreateDescriptor(&my_desc1_handle, DFTI_SINGLE, DFTI_COMPLEX, 1, N);
status = DftiCommitDescriptor(my_desc1_handle);
status = DftiComputeForward(my_desc1_handle, c2c_data);
status = DftiFreeDescriptor(&my_desc1_handle);
cout << round(cabs(c2c_data[s]) / N) << "\n";
return 0;
}
This works for smaller cases of N, but for larger cases (around 2^21), I get a segmentation fault and for even larger cases, I get a Bus error. I have checked that this happens at the DftiComputeForward function. The length of the data is specified in DftiCreateDescriptor which is indeed N in this case, so I am not sure why I am getting this error.
Here is here how I compile my code:
dpcpp test.cpp -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread -liomp5 -ldl -lpthread -o test
It would be great if someone could help. Thank you!