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