annotate src/fftw-3.3.3/mpi/transpose-problem.c @ 23:619f715526df sv_v2.1

Update Vamp plugin SDK to 2.5
author Chris Cannam
date Thu, 09 May 2013 10:52:46 +0100
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-transpose.h"
Chris@10 22
Chris@10 23 static void destroy(problem *ego_)
Chris@10 24 {
Chris@10 25 problem_mpi_transpose *ego = (problem_mpi_transpose *) ego_;
Chris@10 26 MPI_Comm_free(&ego->comm);
Chris@10 27 X(ifree)(ego_);
Chris@10 28 }
Chris@10 29
Chris@10 30 static void hash(const problem *p_, md5 *m)
Chris@10 31 {
Chris@10 32 const problem_mpi_transpose *p = (const problem_mpi_transpose *) p_;
Chris@10 33 int i;
Chris@10 34 X(md5puts)(m, "mpi-transpose");
Chris@10 35 X(md5int)(m, p->I == p->O);
Chris@10 36 /* don't include alignment -- may differ between processes
Chris@10 37 X(md5int)(m, X(alignment_of)(p->I));
Chris@10 38 X(md5int)(m, X(alignment_of)(p->O));
Chris@10 39 ... note that applicability of MPI plans does not depend
Chris@10 40 on alignment (although optimality may, in principle). */
Chris@10 41 X(md5INT)(m, p->vn);
Chris@10 42 X(md5INT)(m, p->nx);
Chris@10 43 X(md5INT)(m, p->ny);
Chris@10 44 X(md5INT)(m, p->block);
Chris@10 45 X(md5INT)(m, p->tblock);
Chris@10 46 MPI_Comm_size(p->comm, &i); X(md5int)(m, i);
Chris@10 47 A(XM(md5_equal)(*m, p->comm));
Chris@10 48 }
Chris@10 49
Chris@10 50 static void print(const problem *ego_, printer *p)
Chris@10 51 {
Chris@10 52 const problem_mpi_transpose *ego = (const problem_mpi_transpose *) ego_;
Chris@10 53 int i;
Chris@10 54 MPI_Comm_size(ego->comm, &i);
Chris@10 55 p->print(p, "(mpi-transpose %d %d %d %D %D %D %D %D %d)",
Chris@10 56 ego->I == ego->O,
Chris@10 57 X(alignment_of)(ego->I),
Chris@10 58 X(alignment_of)(ego->O),
Chris@10 59 ego->vn,
Chris@10 60 ego->nx, ego->ny,
Chris@10 61 ego->block, ego->tblock,
Chris@10 62 i);
Chris@10 63 }
Chris@10 64
Chris@10 65 static void zero(const problem *ego_)
Chris@10 66 {
Chris@10 67 const problem_mpi_transpose *ego = (const problem_mpi_transpose *) ego_;
Chris@10 68 R *I = ego->I;
Chris@10 69 INT i, N = ego->vn * ego->ny;
Chris@10 70 int my_pe;
Chris@10 71
Chris@10 72 MPI_Comm_rank(ego->comm, &my_pe);
Chris@10 73 N *= XM(block)(ego->nx, ego->block, my_pe);
Chris@10 74
Chris@10 75 for (i = 0; i < N; ++i) I[i] = K(0.0);
Chris@10 76 }
Chris@10 77
Chris@10 78 static const problem_adt padt =
Chris@10 79 {
Chris@10 80 PROBLEM_MPI_TRANSPOSE,
Chris@10 81 hash,
Chris@10 82 zero,
Chris@10 83 print,
Chris@10 84 destroy
Chris@10 85 };
Chris@10 86
Chris@10 87 problem *XM(mkproblem_transpose)(INT nx, INT ny, INT vn,
Chris@10 88 R *I, R *O,
Chris@10 89 INT block, INT tblock,
Chris@10 90 MPI_Comm comm,
Chris@10 91 unsigned flags)
Chris@10 92 {
Chris@10 93 problem_mpi_transpose *ego =
Chris@10 94 (problem_mpi_transpose *)X(mkproblem)(sizeof(problem_mpi_transpose), &padt);
Chris@10 95
Chris@10 96 A(nx > 0 && ny > 0 && vn > 0);
Chris@10 97 A(block > 0 && XM(num_blocks_ok)(nx, block, comm)
Chris@10 98 && tblock > 0 && XM(num_blocks_ok)(ny, tblock, comm));
Chris@10 99
Chris@10 100 /* enforce pointer equality if untainted pointers are equal */
Chris@10 101 if (UNTAINT(I) == UNTAINT(O))
Chris@10 102 I = O = JOIN_TAINT(I, O);
Chris@10 103
Chris@10 104 ego->nx = nx;
Chris@10 105 ego->ny = ny;
Chris@10 106 ego->vn = vn;
Chris@10 107 ego->I = I;
Chris@10 108 ego->O = O;
Chris@10 109 ego->block = block > nx ? nx : block;
Chris@10 110 ego->tblock = tblock > ny ? ny : tblock;
Chris@10 111
Chris@10 112 /* canonicalize flags: we can freely assume that the data is
Chris@10 113 "transposed" if one of the dimensions is 1. */
Chris@10 114 if (ego->block == 1)
Chris@10 115 flags |= TRANSPOSED_IN;
Chris@10 116 if (ego->tblock == 1)
Chris@10 117 flags |= TRANSPOSED_OUT;
Chris@10 118 ego->flags = flags;
Chris@10 119
Chris@10 120 MPI_Comm_dup(comm, &ego->comm);
Chris@10 121
Chris@10 122 return &(ego->super);
Chris@10 123 }