4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * Good ROcking Metal Altar for Chronical Sinners
32 static char *SRCID_fftw_mpi_h
= "$Id$";
35 #include <mpi.h> /* need access to the MPI type definitions */
39 #endif /* __cplusplus */
41 /***********************************************************************/
43 typedef fftw_real TRANSPOSE_EL_TYPE
;
46 int block_num
, dest_pe
, send_size
, recv_size
;
47 } transpose_mpi_exchange
;
53 int nx
,ny
,local_nx
,local_ny
;
55 transpose_mpi_exchange
*exchange
;
56 int num_steps
, send_block_size
, recv_block_size
;
60 MPI_Request request
[2];
63 int num_perm_blocks
, perm_block_size
;
66 int *send_block_sizes
, *send_block_offsets
;
67 int *recv_block_sizes
, *recv_block_offsets
;
71 } transpose_mpi_plan_struct
;
73 typedef transpose_mpi_plan_struct
*transpose_mpi_plan
;
75 extern void transpose_mpi_get_local_size(int n
, int my_pe
, int n_pes
,
76 int *local_n
, int *local_start
);
77 extern int transpose_mpi_get_local_storage_size(int nx
, int ny
,
78 int my_pe
, int n_pes
);
80 extern transpose_mpi_plan
transpose_mpi_create_plan(int nx
, int ny
,
82 extern void transpose_mpi_destroy_plan(transpose_mpi_plan p
);
84 extern void transpose_mpi(transpose_mpi_plan p
, int el_size
,
85 TRANSPOSE_EL_TYPE
*local_data
,
86 TRANSPOSE_EL_TYPE
*work
);
88 typedef enum { BEFORE_TRANSPOSE
, AFTER_TRANSPOSE
} transpose_in_place_which
;
90 typedef enum { TRANSPOSE_SYNC
, TRANSPOSE_ASYNC
} transpose_sync_type
;
92 extern void transpose_in_place_local(transpose_mpi_plan p
,
93 int el_size
, TRANSPOSE_EL_TYPE
*local_data
,
94 transpose_in_place_which which
);
96 extern TRANSPOSE_EL_TYPE
*transpose_allocate_send_buf(transpose_mpi_plan p
,
98 extern void transpose_get_send_block(transpose_mpi_plan p
, int step
,
99 int *block_y_start
, int *block_ny
);
100 extern void transpose_start_exchange_step(transpose_mpi_plan p
,
102 TRANSPOSE_EL_TYPE
*local_data
,
103 TRANSPOSE_EL_TYPE
*send_buf
,
105 transpose_sync_type sync_type
);
106 extern void transpose_finish_exchange_step(transpose_mpi_plan p
, int step
);
108 /***********************************************************************/
111 fftw_plan p_fft_x
; /* plan for first dimension */
112 fftwnd_plan p_fft
; /* plan for subsequent dimensions */
113 transpose_mpi_plan p_transpose
, p_transpose_inv
;
114 fftw_complex
*work
; /* extra workspace, if needed */
115 } fftwnd_mpi_plan_data
;
117 typedef fftwnd_mpi_plan_data
*fftwnd_mpi_plan
;
121 FFTW_TRANSPOSED_ORDER
122 } fftwnd_mpi_output_order
;
124 extern fftwnd_mpi_plan
fftwnd_mpi_create_plan(MPI_Comm comm
,
125 int rank
, const int *n
,
128 extern fftwnd_mpi_plan
fftw2d_mpi_create_plan(MPI_Comm comm
,
130 fftw_direction dir
, int flags
);
131 extern fftwnd_mpi_plan
fftw3d_mpi_create_plan(MPI_Comm comm
,
132 int nx
, int ny
, int nz
,
133 fftw_direction dir
, int flags
);
135 extern void fftwnd_mpi_destroy_plan(fftwnd_mpi_plan p
);
137 extern void fftwnd_mpi_local_sizes(fftwnd_mpi_plan p
,
140 int *local_ny_after_transpose
,
141 int *local_y_start_after_transpose
,
142 int *total_local_size
);
144 extern void fftwnd_mpi(fftwnd_mpi_plan p
,
146 fftw_complex
*local_data
, fftw_complex
*work
,
147 fftwnd_mpi_output_order output_order
);
149 extern void fftw_mpi_die(const char *error_string
);
151 /***********************************************************************/
153 typedef struct fftw_mpi_twiddle_struct
{
154 int rows
, rowstart
, cols
, n
;
157 struct fftw_mpi_twiddle_struct
*next
;
160 typedef struct fftw_mpi_plan_struct
{
161 int n
, m
, r
, local_m
, local_m_start
, local_r
, local_r_start
;
162 fftw_complex
*fft_work
;
163 fftw_mpi_twiddle
*tw
;
164 transpose_mpi_plan p_transpose
, p_transpose_inv
;
170 /* new flags for the MPI planner: */
171 #define FFTW_SCRAMBLED_INPUT (8192)
172 #define FFTW_SCRAMBLED_OUTPUT (16384)
174 extern void fftw_mpi_local_sizes(fftw_mpi_plan p
,
177 int *local_n_after_transform
,
178 int *local_start_after_transform
,
179 int *total_local_size
);
181 extern fftw_mpi_plan
fftw_mpi_create_plan(MPI_Comm comm
,
183 fftw_direction dir
, int flags
);
185 extern void fftw_mpi_destroy_plan(fftw_mpi_plan p
);
187 extern void fftw_mpi(fftw_mpi_plan p
, int n_fields
,
188 fftw_complex
*local_data
, fftw_complex
*work
);
190 extern void fftw_mpi_print_plan(fftw_mpi_plan p
);
192 /***********************************************************************/
196 #endif /* __cplusplus */
198 #endif /* FFTW_MPI_H */