| 529 | #endif |
| 530 | |
| 531 | void internal_processmapping_call(PartitionConfig & partition_config, |
| 532 | bool suppress_output, |
| 533 | int* n, |
| 534 | int* vwgt, |
| 535 | kahip_idx* xadj, |
| 536 | kahip_idx* adjcwgt, |
| 537 | kahip_idx* adjncy, |
| 538 | int mode_mapping, |
| 539 | double* imbalance, |
| 540 | kahip_idx* edgecut, |
| 541 | int* qap, |
| 542 | int* part) { |
| 543 | |
| 544 | //streambuf* backup = cout.rdbuf(); |
| 545 | //ofstream ofs; |
| 546 | //ofs.open("/dev/null"); |
| 547 | //if(suppress_output) { |
| 548 | //cout.rdbuf(ofs.rdbuf()); |
| 549 | //} |
| 550 | |
| 551 | partition_config.imbalance = 100*(*imbalance); |
| 552 | graph_access G; |
| 553 | internal_build_graph( partition_config, n, vwgt, xadj, adjcwgt, adjncy, G); |
| 554 | |
| 555 | graph_partitioner partitioner; |
| 556 | if( mode_mapping == MAPMODE_BISECTION ) { |
| 557 | partitioner.perform_partitioning(partition_config, G); |
| 558 | } else { |
| 559 | partitioner.perform_partitioning_krec_hierarchy(partition_config, G); |
| 560 | } |
| 561 | |
| 562 | forall_nodes(G, node) { |
| 563 | part[node] = G.getPartitionIndex(node); |
| 564 | } endfor |
| 565 | |
| 566 | quality_metrics qm; |
| 567 | *edgecut = qm.edge_cut(G); |
| 568 | |
| 569 | int internal_qap = 0; |
| 570 | //check if k is a power of 2 |
| 571 | bool power_of_two = (partition_config.k & (partition_config.k-1)) == 0; |
| 572 | std::vector< NodeID > perm_rank(partition_config.k); |
| 573 | graph_access C; |
| 574 | complete_boundary boundary(&G); |
| 575 | boundary.build(); |
| 576 | boundary.getUnderlyingQuotientGraph(C); |
| 577 | |
| 578 | forall_nodes(C, node) { |
| 579 | C.setNodeWeight(node, 1); |
| 580 | } endfor |
| 581 | |
| 582 | if(!power_of_two ) { |
| 583 | mapping_algorithms ma; |
| 584 | if( partition_config.distance_construction_algorithm != DIST_CONST_HIERARCHY_ONLINE) { |
| 585 | normal_matrix D(partition_config.k, partition_config.k); |
| 586 | ma.construct_a_mapping(partition_config, C, D, perm_rank); |
| 587 | internal_qap = qm.total_qap(C, D, perm_rank ); |
| 588 | } else { |
no test coverage detected