annotate src/fftw-3.3.5/mpi/rdft-problem.c @ 43:5ea0608b923f

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