169 const RCP<const Environment> &env,
170 const RCP<
const Comm<int> > &comm,
172 const LocalOrderingSolution<typename Adapter::lno_t> *localSoln)
174 env->debug(DETAILED_STATUS,
"Entering orderingMetrics");
176 typedef StridedData<lno_t, scalar_t> input_t;
179 std::bitset<NUM_MODEL_FLAGS> modelFlags;
180 RCP<GraphModel<base_adapter_t> > graph;
181 const RCP<const base_adapter_t> bia =
182 rcp(
dynamic_cast<const base_adapter_t *
>(ia),
false);
183 graph = rcp(
new GraphModel<base_adapter_t>(bia,env,comm,modelFlags));
184 ArrayView<const gno_t> Ids;
185 ArrayView<input_t> vwgts;
186 ArrayView<const gno_t> edgeIds;
187 ArrayView<const offset_t> offsets;
188 ArrayView<input_t> wgts;
189 ArrayView<input_t> vtx;
190 graph->getEdgeList(edgeIds, offsets, wgts);
191 lno_t numVertex = graph->getVertexList(Ids, vwgts);
193 lno_t * perm = localSoln->getPermutationView();
198 for(
int checkRank = 0; checkRank < comm->getSize(); ++checkRank ) {
200 if( checkRank == comm->getRank() ) {
201 std::cout <<
"-----------------------------------------" << std::endl;
202 std::cout <<
"Inspect rank: " << checkRank << std::endl;
203 std::cout << std::endl;
205 Array<lno_t> oldMatrix(numVertex*numVertex);
206 Array<lno_t> newMatrix(numVertex*numVertex);
209 std::cout << std::endl <<
"perm: ";
210 for(lno_t n = 0; n < numVertex; ++n) {
211 std::cout <<
" " << perm[n] <<
" ";
214 lno_t * iperm = localSoln->getPermutationView(
true);
215 std::cout << std::endl <<
"iperm: ";
216 for(lno_t n = 0; n < numVertex; ++n) {
217 std::cout <<
" " << iperm[n] <<
" ";
219 std::cout << std::endl;
221 for (lno_t y = 0; y < numVertex; y++) {
222 for (offset_t n = offsets[y]; n < offsets[y+1]; ++n) {
223 lno_t x =
static_cast<lno_t
>(edgeIds[n]);
224 if (x < numVertex && y < numVertex) {
225 oldMatrix[x + y*numVertex] = 1;
226 newMatrix[perm[x] + perm[y]*numVertex] = 1;
232 std::cout << std::endl <<
"original graph in matrix form:" << std::endl;
233 for(lno_t y = 0; y < numVertex; ++y) {
234 for(lno_t x = 0; x < numVertex; ++x) {
235 std::cout <<
" " << oldMatrix[x + y*numVertex];
237 std::cout << std::endl;
241 std::cout << std::endl <<
"reordered graph in matrix form:" << std::endl;
242 for(lno_t y = 0; y < numVertex; ++y) {
243 for(lno_t x = 0; x < numVertex; ++x) {
244 std::cout <<
" " << newMatrix[x + y*numVertex];
246 std::cout << std::endl;
248 std::cout << std::endl;
261 for (lno_t j = 0; j < numVertex; j++) {
263 for (offset_t n = offsets[j]; n < offsets[j+1]; ++n) {
264 lno_t x =
static_cast<lno_t
>(edgeIds[n]);
270 lno_t delta_right = y2 - x2;
271 if (delta_right > bw_right) {
272 bw_right = delta_right;
274 lno_t delta_left = y2 - x2;
275 if (delta_left > bw_left) {
276 bw_left = delta_left;
280 if(delta_right > 0) {
281 envelope += delta_right;
284 envelope += delta_left;
291 bandwidth = (bw_left + bw_right + 1);
296 env->debug(DETAILED_STATUS,
"Exiting orderingMetrics");