annotate src/fftw-3.3.8/mpi/transpose-problem.c @ 82:d0c2a83c1364

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