MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
chacowrap.cc File Reference
#include "mbconfig.h"
#include <vector>
#include <iostream>
#include "chacowrap.h"
Include dependency graph for chacowrap.cc:

Go to the source code of this file.

Functions

int interface (int nvtxs, int *start, int *adjacency, int *vwgts, float *ewgts, float *x, float *y, float *z, char *outassignname, char *outfilename, short *assignment, int architecture, int ndims_tot, int mesh_dims[3], double *goal, int global_method, int local_method, int rqi_flag, int vmax, int ndims, double eigtol, long seed)
 
void chaco_interface (const int iTotVertices, int *start, int *adjacency, int *vertex_weights, int *comm_weights, int *edge_weights, const int num_processors, int *pParAmgProcs)
 

Variables

int FREE_GRAPH
 

Function Documentation

void chaco_interface ( const int  iTotVertices,
int start,
int adjacency,
int vertex_weights,
int comm_weights,
int edge_weights,
const int  num_processors,
int pParAmgProcs 
)

Definition at line 63 of file chacowrap.cc.

References interface().

73 {
74  std::vector<short> set_assignment(iTotVertices);
75 
76  const int architecture(1), /* The computers are connected as a
77  * simple one-dimensional mesh
78  * 0 => hypercube, d => d-dimensional mesh */
79  global_method(2), /* Use Spectral decomposition */
80  local_method(1), /* With KL local refinement */
81  rqi_flag(0), /* Use Lanczos for solving the
82  * eigenvalue problem for spectral
83  * decomposition */
84  vmax(100), /* When to stop coarsening. Not used */
85  seed(7654321); /* A random number seed */
86  int mesh_dims[] = { /* if architecture > 0, mesh size goes here */
87  num_processors, 1, 1
88  };
89  double eigtol(1.e-3); /* */
90 
91  /* Chaco vertices are base 1 */
92  for (int i = 0; i < start[iTotVertices]; i++) {
93  adjacency[i]++;
94  }
95 
96  /* weights = 0 are not allowed */
97  std::vector<int> ivertex_weights(iTotVertices);
98  if (vertex_weights) {
99  for (int i = 0; i < iTotVertices; i++) {
100  /* trying to emulate communication weights? */
101  if (comm_weights) {
102  vertex_weights[i] += comm_weights[i];
103  }
104 
105  if (vertex_weights[i] == 0) {
106  ivertex_weights[i] = 1;
107  } else {
108  ivertex_weights[i] = vertex_weights[i];
109  }
110  }
111  }
112 
113  /* Chaco uses floats for the communication weights */
114  std::vector<float> fedge_weights(2*start[iTotVertices]);
115  if (edge_weights) {
116  for (int i = 0; i < iTotVertices; i++) {
117  fedge_weights[i] = edge_weights[i];
118  fedge_weights[start[iTotVertices] + i] = edge_weights[i];
119  }
120  }
121 
122  /* NOTE: don't free() adjacency !!! (default in Chaco 2.2) */
123  if (FREE_GRAPH) {
124  FREE_GRAPH = 0;
125  }
126 
127  int rc = interface(
128  iTotVertices, /* number of vertices in full graph */
129  start, /* start of edge list for each vertex */
130  adjacency, /* edge list data */
131  vertex_weights ? &ivertex_weights[0] : 0, /* weights for all vertices */
132  edge_weights ? &fedge_weights[0] : 0, /* weights for all edges */
133  NULL, /* coordinates for inertial method */
134  NULL, /* ... */
135  NULL, /* ... */
136  NULL, /* name of assignment output file */
137  NULL, /* output file name */
138  &set_assignment[0], /* set number of each vtx (length n) */
139  architecture, /* 0 => hypercube, d => d-dimensional mesh */
140  num_processors, /* total number of cube dimensions to divide */
141  mesh_dims, /* dimensions of mesh of processors */
142  NULL, /* desired set sizes for each set */
143  global_method, /* global partitioning algorithm */
144  local_method, /* local partitioning algorithm */
145  rqi_flag, /* should I use RQI/Symmlq eigensolver? */
146  vmax, /* how many vertices to coarsen down to? */
147  1, /* number of eigenvectors (2^d sets) */
148  eigtol, /* tolerance on eigenvectors */
149  seed /* for random graph mutations */
150  );
151 
152  /* Chaco vertices are base 1 */
153  for (int i = 0; i < start[iTotVertices]; i++) {
154  adjacency[i]--;
155  }
156 
157  if (rc != 0) {
158  silent_cerr("chaco_interface(): partition failed" << std::endl);
159  }
160 
161  for (int i = 0; i < iTotVertices; i++) {
162  pParAmgProcs[i] = set_assignment[i];
163  }
164 }
int interface(int nvtxs, int *start, int *adjacency, int *vwgts, float *ewgts, float *x, float *y, float *z, char *outassignname, char *outfilename, short *assignment, int architecture, int ndims_tot, int mesh_dims[3], double *goal, int global_method, int local_method, int rqi_flag, int vmax, int ndims, double eigtol, long seed)
int FREE_GRAPH
Definition: chacowrap.cc:60

Here is the call graph for this function:

int interface ( int  nvtxs,
int start,
int adjacency,
int vwgts,
float *  ewgts,
float *  x,
float *  y,
float *  z,
char *  outassignname,
char *  outfilename,
short *  assignment,
int  architecture,
int  ndims_tot,
int  mesh_dims[3],
double *  goal,
int  global_method,
int  local_method,
int  rqi_flag,
int  vmax,
int  ndims,
double  eigtol,
long  seed 
)

Referenced by chaco_interface().

Variable Documentation

int FREE_GRAPH

Definition at line 60 of file chacowrap.cc.