changed reading hint
[gromacs/adressmacs.git] / include / fftw_mpi.h
blob3296016e30149a0e2e07784a3920bfa17556d3b5
1 /*
2 * $Id$
3 *
4 * This source code is part of
5 *
6 * G R O M A C S
7 *
8 * GROningen MAchine for Chemical Simulations
9 *
10 * VERSION 2.0
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * Please refer to:
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
23 * or e-mail to:
24 * gromacs@chem.rug.nl
26 * And Hey:
27 * Good ROcking Metal Altar for Chronical Sinners
29 #ifndef FFTW_MPI_H
30 #define FFTW_MPI_H
32 static char *SRCID_fftw_mpi_h = "$Id$";
34 #include "fftw.h"
35 #include <mpi.h> /* need access to the MPI type definitions */
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
41 /***********************************************************************/
43 typedef fftw_real TRANSPOSE_EL_TYPE;
45 typedef struct {
46 int block_num, dest_pe, send_size, recv_size;
47 } transpose_mpi_exchange;
49 typedef struct {
50 MPI_Comm comm;
51 int n_pes, my_pe;
53 int nx,ny,local_nx,local_ny;
55 transpose_mpi_exchange *exchange;
56 int num_steps, send_block_size, recv_block_size;
58 MPI_Datatype el_type;
60 MPI_Request request[2];
62 int *perm_block_dest;
63 int num_perm_blocks, perm_block_size;
65 int all_blocks_equal;
66 int *send_block_sizes, *send_block_offsets;
67 int *recv_block_sizes, *recv_block_offsets;
69 char *move;
70 int move_size;
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,
81 MPI_Comm comm);
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,
97 int el_size);
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,
101 int el_size,
102 TRANSPOSE_EL_TYPE *local_data,
103 TRANSPOSE_EL_TYPE *send_buf,
104 int step,
105 transpose_sync_type sync_type);
106 extern void transpose_finish_exchange_step(transpose_mpi_plan p, int step);
108 /***********************************************************************/
110 typedef struct {
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;
119 typedef enum {
120 FFTW_NORMAL_ORDER,
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,
126 fftw_direction dir,
127 int flags);
128 extern fftwnd_mpi_plan fftw2d_mpi_create_plan(MPI_Comm comm,
129 int nx, int ny,
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,
138 int *local_nx,
139 int *local_x_start,
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,
145 int n_fields,
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;
155 fftw_complex *W;
156 int refcount;
157 struct fftw_mpi_twiddle_struct *next;
158 } fftw_mpi_twiddle;
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;
165 fftw_plan pm, pr;
166 int flags;
167 fftw_direction dir;
168 } *fftw_mpi_plan;
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,
175 int *local_n,
176 int *local_start,
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,
182 int n,
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 /***********************************************************************/
194 #ifdef __cplusplus
195 } /* extern "C" */
196 #endif /* __cplusplus */
198 #endif /* FFTW_MPI_H */