Debian Codegraph @

packages/seacas/libraries/chaco/main/chaco.h

raw
1 /*
2 * Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions
3 * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
4 * NTESS, the U.S. Government retains certain rights in this software.
5 *
6 * See packages/seacas/LICENSE for details
7 */
8 #pragma once
9 /**
10 * Calling Chaco from other programs. Throughout this document we have
11 * assumed that Chaco is being used as a stand{alone program. However,
12 * this needn't be the case. We designed version 2.0 to allow for easy
13 * interface with other codes written in either C or Fortran. The
14 * mechanism for this interface is described below. Some familiarity
15 * with the remainder of this document is assumed. The interface()
16 * routine and can be found in \code/main/interface.c". This is the
17 * routine that Chaco itself invokes after prompting the user for all
18 * the necessary input. Consequently, no functionality is lost by
19 * calling interface() yourself.
20 *
21 * The input can still be checked for consistency, all the output
22 * options are still active and the ability to modify parameters at
23 * run time by reading a file as described in x6.10 is
24 * maintained. (The parameters ARCHITECTURE, EIGEN TOLERANCE and
25 * RANDOM SEED are made obsolete by the arguments to interface() as
26 * detailed below, and DEBUG INPUT and PROMPT become irrelevant, but
27 * all other parameters remain active.) The ability to control the
28 * goals argument described below actually gives you greater
29 * functionality than you would have in standalone mode.
30 *
31 * The interface routine returns 0 if the partitioning is successful,
32 * and 1 otherwise. Typically, a return code of 1 indicates the
33 * detection of some inconsistencies in the input arguments. The
34 * arguments to interface() describe the graph, input and output files
35 * and arrays, properties of the desired decomposition and the
36 * requested partitioning algorithm. The arguments are described below
37 * in the order in which they occur.
38 *
39 * A. Arguments describing the graph.
40 *
41 * 1. nvtxs. Type int. This is the number of vertices in the graph. Vertices are
42 * numbered from 1 to nvtxs.
43 * 2. start. Type int *. Although Chaco internally uses a C structure to represent
44 * the graph, a simpler representation at the start allows for interface with Fortran
45 * programs. The start array is of size (nvtxs+1). It's values are indices into the
46 * adjacency array. The values in adjacency from start i ; 1] to start i];1 are the
47 * vertices adjacent to vertex i in the graph. (Note that C arrays begin at zero,
48 * so in Fortran, the relevant range would be start i] to start(i + 1) ; 1.)
49 * 3. adjacency. Type int *. As indicated in the description of start, this array contains
50 * a list of edges for all vertices in the graph. Note that if the FREE GRAPH
51 * parameter from x6.8 is set to TRUE, then after converting to a new data structure,
52 * both start and adjacency are freed. If this is inappropriate for your application
53 * (e.g. you want to keep the graph, or you didn't dynamically allocate
54 * these arrays), then you should set FREE GRAPH to FALSE.
55 * 4. vwgts. Type int *. This array of length nvtxs specifies weights for all the
56 * vertices. If you pass in a NULL pointer, then all vertices are given unit weight.
57 * Vertex weights should be positive.
58 *
59 * 5. ewgts. Type float * (Fortran type real*4). This array
60 * specifies weights for all the edges. It is of the same length
61 * as adjacency and is indexed in the same way. If you use
62 * Kernighan-Lin or the multilevel partitioner, these values
63 * will be rounded to the nearest integer. We suggest scaling
64 * them so they are neither very small nor very big. Edge
65 * weights should be positive.
66 *
67 * 6. x. Type float *. If you are using the inertial
68 * partitioner, you need to specify geometric coordinates for
69 * each vertex. This array of length nvtxs specifies the x
70 * coordinate for each vertex.
71 *
72 * 7. y. Type float *. This array specifies the y coordinate for
73 * each vertex. If it is NULL, the geometry is assumed to
74 * one-dimensional.
75 *
76 * 8. z. Type float *. This array specifies the z coordinate for
77 * he each vertex. If z is NULL and y is not NULL, the geometry
78 * is assumed to be two-dimensional.
79 *
80 * B. Output le names.
81 *
82 * 9. outassignname. Type char *. If you desire the final
83 * assignment to be written to a file, this argument gives the
84 * name of that file. If this argument is NULL or if the
85 * parameter OUTPUT ASSIGN is 0, then the assignment is not
86 * written to a file.
87 *
88 * 10. out filename. Type char *. This is the name of a file in
89 * which the results of the run are printed. If it is NULL or if
90 * the parameter ECHO is not negative, then no file output is
91 * performed.
92 *
93 * C. Assignment.
94 * 11. assignment. Type int *. This is the only output argument to interface().
95 * It is an array of length nvtxs and returns the set number to which each vertex
96 * is assigned. The set number for vertex i is returned in assignment i ; 1] (or for
97 * Fortran, in assignment(i)). This can also be an input argument if global method,
98 * argument 16 below, is set to 7. A description of what functionality can be used
99 * with an input assignment can be found in x4.4
100 * NOTE: This argument was a short in the original implementation and documentation.
101 * Since this limits the processor decomposition to < 32,768 processors, it needed
102 * to be changed to an integer as were all other shorts in the library.
103 *
104 * D. Description of the target machine.
105 * 12. architecture. Type int. This parameter designates the topology of the par-
106 * allel machine for which you are partitioning. Current capabilities include a
107 * hypercube (indicated by a value of 0), and a one-, two- or three-dimensional
108 * mesh (indicated by a value of 1, 2 or 3 respectively.) Note that this argument
109 * overrides the ARCHITECTURE parameter.
110 * 13. ndims tot. Type int. If architecture is zero, indicating a hypercube, this
111 * value is the number of dimensions in the hypercube.
112 * 14. mesh dims. Type int array of size 3. If architecture is 1, 2 or 3, indicating a
113 * mesh, the values in this array denote the size of the mesh in each dimension.
114 * 15. goal. Type double *. This optional array speci es the desired sizes of the
115 * di erent sets. The total number of sets is implicit in the architectural speci -
116 * cations provided by the preceding three parameters. If a null value is passed
117 * for goal, the code will try to make each set have the same vertex weight sum.
118 * If it is not null, the goal array should be as long as the total number of sets.
119 * The value in goal i] (or, for Fortran, goal(i + 1)) should be the desired sum
120 * of vertex weights of vertices assigned to set i. Note that set numbers begin
121 * at zero. Chaco will try to get as close to this goal as possible, but may not
122 * succeed exactly. The sum of all the goals should equal the sum of all the vertex
123 * weights, and values should be nonnegative.
124 * Although the default is to make all set sizes equal, there are applications where
125 * this may be undesirable. One example would be if you are decomposing a
126 * computation among processors of di erent speeds. All the code in Chaco
127 * handles this more general case, and should work for any consistent values in
128 * goal.
129 *
130 * E. Partitioning options.
131 * 16. global method. Type int. This argument speci es the global partitioning
132 * method and should have a value from 1 and 7. These values are the same
133 * as those on the "Global method" menu when running Chaco in standalone
134 * method, as reviewed in x5.4.
135 *
136 * 17. local method. Type int. This argument speci es the local
137 * partitioning method and should have a value of 1 or 2. These
138 * values are the same as those on the "Local method" menu when
139 * running Chaco in stand{alone method, as reviewed in x5.4.
140 *
141 * 18. rqi flag. Type int. If you requested spectral partitioning and wish to use the
142 * multilevel RQI/Symmlq eigensolver, this argument should be set to 1. If you
143 * wish instead to use Lanczos, it should be set to 0.
144 *
145 * 19. vmax. Type int. If you are using either the multilevel-KL partitioner, or
146 * the multilevel RQI/Symmlq eigensolver, you need to specify when the coarsest
147 * graph is small enough. When a coarse graph has no more than vmax vertices,
148 * the recursive coarsening is finished.
149 * 20. ndims. Type int. This argument should have a value of 1, 2 or 3 indicating
150 * partitioning by bisection, quadrisection or octasection.
151 * 21. eigtol. Type double. If you are using a spectral method or multilevel-KL,
152 * this argument specifies the tolerance you request for the eigensolver. A
153 * discussion of an appropriate choice can be found in the description of the
154 * EIGEN TOLERANCE parameter in x6.2. Note that this argument overrides the
155 * value of the EIGEN TOLERANCE parameter.
156 * 22. seed. Type long. This is a seed for the random number generator "rand()".
157 * Note that it overrides the RANDOM SEED parameter.
158 */
159 #ifdef __cplusplus
160 extern "C" {
161 #endif
162
163 #include <stdio.h>
164
165 #ifdef _MSC_VER
166 #define INTER_FACE interFace
167 #else
168 #define INTER_FACE interface
169 #endif
170
171 extern int INTER_FACE(int nvtxs, /**< number of vertices in full graph */
172 int *start, /**< start of edge list for each vertex */
173 int *adjacency, /**< edge list data */
174 int *vwgts, /**< weights for all vertices */
175 float *ewgts, /**< weights for all edges */
176 float *x, float *y, float *z, /**< coordinates for inertial method */
177 char *outassignname, /**< name of assignment output file */
178 char *outfilename, /**< output file name */
179 int *assignment, /**< set number of each vtx (length n) */
180 int architecture, /**< 0 => hypercube, d => d-dimensional mesh */
181 int ndims_tot, /**< total number of cube dimensions to divide */
182 int mesh_dims[3], /**< dimensions of mesh of processors */
183 double *goal, /**< desired set sizes for each set */
184 int global_method, /**< global partitioning algorithm */
185 int local_method, /**< local partitioning algorithm */
186 int rqi_flag, /**< should I use RQI/Symmlq eigensolver? */
187 int vmax, /**< how many vertices to coarsen down to? */
188 int ndims, /**< number of eigenvectors (2^d sets) */
189 double eigtol, /**< tolerance on eigenvectors */
190 long seed); /**< for random graph mutations */
191
192 /* Chaco interface to read assignment vector from file */
193 extern int input_assign(FILE *, char *, int, int *);
194
195 #define CHACO_VERSION_MAJOR 3
196 #define CHACO_VERSION_MINOR 0
197 #define CHACO_VERSION_PATCH 0
198
199 #ifdef __cplusplus
200 } /* close brackets on extern "C" declaration */
201 #endif