mkl_dfti.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*******************************************************************************
  2. * Copyright 2002-2022 Intel Corporation.
  3. *
  4. * This software and the related documents are Intel copyrighted materials, and
  5. * your use of them is governed by the express license under which they were
  6. * provided to you (License). Unless the License provides otherwise, you may not
  7. * use, modify, copy, publish, distribute, disclose or transmit this software or
  8. * the related documents without Intel's prior written permission.
  9. *
  10. * This software and the related documents are provided as is, with no express
  11. * or implied warranties, other than those that are expressly stated in the
  12. * License.
  13. *******************************************************************************/
  14. /*
  15. ! Content:
  16. ! Intel(R) oneAPI Math Kernel Library (oneMKL)
  17. ! Discrete Fourier Transform Interface (DFTI)
  18. !****************************************************************************/
  19. #ifndef _MKL_DFTI_H_
  20. #define _MKL_DFTI_H_
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif /* __cplusplus */
  24. #include "mkl_types.h"
  25. #if defined(__cplusplus_cli)
  26. struct DFTI_DESCRIPTOR{};
  27. #endif
  28. #if !defined(_WIN32)
  29. #define DFTI_EXTERN
  30. #else
  31. #if defined(DFTI_BUILD_DLL)
  32. #define DFTI_EXTERN __declspec(dllexport)
  33. #elif defined(DFTI_USE_DLL)
  34. #define DFTI_EXTERN __declspec(dllimport)
  35. #else
  36. #define DFTI_EXTERN
  37. #endif /* defined(DFTI_BUILD_DLL) */
  38. #endif /* _WIN32 */
  39. /* Error classes */
  40. #define DFTI_NO_ERROR 0
  41. #define DFTI_MEMORY_ERROR 1
  42. #define DFTI_INVALID_CONFIGURATION 2
  43. #define DFTI_INCONSISTENT_CONFIGURATION 3
  44. #define DFTI_MULTITHREADED_ERROR 4
  45. #define DFTI_BAD_DESCRIPTOR 5
  46. #define DFTI_UNIMPLEMENTED 6
  47. #define DFTI_MKL_INTERNAL_ERROR 7
  48. #define DFTI_NUMBER_OF_THREADS_ERROR 8
  49. #define DFTI_1D_LENGTH_EXCEEDS_INT32 9
  50. #define DFTI_1D_MEMORY_EXCEEDS_INT32 9
  51. #define DFTI_NO_WORKSPACE 11
  52. #define DFTI_MAX_MESSAGE_LENGTH 80 /* Maximum length of error string */
  53. #define DFTI_MAX_NAME_LENGTH 10 /* DEPRECATED */
  54. #define DFTI_VERSION_LENGTH 198 /* Maximum length of oneMKL version string */
  55. /* Descriptor configuration parameters [default values in brackets] */
  56. enum DFTI_CONFIG_PARAM
  57. {
  58. /* Domain for forward transform. No default value */
  59. DFTI_FORWARD_DOMAIN = 0,
  60. /* Dimensionality, or rank. No default value */
  61. DFTI_DIMENSION = 1,
  62. /* Length(s) of transform. No default value */
  63. DFTI_LENGTHS = 2,
  64. /* Floating point precision. No default value */
  65. DFTI_PRECISION = 3,
  66. /* Scale factor for forward transform [1.0] */
  67. DFTI_FORWARD_SCALE = 4,
  68. /* Scale factor for backward transform [1.0] */
  69. DFTI_BACKWARD_SCALE = 5,
  70. /* Exponent sign for forward transform [DFTI_NEGATIVE] */
  71. /* DFTI_FORWARD_SIGN = 6, ## NOT IMPLEMENTED */
  72. /* Number of data sets to be transformed [1] */
  73. DFTI_NUMBER_OF_TRANSFORMS = 7,
  74. /* Storage of finite complex-valued sequences in complex domain
  75. [DFTI_COMPLEX_COMPLEX] */
  76. DFTI_COMPLEX_STORAGE = 8,
  77. /* Storage of finite real-valued sequences in real domain
  78. [DFTI_REAL_REAL] */
  79. DFTI_REAL_STORAGE = 9,
  80. /* Storage of finite complex-valued sequences in conjugate-even
  81. domain [DFTI_COMPLEX_REAL] */
  82. DFTI_CONJUGATE_EVEN_STORAGE = 10,
  83. /* Placement of result [DFTI_INPLACE] */
  84. DFTI_PLACEMENT = 11,
  85. /* Generalized strides for input data layout [tight, row-major for
  86. C] */
  87. DFTI_INPUT_STRIDES = 12,
  88. /* Generalized strides for output data layout [tight, row-major
  89. for C] */
  90. DFTI_OUTPUT_STRIDES = 13,
  91. /* Distance between first input elements for multiple transforms
  92. [0] */
  93. DFTI_INPUT_DISTANCE = 14,
  94. /* Distance between first output elements for multiple transforms
  95. [0] */
  96. DFTI_OUTPUT_DISTANCE = 15,
  97. /* Effort spent in initialization [DFTI_MEDIUM] */
  98. /* DFTI_INITIALIZATION_EFFORT = 16, ## NOT IMPLEMENTED */
  99. /* Use of workspace during computation [DFTI_ALLOW] */
  100. DFTI_WORKSPACE = 17,
  101. /* Ordering of the result [DFTI_ORDERED] */
  102. DFTI_ORDERING = 18,
  103. /* Possible transposition of result [DFTI_NONE] */
  104. DFTI_TRANSPOSE = 19,
  105. /* User-settable descriptor name [""] */
  106. DFTI_DESCRIPTOR_NAME = 20, /* DEPRECATED */
  107. /* Packing format for DFTI_COMPLEX_REAL storage of finite
  108. conjugate-even sequences [DFTI_CCS_FORMAT] */
  109. DFTI_PACKED_FORMAT = 21,
  110. /* Commit status of the descriptor - R/O parameter */
  111. DFTI_COMMIT_STATUS = 22,
  112. /* Version string for this DFTI implementation - R/O parameter */
  113. DFTI_VERSION = 23,
  114. /* Ordering of the forward transform - R/O parameter */
  115. /* DFTI_FORWARD_ORDERING = 24, ## NOT IMPLEMENTED */
  116. /* Ordering of the backward transform - R/O parameter */
  117. /* DFTI_BACKWARD_ORDERING = 25, ## NOT IMPLEMENTED */
  118. /* Number of user threads that share the descriptor [1] */
  119. DFTI_NUMBER_OF_USER_THREADS = 26,
  120. /* Limit the number of threads used by this descriptor [0 = don't care] */
  121. DFTI_THREAD_LIMIT = 27,
  122. /* Possible input data destruction [DFTI_AVOID = prevent input data]*/
  123. DFTI_DESTROY_INPUT = 28,
  124. /* Distance between first input elements for multiple transforms
  125. [0] */
  126. DFTI_FWD_DISTANCE = 58,
  127. /* Distance between first input elements for multiple transforms
  128. [0] */
  129. DFTI_BWD_DISTANCE = 59
  130. };
  131. /* Values of the descriptor configuration parameters */
  132. enum DFTI_CONFIG_VALUE
  133. {
  134. /* DFTI_COMMIT_STATUS */
  135. DFTI_COMMITTED = 30,
  136. DFTI_UNCOMMITTED = 31,
  137. /* DFTI_FORWARD_DOMAIN */
  138. DFTI_COMPLEX = 32,
  139. DFTI_REAL = 33,
  140. /* DFTI_CONJUGATE_EVEN = 34, ## NOT IMPLEMENTED */
  141. /* DFTI_PRECISION */
  142. DFTI_SINGLE = 35,
  143. DFTI_DOUBLE = 36,
  144. /* DFTI_FORWARD_SIGN */
  145. /* DFTI_NEGATIVE = 37, ## NOT IMPLEMENTED */
  146. /* DFTI_POSITIVE = 38, ## NOT IMPLEMENTED */
  147. /* DFTI_COMPLEX_STORAGE and DFTI_CONJUGATE_EVEN_STORAGE */
  148. DFTI_COMPLEX_COMPLEX = 39,
  149. DFTI_COMPLEX_REAL = 40,
  150. /* DFTI_REAL_STORAGE */
  151. DFTI_REAL_COMPLEX = 41,
  152. DFTI_REAL_REAL = 42,
  153. /* DFTI_PLACEMENT */
  154. DFTI_INPLACE = 43, /* Result overwrites input */
  155. DFTI_NOT_INPLACE = 44, /* Have another place for result */
  156. /* DFTI_INITIALIZATION_EFFORT */
  157. /* DFTI_LOW = 45, ## NOT IMPLEMENTED */
  158. /* DFTI_MEDIUM = 46, ## NOT IMPLEMENTED */
  159. /* DFTI_HIGH = 47, ## NOT IMPLEMENTED */
  160. /* DFTI_ORDERING */
  161. DFTI_ORDERED = 48,
  162. DFTI_BACKWARD_SCRAMBLED = 49,
  163. /* DFTI_FORWARD_SCRAMBLED = 50, ## NOT IMPLEMENTED */
  164. /* Allow/avoid certain usages */
  165. DFTI_ALLOW = 51, /* Allow transposition or workspace */
  166. DFTI_AVOID = 52,
  167. DFTI_NONE = 53,
  168. /* DFTI_PACKED_FORMAT (for storing congugate-even finite sequence
  169. in real array) */
  170. DFTI_CCS_FORMAT = 54, /* Complex conjugate-symmetric */
  171. DFTI_PACK_FORMAT = 55, /* Pack format for real DFT */
  172. DFTI_PERM_FORMAT = 56, /* Perm format for real DFT */
  173. DFTI_CCE_FORMAT = 57 /* Complex conjugate-even */
  174. };
  175. typedef struct DFTI_DESCRIPTOR *DFTI_DESCRIPTOR_HANDLE;
  176. typedef struct DFTI_DESCRIPTOR DFTI_DESCRIPTOR; /* deprecated */
  177. #define DFTI_DFT_Desc_struct DFTI_DESCRIPTOR /* deprecated */
  178. #define DFTI_Descriptor_struct DFTI_DESCRIPTOR /* deprecated */
  179. #define DFTI_Descriptor DFTI_DESCRIPTOR /* deprecated */
  180. DFTI_EXTERN MKL_LONG DftiCreateDescriptor(DFTI_DESCRIPTOR_HANDLE*,
  181. enum DFTI_CONFIG_VALUE, /* precision */
  182. enum DFTI_CONFIG_VALUE, /* domain */
  183. MKL_LONG, ...);
  184. DFTI_EXTERN MKL_LONG DftiCopyDescriptor(DFTI_DESCRIPTOR_HANDLE, /* from descriptor */
  185. DFTI_DESCRIPTOR_HANDLE*); /* to descriptor */
  186. DFTI_EXTERN MKL_LONG DftiCommitDescriptor(DFTI_DESCRIPTOR_HANDLE);
  187. DFTI_EXTERN MKL_LONG DftiComputeForward(DFTI_DESCRIPTOR_HANDLE, void*, ...);
  188. DFTI_EXTERN MKL_LONG DftiComputeBackward(DFTI_DESCRIPTOR_HANDLE, void*, ...);
  189. DFTI_EXTERN MKL_LONG DftiSetValue(DFTI_DESCRIPTOR_HANDLE, enum DFTI_CONFIG_PARAM, ...);
  190. DFTI_EXTERN MKL_LONG DftiGetValue(DFTI_DESCRIPTOR_HANDLE, enum DFTI_CONFIG_PARAM, ...);
  191. DFTI_EXTERN MKL_LONG DftiFreeDescriptor(DFTI_DESCRIPTOR_HANDLE*);
  192. DFTI_EXTERN char* DftiErrorMessage(MKL_LONG);
  193. DFTI_EXTERN MKL_LONG DftiErrorClass(MKL_LONG, MKL_LONG);
  194. /**********************************************************************
  195. * INTERNAL INTERFACES. These internal interfaces are not intended to
  196. * be called directly by oneMKL users and may change in future releases.
  197. */
  198. DFTI_EXTERN MKL_LONG DftiCreateDescriptor_s_1d(DFTI_DESCRIPTOR_HANDLE *,
  199. enum DFTI_CONFIG_VALUE domain,
  200. ... /* MKL_LONG onedim */);
  201. DFTI_EXTERN MKL_LONG DftiCreateDescriptor_s_md(DFTI_DESCRIPTOR_HANDLE *,
  202. enum DFTI_CONFIG_VALUE domain,
  203. MKL_LONG many,
  204. ... /* MKL_LONG *dims */);
  205. DFTI_EXTERN MKL_LONG DftiCreateDescriptor_d_1d(DFTI_DESCRIPTOR_HANDLE *,
  206. enum DFTI_CONFIG_VALUE domain,
  207. ... /* MKL_LONG onedim */);
  208. DFTI_EXTERN MKL_LONG DftiCreateDescriptor_d_md(DFTI_DESCRIPTOR_HANDLE *,
  209. enum DFTI_CONFIG_VALUE domain,
  210. MKL_LONG many,
  211. ... /* MKL_LONG *dims */);
  212. /**********************************************************************
  213. * Compile-time separation of specific cases
  214. */
  215. #ifndef DftiCreateDescriptor
  216. #define DftiCreateDescriptor(desc,prec,domain,dim,sizes) \
  217. (/* single precision specific cases */ \
  218. ((prec)==DFTI_SINGLE && (dim)==1) ? \
  219. DftiCreateDescriptor_s_1d((desc),(domain),(sizes)) : \
  220. ((prec)==DFTI_SINGLE) ? \
  221. DftiCreateDescriptor_s_md((desc),(domain),(dim),(sizes)) : \
  222. /* double precision specific cases */ \
  223. ((prec)==DFTI_DOUBLE && (dim)==1) ? \
  224. DftiCreateDescriptor_d_1d((desc),(domain),(sizes)) : \
  225. ((prec)==DFTI_DOUBLE) ? \
  226. DftiCreateDescriptor_d_md((desc),(domain),(dim),(sizes)) : \
  227. /* no specific case matches, fall back to original call */ \
  228. DftiCreateDescriptor((desc),(prec),(domain),(dim),(sizes)))
  229. #endif
  230. #ifdef __cplusplus
  231. }
  232. #endif /* __cplusplus */
  233. #endif /* _MKL_DFTI_H_ */