mkl_vml_defines.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /* file: mkl_vml_defines.h */
  2. /*******************************************************************************
  3. * Copyright 2006-2022 Intel Corporation.
  4. *
  5. * This software and the related documents are Intel copyrighted materials, and
  6. * your use of them is governed by the express license under which they were
  7. * provided to you (License). Unless the License provides otherwise, you may not
  8. * use, modify, copy, publish, distribute, disclose or transmit this software or
  9. * the related documents without Intel's prior written permission.
  10. *
  11. * This software and the related documents are provided as is, with no express
  12. * or implied warranties, other than those that are expressly stated in the
  13. * License.
  14. *******************************************************************************/
  15. /*
  16. //++
  17. // Macro definitions visible on user level.
  18. //--
  19. */
  20. #ifndef __MKL_VML_DEFINES_H__
  21. #define __MKL_VML_DEFINES_H__
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif /* __cplusplus */
  25. /*
  26. //++
  27. // MACRO DEFINITIONS
  28. // Macro definitions for VML mode and VML error status.
  29. //
  30. // VML mode controls VML function accuracy, floating-point settings (rounding
  31. // mode and precision) and VML error handling options. Default VML mode is
  32. // VML_HA | VML_ERRMODE_DEFAULT | VML_FTZDAZ_CURRENT,
  33. // i.e. VML high accuracy functions are called,
  34. // current floating-point precision and the rounding mode is used,
  35. // current MXCSR settings are left unchanged.
  36. //
  37. // Error status macros are used for error classification.
  38. //--
  39. */
  40. /*
  41. // VML FUNCTION ACCURACY CONTROL
  42. // VML_HA - when VML_HA is set, high accuracy VML functions are called
  43. // VML_LA - when VML_LA is set, low accuracy VML functions are called
  44. // VML_EP - when VML_EP is set, enhanced performance VML functions are called
  45. //
  46. // NOTE: VML_HA, VML_LA and VML_EP must not be used in combination
  47. */
  48. #define VML_LA 0x00000001
  49. #define VML_HA 0x00000002
  50. #define VML_EP 0x00000003
  51. #define VML_LA_64 0x0000000000000001
  52. #define VML_HA_64 0x0000000000000002
  53. #define VML_EP_64 0x0000000000000003
  54. /*
  55. // SETTING OPTIMAL FLOATING-POINT PRECISION AND ROUNDING MODE
  56. // Definitions below are to set optimal floating-point control word
  57. // (precision and rounding mode).
  58. //
  59. // For their correct work, VML functions change floating-point precision and
  60. // rounding mode (if necessary). Since control word changing is typically
  61. // expensive operation, it is recommended to set precision and rounding mode
  62. // to optimal values before VML function calls.
  63. //
  64. // VML_FLOAT_CONSISTENT - use this value if the calls are typically to single
  65. // precision VML functions
  66. // VML_DOUBLE_CONSISTENT - use this value if the calls are typically to double
  67. // precision VML functions
  68. // VML_RESTORE - restore original floating-point precision and
  69. // rounding mode
  70. // VML_DEFAULT_PRECISION - use default (current) floating-point precision and
  71. // rounding mode
  72. // NOTE: VML_FLOAT_CONSISTENT, VML_DOUBLE_CONSISTENT, VML_RESTORE and
  73. // VML_DEFAULT_PRECISION must not be used in combination
  74. */
  75. #define VML_DEFAULT_PRECISION 0x00000000
  76. #define VML_FLOAT_CONSISTENT 0x00000010
  77. #define VML_DOUBLE_CONSISTENT 0x00000020
  78. #define VML_RESTORE 0x00000030
  79. #define VML_DEFAULT_PRECISION_64 0x0000000000000000
  80. #define VML_FLOAT_CONSISTENT_64 0x0000000000000010
  81. #define VML_DOUBLE_CONSISTENT_64 0x0000000000000020
  82. #define VML_RESTORE_64 0x0000000000000030
  83. /*
  84. // VML ERROR HANDLING CONTROL
  85. // Macros below are used to control VML error handler.
  86. //
  87. // VML_ERRMODE_IGNORE - ignore errors
  88. // VML_ERRMODE_ERRNO - errno variable is set on error
  89. // VML_ERRMODE_STDERR - error description text is written to stderr on error
  90. // VML_ERRMODE_EXCEPT - exception is raised on error
  91. // VML_ERRMODE_CALLBACK - user's error handler function is called on error
  92. // VML_ERRMODE_NOERR - ignore errors and do not update status
  93. // VML_ERRMODE_DEFAULT - errno variable is set, exceptions are raised and
  94. // user's error handler is called on error
  95. // NOTE: VML_ERRMODE_IGNORE must not be used in combination with
  96. // VML_ERRMODE_ERRNO, VML_ERRMODE_STDERR, VML_ERRMODE_EXCEPT,
  97. // VML_ERRMODE_CALLBACK and VML_ERRMODE_DEFAULT.
  98. // NOTE: VML_ERRMODE_NOERR must not be used in combination with any
  99. // other VML_ERRMODE setting.
  100. */
  101. #define VML_ERRMODE_IGNORE 0x00000100
  102. #define VML_ERRMODE_ERRNO 0x00000200
  103. #define VML_ERRMODE_STDERR 0x00000400
  104. #define VML_ERRMODE_EXCEPT 0x00000800
  105. #define VML_ERRMODE_CALLBACK 0x00001000
  106. #define VML_ERRMODE_NOERR 0x00002000
  107. #define VML_ERRMODE_DEFAULT \
  108. VML_ERRMODE_ERRNO | VML_ERRMODE_CALLBACK | VML_ERRMODE_EXCEPT
  109. #define VML_ERRMODE_IGNORE_64 0x0000000000000100
  110. #define VML_ERRMODE_ERRNO_64 0x0000000000000200
  111. #define VML_ERRMODE_STDERR_64 0x0000000000000400
  112. #define VML_ERRMODE_EXCEPT_64 0x0000000000000800
  113. #define VML_ERRMODE_CALLBACK_64 0x0000000000001000
  114. #define VML_ERRMODE_NOERR_64 0x0000000000002000
  115. #define VML_ERRMODE_DEFAULT_64 \
  116. VML_ERRMODE_ERRNO_64 | VML_ERRMODE_CALLBACK_64 | VML_ERRMODE_EXCEPT_64
  117. /*
  118. // OpenMP(R) number of threads mode macros
  119. // VML_NUM_THREADS_OMP_AUTO - Maximum number of threads is determined by
  120. // environmental variable OMP_NUM_THREADS or
  121. // omp_set_num_threads() function
  122. // VML_NUM_THREADS_OMP_FIXED - Number of threads is determined by
  123. // environmental variable OMP_NUM_THREADS
  124. // omp_set_num_threads() functions
  125. */
  126. #define VML_NUM_THREADS_OMP_AUTO 0x00000000
  127. #define VML_NUM_THREADS_OMP_FIXED 0x00010000
  128. #define VML_NUM_THREADS_OMP_AUTO_64 0x0000000000000000
  129. #define VML_NUM_THREADS_OMP_FIXED_64 0x0000000000010000
  130. /*
  131. // TBB partitioner control macros
  132. // VML_TBB_PARTITIONER_AUTO - Automatic TBB partitioner tbb::auto_partitioner().
  133. // Performs sufficient splitting to balance load.
  134. // VML_TBB_PARTITIONER_STATIC - Static TBB partitioner tbb::static_partitioner().
  135. // Distributes range iterations among worker threads as uniformly as possible,
  136. // without a possibility for further load balancing.
  137. // VML_TBB_PARTITIONER_SIMPLE - Simple TBB partitioner tbb::simple_partitioner().
  138. // Recursively splits a range until it is no longer divisible.
  139. //
  140. */
  141. #define VML_TBB_PARTITIONER_AUTO 0x00000000
  142. #define VML_TBB_PARTITIONER_STATIC 0x00010000
  143. #define VML_TBB_PARTITIONER_SIMPLE 0x00020000
  144. #define VML_TBB_PARTITIONER_AUTO_64 0x0000000000000000
  145. #define VML_TBB_PARTITIONER_STATIC_64 0x0000000000010000
  146. #define VML_TBB_PARTITIONER_SIMPLE_64 0x0000000000020000
  147. /*
  148. // FTZ & DAZ mode macros
  149. // VML_FTZDAZ_ON - FTZ & DAZ MXCSR mode enabled
  150. // for faster (sub)denormal values processing
  151. // VML_FTZDAZ_OFF - FTZ & DAZ MXCSR mode disabled
  152. // for accurate (sub)denormal values processing
  153. // VML_FTZDAZ_CURRENT - FTZ & DAZ MXCSR mode is kept as currently on CPU
  154. // (no slow MXCSR access during entry/exit)
  155. // for increased performance
  156. */
  157. #define VML_FTZDAZ_ON 0x00280000
  158. #define VML_FTZDAZ_OFF 0x00140000
  159. #define VML_FTZDAZ_CURRENT 0x00000000
  160. #define VML_FTZDAZ_ON_64 0x0000000000280000
  161. #define VML_FTZDAZ_OFF_64 0x0000000000140000
  162. #define VML_FTZDAZ_CURRENT_64 0x0000000000000000
  163. /*
  164. // Exception trap macros
  165. // VML_TRAP_INVALID Trap invalid arithmetic operand exception
  166. // VML_TRAP_DIVBYZERO Trap divide-by-zero exception
  167. // VML_TRAP_OVERFLOW Trap numeric overflow exception
  168. // VML_TRAP_UNDERFLOW Trap numeric underflow exception
  169. */
  170. #define VML_TRAP_INVALID 0x01000000
  171. #define VML_TRAP_DIVBYZERO 0x02000000
  172. #define VML_TRAP_OVERFLOW 0x04000000
  173. #define VML_TRAP_UNDERFLOW 0x08000000
  174. #define VML_TRAP_INVALID_64 0x0000000001000000
  175. #define VML_TRAP_DIVBYZERO_64 0x0000000002000000
  176. #define VML_TRAP_OVERFLOW_64 0x0000000004000000
  177. #define VML_TRAP_UNDERFLOW_64 0x0000000008000000
  178. /*
  179. // ACCURACY, FLOATING-POINT CONTROL, FTZDAZ AND ERROR HANDLING MASKS
  180. // Accuracy, floating-point and error handling control are packed in
  181. // the VML mode variable. Macros below are useful to extract accuracy and/or
  182. // floating-point control and/or error handling control settings.
  183. //
  184. // VML_ACCURACY_MASK - extract accuracy bits
  185. // VML_FPUMODE_MASK - extract floating-point control bits
  186. // VML_ERRMODE_MASK - extract error handling control bits
  187. // (including error callback bits)
  188. // VML_ERRMODE_STDHANDLER_MASK - extract error handling control bits
  189. // (not including error callback bits)
  190. // VML_ERRMODE_CALLBACK_MASK - extract error callback bits
  191. // VML_NUM_THREADS_OMP_MASK - extract OpenMP(R) number of threads mode bits
  192. // VML_TBB_PARTITIONER_MASK - extract TBB partitioner control bits
  193. // VML_FTZDAZ_MASK - extract FTZ & DAZ bits
  194. // VML_TRAP_EXCEPTIONS_MASK - extract exception trap bits
  195. */
  196. #define VML_ACCURACY_MASK 0x0000000F
  197. #define VML_FPUMODE_MASK 0x000000F0
  198. #define VML_ERRMODE_MASK 0x0000FF00
  199. #define VML_ERRMODE_STDHANDLER_MASK 0x00002F00
  200. #define VML_ERRMODE_CALLBACK_MASK 0x00001000
  201. #define VML_NUM_THREADS_OMP_MASK 0x00030000
  202. #define VML_TBB_PARTITIONER_MASK 0x00030000
  203. #define VML_FTZDAZ_MASK 0x003C0000
  204. #define VML_TRAP_EXCEPTIONS_MASK 0x0F000000
  205. #define VML_ACCURACY_MASK_64 0x000000000000000F
  206. #define VML_FPUMODE_MASK_64 0x00000000000000F0
  207. #define VML_ERRMODE_MASK_64 0x000000000000FF00
  208. #define VML_ERRMODE_STDHANDLER_MASK_64 0x0000000000002F00
  209. #define VML_ERRMODE_CALLBACK_MASK_64 0x0000000000001000
  210. #define VML_NUM_THREADS_OMP_MASK_64 0x0000000000030000
  211. #define VML_TBB_PARTITIONER_MASK_64 0x0000000000030000
  212. #define VML_FTZDAZ_MASK_64 0x00000000003C0000
  213. #define VML_TRAP_EXCEPTIONS_MASK_64 0x000000000F000000
  214. /*
  215. // ERROR STATUS MACROS
  216. // VML_STATUS_OK - no errors
  217. // VML_STATUS_BADSIZE - array dimension is not positive
  218. // VML_STATUS_BADMEM - invalid pointer passed
  219. // VML_STATUS_ERRDOM - at least one of arguments is out of function domain
  220. // VML_STATUS_SING - at least one of arguments caused singularity
  221. // VML_STATUS_OVERFLOW - at least one of arguments caused overflow
  222. // VML_STATUS_UNDERFLOW - at least one of arguments caused underflow
  223. // VML_STATUS_ACCURACYWARNING - function doesn't support set accuracy mode,
  224. // lower accuracy mode was used instead
  225. */
  226. #define VML_STATUS_OK 0
  227. #define VML_STATUS_BADSIZE -1
  228. #define VML_STATUS_BADMEM -2
  229. #define VML_STATUS_ERRDOM 1
  230. #define VML_STATUS_SING 2
  231. #define VML_STATUS_OVERFLOW 3
  232. #define VML_STATUS_UNDERFLOW 4
  233. #define VML_STATUS_ACCURACYWARNING 1000
  234. #define VML_STATUS_OK_64 0
  235. #define VML_STATUS_BADSIZE_64 -1
  236. #define VML_STATUS_BADMEM_64 -2
  237. #define VML_STATUS_ERRDOM_64 1
  238. #define VML_STATUS_SING_64 2
  239. #define VML_STATUS_OVERFLOW_64 3
  240. #define VML_STATUS_UNDERFLOW_64 4
  241. #define VML_STATUS_ACCURACYWARNING_64 1000
  242. #ifdef __cplusplus
  243. }
  244. #endif /* __cplusplus */
  245. #endif /* __MKL_VML_DEFINES_H__ */