Skip to content

Commit

Permalink
fix tools
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Maas committed Dec 19, 2024
1 parent 91f8817 commit ce2e7ba
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ target_link_libraries(BenchShuffle MtKaHyPar-ToolsMin)
add_executable(MtxToGraph mtx_to_graph.cc)
target_link_libraries(MtxToGraph MtKaHyPar-BuildFlags)

add_executable(FixedVertexFileGenerator fixed_vertex_file_generator.cc)
target_link_libraries(FixedVertexFileGenerator MtKaHyPar-ToolsMin)


#################################################################
## Tools with more dependencies ##
Expand Down Expand Up @@ -66,6 +69,3 @@ target_link_libraries(EvaluatePartition MtKaHyPar-BuildTools)

add_executable(VerifyPartition verify_partition.cc)
target_link_libraries(VerifyPartition MtKaHyPar-BuildTools)

add_executable(FixedVertexFileGenerator fixed_vertex_file_generator.cc)
target_link_libraries(FixedVertexFileGenerator MtKaHyPar-BuildTools)
12 changes: 10 additions & 2 deletions tools/fixed_vertex_file_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#include "mt-kahypar/macros.h"
#include "mt-kahypar/datastructures/hypergraph_common.h"
#include "mt-kahypar/io/hypergraph_io.h"
#include "mt-kahypar/utils/randomize.h"

namespace po = boost::program_options;
Expand Down Expand Up @@ -60,7 +59,16 @@ int main(int argc, char* argv[]) {
po::notify(cmd_vm);

std::vector<PartitionID> partition;
io::readPartitionFile(partition_file, partition);
std::ifstream file(partition_file);
if (file) {
int part;
while (file >> part) {
partition.push_back(part);
}
file.close();
} else {
ERR("File not found:" << partition_file);
}

int threshold = percentage * 1000;
std::string fixed_vertex_file = partition_file;
Expand Down
2 changes: 1 addition & 1 deletion tools/one_to_one_mapping.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ int main(int argc, char* argv[]) {

// Read Partition
std::vector<PartitionID> partition;
io::readPartitionFile(context.partition.graph_partition_filename, partition);
io::readPartitionFile(context.partition.graph_partition_filename, hg.initialNumNodes(), partition);
PartitionedHypergraph partitioned_hg(context.partition.k, hg, parallel_tag_t { });
partitioned_hg.doParallelForAllNodes([&](const HypernodeID& hn) {
partitioned_hg.setOnlyNodePart(hn, partition[hn]);
Expand Down
2 changes: 1 addition & 1 deletion tools/verify_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ using PartitionedHypergraph = ds::PartitionedHypergraph<Hypergraph, ds::Connecti
bool readPartitionFile(const std::string& partition_file, PartitionedHypergraph& hypergraph) {
bool success = true;
std::vector<PartitionID> partition;
mt_kahypar::io::readPartitionFile(partition_file, partition);
mt_kahypar::io::readPartitionFile(partition_file, hypergraph.initialNumNodes(), partition);
for ( const HypernodeID& hn : hypergraph.nodes() ) {
if ( partition[hn] == kInvalidPartition ) {
LOG << RED << "[ERROR]" << END << "Hypernode" << hn << "is not assigned to a block";
Expand Down
2 changes: 1 addition & 1 deletion tools/verify_target_graph_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int main(int argc, char* argv[]) {

// Read Partition
std::vector<PartitionID> partition;
io::readPartitionFile(context.partition.graph_partition_filename, partition);
io::readPartitionFile(context.partition.graph_partition_filename, hg.initialNumNodes(), partition);
PartitionedHypergraph partitioned_hg(context.partition.k, hg, parallel_tag_t { });
partitioned_hg.doParallelForAllNodes([&](const HypernodeID& hn) {
partitioned_hg.setOnlyNodePart(hn, partition[hn]);
Expand Down

0 comments on commit ce2e7ba

Please sign in to comment.