fftw3-mpi.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * Copyright (c) 2003, 2007-14 Matteo Frigo
  3. * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
  4. *
  5. * The following statement of license applies *only* to this header file,
  6. * and *not* to the other files distributed with FFTW or derived therefrom:
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  20. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  23. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  25. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  27. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. /***************************** NOTE TO USERS *********************************
  32. *
  33. * THIS IS A HEADER FILE, NOT A MANUAL
  34. *
  35. * If you want to know how to use FFTW, please read the manual,
  36. * online at http://www.fftw.org/doc/ and also included with FFTW.
  37. * For a quick start, see the manual's tutorial section.
  38. *
  39. * (Reading header files to learn how to use a library is a habit
  40. * stemming from code lacking a proper manual. Arguably, it's a
  41. * *bad* habit in most cases, because header files can contain
  42. * interfaces that are not part of the public, stable API.)
  43. *
  44. ****************************************************************************/
  45. #ifndef FFTW3_MPI_H
  46. #define FFTW3_MPI_H
  47. #include "fftw3.h"
  48. #include <mpi.h>
  49. #ifdef __cplusplus
  50. extern "C"
  51. {
  52. #endif /* __cplusplus */
  53. struct fftw_mpi_ddim_do_not_use_me {
  54. ptrdiff_t n; /* dimension size */
  55. ptrdiff_t ib; /* input block */
  56. ptrdiff_t ob; /* output block */
  57. };
  58. /*
  59. huge second-order macro that defines prototypes for all API
  60. functions. We expand this macro for each supported precision
  61. XM: name-mangling macro (MPI)
  62. X: name-mangling macro (serial)
  63. R: real data type
  64. C: complex data type
  65. */
  66. #define FFTW_MPI_DEFINE_API(XM, X, R, C) \
  67. \
  68. typedef struct fftw_mpi_ddim_do_not_use_me XM(ddim); \
  69. \
  70. FFTW_EXTERN void XM(init)(void); \
  71. FFTW_EXTERN void XM(cleanup)(void); \
  72. \
  73. FFTW_EXTERN ptrdiff_t XM(local_size_many_transposed) \
  74. (int rnk, const ptrdiff_t *n, ptrdiff_t howmany, \
  75. ptrdiff_t block0, ptrdiff_t block1, MPI_Comm comm, \
  76. ptrdiff_t *local_n0, ptrdiff_t *local_0_start, \
  77. ptrdiff_t *local_n1, ptrdiff_t *local_1_start); \
  78. FFTW_EXTERN ptrdiff_t XM(local_size_many) \
  79. (int rnk, const ptrdiff_t *n, ptrdiff_t howmany, \
  80. ptrdiff_t block0, MPI_Comm comm, \
  81. ptrdiff_t *local_n0, ptrdiff_t *local_0_start); \
  82. FFTW_EXTERN ptrdiff_t XM(local_size_transposed) \
  83. (int rnk, const ptrdiff_t *n, MPI_Comm comm, \
  84. ptrdiff_t *local_n0, ptrdiff_t *local_0_start, \
  85. ptrdiff_t *local_n1, ptrdiff_t *local_1_start); \
  86. FFTW_EXTERN ptrdiff_t XM(local_size) \
  87. (int rnk, const ptrdiff_t *n, MPI_Comm comm, \
  88. ptrdiff_t *local_n0, ptrdiff_t *local_0_start); \
  89. FFTW_EXTERN ptrdiff_t XM(local_size_many_1d)( \
  90. ptrdiff_t n0, ptrdiff_t howmany, \
  91. MPI_Comm comm, int sign, unsigned flags, \
  92. ptrdiff_t *local_ni, ptrdiff_t *local_i_start, \
  93. ptrdiff_t *local_no, ptrdiff_t *local_o_start); \
  94. FFTW_EXTERN ptrdiff_t XM(local_size_1d)( \
  95. ptrdiff_t n0, MPI_Comm comm, int sign, unsigned flags, \
  96. ptrdiff_t *local_ni, ptrdiff_t *local_i_start, \
  97. ptrdiff_t *local_no, ptrdiff_t *local_o_start); \
  98. FFTW_EXTERN ptrdiff_t XM(local_size_2d)( \
  99. ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm, \
  100. ptrdiff_t *local_n0, ptrdiff_t *local_0_start); \
  101. FFTW_EXTERN ptrdiff_t XM(local_size_2d_transposed)( \
  102. ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm, \
  103. ptrdiff_t *local_n0, ptrdiff_t *local_0_start, \
  104. ptrdiff_t *local_n1, ptrdiff_t *local_1_start); \
  105. FFTW_EXTERN ptrdiff_t XM(local_size_3d)( \
  106. ptrdiff_t n0, ptrdiff_t n1, ptrdiff_t n2, MPI_Comm comm, \
  107. ptrdiff_t *local_n0, ptrdiff_t *local_0_start); \
  108. FFTW_EXTERN ptrdiff_t XM(local_size_3d_transposed)( \
  109. ptrdiff_t n0, ptrdiff_t n1, ptrdiff_t n2, MPI_Comm comm, \
  110. ptrdiff_t *local_n0, ptrdiff_t *local_0_start, \
  111. ptrdiff_t *local_n1, ptrdiff_t *local_1_start); \
  112. \
  113. FFTW_EXTERN X(plan) XM(plan_many_transpose) \
  114. (ptrdiff_t n0, ptrdiff_t n1, \
  115. ptrdiff_t howmany, ptrdiff_t block0, ptrdiff_t block1, \
  116. R *in, R *out, MPI_Comm comm, unsigned flags); \
  117. FFTW_EXTERN X(plan) XM(plan_transpose) \
  118. (ptrdiff_t n0, ptrdiff_t n1, \
  119. R *in, R *out, MPI_Comm comm, unsigned flags); \
  120. \
  121. FFTW_EXTERN X(plan) XM(plan_many_dft) \
  122. (int rnk, const ptrdiff_t *n, ptrdiff_t howmany, \
  123. ptrdiff_t block, ptrdiff_t tblock, C *in, C *out, \
  124. MPI_Comm comm, int sign, unsigned flags); \
  125. FFTW_EXTERN X(plan) XM(plan_dft) \
  126. (int rnk, const ptrdiff_t *n, C *in, C *out, \
  127. MPI_Comm comm, int sign, unsigned flags); \
  128. FFTW_EXTERN X(plan) XM(plan_dft_1d) \
  129. (ptrdiff_t n0, C *in, C *out, \
  130. MPI_Comm comm, int sign, unsigned flags); \
  131. FFTW_EXTERN X(plan) XM(plan_dft_2d) \
  132. (ptrdiff_t n0, ptrdiff_t n1, C *in, C *out, \
  133. MPI_Comm comm, int sign, unsigned flags); \
  134. FFTW_EXTERN X(plan) XM(plan_dft_3d) \
  135. (ptrdiff_t n0, ptrdiff_t n1, ptrdiff_t n2, C *in, C *out, \
  136. MPI_Comm comm, int sign, unsigned flags); \
  137. \
  138. FFTW_EXTERN X(plan) XM(plan_many_r2r) \
  139. (int rnk, const ptrdiff_t *n, ptrdiff_t howmany, \
  140. ptrdiff_t iblock, ptrdiff_t oblock, R *in, R *out, \
  141. MPI_Comm comm, const X(r2r_kind) *kind, unsigned flags); \
  142. FFTW_EXTERN X(plan) XM(plan_r2r) \
  143. (int rnk, const ptrdiff_t *n, R *in, R *out, \
  144. MPI_Comm comm, const X(r2r_kind) *kind, unsigned flags); \
  145. FFTW_EXTERN X(plan) XM(plan_r2r_2d) \
  146. (ptrdiff_t n0, ptrdiff_t n1, R *in, R *out, MPI_Comm comm, \
  147. X(r2r_kind) kind0, X(r2r_kind) kind1, unsigned flags); \
  148. FFTW_EXTERN X(plan) XM(plan_r2r_3d) \
  149. (ptrdiff_t n0, ptrdiff_t n1, ptrdiff_t n2, \
  150. R *in, R *out, MPI_Comm comm, X(r2r_kind) kind0, \
  151. X(r2r_kind) kind1, X(r2r_kind) kind2, unsigned flags); \
  152. \
  153. FFTW_EXTERN X(plan) XM(plan_many_dft_r2c) \
  154. (int rnk, const ptrdiff_t *n, ptrdiff_t howmany, \
  155. ptrdiff_t iblock, ptrdiff_t oblock, R *in, C *out, \
  156. MPI_Comm comm, unsigned flags); \
  157. FFTW_EXTERN X(plan) XM(plan_dft_r2c) \
  158. (int rnk, const ptrdiff_t *n, R *in, C *out, \
  159. MPI_Comm comm, unsigned flags); \
  160. FFTW_EXTERN X(plan) XM(plan_dft_r2c_2d) \
  161. (ptrdiff_t n0, ptrdiff_t n1, R *in, C *out, \
  162. MPI_Comm comm, unsigned flags); \
  163. FFTW_EXTERN X(plan) XM(plan_dft_r2c_3d) \
  164. (ptrdiff_t n0, ptrdiff_t n1, ptrdiff_t n2, R *in, C *out, \
  165. MPI_Comm comm, unsigned flags); \
  166. \
  167. FFTW_EXTERN X(plan) XM(plan_many_dft_c2r) \
  168. (int rnk, const ptrdiff_t *n, ptrdiff_t howmany, \
  169. ptrdiff_t iblock, ptrdiff_t oblock, C *in, R *out, \
  170. MPI_Comm comm, unsigned flags); \
  171. FFTW_EXTERN X(plan) XM(plan_dft_c2r) \
  172. (int rnk, const ptrdiff_t *n, C *in, R *out, \
  173. MPI_Comm comm, unsigned flags); \
  174. FFTW_EXTERN X(plan) XM(plan_dft_c2r_2d) \
  175. (ptrdiff_t n0, ptrdiff_t n1, C *in, R *out, \
  176. MPI_Comm comm, unsigned flags); \
  177. FFTW_EXTERN X(plan) XM(plan_dft_c2r_3d) \
  178. (ptrdiff_t n0, ptrdiff_t n1, ptrdiff_t n2, C *in, R *out, \
  179. MPI_Comm comm, unsigned flags); \
  180. \
  181. FFTW_EXTERN void XM(gather_wisdom)(MPI_Comm comm_); \
  182. FFTW_EXTERN void XM(broadcast_wisdom)(MPI_Comm comm_); \
  183. \
  184. FFTW_EXTERN void XM(execute_dft)(X(plan) p, C *in, C *out); \
  185. FFTW_EXTERN void XM(execute_dft_r2c)(X(plan) p, R *in, C *out); \
  186. FFTW_EXTERN void XM(execute_dft_c2r)(X(plan) p, C *in, R *out); \
  187. FFTW_EXTERN void XM(execute_r2r)(X(plan) p, R *in, R *out);
  188. /* end of FFTW_MPI_DEFINE_API macro */
  189. #define FFTW_MPI_MANGLE_DOUBLE(name) FFTW_MANGLE_DOUBLE(FFTW_CONCAT(mpi_,name))
  190. #define FFTW_MPI_MANGLE_FLOAT(name) FFTW_MANGLE_FLOAT(FFTW_CONCAT(mpi_,name))
  191. #define FFTW_MPI_MANGLE_LONG_DOUBLE(name) FFTW_MANGLE_LONG_DOUBLE(FFTW_CONCAT(mpi_,name))
  192. FFTW_MPI_DEFINE_API(FFTW_MPI_MANGLE_DOUBLE, FFTW_MANGLE_DOUBLE, double, fftw_complex)
  193. FFTW_MPI_DEFINE_API(FFTW_MPI_MANGLE_FLOAT, FFTW_MANGLE_FLOAT, float, fftwf_complex)
  194. FFTW_MPI_DEFINE_API(FFTW_MPI_MANGLE_LONG_DOUBLE, FFTW_MANGLE_LONG_DOUBLE, long double, fftwl_complex)
  195. #define FFTW_MPI_DEFAULT_BLOCK (0)
  196. /* MPI-specific flags */
  197. #define FFTW_MPI_SCRAMBLED_IN (1U << 27)
  198. #define FFTW_MPI_SCRAMBLED_OUT (1U << 28)
  199. #define FFTW_MPI_TRANSPOSED_IN (1U << 29)
  200. #define FFTW_MPI_TRANSPOSED_OUT (1U << 30)
  201. #ifdef __cplusplus
  202. } /* extern "C" */
  203. #endif /* __cplusplus */
  204. #endif /* FFTW3_MPI_H */