1
/* Copyright 2004,2007 ENSEIRB, INRIA & CNRS
3
** This file is part of the Scotch software package for static mapping,
4
** graph partitioning and sparse matrix ordering.
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".
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
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.
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.
32
/************************************************************/
34
/** NAME : vgraph_store.c **/
36
/** AUTHOR : Francois PELLEGRINI **/
38
/** FUNCTION : This module contains the save data **/
39
/** structure handling routines for separa- **/
42
/** DATES : # Version 3.3 : from : 17 oct 1998 **/
43
/** to 17 oct 1998 **/
44
/** # Version 3.4 : from : 11 dec 2001 **/
45
/** to : 11 dec 2001 **/
46
/** # Version 4.0 : from : 01 jan 2002 **/
47
/** to : 06 jan 2002 **/
49
/************************************************************/
52
** The defines and includes.
62
/**********************************/
64
/* Store graph handling routines. */
66
/**********************************/
68
/* This routine builds a save structure
69
** for the given active graph.
71
** - 0 : if allocation succeeded.
77
const Vgraph * restrict const grafptr,
78
VgraphStore * restrict const storptr)
82
savsize = grafptr->s.vertnbr * (sizeof (GraphPart) + sizeof (Gnum)); /* Compute size for frontier and part arrays */
84
if ((storptr->datatab = (byte *) memAlloc (savsize)) == NULL) { /* Allocate save structure */
85
errorPrint ("vgraphStoreInit: out of memory");
92
/* This routine frees a save structure.
94
** - VOID : in all cases.
99
VgraphStore * const storptr)
101
memFree (storptr->datatab);
102
#ifdef SCOTCH_DEBUG_VGRAPH2
103
storptr->datatab = NULL;
104
#endif /* SCOTCH_DEBUG_VGRAPH2 */
107
/* This routine saves partition data from the
108
** given active graph to the given save structure.
110
** - VOID : in all cases.
115
const Vgraph * const grafptr,
116
VgraphStore * const storptr)
118
byte * parttab; /* Pointer to part data save area */
119
byte * frontab; /* Pointer to frontier data save area */
121
storptr->fronnbr = grafptr->fronnbr; /* Save partition parameters */
122
storptr->comploaddlt = grafptr->comploaddlt;
123
storptr->compload[0] = grafptr->compload[0];
124
storptr->compload[1] = grafptr->compload[1];
125
storptr->compsize0 = grafptr->compsize[0];
127
frontab = storptr->datatab; /* Compute data offsets within save structure */
128
parttab = frontab + grafptr->fronnbr * sizeof (Gnum);
130
memCpy (frontab, grafptr->frontab, grafptr->fronnbr * sizeof (Gnum));
131
memCpy (parttab, grafptr->parttax + grafptr->s.baseval, grafptr->s.vertnbr * sizeof (GraphPart));
134
/* This routine updates partition data of the
135
** given active graph, using the given save graph.
137
** - VOID : in all cases.
142
Vgraph * const grafptr,
143
const VgraphStore * const storptr)
145
byte * frontab; /* Pointer to frontier data save area */
146
byte * parttab; /* Pointer to part data save area */
148
grafptr->compload[0] = storptr->compload[0]; /* Load partition parameters */
149
grafptr->compload[1] = storptr->compload[1];
150
grafptr->compload[2] = grafptr->s.velosum - (storptr->compload[0] + storptr->compload[1]);
151
grafptr->comploaddlt = storptr->comploaddlt;
152
grafptr->compsize[0] = storptr->compsize0;
153
grafptr->compsize[1] = grafptr->s.vertnbr - (storptr->compsize0 + storptr->fronnbr);
154
grafptr->fronnbr = storptr->fronnbr;
156
frontab = storptr->datatab; /* Compute data offsets within save structure */
157
parttab = frontab + grafptr->fronnbr * sizeof (Gnum);
159
memCpy (grafptr->frontab, frontab, grafptr->fronnbr * sizeof (Gnum));
160
memCpy (grafptr->parttax + grafptr->s.baseval, parttab, grafptr->s.vertnbr * sizeof (GraphPart));
162
#ifdef SCOTCH_DEBUG_VGRAPH2
163
if (vgraphCheck (grafptr) != 0)
164
errorPrint ("vgraphStoreUpdt: inconsistent graph data");
165
#endif /* SCOTCH_DEBUG_VGRAPH2 */