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

« back to all changes in this revision

Viewing changes to src/libscotch/hgraph_order_hf.c

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2008-01-25 09:13:53 UTC
  • Revision ID: james.westby@ubuntu.com-20080125091353-zghdao60dfsyc2bt
Tags: upstream-5.0.1.dfsg
ImportĀ upstreamĀ versionĀ 5.0.1.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2004,2007 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       : hgraph_order_hf.c                       **/
 
35
/**                                                        **/
 
36
/**   AUTHOR     : Francois PELLEGRINI                     **/
 
37
/**                                                        **/
 
38
/**   FUNCTION   : This module orders a subgraph using     **/
 
39
/**                the block-oriented Halo Approximate     **/
 
40
/**                (Multiple) Minimum Fill algorithm,      **/
 
41
/**                with super-variable accounting          **/
 
42
/**                R2HAMDf4 v2.0).                         **/
 
43
/**                                                        **/
 
44
/**   DATES      : # Version 3.4  : from : 15 may 2001     **/
 
45
/**                                 to   : 23 nov 2001     **/
 
46
/**                # Version 4.0  : from : 10 jan 2003     **/
 
47
/**                                 to   : 24 jan 2004     **/
 
48
/**                # Version 5.0  : from : 10 sep 2007     **/
 
49
/**                                 to   : 10 sep 2007     **/
 
50
/**                                                        **/
 
51
/************************************************************/
 
52
 
 
53
/*
 
54
**  The defines and includes.
 
55
*/
 
56
 
 
57
#define HGRAPH_ORDER_HF
 
58
 
 
59
#include "module.h"
 
60
#include "common.h"
 
61
#include "graph.h"
 
62
#include "order.h"
 
63
#include "hgraph.h"
 
64
#include "hall_order_hf.h"
 
65
#include "hall_order_hx.h"
 
66
#include "hgraph_order_hf.h"
 
67
#include "hgraph_order_hx.h"
 
68
#include "hgraph_order_si.h"
 
69
 
 
70
/*****************************/
 
71
/*                           */
 
72
/* This is the main routine. */
 
73
/*                           */
 
74
/*****************************/
 
75
 
 
76
/* This routine performs the ordering.
 
77
** It returns:
 
78
** - 0   : if the ordering could be computed.
 
79
** - !0  : on error.
 
80
*/
 
81
 
 
82
int
 
83
hgraphOrderHf (
 
84
const Hgraph * restrict const             grafptr,
 
85
Order * restrict const                    ordeptr,
 
86
const Gnum                                ordenum, /*+ Zero-based ordering number +*/
 
87
OrderCblk * restrict const                cblkptr, /*+ Multiple column-block      +*/
 
88
const HgraphOrderHfParam * restrict const paraptr)
 
89
{
 
90
  Gnum                nbbuck;
 
91
  Gnum * restrict     petab;
 
92
  Gnum                pfree;
 
93
  Gnum                iwlen;
 
94
  Gnum * restrict     iwtab;
 
95
  Gnum * restrict     lentab;
 
96
  Gnum * restrict     nvartab;
 
97
  Gnum * restrict     elentab;
 
98
  Gnum * restrict     lasttab;
 
99
  Gnum * restrict     leaftab;
 
100
  Gnum * restrict     secntab;                    /* Array of index to first secondary variable */
 
101
  Gnum * restrict     nexttab;                    /* Array of index of next principal variable  */
 
102
  Gnum * restrict     frsttab;
 
103
  Gnum * restrict     headtab;                    /* Head array : nbbuck = 2 * n                 */
 
104
  Gnum                ncmpa;
 
105
  Gnum                n;                          /* Number of nodes to order (with halo or not) */
 
106
  int                 o;
 
107
 
 
108
  if (grafptr->s.vertnbr < paraptr->colmin)       /* If graph is too small, order simply */
 
109
    return (hgraphOrderSi (grafptr, ordeptr, ordenum, cblkptr));
 
110
 
 
111
  n      = grafptr->s.vertnbr;
 
112
  nbbuck = n * 2;
 
113
  iwlen  = (Gnum) ((double) grafptr->s.edgenbr * HGRAPHORDERHFCOMPRAT) + 32;
 
114
  if (iwlen < n)                                  /* Prepare to re-use array */
 
115
    iwlen = n;
 
116
 
 
117
  if (memAllocGroup ((void **) (void *)
 
118
                     &petab,   (size_t) (n     * sizeof (Gnum)),
 
119
                     &iwtab,   (size_t) (iwlen * sizeof (Gnum)),
 
120
                     &lentab,  (size_t) (n     * sizeof (Gnum)),
 
121
                     &nvartab, (size_t) (n     * sizeof (Gnum)),
 
122
                     &elentab, (size_t) (n     * sizeof (Gnum)),
 
123
                     &lasttab, (size_t) (n     * sizeof (Gnum)),
 
124
                     &leaftab, (size_t) (n     * sizeof (Gnum)),
 
125
                     &frsttab, (size_t) (n     * sizeof (Gnum)),
 
126
                     &secntab, (size_t) (n     * sizeof (Gnum)),
 
127
                     &nexttab, (size_t) (n     * sizeof (Gnum)),
 
128
                     &headtab, (size_t) ((nbbuck + 2) * sizeof (Gnum)), NULL) == NULL) {
 
129
    errorPrint  ("hgraphOrderHf: out of memory");
 
130
    return      (1);
 
131
  }
 
132
 
 
133
  hgraphOrderHxFill (grafptr, petab, lentab, iwtab, elentab, &pfree);
 
134
 
 
135
  hallOrderHfR2hamdf4 (n, 0, nbbuck, iwlen, petab, pfree, /* No elements here */
 
136
                       lentab, iwtab, nvartab, elentab, lasttab, &ncmpa,
 
137
                       leaftab, secntab, nexttab, frsttab, headtab);
 
138
  if (ncmpa < 0) {
 
139
    errorPrint ("hgraphOrderHf: internal error");
 
140
    memFree    (petab);                           /* Free group leader */
 
141
    return     (1);
 
142
  }
 
143
 
 
144
  o = hallOrderHxBuild (grafptr->s.baseval, n, grafptr->vnohnbr,
 
145
                        grafptr->s.vnumtax, ordeptr, cblkptr,
 
146
                        nvartab - grafptr->s.baseval,
 
147
                        lentab  - grafptr->s.baseval,
 
148
                        petab   - grafptr->s.baseval,
 
149
                        frsttab - grafptr->s.baseval,
 
150
                        nexttab - grafptr->s.baseval,
 
151
                        secntab - grafptr->s.baseval,
 
152
                        iwtab   - grafptr->s.baseval,
 
153
                        elentab - grafptr->s.baseval,
 
154
                        ordeptr->peritab + ordenum, /* Use given inverse permutation as inverse permutation space, never based */
 
155
                        leaftab,
 
156
                        paraptr->colmin, paraptr->colmax, (float) paraptr->fillrat);
 
157
 
 
158
  memFree (petab);                                /* Free group leader */
 
159
 
 
160
  return (o);
 
161
}