cmdline_ndmetis.c
Go to the documentation of this file.
1 
10 #include "metisbin.h"
11 
12 
13 /*-------------------------------------------------------------------
14  * Command-line options
15  *-------------------------------------------------------------------*/
16 static struct gk_option long_options[] = {
17  {"ctype", 1, 0, METIS_OPTION_CTYPE},
18  {"iptype", 1, 0, METIS_OPTION_IPTYPE},
19  {"rtype", 1, 0, METIS_OPTION_RTYPE},
20  {"ufactor", 1, 0, METIS_OPTION_UFACTOR},
21  {"pfactor", 1, 0, METIS_OPTION_PFACTOR},
22  {"nocompress", 0, 0, METIS_OPTION_COMPRESS},
23  {"ccorder", 0, 0, METIS_OPTION_CCORDER},
24  {"no2hop", 0, 0, METIS_OPTION_NO2HOP},
25  {"nooutput", 0, 0, METIS_OPTION_NOOUTPUT},
26  {"niter", 1, 0, METIS_OPTION_NITER},
27  {"nseps", 1, 0, METIS_OPTION_NSEPS},
28  {"seed", 1, 0, METIS_OPTION_SEED},
29  {"dbglvl", 1, 0, METIS_OPTION_DBGLVL},
30  {"help", 0, 0, METIS_OPTION_HELP},
31  {0, 0, 0, 0}
32 };
33 
34 
36  {"rm", METIS_CTYPE_RM},
37  {"shem", METIS_CTYPE_SHEM},
38  {NULL, 0}
39 };
40 
42  {"edge", METIS_IPTYPE_EDGE},
43  {"node", METIS_IPTYPE_NODE},
44  {NULL, 0}
45 };
46 
48  {"2sided", METIS_RTYPE_SEP2SIDED},
49  {"1sided", METIS_RTYPE_SEP1SIDED},
50  {NULL, 0}
51 };
52 
53 
54 
55 /*-------------------------------------------------------------------
56  * Mini help
57  *-------------------------------------------------------------------*/
58 static char helpstr[][100] =
59 {
60 " ",
61 "Usage: ndmetis [options] <filename>",
62 " ",
63 " Required parameters",
64 " filename Stores the graph to be partitioned.",
65 " ",
66 " Optional parameters",
67 " -ctype=string",
68 " Specifies the scheme to be used to match the vertices of the graph",
69 " during the coarsening.",
70 " The possible values are:",
71 " rm - Random matching",
72 " shem - Sorted heavy-edge matching [default]",
73 " ",
74 " -iptype=string [applies only when -ptype=rb]",
75 " Specifies the scheme to be used to compute the initial bisection",
76 " of the graph.",
77 " The possible values are:",
78 " edge - Separator from an edge cut",
79 " node - Separator from a greedy node-based strategy [default]",
80 " ",
81 " -rtype=string",
82 " Specifies the scheme to be used for refinement.",
83 " The possible values are:",
84 " 1sided - 1-sided node-based refinement [default]",
85 " 2sided - 2-sided node-based refinement",
86 " ",
87 " -ufactor=int",
88 " Specifies the maximum allowed load imbalance between the left and",
89 " right partitions during each bisection. The load imbalanced is",
90 " measured as the ratio of the 2*max(left,right)/(left+right), where",
91 " left and right are the sizes of the respective partitions. ",
92 " A value of x indicates that the allowed load imbalance is 1+x/1000.",
93 " Default is 200, indicating a load imbalance of 1.20.",
94 " ",
95 " -pfactor=int",
96 " Specifies the minimum degree of the vertices that will be ordered ",
97 " last. If the specified value is x>0, then any vertices with a degree",
98 " greater than 0.1*x*(average degree) are removed from the graph, an",
99 " ordering of the rest of the vertices is computed, and an overall ",
100 " ordering is computed by ordering the removed vertices at the end ",
101 " of the overall ordering.",
102 " Default value is 0, indicating that no vertices are removed",
103 " ",
104 " -no2hop",
105 " Specifies that the coarsening will not perform any 2-hop matchings",
106 " when the standard matching fails to sufficiently contract the graph.",
107 " ",
108 " -nocompress",
109 " Specifies that the graph should not be compressed by combining",
110 " together vertices that have identical adjacency lists.",
111 " ",
112 " -ccorder",
113 " Specifies if the connected components of the graph should first be ",
114 " identified and ordered separately.",
115 " ",
116 " -niter=int",
117 " Specifies the maximum number of iterations for the refinement ",
118 " algorithms at each stage of the uncoarsening process. Default is 10.",
119 " ",
120 " -nseps=int",
121 " Specifies the number of different separators that it will compute at",
122 " each level of the nested dissection. The final separator that is used",
123 " is the smallest one. Default is 1.",
124 " ",
125 " -nooutput",
126 " Specifies that no ordering file should be generated.",
127 " ",
128 " -seed=int",
129 " Selects the seed of the random number generator. ",
130 " ",
131 " -dbglvl=int ",
132 " Selects the dbglvl. ",
133 " ",
134 " -help",
135 " Prints this message.",
136 ""
137 };
138 
139 static char shorthelpstr[][100] = {
140 " ",
141 " Usage: ndmetis [options] <filename>",
142 " use 'ndmetis -help' for a summary of the options.",
143 ""
144 };
145 
146 
147 
148 /*************************************************************************/
150 /*************************************************************************/
151 params_t *parse_cmdline(int argc, char *argv[])
152 {
153  int i, j, k;
154  int c, option_index;
155  params_t *params;
156 
157  params = (params_t *)gk_malloc(sizeof(params_t), "parse_cmdline");
158  memset((void *)params, 0, sizeof(params_t));
159 
160  /* initialize the params data structure */
161  params->ctype = METIS_CTYPE_SHEM;
162  params->iptype = METIS_IPTYPE_NODE;
163  params->rtype = METIS_RTYPE_SEP1SIDED;
164 
165  params->ufactor = OMETIS_DEFAULT_UFACTOR;
166  params->pfactor = 0;
167  params->compress = 1;
168  params->ccorder = 0;
169  params->no2hop = 0;
170 
171  params->nooutput = 0;
172  params->wgtflag = 1;
173 
174  params->nseps = 1;
175  params->niter = 10;
176 
177  params->seed = -1;
178  params->dbglvl = 0;
179 
180  params->filename = NULL;
181  params->nparts = 1;
182 
183 
184  gk_clearcputimer(params->iotimer);
185  gk_clearcputimer(params->parttimer);
186  gk_clearcputimer(params->reporttimer);
187 
188 
189  /* Parse the command line arguments */
190  while ((c = gk_getopt_long_only(argc, argv, "", long_options, &option_index)) != -1) {
191  switch (c) {
192  case METIS_OPTION_CTYPE:
193  if (gk_optarg)
194  if ((params->ctype = gk_GetStringID(ctype_options, gk_optarg)) == -1)
195  errexit("Invalid option -%s=%s\n", long_options[option_index].name, gk_optarg);
196  break;
197  case METIS_OPTION_IPTYPE:
198  if (gk_optarg)
199  if ((params->iptype = gk_GetStringID(iptype_options, gk_optarg)) == -1)
200  errexit("Invalid option -%s=%s\n", long_options[option_index].name, gk_optarg);
201  break;
202 
203  case METIS_OPTION_RTYPE:
204  if (gk_optarg)
205  if ((params->rtype = gk_GetStringID(rtype_options, gk_optarg)) == -1)
206  errexit("Invalid option -%s=%s\n", long_options[option_index].name, gk_optarg);
207  break;
208 
210  if (gk_optarg) params->ufactor = (idx_t)atoi(gk_optarg);
211  break;
212 
214  if (gk_optarg) params->pfactor = (idx_t)atoi(gk_optarg);
215  break;
216 
218  params->compress = 0;
219  break;
220 
222  params->ccorder = 1;
223  break;
224 
225  case METIS_OPTION_NO2HOP:
226  params->no2hop = 1;
227  break;
228 
230  params->nooutput = 1;
231  break;
232 
233  case METIS_OPTION_NSEPS:
234  if (gk_optarg) params->nseps = (idx_t)atoi(gk_optarg);
235  break;
236  case METIS_OPTION_NITER:
237  if (gk_optarg) params->niter = (idx_t)atoi(gk_optarg);
238  break;
239 
240  case METIS_OPTION_SEED:
241  if (gk_optarg) params->seed = (idx_t)atoi(gk_optarg);
242  break;
243 
244  case METIS_OPTION_DBGLVL:
245  if (gk_optarg) params->dbglvl = (idx_t)atoi(gk_optarg);
246  break;
247 
248  case METIS_OPTION_HELP:
249  for (i=0; strlen(helpstr[i]) > 0; i++)
250  printf("%s\n", helpstr[i]);
251  exit(0);
252  break;
253  case '?':
254  default:
255  errexit("Illegal command-line option(s)\n"
256  "Use %s -help for a summary of the options.\n", argv[0]);
257  }
258  }
259 
260  if (argc-gk_optind != 1) {
261  printf("Missing parameters.");
262  for (i=0; strlen(shorthelpstr[i]) > 0; i++)
263  printf("%s\n", shorthelpstr[i]);
264  exit(0);
265  }
266 
267  params->filename = gk_strdup(argv[gk_optind++]);
268 
269  return params;
270 }
271 
272 
long_options
static struct gk_option long_options[]
Definition: cmdline_ndmetis.c:16
gk_optarg
char * gk_optarg
For communication arguments to the caller.
Definition: getopt.c:56
METIS_OPTION_UFACTOR
@ METIS_OPTION_UFACTOR
Definition: include/metis.h:287
METIS_OPTION_NOOUTPUT
@ METIS_OPTION_NOOUTPUT
Definition: include/metis.h:294
name
Annotation for function names.
Definition: attr.h:51
METIS_OPTION_SEED
@ METIS_OPTION_SEED
Definition: include/metis.h:279
METIS_OPTION_COMPRESS
@ METIS_OPTION_COMPRESS
Definition: include/metis.h:283
gk_strdup
char * gk_strdup(char *orgstr)
Duplicates a string.
Definition: string.c:372
METIS_IPTYPE_EDGE
@ METIS_IPTYPE_EDGE
Definition: include/metis.h:323
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
parse_cmdline
params_t * parse_cmdline(int argc, char *argv[])
Definition: cmdline_ndmetis.c:151
ctype_options
static gk_StringMap_t ctype_options[]
Definition: cmdline_ndmetis.c:35
errexit
void errexit(char *f_str,...)
Definition: error.c:53
params_t
Definition: fis.c:15
METIS_CTYPE_SHEM
@ METIS_CTYPE_SHEM
Definition: include/metis.h:316
helpstr
static char helpstr[][100]
Definition: cmdline_ndmetis.c:58
vanilla::params
static const SmartProjectionParams params
Definition: smartFactorScenarios.h:69
METIS_OPTION_NITER
@ METIS_OPTION_NITER
Definition: include/metis.h:277
gk_GetStringID
int gk_GetStringID(gk_StringMap_t *strmap, char *key)
Definition: string.c:519
gk_option
The structure that stores the information about the command-line options.
Definition: gk_getopt.h:28
gk_optind
int gk_optind
Index in ARGV of the next element to be scanned.
Definition: getopt.c:68
METIS_OPTION_IPTYPE
@ METIS_OPTION_IPTYPE
Definition: include/metis.h:274
OMETIS_DEFAULT_UFACTOR
#define OMETIS_DEFAULT_UFACTOR
Definition: libmetis/defs.h:55
METIS_OPTION_CTYPE
@ METIS_OPTION_CTYPE
Definition: include/metis.h:273
rtype_options
static gk_StringMap_t rtype_options[]
Definition: cmdline_ndmetis.c:47
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
metisbin.h
METIS_RTYPE_SEP1SIDED
@ METIS_RTYPE_SEP1SIDED
Definition: include/metis.h:334
METIS_OPTION_DBGLVL
@ METIS_OPTION_DBGLVL
Definition: include/metis.h:276
METIS_CTYPE_RM
@ METIS_CTYPE_RM
Definition: include/metis.h:315
METIS_OPTION_RTYPE
@ METIS_OPTION_RTYPE
Definition: include/metis.h:275
iptype_options
static gk_StringMap_t iptype_options[]
Definition: cmdline_ndmetis.c:41
METIS_RTYPE_SEP2SIDED
@ METIS_RTYPE_SEP2SIDED
Definition: include/metis.h:333
shorthelpstr
static char shorthelpstr[][100]
Definition: cmdline_ndmetis.c:139
METIS_OPTION_NO2HOP
@ METIS_OPTION_NO2HOP
Definition: include/metis.h:280
gk_clearcputimer
#define gk_clearcputimer(tmr)
Definition: gk_macros.h:32
gk_StringMap_t
Definition: gk_struct.h:119
METIS_IPTYPE_NODE
@ METIS_IPTYPE_NODE
Definition: include/metis.h:324
NULL
#define NULL
Definition: ccolamd.c:609
gk_getopt_long_only
int gk_getopt_long_only(int argc, char **argv, char *options, struct gk_option *long_options, int *opt_index)
Parse command-line arguments with only long options.
Definition: getopt.c:850
gk_malloc
void * gk_malloc(size_t nbytes, char *msg)
Definition: memory.c:140
METIS_OPTION_HELP
@ METIS_OPTION_HELP
Definition: include/metis.h:291
METIS_OPTION_PFACTOR
@ METIS_OPTION_PFACTOR
Definition: include/metis.h:285
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
idx_t
int32_t idx_t
Definition: include/metis.h:101
METIS_OPTION_CCORDER
@ METIS_OPTION_CCORDER
Definition: include/metis.h:284
METIS_OPTION_NSEPS
@ METIS_OPTION_NSEPS
Definition: include/metis.h:286


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:01:59