Chris@82: /* Chris@82: * Copyright (c) 2003, 2007-14 Matteo Frigo Chris@82: * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology Chris@82: * Chris@82: * This program is free software; you can redistribute it and/or modify Chris@82: * it under the terms of the GNU General Public License as published by Chris@82: * the Free Software Foundation; either version 2 of the License, or Chris@82: * (at your option) any later version. Chris@82: * Chris@82: * This program is distributed in the hope that it will be useful, Chris@82: * but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@82: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@82: * GNU General Public License for more details. Chris@82: * Chris@82: * You should have received a copy of the GNU General Public License Chris@82: * along with this program; if not, write to the Free Software Chris@82: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Chris@82: * Chris@82: */ Chris@82: Chris@82: /* FFTW-MPI internal header file */ Chris@82: #ifndef __IFFTW_MPI_H__ Chris@82: #define __IFFTW_MPI_H__ Chris@82: Chris@82: #include "kernel/ifftw.h" Chris@82: #include "rdft/rdft.h" Chris@82: Chris@82: #include Chris@82: Chris@82: /* mpi problem flags: problem-dependent meaning, but in general Chris@82: SCRAMBLED means some reordering *within* the dimensions, while Chris@82: TRANSPOSED means some reordering *of* the dimensions */ Chris@82: #define SCRAMBLED_IN (1 << 0) Chris@82: #define SCRAMBLED_OUT (1 << 1) Chris@82: #define TRANSPOSED_IN (1 << 2) Chris@82: #define TRANSPOSED_OUT (1 << 3) Chris@82: #define RANK1_BIGVEC_ONLY (1 << 4) /* for rank=1, allow only bigvec solver */ Chris@82: Chris@82: #define ONLY_SCRAMBLEDP(flags) (!((flags) & ~(SCRAMBLED_IN|SCRAMBLED_OUT))) Chris@82: #define ONLY_TRANSPOSEDP(flags) (!((flags) & ~(TRANSPOSED_IN|TRANSPOSED_OUT))) Chris@82: Chris@82: #if defined(FFTW_SINGLE) Chris@82: # define FFTW_MPI_TYPE MPI_FLOAT Chris@82: #elif defined(FFTW_LDOUBLE) Chris@82: # define FFTW_MPI_TYPE MPI_LONG_DOUBLE Chris@82: #elif defined(FFTW_QUAD) Chris@82: # error MPI quad-precision type is unknown Chris@82: #else Chris@82: # define FFTW_MPI_TYPE MPI_DOUBLE Chris@82: #endif Chris@82: Chris@82: /* all fftw-mpi identifiers start with fftw_mpi (or fftwf_mpi etc.) */ Chris@82: #define XM(name) X(CONCAT(mpi_, name)) Chris@82: Chris@82: /***********************************************************************/ Chris@82: /* block distributions */ Chris@82: Chris@82: /* a distributed dimension of length n with input and output block Chris@82: sizes ib and ob, respectively. */ Chris@82: typedef enum { IB = 0, OB } block_kind; Chris@82: typedef struct { Chris@82: INT n; Chris@82: INT b[2]; /* b[IB], b[OB] */ Chris@82: } ddim; Chris@82: Chris@82: /* Loop over k in {IB, OB}. Note: need explicit casts for C++. */ Chris@82: #define FORALL_BLOCK_KIND(k) for (k = IB; k <= OB; k = (block_kind) (((int) k) + 1)) Chris@82: Chris@82: /* unlike tensors in the serial FFTW, the ordering of the dtensor Chris@82: dimensions matters - both the array and the block layout are Chris@82: row-major order. */ Chris@82: typedef struct { Chris@82: int rnk; Chris@82: #if defined(STRUCT_HACK_KR) Chris@82: ddim dims[1]; Chris@82: #elif defined(STRUCT_HACK_C99) Chris@82: ddim dims[]; Chris@82: #else Chris@82: ddim *dims; Chris@82: #endif Chris@82: } dtensor; Chris@82: Chris@82: Chris@82: /* dtensor.c: */ Chris@82: dtensor *XM(mkdtensor)(int rnk); Chris@82: void XM(dtensor_destroy)(dtensor *sz); Chris@82: dtensor *XM(dtensor_copy)(const dtensor *sz); Chris@82: dtensor *XM(dtensor_canonical)(const dtensor *sz, int compress); Chris@82: int XM(dtensor_validp)(const dtensor *sz); Chris@82: void XM(dtensor_md5)(md5 *p, const dtensor *t); Chris@82: void XM(dtensor_print)(const dtensor *t, printer *p); Chris@82: Chris@82: /* block.c: */ Chris@82: Chris@82: /* for a single distributed dimension: */ Chris@82: INT XM(num_blocks)(INT n, INT block); Chris@82: int XM(num_blocks_ok)(INT n, INT block, MPI_Comm comm); Chris@82: INT XM(default_block)(INT n, int n_pes); Chris@82: INT XM(block)(INT n, INT block, int which_block); Chris@82: Chris@82: /* for multiple distributed dimensions: */ Chris@82: INT XM(num_blocks_total)(const dtensor *sz, block_kind k); Chris@82: int XM(idle_process)(const dtensor *sz, block_kind k, int which_pe); Chris@82: void XM(block_coords)(const dtensor *sz, block_kind k, int which_pe, Chris@82: INT *coords); Chris@82: INT XM(total_block)(const dtensor *sz, block_kind k, int which_pe); Chris@82: int XM(is_local_after)(int dim, const dtensor *sz, block_kind k); Chris@82: int XM(is_local)(const dtensor *sz, block_kind k); Chris@82: int XM(is_block1d)(const dtensor *sz, block_kind k); Chris@82: Chris@82: /* choose-radix.c */ Chris@82: INT XM(choose_radix)(ddim d, int n_pes, unsigned flags, int sign, Chris@82: INT rblock[2], INT mblock[2]); Chris@82: Chris@82: /***********************************************************************/ Chris@82: /* any_true.c */ Chris@82: int XM(any_true)(int condition, MPI_Comm comm); Chris@82: int XM(md5_equal)(md5 m, MPI_Comm comm); Chris@82: Chris@82: /* conf.c */ Chris@82: void XM(conf_standard)(planner *p); Chris@82: Chris@82: /***********************************************************************/ Chris@82: /* rearrange.c */ Chris@82: Chris@82: /* Different ways to rearrange the vector dimension vn during transposition, Chris@82: reflecting different tradeoffs between ease of transposition and Chris@82: contiguity during the subsequent DFTs. Chris@82: Chris@82: TODO: can we pare this down to CONTIG and DISCONTIG, at least Chris@82: in MEASURE mode? SQUARE_MIDDLE is also used for 1d destroy-input DFTs. */ Chris@82: typedef enum { Chris@82: CONTIG = 0, /* vn x 1: make subsequent DFTs contiguous */ Chris@82: DISCONTIG, /* P x (vn/P) for P processes */ Chris@82: SQUARE_BEFORE, /* try to get square transpose at beginning */ Chris@82: SQUARE_MIDDLE, /* try to get square transpose in the middle */ Chris@82: SQUARE_AFTER /* try to get square transpose at end */ Chris@82: } rearrangement; Chris@82: Chris@82: /* skipping SQUARE_AFTER since it doesn't seem to offer any advantage Chris@82: over SQUARE_BEFORE */ Chris@82: #define FORALL_REARRANGE(rearrange) for (rearrange = CONTIG; rearrange <= SQUARE_MIDDLE; rearrange = (rearrangement) (((int) rearrange) + 1)) Chris@82: Chris@82: int XM(rearrange_applicable)(rearrangement rearrange, Chris@82: ddim dim0, INT vn, int n_pes); Chris@82: INT XM(rearrange_ny)(rearrangement rearrange, ddim dim0, INT vn, int n_pes); Chris@82: Chris@82: /***********************************************************************/ Chris@82: Chris@82: #endif /* __IFFTW_MPI_H__ */ Chris@82: