annotate fft/fftw/fftw-3.3.4/mpi/transpose-problem.c @ 40:223f770b5341 kissfft-double tip

Try a double-precision kissfft
author Chris Cannam
date Wed, 07 Sep 2016 10:40:32 +0100
parents 26056e866c29
children
rev   line source
Chris@19 1 /*
Chris@19 2 * Copyright (c) 2003, 2007-14 Matteo Frigo
Chris@19 3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
Chris@19 4 *
Chris@19 5 * This program is free software; you can redistribute it and/or modify
Chris@19 6 * it under the terms of the GNU General Public License as published by
Chris@19 7 * the Free Software Foundation; either version 2 of the License, or
Chris@19 8 * (at your option) any later version.
Chris@19 9 *
Chris@19 10 * This program is distributed in the hope that it will be useful,
Chris@19 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@19 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@19 13 * GNU General Public License for more details.
Chris@19 14 *
Chris@19 15 * You should have received a copy of the GNU General Public License
Chris@19 16 * along with this program; if not, write to the Free Software
Chris@19 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Chris@19 18 *
Chris@19 19 */
Chris@19 20
Chris@19 21 #include "mpi-transpose.h"
Chris@19 22
Chris@19 23 static void destroy(problem *ego_)
Chris@19 24 {
Chris@19 25 problem_mpi_transpose *ego = (problem_mpi_transpose *) ego_;
Chris@19 26 MPI_Comm_free(&ego->comm);
Chris@19 27 X(ifree)(ego_);
Chris@19 28 }
Chris@19 29
Chris@19 30 static void hash(const problem *p_, md5 *m)
Chris@19 31 {
Chris@19 32 const problem_mpi_transpose *p = (const problem_mpi_transpose *) p_;
Chris@19 33 int i;
Chris@19 34 X(md5puts)(m, "mpi-transpose");
Chris@19 35 X(md5int)(m, p->I == p->O);
Chris@19 36 /* don't include alignment -- may differ between processes
Chris@19 37 X(md5int)(m, X(alignment_of)(p->I));
Chris@19 38 X(md5int)(m, X(alignment_of)(p->O));
Chris@19 39 ... note that applicability of MPI plans does not depend
Chris@19 40 on alignment (although optimality may, in principle). */
Chris@19 41 X(md5INT)(m, p->vn);
Chris@19 42 X(md5INT)(m, p->nx);
Chris@19 43 X(md5INT)(m, p->ny);
Chris@19 44 X(md5INT)(m, p->block);
Chris@19 45 X(md5INT)(m, p->tblock);
Chris@19 46 MPI_Comm_size(p->comm, &i); X(md5int)(m, i);
Chris@19 47 A(XM(md5_equal)(*m, p->comm));
Chris@19 48 }
Chris@19 49
Chris@19 50 static void print(const problem *ego_, printer *p)
Chris@19 51 {
Chris@19 52 const problem_mpi_transpose *ego = (const problem_mpi_transpose *) ego_;
Chris@19 53 int i;
Chris@19 54 MPI_Comm_size(ego->comm, &i);
Chris@19 55 p->print(p, "(mpi-transpose %d %d %d %D %D %D %D %D %d)",
Chris@19 56 ego->I == ego->O,
Chris@19 57 X(alignment_of)(ego->I),
Chris@19 58 X(alignment_of)(ego->O),
Chris@19 59 ego->vn,
Chris@19 60 ego->nx, ego->ny,
Chris@19 61 ego->block, ego->tblock,
Chris@19 62 i);
Chris@19 63 }
Chris@19 64
Chris@19 65 static void zero(const problem *ego_)
Chris@19 66 {
Chris@19 67 const problem_mpi_transpose *ego = (const problem_mpi_transpose *) ego_;
Chris@19 68 R *I = ego->I;
Chris@19 69 INT i, N = ego->vn * ego->ny;
Chris@19 70 int my_pe;
Chris@19 71
Chris@19 72 MPI_Comm_rank(ego->comm, &my_pe);
Chris@19 73 N *= XM(block)(ego->nx, ego->block, my_pe);
Chris@19 74
Chris@19 75 for (i = 0; i < N; ++i) I[i] = K(0.0);
Chris@19 76 }
Chris@19 77
Chris@19 78 static const problem_adt padt =
Chris@19 79 {
Chris@19 80 PROBLEM_MPI_TRANSPOSE,
Chris@19 81 hash,
Chris@19 82 zero,
Chris@19 83 print,
Chris@19 84 destroy
Chris@19 85 };
Chris@19 86
Chris@19 87 problem *XM(mkproblem_transpose)(INT nx, INT ny, INT vn,
Chris@19 88 R *I, R *O,
Chris@19 89 INT block, INT tblock,
Chris@19 90 MPI_Comm comm,
Chris@19 91 unsigned flags)
Chris@19 92 {
Chris@19 93 problem_mpi_transpose *ego =
Chris@19 94 (problem_mpi_transpose *)X(mkproblem)(sizeof(problem_mpi_transpose), &padt);
Chris@19 95
Chris@19 96 A(nx > 0 && ny > 0 && vn > 0);
Chris@19 97 A(block > 0 && XM(num_blocks_ok)(nx, block, comm)
Chris@19 98 && tblock > 0 && XM(num_blocks_ok)(ny, tblock, comm));
Chris@19 99
Chris@19 100 /* enforce pointer equality if untainted pointers are equal */
Chris@19 101 if (UNTAINT(I) == UNTAINT(O))
Chris@19 102 I = O = JOIN_TAINT(I, O);
Chris@19 103
Chris@19 104 ego->nx = nx;
Chris@19 105 ego->ny = ny;
Chris@19 106 ego->vn = vn;
Chris@19 107 ego->I = I;
Chris@19 108 ego->O = O;
Chris@19 109 ego->block = block > nx ? nx : block;
Chris@19 110 ego->tblock = tblock > ny ? ny : tblock;
Chris@19 111
Chris@19 112 /* canonicalize flags: we can freely assume that the data is
Chris@19 113 "transposed" if one of the dimensions is 1. */
Chris@19 114 if (ego->block == 1)
Chris@19 115 flags |= TRANSPOSED_IN;
Chris@19 116 if (ego->tblock == 1)
Chris@19 117 flags |= TRANSPOSED_OUT;
Chris@19 118 ego->flags = flags;
Chris@19 119
Chris@19 120 MPI_Comm_dup(comm, &ego->comm);
Chris@19 121
Chris@19 122 return &(ego->super);
Chris@19 123 }