![]() |
ESPResSo 3.2.0-11-g9950804-git
Extensible Simulation Package for Soft Matter Research
|
Routines, row decomposition, data structures and communication for the 3D-FFT. More...
#include "fft-common.h"#include <string.h>#include <fftw3.h>#include <mpi.h>#include "utils.h"#include "communication.h"
Go to the source code of this file.
Functions | |
| void | fft_common_pre_init (fft_data_struct *fft) |
| Initialize FFT data structure. | |
| void | fft_pack_block (double *in, double *out, int start[3], int size[3], int dim[3], int element) |
| pack a block (size[3] starting at start[3]) of an input 3d-grid with dimension dim[3] into an output 3d-block with dimension size[3]. | |
| void | fft_pack_block_permute1 (double *in, double *out, int start[3], int size[3], int dim[3], int element) |
| pack a block with dimensions (size[0] * size[1] * aize[2]) starting at start[3] of an input 3d-grid with dimension dim[3] into an output 3d-grid with dimensions (size[2] * size[0] * size[1]) with a simulatanous one-fold permutation of the indices. | |
| void | fft_pack_block_permute2 (double *in, double *out, int start[3], int size[3], int dim[3], int element) |
| pack a block with dimensions (size[0] * size[1] * aize[2]) starting at start[3] of an input 3d-grid with dimension dim[3] into an output 3d-grid with dimensions (size[2] * size[0] * size[1]), this is a simulatanous two-fold permutation of the indices. | |
| void | fft_unpack_block (double *in, double *out, int start[3], int size[3], int dim[3], int element) |
| unpack a 3d-grid input block (size[3]) into an output 3d-grid with dimension dim[3] at start position start[3]. | |
| int | fft_find_comm_groups (int grid1[3], int grid2[3], int *node_list1, int *node_list2, int *group, int *pos, int *my_pos) |
| This ugly function does the bookkepping which nodes have to communicate to each other, when you change the node grid. | |
| int | fft_calc_local_mesh (int n_pos[3], int n_grid[3], int mesh[3], double mesh_off[3], int loc_mesh[3], int start[3]) |
| Calculate the local fft mesh. | |
| int | fft_calc_send_block (int pos1[3], int grid1[3], int pos2[3], int grid2[3], int mesh[3], double mesh_off[3], int block[6]) |
| Calculate a send (or recv.) block for grid communication during a decomposition change. | |
| void | fft_print_fft_plan (fft_forw_plan pl) |
| Debug function to print fft_forw_plan structure. | |
| void | fft_print_global_fft_mesh (fft_forw_plan plan, double *data, int element, int num) |
| Debug function to print global fft mesh. | |
Routines, row decomposition, data structures and communication for the 3D-FFT.
Definition in file fft-common.c.
| int fft_calc_local_mesh | ( | int | n_pos[3], |
| int | n_grid[3], | ||
| int | mesh[3], | ||
| double | mesh_off[3], | ||
| int | loc_mesh[3], | ||
| int | start[3] | ||
| ) |
Calculate the local fft mesh.
Calculate the local mesh (loc_mesh) of a node at position (n_pos) in a node grid (n_grid) for a global mesh of size (mesh) and a mesh offset (mesh_off (in mesh units)) and store also the first point (start) of the local mesh.
| n_pos | Position of the node in n_grid. |
| n_grid | node grid. |
| mesh | global mesh dimensions. |
| mesh_off | global mesh offset (see p3m_data_struct). |
| loc_mesh | local mesh dimension (output). |
| start | first point of local mesh in global mesh (output). |
Definition at line 266 of file fft-common.c.
References i.
Referenced by dfft_init(), fft_calc_send_block(), and fft_init().
| int fft_calc_send_block | ( | int | pos1[3], |
| int | grid1[3], | ||
| int | pos2[3], | ||
| int | grid2[3], | ||
| int | mesh[3], | ||
| double | mesh_off[3], | ||
| int | block[6] | ||
| ) |
Calculate a send (or recv.) block for grid communication during a decomposition change.
Calculate the send block specification (block = lower left corner and upper right corner) which a node at position (pos1) in the actual node grid (grid1) has to send to another node at position (pos2) in the desired node grid (grid2). The global mesh, subject to communication, is specified via its size (mesh) and its mesh offset (mesh_off (in mesh units)).
For the calculation of a receive block you have to change the arguments in the following way:
pos1 - position of receiving node in the desired node grid.
grid1 - desired node grid.
pos2 - position of the node you intend to receive the data from in the actual node grid.
grid2 - actual node grid.
| pos1 | Position of send node in grid1. |
| grid1 | node grid 1. |
| pos2 | Position of recv node in grid2. |
| grid2 | node grid 2. |
| mesh | global mesh dimensions. |
| mesh_off | global mesh offset (see p3m_data_struct). |
| block | send block specification. |
Definition at line 284 of file fft-common.c.
References fft_calc_local_mesh(), i, imax(), and imin().
Referenced by dfft_init(), and fft_init().
| void fft_common_pre_init | ( | fft_data_struct * | fft | ) |
Initialize FFT data structure.
Definition at line 38 of file fft-common.c.
References fft_data_struct::data_buf, fft_forw_plan::group, i, fft_data_struct::init_tag, malloc, fft_data_struct::max_comm_size, fft_data_struct::max_mesh_size, n_nodes, fft_data_struct::plan, fft_forw_plan::recv_block, fft_data_struct::recv_buf, fft_forw_plan::recv_size, fft_forw_plan::send_block, fft_data_struct::send_buf, and fft_forw_plan::send_size.
Referenced by dfft_pre_init(), and fft_pre_init().
| int fft_find_comm_groups | ( | int | grid1[3], |
| int | grid2[3], | ||
| int * | node_list1, | ||
| int * | node_list2, | ||
| int * | group, | ||
| int * | pos, | ||
| int * | my_pos | ||
| ) |
This ugly function does the bookkepping which nodes have to communicate to each other, when you change the node grid.
Changing the domain decomposition requieres communication. This function finds (hopefully) the best way to do this. As input it needs the two grids (grid1, grid2) and a linear list (node_list1) with the node identities for grid1. The linear list (node_list2) for the second grid is calculated. For the communication group of the calling node it calculates a list (group) with the node identities and the positions (pos1, pos2) of that nodes in grid1 and grid2. The return value is the size of the communication group. It gives -1 if the two grids do not fit to each other (grid1 and grid2 have to be component wise multiples of each other. see e.g. calc_2d_grid in grid.c for how to do this.).
| grid1 | The node grid you start with (Input). |
| grid2 | The node grid you want to have (Input). |
| node_list1 | Linear node index list for grid1 (Input). |
| node_list2 | Linear node index list for grid2 (Output). |
| group | communication group (node identity list) for the calling node (Output). |
| pos | positions of the nodes in in grid2 (Output). |
| my_pos | position of this_node in grid2. |
Definition at line 185 of file fft-common.c.
References FFT_TRACE, get_linear_index(), i, and this_node.
Referenced by dfft_init(), and fft_init().
| void fft_pack_block | ( | double * | in, |
| double * | out, | ||
| int | start[3], | ||
| int | size[3], | ||
| int | dim[3], | ||
| int | element | ||
| ) |
pack a block (size[3] starting at start[3]) of an input 3d-grid with dimension dim[3] into an output 3d-block with dimension size[3].
The block with dimensions (size[0], size[1], size[2]) is stored in 'row-major-order' or 'C-order', that means the first index is changing slowest when running through the linear array. The element (i0 (slow), i1 (mid), i2 (fast)) has the linear index li = i2 + size[2] * (i1 + (size[1]*i0))
| in | pointer to input 3d-grid. |
| out | pointer to output 3d-grid (block). |
| start | start index of the block in the in-grid. |
| size | size of the block (=dimension of the out-grid). |
| dim | size of the in-grid. |
| element | size of a grid element (e.g. 1 for Real, 2 for Complex). |
Definition at line 56 of file fft-common.c.
Referenced by dfft_init(), dp3m_gather_fft_grid(), dp3m_spread_force_grid(), fft_init(), p3m_gather_fft_grid(), and p3m_spread_force_grid().
| void fft_pack_block_permute1 | ( | double * | in, |
| double * | out, | ||
| int | start[3], | ||
| int | size[3], | ||
| int | dim[3], | ||
| int | element | ||
| ) |
pack a block with dimensions (size[0] * size[1] * aize[2]) starting at start[3] of an input 3d-grid with dimension dim[3] into an output 3d-grid with dimensions (size[2] * size[0] * size[1]) with a simulatanous one-fold permutation of the indices.
The permutation is defined as: slow_in -> fast_out, mid_in ->slow_out, fast_in -> mid_out
An element (i0_in , i1_in , i2_in ) is then (i0_out = i1_in-start[1], i1_out = i2_in-start[2], i2_out = i0_in-start[0]) and for the linear indices we have:
li_in = i2_in + size[2] * (i1_in + (size[1]*i0_in))
li_out = i2_out + size[0] * (i1_out + (size[2]*i0_out))
For index definition see fft_pack_block.
| in | pointer to input 3d-grid. |
| out | pointer to output 3d-grid (block). |
| start | start index of the block in the in-grid. |
| size | size of the block (=dimension of the out-grid). |
| dim | size of the in-grid. |
| element | size of a grid element (e.g. 1 for Real, 2 for Complex). |
Definition at line 85 of file fft-common.c.
References element.
Referenced by dfft_init(), and fft_init().
| void fft_pack_block_permute2 | ( | double * | in, |
| double * | out, | ||
| int | start[3], | ||
| int | size[3], | ||
| int | dim[3], | ||
| int | element | ||
| ) |
pack a block with dimensions (size[0] * size[1] * aize[2]) starting at start[3] of an input 3d-grid with dimension dim[3] into an output 3d-grid with dimensions (size[2] * size[0] * size[1]), this is a simulatanous two-fold permutation of the indices.
The permutation is defined as: slow_in -> mid_out, mid_in ->fast_out, fast_in -> slow_out
An element (i0_in , i1_in , i2_in ) is then (i0_out = i2_in-start[2], i1_out = i0_in-start[0], i2_out = i1_in-start[1]) and for the linear indices we have:
li_in = i2_in + size[2] * (i1_in + (size[1]*i0_in))
li_out = i2_out + size[0] * (i1_out + (size[2]*i0_out))
For index definition see fft_pack_block.
| in | pointer to input 3d-grid. |
| out | pointer to output 3d-grid (block). |
| start | start index of the block in the in-grid. |
| size | size of the block (=dimension of the out-grid). |
| dim | size of the in-grid. |
| element | size of a grid element (e.g. 1 for Real, 2 for Complex). |
Definition at line 116 of file fft-common.c.
References element.
Referenced by dfft_init(), and fft_init().
| void fft_print_fft_plan | ( | fft_forw_plan | pl | ) |
Debug function to print fft_forw_plan structure.
| pl | fft/communication plan (see fft_forw_plan). |
Definition at line 304 of file fft-common.c.
References fft_forw_plan::dir, fft_forw_plan::g_size, fft_forw_plan::group, i, fft_forw_plan::n_ffts, fft_forw_plan::n_permute, fft_forw_plan::new_mesh, fft_forw_plan::old_mesh, fft_forw_plan::recv_block, fft_forw_plan::row_dir, fft_forw_plan::send_block, fft_forw_plan::start, and this_node.
Referenced by dfft_init(), and fft_init().
| void fft_print_global_fft_mesh | ( | fft_forw_plan | plan, |
| double * | data, | ||
| int | element, | ||
| int | num | ||
| ) |
Debug function to print global fft mesh.
Print a globaly distributed mesh contained in data. Element size is element.
| plan | fft/communication plan (see fft_forw_plan). |
| data | mesh data. |
| element | element size. |
| num | element index to print. |
Definition at line 333 of file fft-common.c.
References comm_cart, imin(), MPI_Barrier(), n_nodes, fft_forw_plan::new_mesh, fft_forw_plan::start, and this_node.
| void fft_unpack_block | ( | double * | in, |
| double * | out, | ||
| int | start[3], | ||
| int | size[3], | ||
| int | dim[3], | ||
| int | element | ||
| ) |
unpack a 3d-grid input block (size[3]) into an output 3d-grid with dimension dim[3] at start position start[3].
see also fft_pack_block.
| in | pointer to input 3d-grid. |
| out | pointer to output 3d-grid (block). |
| start | start index of the block in the in-grid. |
| size | size of the block (=dimension of the out-grid). |
| dim | size of the in-grid. |
| element | size of a grid element (e.g. 1 for Real, 2 for Complex). |
Definition at line 150 of file fft-common.c.
Referenced by dfft_back_grid_comm(), dfft_forw_grid_comm(), dp3m_spread_force_grid(), fft_back_grid_comm(), fft_forw_grid_comm(), and p3m_spread_force_grid().
1.7.5.1