MICFFT.h 2.25 KB
Newer Older
Uldis Locans's avatar
Uldis Locans committed
1 2 3 4 5 6 7 8 9
#ifndef H_MIC_FFT
#define H_MIC_FFT

#include <iostream>
#include <complex>

#include <offload.h>
#include <mkl_dfti.h>

Uldis Locans's avatar
Uldis Locans committed
10
#include "../Algorithms/FFT.h"
Uldis Locans's avatar
Uldis Locans committed
11 12
#include "MICBase.h"

13
class MICFFT : public FFT {
Uldis Locans's avatar
Uldis Locans committed
14 15 16

private:

Uldis Locans's avatar
Uldis Locans committed
17
  bool m_fftsetup;
Uldis Locans's avatar
Uldis Locans committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
  MICBase *m_micbase;

  /// Internal FFT object for performing serial FFTs.
#pragma offload_attribute(push,target(mic))
  DFTI_DESCRIPTOR_HANDLE FFTHandle_m; //declspec only works for global variables
  DFTI_DESCRIPTOR_HANDLE handle;
  DFTI_DESCRIPTOR_HANDLE rc_handle; //handle for REAL->COMPLEX
  DFTI_DESCRIPTOR_HANDLE cr_handle; //handle for COMPLEX->REAL

#pragma offload_attribute(pop)

  __attribute__((target(mic:0))) DFTI_DESCRIPTOR_HANDLE& getHandle(void) { 
    return FFTHandle_m; 
  }

  __attribute__((target(mic:0))) DFTI_DESCRIPTOR_HANDLE& getHandle1(void) { 
    return handle; 
  }

  __attribute__((target(mic:0))) DFTI_DESCRIPTOR_HANDLE& getHandleRC(void) { 
    return rc_handle; 
  }

  __attribute__((target(mic:0))) DFTI_DESCRIPTOR_HANDLE& getHandleCR(void) { 
    return cr_handle; 
  }

public:

  /* constructor */
  MICFFT(MICBase *base);

  /* destructir */
  ~MICFFT();

  /* 
     Info: setup mkl fft
     Return: success or error code
  */ 
  int setupFFT(int ndim, int N[3]);
  //BENI: 
  int setupFFTRC(int ndim, int N[3], double scale = 1.0);
  //BENI: 
  int setupFFTCR(int ndim, int N[3], double scale = 1.0);

  /* execute FFT on MIC */
  int executeFFT(void *mem_ptr, int ndim, int N[3], int streamId = -1, bool forward = true);

  /* execute IFFT on MIC */
  int executeIFFT(void *mem_ptr, int ndim, int N[3], int streamId = -1);

  /* execute REAL->COMPLEX FFT on MIC */
  int executeRCFFT(void *in_ptr, void *out_ptr, int ndim, int N[3], int streamId = -1);

  /* execute COMPLEX->REAL FFT on MIC */
  int executeCRFFT(void *in_ptr, void *out_ptr, int ndim, int N[3], int streamId = -1);

  /* normalize IFFT on MIC */
  int normalizeFFT(void *mem_ptr, int ndim, int N[3], int streamId = -1);

Uldis Locans's avatar
Uldis Locans committed
78 79 80 81 82 83 84 85 86 87 88 89
  /**
   * Info: destroy default FFT plans
   * Return: success or error code
   */
  int destroyFFT() { return DKS_SUCCESS; }

  /*
    Info: execute normalize for complex to real iFFT
    Return: success or error code
  */
  int normalizeCRFFT(void *real_ptr, int ndim, int N[3], int streamId = -1) { return DKS_SUCCESS; }

Uldis Locans's avatar
Uldis Locans committed
90 91 92
};

#endif