- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since my previous post didn't have much success I've made a reproducible program in case anyone wants to take a look.
I'm trying to do an FFT on .NET using MKL. I've downloaded the examples and modified the code to show my case.
public class Test_dfti
{
private Test_dfti() { }
public static void Main(string[] args)
{
int num_samples = 20480;
/* The data to be transformed */
float[] x_normal = new float[num_samples + 2]; // CSS requires an array of N + 2
/* Initialize the data array */
int sampling_freq = 1024000;
int tone = 16000;
int amplitude = 1;
for (int i = 0; i < num_samples; i++)
{
x_normal[i] = amplitude * (float)Math.Sin((2 * 3.14159265358979323846 / sampling_freq) * i * tone);
}
IntPtr desc = new();
/* Create new DFTI descriptor */
if (
(DFTI.DftiCreateDescriptor(ref desc, DFTI.SINGLE, DFTI.REAL, 1, num_samples) == 0)
&& (DFTI.DftiSetValue(desc, DFTI.PLACEMENT, DFTI.INPLACE) == 0)
&& (DFTI.DftiSetValue(desc, DFTI.PACKED_FORMAT, DFTI.CCS_FORMAT) == 0)
&& (DFTI.DftiCommitDescriptor(desc) == 0)
&& (DFTI.DftiComputeForward(desc, x_normal) == 0))
{
Console.WriteLine(x_normal[19840] + " - " + x_normal[19841]);
}
}
}
As can be seen in the code, I'm doing a 1D, inplace, single precission fft of 20480 samples from a tone of 16K sampled at 1.024 Msps. The output is in CCS format.
The problem is that bin 9920 (array positions 19840, 19840 + 1) is 0+0i. I understand that this shouldn't happen with the input tone. This 0+0i bin happens at different places with different frequencies other than 16K. Sometimes there's no 0+0i bin, sometimes there are several, depending on the input tone.
I attached the visual studio project with the full code in case someone tries to reproduce it.
Note:
This is the output of MKL_VERBOSE
MKL_VERBOSE Intel(R) MKL 2021.0 Update 2 Product build 20210312 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) enabled processors, Win 3.60GHz intel_thread
MKL_VERBOSE FFT(srfi20480,pack:ccs,tLim:1,unaligned_input,desc:000002154E347840) 127.94us CNR:OFF Dyn:1 FastMM:1 TID:0 NThr:1
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Your issue was reproducible, but unfortunately, we only support C/C++, DPC++, and Fortran for now. Please visit the below system requirements page.
Please try using the supported languages mentioned above and let us know if the issue remains.
Regards
Rajesh.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rajesh,
In your example you are using DOUBLE instead of SINGLE. You should reproduce the problem by changing to SINGLE.
UPDATE: I've changed to SINGLE and it doesn't reproduces. I'll take a look.
Regards,
Pedro.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rajesh,
You were using doubles throughout all the code, not just in the fft descriptor. We must use floats for performance reasons. The problem only arises with floats.
I've modified your code, basically just changed the precision of the descriptor to SINGLE and replaced all doubles with floats. Also, I write to the console after the forward fft, not after the backward one.
I attach the modified code, you can reproduce the problem from it.
Regards,
Pedro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Your issue was reproducible, but unfortunately, we only support C/C++, DPC++, and Fortran for now. Please visit the below system requirements page.
Please try using the supported languages mentioned above and let us know if the issue remains.
Regards
Rajesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for accepting as a solution!
We will no longer respond to this thread. If you require any additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.
Have a Good day.
Regards
Rajesh

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page