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