1
|
#include <stdio.h>
|
2
|
#include <stdlib.h>
|
3
|
#include <string.h>
|
4
|
#include <math.h>
|
5
|
#include <mkl.h>
|
6
|
#include <mkl_dfti.h>
|
7
|
#include <immintrin.h>
|
8
|
#include<time.h>
|
9
|
|
10
|
float *input;
|
11
|
float *output;
|
12
|
|
13
|
#define nFFT (98304)
|
14
|
|
15
|
DFTI_DESCRIPTOR_HANDLE HandlerIdft;
|
16
|
MKL_LONG status = 0;
|
17
|
int main(void)
|
18
|
{
|
19
|
__m512i in;
|
20
|
__m512i out;
|
21
|
input = (float *)malloc(nFFT*2*sizeof(float));
|
22
|
output = (float *)malloc(nFFT*2*sizeof(float));
|
23
|
memset(output,0,nFFT*2);
|
24
|
/********************print input*********************/
|
25
|
printf("input: ");
|
26
|
for(int i = 0; i < nFFT*2; i++)
|
27
|
{
|
28
|
input[i] = i+1;
|
29
|
//printf(" %f ",*(input+i));
|
30
|
}
|
31
|
printf("\n");
|
32
|
/****************************************************/
|
33
|
float para = 1.0f / nFFT;
|
34
|
/*
|
35
|
Matlab IFFT scale: para = 1.0f / nFFT
|
36
|
x86 MKL DftBackward scale: para = 1.0f / sqrt(nFFT)
|
37
|
*/
|
38
|
|
39
|
int irc = mkl_enable_instructions(MKL_ENABLE_AVX512);
|
40
|
printf("irc-%d\n", irc);
|
41
|
status = DftiCreateDescriptor(&HandlerIdft, DFTI_SINGLE, DFTI_COMPLEX, 1, nFFT);
|
42
|
/* HandlerIdft: Descriptor Handler
|
43
|
DFTI_SINGLE: Precision of the computation - DFTI_SINGLE or DFTI_DOUBLE
|
44
|
DFTI_COMPLEX: Type of the transform - DFTI_COMPLEX or DFTI_REAL
|
45
|
1(DFTI_DIMENSION): Integer
|
46
|
DFTI_LENGTHS: DFTI_LENGTHS
|
47
|
*/
|
48
|
status = DftiSetValue(HandlerIdft, DFTI_BACKWARD_SCALE, para);
|
49
|
/* DFTI_FORWARD_SCALE/DFTI_BACKWARD_SCALE:
|
50
|
Floating-point scalar
|
51
|
Scale factor for the forward transform/backward transform
|
52
|
*/
|
53
|
status = DftiSetValue(HandlerIdft, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
|
54
|
/* DFTI_PLACEMENT: Named constant DFTI_INPLACE or DFTI_NOT_INPLACE
|
55
|
Defines whether the result overwrites the input data.
|
56
|
Default value: DFTI_INPLACE.
|
57
|
*/
|
58
|
//status = DftiSetValue(HandlerIdft, DFTI_THREAD_LIMIT, 1);
|
59
|
status = DftiCommitDescriptor(HandlerIdft);
|
60
|
/* ================================================ */
|
61
|
/* INTRINSICS TO BE TESTED */
|
62
|
/* ================================================ */
|
63
|
struct timespec CrcSendtime;
|
64
|
struct timespec endtime;
|
65
|
clock_gettime(CLOCK_REALTIME, &CrcSendtime);
|
66
|
|
67
|
status = DftiComputeBackward(HandlerIdft, input, output);
|
68
|
|
69
|
clock_gettime(CLOCK_REALTIME, &endtime);
|
70
|
printf("msec [%f]\n", (float)(endtime.tv_nsec - CrcSendtime.tv_nsec)/1000000);
|
71
|
printf("status[%d]\n ", *(int *)(&status));
|
72
|
/********************print output********************/
|
73
|
printf("output: ");
|
74
|
for(int i = 0; i < 66; i++)
|
75
|
{
|
76
|
//printf(" %f ",*(output+i));
|
77
|
}
|
78
|
printf("\n");
|
79
|
/****************************************************/
|
80
|
|
81
|
status = DftiFreeDescriptor(&HandlerIdft);
|
82
|
return 0;
|
83
|
}
|