~ubuntu-branches/ubuntu/utopic/fftw3/utopic

« back to all changes in this revision

Viewing changes to mpi/any-true.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-12-14 13:21:22 UTC
  • mfrom: (3.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20111214132122-l4avyl2kkr7vq5aj
Tags: 3.3-1ubuntu1
* Merge with Debian; remaining changes:
  - Revert the ARM workaround.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2003, 2007-11 Matteo Frigo
 
3
 * Copyright (c) 2003, 2007-11 Massachusetts Institute of Technology
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 *
 
19
 */
 
20
 
 
21
#include "ifftw-mpi.h"
 
22
 
 
23
/* During planning, if any process fails to create a plan then
 
24
   all of the processes must fail.  This synchronization is implemented
 
25
   by the following routine.
 
26
 
 
27
   Instead of 
 
28
        if (failure) goto nada;
 
29
   we instead do:
 
30
        if (any_true(failure, comm)) goto nada;
 
31
*/
 
32
 
 
33
int XM(any_true)(int condition, MPI_Comm comm)
 
34
{
 
35
     int result;
 
36
     MPI_Allreduce(&condition, &result, 1, MPI_INT, MPI_LOR, comm);
 
37
     return result;
 
38
}
 
39
 
 
40
/***********************************************************************/
 
41
 
 
42
#if defined(FFTW_DEBUG)
 
43
/* for debugging, we include an assertion to make sure that
 
44
   MPI problems all produce equal hashes, as checked by this routine: */
 
45
 
 
46
int XM(md5_equal)(md5 m, MPI_Comm comm)
 
47
{
 
48
     unsigned long s0[4];
 
49
     int i, eq_me, eq_all;
 
50
 
 
51
     X(md5end)(&m);
 
52
     for (i = 0; i < 4; ++i) s0[i] = m.s[i];
 
53
     MPI_Bcast(s0, 4, MPI_UNSIGNED_LONG, 0, comm);
 
54
     for (i = 0; i < 4 && s0[i] == m.s[i]; ++i) ;
 
55
     eq_me = i == 4;
 
56
     MPI_Allreduce(&eq_me, &eq_all, 1, MPI_INT, MPI_LAND, comm);
 
57
     return eq_all;
 
58
}
 
59
#endif