annotate src/fftw-3.3.3/mpi/dft-problem.c @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 89f5e221ed7b
children
rev   line source
cannam@95 1 /*
cannam@95 2 * Copyright (c) 2003, 2007-11 Matteo Frigo
cannam@95 3 * Copyright (c) 2003, 2007-11 Massachusetts Institute of Technology
cannam@95 4 *
cannam@95 5 * This program is free software; you can redistribute it and/or modify
cannam@95 6 * it under the terms of the GNU General Public License as published by
cannam@95 7 * the Free Software Foundation; either version 2 of the License, or
cannam@95 8 * (at your option) any later version.
cannam@95 9 *
cannam@95 10 * This program is distributed in the hope that it will be useful,
cannam@95 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@95 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@95 13 * GNU General Public License for more details.
cannam@95 14 *
cannam@95 15 * You should have received a copy of the GNU General Public License
cannam@95 16 * along with this program; if not, write to the Free Software
cannam@95 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
cannam@95 18 *
cannam@95 19 */
cannam@95 20
cannam@95 21 #include "mpi-dft.h"
cannam@95 22
cannam@95 23 static void destroy(problem *ego_)
cannam@95 24 {
cannam@95 25 problem_mpi_dft *ego = (problem_mpi_dft *) ego_;
cannam@95 26 XM(dtensor_destroy)(ego->sz);
cannam@95 27 MPI_Comm_free(&ego->comm);
cannam@95 28 X(ifree)(ego_);
cannam@95 29 }
cannam@95 30
cannam@95 31 static void hash(const problem *p_, md5 *m)
cannam@95 32 {
cannam@95 33 const problem_mpi_dft *p = (const problem_mpi_dft *) p_;
cannam@95 34 int i;
cannam@95 35 X(md5puts)(m, "mpi-dft");
cannam@95 36 X(md5int)(m, p->I == p->O);
cannam@95 37 /* don't include alignment -- may differ between processes
cannam@95 38 X(md5int)(m, X(alignment_of)(p->I));
cannam@95 39 X(md5int)(m, X(alignment_of)(p->O));
cannam@95 40 ... note that applicability of MPI plans does not depend
cannam@95 41 on alignment (although optimality may, in principle). */
cannam@95 42 XM(dtensor_md5)(m, p->sz);
cannam@95 43 X(md5INT)(m, p->vn);
cannam@95 44 X(md5int)(m, p->sign);
cannam@95 45 X(md5int)(m, p->flags);
cannam@95 46 MPI_Comm_size(p->comm, &i); X(md5int)(m, i);
cannam@95 47 A(XM(md5_equal)(*m, p->comm));
cannam@95 48 }
cannam@95 49
cannam@95 50 static void print(const problem *ego_, printer *p)
cannam@95 51 {
cannam@95 52 const problem_mpi_dft *ego = (const problem_mpi_dft *) ego_;
cannam@95 53 int i;
cannam@95 54 p->print(p, "(mpi-dft %d %d %d ",
cannam@95 55 ego->I == ego->O,
cannam@95 56 X(alignment_of)(ego->I),
cannam@95 57 X(alignment_of)(ego->O));
cannam@95 58 XM(dtensor_print)(ego->sz, p);
cannam@95 59 p->print(p, " %D %d %d", ego->vn, ego->sign, ego->flags);
cannam@95 60 MPI_Comm_size(ego->comm, &i); p->print(p, " %d)", i);
cannam@95 61 }
cannam@95 62
cannam@95 63 static void zero(const problem *ego_)
cannam@95 64 {
cannam@95 65 const problem_mpi_dft *ego = (const problem_mpi_dft *) ego_;
cannam@95 66 R *I = ego->I;
cannam@95 67 INT i, N;
cannam@95 68 int my_pe;
cannam@95 69
cannam@95 70 MPI_Comm_rank(ego->comm, &my_pe);
cannam@95 71 N = 2 * ego->vn * XM(total_block)(ego->sz, IB, my_pe);
cannam@95 72 for (i = 0; i < N; ++i) I[i] = K(0.0);
cannam@95 73 }
cannam@95 74
cannam@95 75 static const problem_adt padt =
cannam@95 76 {
cannam@95 77 PROBLEM_MPI_DFT,
cannam@95 78 hash,
cannam@95 79 zero,
cannam@95 80 print,
cannam@95 81 destroy
cannam@95 82 };
cannam@95 83
cannam@95 84 problem *XM(mkproblem_dft)(const dtensor *sz, INT vn,
cannam@95 85 R *I, R *O,
cannam@95 86 MPI_Comm comm,
cannam@95 87 int sign,
cannam@95 88 unsigned flags)
cannam@95 89 {
cannam@95 90 problem_mpi_dft *ego =
cannam@95 91 (problem_mpi_dft *)X(mkproblem)(sizeof(problem_mpi_dft), &padt);
cannam@95 92 int n_pes;
cannam@95 93
cannam@95 94 A(XM(dtensor_validp)(sz) && FINITE_RNK(sz->rnk));
cannam@95 95 MPI_Comm_size(comm, &n_pes);
cannam@95 96 A(n_pes >= XM(num_blocks_total)(sz, IB)
cannam@95 97 && n_pes >= XM(num_blocks_total)(sz, OB));
cannam@95 98 A(vn >= 0);
cannam@95 99 A(sign == -1 || sign == 1);
cannam@95 100
cannam@95 101 /* enforce pointer equality if untainted pointers are equal */
cannam@95 102 if (UNTAINT(I) == UNTAINT(O))
cannam@95 103 I = O = JOIN_TAINT(I, O);
cannam@95 104
cannam@95 105 ego->sz = XM(dtensor_canonical)(sz, 1);
cannam@95 106 ego->vn = vn;
cannam@95 107 ego->I = I;
cannam@95 108 ego->O = O;
cannam@95 109 ego->sign = sign;
cannam@95 110
cannam@95 111 /* canonicalize: replace TRANSPOSED_IN with TRANSPOSED_OUT by
cannam@95 112 swapping the first two dimensions (for rnk > 1) */
cannam@95 113 if ((flags & TRANSPOSED_IN) && ego->sz->rnk > 1) {
cannam@95 114 ddim dim0 = ego->sz->dims[0];
cannam@95 115 ego->sz->dims[0] = ego->sz->dims[1];
cannam@95 116 ego->sz->dims[1] = dim0;
cannam@95 117 flags &= ~TRANSPOSED_IN;
cannam@95 118 flags ^= TRANSPOSED_OUT;
cannam@95 119 }
cannam@95 120 ego->flags = flags;
cannam@95 121
cannam@95 122 MPI_Comm_dup(comm, &ego->comm);
cannam@95 123
cannam@95 124 return &(ego->super);
cannam@95 125 }
cannam@95 126
cannam@95 127 problem *XM(mkproblem_dft_d)(dtensor *sz, INT vn,
cannam@95 128 R *I, R *O,
cannam@95 129 MPI_Comm comm,
cannam@95 130 int sign,
cannam@95 131 unsigned flags)
cannam@95 132 {
cannam@95 133 problem *p = XM(mkproblem_dft)(sz, vn, I, O, comm, sign, flags);
cannam@95 134 XM(dtensor_destroy)(sz);
cannam@95 135 return p;
cannam@95 136 }