GADGET-4
pm_mpi_fft.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * \copyright This file is part of the GADGET4 N-body/SPH code developed
3  * \copyright by Volker Springel. Copyright (C) 2014-2020 by Volker Springel
4  * \copyright (vspringel@mpa-garching.mpg.de) and all contributing authors.
5  *******************************************************************************/
6 
12 #ifndef PM_MPI_FFT_H
13 #define PM_MPI_FFT_H
14 
15 #include "../mpi_utils/setcomm.h"
16 
17 #ifndef FFTW
18 #define CONCAT(prefix, name) prefix##name
19 #ifdef DOUBLEPRECISION_FFTW
20 #define FFTW(x) CONCAT(fftw_, x)
21 #else
22 #define FFTW(x) CONCAT(fftwf_, x)
23 #endif
24 #endif
25 
26 class pm_mpi_fft : public virtual setcomm
27 {
28  public:
29  pm_mpi_fft(MPI_Comm comm) : setcomm(comm) {}
30 
31  struct fft_plan
32  {
34  int Ngridz, Ngrid2;
35 
36  FFTW(plan) forward_plan_zdir;
37  FFTW(plan) forward_plan_xdir;
38  FFTW(plan) forward_plan_ydir;
39 
40  FFTW(plan) backward_plan_zdir;
41  FFTW(plan) backward_plan_ydir;
42  FFTW(plan) backward_plan_xdir;
43 
44 #ifndef FFT_COLUMN_BASED
45 
46  int *slab_to_task;
56 #else
57  size_t max_datasize;
58  size_t fftsize;
59 
60  int firstcol_XY, ncol_XY, lastcol_XY;
61  int firstcol_XZ, ncol_XZ, lastcol_XZ;
62  int firstcol_ZY, ncol_ZY, lastcol_ZY;
63 
64  int transposed_firstcol, transposed_ncol;
65  int second_transposed_firstcol, second_transposed_ncol;
66  size_t second_transposed_ncells;
67 
68  // int pivotcol; /* to go from column number to task */
69  // int avg;
70  // int tasklastsection;
71 
72  size_t *offsets_send_A;
73  size_t *offsets_recv_A;
74  size_t *offsets_send_B;
75  size_t *offsets_recv_B;
76  size_t *offsets_send_C;
77  size_t *offsets_recv_C;
78  size_t *offsets_send_D;
79  size_t *offsets_recv_D;
80 
81  size_t *count_send_A;
82  size_t *count_recv_A;
83  size_t *count_send_B;
84  size_t *count_recv_B;
85  size_t *count_send_C;
86  size_t *count_recv_C;
87  size_t *count_send_D;
88  size_t *count_recv_D;
89  size_t *count_send_13;
90  size_t *count_recv_13;
91  size_t *count_send_23;
92  size_t *count_recv_23;
93  size_t *count_send_13back;
94  size_t *count_recv_13back;
95  size_t *count_send_23back;
96  size_t *count_recv_23back;
97 #endif
98  };
99 
100  void my_slab_based_fft_init(fft_plan *plan, int NgridX, int NgridY, int NgridZ);
101  void my_slab_based_fft(fft_plan *plan, void *data, void *workspace, int forward);
103 
104  void my_column_based_fft_init(fft_plan *plan, int NgridX, int NgridY, int NgridZ);
105  void my_column_based_fft(fft_plan *plan, void *data, void *workspace, int forward);
107 
108  void my_slab_transposeA(fft_plan *plan, fft_real *field, fft_real *scratch);
109  void my_slab_transposeB(fft_plan *plan, fft_real *field, fft_real *scratch);
110 
111  void my_fft_swap23(fft_plan *plan, fft_real *data, fft_real *out);
112  void my_fft_swap13(fft_plan *plan, fft_real *data, fft_real *out);
113  void my_fft_swap23back(fft_plan *plan, fft_real *data, fft_real *out);
114  void my_fft_swap13back(fft_plan *plan, fft_real *data, fft_real *out);
115 
116  private:
117 #ifndef FFT_COLUMN_BASED
118 
119  void my_slab_transpose(void *av, void *bv, int *sx, int *firstx, int *sy, int *firsty, int nx, int ny, int nz, int mode);
120 
121 #else
122  void my_fft_column_remap(fft_complex *data, int Ndims[3], int in_firstcol, int in_ncol, fft_complex *out, int perm[3],
123  int out_firstcol, int out_ncol, size_t *offset_send, size_t *offset_recv, size_t *count_send,
124  size_t *count_recv, size_t just_count_flag);
125 
126  void my_fft_column_transpose(fft_real *data, int Ndims[3], /* global dimensions of data cube */
127  int in_firstcol, int in_ncol, /* first column and number of columns */
128  fft_real *out, int perm[3], int out_firstcol, int out_ncol, size_t *count_send, size_t *count_recv,
129  size_t just_count_flag);
130 
131 #endif
132 };
133 
134 #endif
void my_slab_based_fft_free(fft_plan *plan)
void my_column_based_fft_free(fft_plan *plan)
void my_column_based_fft_init(fft_plan *plan, int NgridX, int NgridY, int NgridZ)
void my_column_based_fft(fft_plan *plan, void *data, void *workspace, int forward)
void my_fft_swap13back(fft_plan *plan, fft_real *data, fft_real *out)
void my_fft_swap13(fft_plan *plan, fft_real *data, fft_real *out)
void my_slab_transposeB(fft_plan *plan, fft_real *field, fft_real *scratch)
void my_slab_based_fft(fft_plan *plan, void *data, void *workspace, int forward)
void my_fft_swap23(fft_plan *plan, fft_real *data, fft_real *out)
void my_fft_swap23back(fft_plan *plan, fft_real *data, fft_real *out)
void my_slab_transposeA(fft_plan *plan, fft_real *field, fft_real *scratch)
void my_slab_based_fft_init(fft_plan *plan, int NgridX, int NgridY, int NgridZ)
pm_mpi_fft(MPI_Comm comm)
Definition: pm_mpi_fft.h:29
int * first_slab_x_of_task
Definition: pm_mpi_fft.h:48
int * first_slab_y_of_task
Definition: pm_mpi_fft.h:50
FFTW(plan) forward_plan_zdir
FFTW(plan) forward_plan_xdir
FFTW(plan) forward_plan_ydir
FFTW(plan) backward_plan_zdir
FFTW(plan) backward_plan_xdir
FFTW(plan) backward_plan_ydir