annotate src/fftw-3.3.3/mpi/rdft-problem.c @ 83:ae30d91d2ffe

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