~ubuntu-branches/ubuntu/trusty/scotch/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libscotch/comm.c

  • Committer: Bazaar Package Importer
  • Author(s): "Adam C. Powell, IV", Christophe Trophime, Adam C. Powell, IV
  • Date: 2010-12-29 13:07:19 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20101229130719-jwalolw5d6av6wqx
Tags: 5.1.11.dfsg-1
[Christophe Trophime]
* New upstream release
* Forward-ported patches to version 5.1.10b.
* Install scotch headers properly.
* Fix chrpath commands in debian/rules.
* Fix (pt)scotch library install paths.
* Fix lintian errors and warnings.

[Adam C. Powell, IV]
* Forward-ported patches to version 5.1.11.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2010 ENSEIRB, INRIA & CNRS
 
2
**
 
3
** This file is part of the Scotch software package for static mapping,
 
4
** graph partitioning and sparse matrix ordering.
 
5
**
 
6
** This software is governed by the CeCILL-C license under French law
 
7
** and abiding by the rules of distribution of free software. You can
 
8
** use, modify and/or redistribute the software under the terms of the
 
9
** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
 
10
** URL: "http://www.cecill.info".
 
11
** 
 
12
** As a counterpart to the access to the source code and rights to copy,
 
13
** modify and redistribute granted by the license, users are provided
 
14
** only with a limited warranty and the software's author, the holder of
 
15
** the economic rights, and the successive licensors have only limited
 
16
** liability.
 
17
** 
 
18
** In this respect, the user's attention is drawn to the risks associated
 
19
** with loading, using, modifying and/or developing or reproducing the
 
20
** software by the user in light of its specific status of free software,
 
21
** that may mean that it is complicated to manipulate, and that also
 
22
** therefore means that it is reserved for developers and experienced
 
23
** professionals having in-depth computer knowledge. Users are therefore
 
24
** encouraged to load and test the software's suitability as regards
 
25
** their requirements in conditions enabling the security of their
 
26
** systems and/or data to be ensured and, more generally, to use and
 
27
** operate it in the same conditions as regards security.
 
28
** 
 
29
** The fact that you are presently reading this means that you have had
 
30
** knowledge of the CeCILL-C license and that you accept its terms.
 
31
*/
 
32
/************************************************************/
 
33
/**                                                        **/
 
34
/**   NAME       : comm.c                                  **/
 
35
/**                                                        **/
 
36
/**   AUTHOR     : Francois PELLEGRINI                     **/
 
37
/**                                                        **/
 
38
/**   FUNCTION   : This module contains the large size     **/
 
39
/**                communication handling routines.        **/
 
40
/**                                                        **/
 
41
/**    DATES     : # Version 5.1  : from : 30 jul 2010     **/
 
42
/**                                 to   : 30 jul 2010     **/
 
43
/**                                                        **/
 
44
/************************************************************/
 
45
 
 
46
/*
 
47
** The defines and includes.
 
48
*/
 
49
 
 
50
#define COMM
 
51
 
 
52
#include "module.h"
 
53
#include "common.h"
 
54
#include "comm.h"
 
55
 
 
56
/************************************/
 
57
/*                                  */
 
58
/* These routines handle large size */
 
59
/* communications                   */
 
60
/*                                  */
 
61
/************************************/
 
62
 
 
63
/*
 
64
**
 
65
*/
 
66
 
 
67
int
 
68
commAllgatherv (
 
69
void * const                senddattab,
 
70
const Gnum                  sendcntnbr,
 
71
MPI_Datatype                sendtypval,
 
72
void * const                recvdattab,
 
73
const Gnum * const          recvcnttab,
 
74
const Gnum * const          recvdsptab,
 
75
MPI_Datatype                recvtypval,
 
76
MPI_Comm                    comm)
 
77
{
 
78
  int * restrict      ircvcnttab;
 
79
  int * restrict      ircvdsptab;
 
80
  int                 procglbnbr;
 
81
  int                 procnum;
 
82
  int                 o;
 
83
 
 
84
  MPI_Comm_size (comm, &procglbnbr);
 
85
  if (memAllocGroup ((void **) (void *)
 
86
                     &ircvcnttab, (size_t) (procglbnbr * sizeof (int)),
 
87
                     &ircvdsptab, (size_t) (procglbnbr * sizeof (int)), NULL) == NULL) {
 
88
    errorPrint ("commAllgatherv: out of memory");
 
89
    return     (MPI_ERR_OTHER);
 
90
  }
 
91
 
 
92
  for (procnum = 0; procnum < procglbnbr; procnum ++) {
 
93
    ircvcnttab[procnum] = (int) recvcnttab[procnum];
 
94
    ircvdsptab[procnum] = (int) recvdsptab[procnum];
 
95
    if (((Gnum) ircvcnttab[procnum] != recvcnttab[procnum]) ||
 
96
        ((Gnum) ircvdsptab[procnum] != recvdsptab[procnum])) {
 
97
      errorPrint ("commAllgatherv: communication indices out of range");
 
98
      memFree    (ircvcnttab);
 
99
      return     (MPI_ERR_ARG);
 
100
    }
 
101
  }
 
102
 
 
103
  o = MPI_Allgatherv (senddattab, sendcntnbr, sendtypval,
 
104
                      recvdattab, ircvcnttab, ircvdsptab, recvtypval, comm);
 
105
 
 
106
  memFree (ircvcnttab);
 
107
 
 
108
  return (o);
 
109
}
 
110
 
 
111
/*
 
112
**
 
113
*/
 
114
 
 
115
int
 
116
commGatherv (
 
117
void * const                senddattab,
 
118
const Gnum                  sendcntnbr,
 
119
MPI_Datatype                sendtypval,
 
120
void * const                recvdattab,
 
121
const Gnum * const          recvcnttab,
 
122
const Gnum * const          recvdsptab,
 
123
MPI_Datatype                recvtypval,
 
124
const int                   rootnum,
 
125
MPI_Comm                    comm)
 
126
{
 
127
  int * restrict      ircvcnttab;
 
128
  int * restrict      ircvdsptab;
 
129
  int                 proclocnum;
 
130
  int                 o;
 
131
 
 
132
  MPI_Comm_rank (comm, &proclocnum);
 
133
 
 
134
  ircvcnttab = NULL;
 
135
 
 
136
  if (rootnum == proclocnum) {
 
137
    int                 procglbnbr;
 
138
    int                 procnum;
 
139
 
 
140
    MPI_Comm_size (comm, &procglbnbr);
 
141
    if (memAllocGroup ((void **) (void *)
 
142
                       &ircvcnttab, (size_t) (procglbnbr * sizeof (int)),
 
143
                       &ircvdsptab, (size_t) (procglbnbr * sizeof (int)), NULL) == NULL) {
 
144
      errorPrint ("commGatherv: out of memory");
 
145
      return     (MPI_ERR_OTHER);
 
146
    }
 
147
 
 
148
    for (procnum = 0; procnum < procglbnbr; procnum ++) {
 
149
      ircvcnttab[procnum] = (int) recvcnttab[procnum];
 
150
      ircvdsptab[procnum] = (int) recvdsptab[procnum];
 
151
      if (((Gnum) ircvcnttab[procnum] != recvcnttab[procnum]) ||
 
152
          ((Gnum) ircvdsptab[procnum] != recvdsptab[procnum])) {
 
153
        errorPrint ("commGatherv: communication indices out of range");
 
154
        memFree    (ircvcnttab);
 
155
        return     (MPI_ERR_ARG);
 
156
      }
 
157
    }
 
158
  }
 
159
 
 
160
  o = MPI_Gatherv (senddattab, sendcntnbr, sendtypval,
 
161
                   recvdattab, ircvcnttab, ircvdsptab, recvtypval, rootnum, comm);
 
162
 
 
163
  if (ircvcnttab != NULL)
 
164
    memFree (ircvcnttab);
 
165
 
 
166
  return (o);
 
167
}
 
168
 
 
169
/*
 
170
**
 
171
*/
 
172
 
 
173
int
 
174
commScatterv (
 
175
void * const                senddattab,
 
176
const Gnum * const          sendcnttab,
 
177
const Gnum * const          senddsptab,
 
178
MPI_Datatype                sendtypval,
 
179
void * const                recvdattab,
 
180
const Gnum                  recvcntnbr,
 
181
MPI_Datatype                recvtypval,
 
182
const int                   rootnum,
 
183
MPI_Comm                    comm)
 
184
{
 
185
  int * restrict      isndcnttab;
 
186
  int * restrict      isnddsptab;
 
187
  int                 proclocnum;
 
188
  int                 o;
 
189
 
 
190
  MPI_Comm_rank (comm, &proclocnum);
 
191
 
 
192
  isndcnttab = NULL;
 
193
 
 
194
  if (rootnum == proclocnum) {
 
195
    int                 procglbnbr;
 
196
    int                 procnum;
 
197
 
 
198
    MPI_Comm_size (comm, &procglbnbr);
 
199
    if (memAllocGroup ((void **) (void *)
 
200
                       &isndcnttab, (size_t) (procglbnbr * sizeof (int)),
 
201
                       &isnddsptab, (size_t) (procglbnbr * sizeof (int)), NULL) == NULL) {
 
202
      errorPrint ("commScatterv: out of memory");
 
203
      return     (MPI_ERR_OTHER);
 
204
    }
 
205
 
 
206
    for (procnum = 0; procnum < procglbnbr; procnum ++) {
 
207
      isndcnttab[procnum] = (int) sendcnttab[procnum];
 
208
      isnddsptab[procnum] = (int) senddsptab[procnum];
 
209
      if (((Gnum) isndcnttab[procnum] != sendcnttab[procnum]) ||
 
210
          ((Gnum) isnddsptab[procnum] != senddsptab[procnum])) {
 
211
        errorPrint ("commScatterv: communication indices out of range");
 
212
        memFree    (isndcnttab);
 
213
        return     (MPI_ERR_ARG);
 
214
      }
 
215
    }
 
216
  }
 
217
 
 
218
  o = MPI_Scatterv (senddattab, isndcnttab, isnddsptab, sendtypval,
 
219
                    recvdattab, (int) recvcntnbr, recvtypval, rootnum, comm);
 
220
 
 
221
  if (isndcnttab != NULL)
 
222
    memFree (isndcnttab);
 
223
 
 
224
  return (o);
 
225
}