Skip to content

Commit

Permalink
Add kaval support.
Browse files Browse the repository at this point in the history
  • Loading branch information
niklas-uhl committed Jun 27, 2024
1 parent f4e9574 commit 62e3d75
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "external/KaGen"]
path = external/KaGen
url = https://github.com/KarlsruheGraphGeneration/KaGen.git
[submodule "kaval"]
path = kaval
url = https://github.com/niklas-uhl/kaval
15 changes: 15 additions & 0 deletions eval.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env Rscript
library(plyr, warn.conflict = FALSE)
library(dplyr, warn.conflict = FALSE)

aggregator <- function(df) data.frame(AvgTime = mean(df$LabelProbTime, na.rm = TRUE))
load <- function(file) ddply(read.csv(file), "Graph", aggregator)

mpi <- load("PlainMPI.csv")
kamping <- load("KaMPIngWrapper.csv")
kaminpar <- load("dKaMinParWrapper.csv")

cat("PlainMPI:\t\t", mean(mpi$AvgTime), "\n")
cat("KaMPIngWrapper:\t\t", mean(kamping$AvgTime), "\n")
cat("dKaMinParWrapper:\t", mean(kaminpar$AvgTime), "\n")

1 change: 1 addition & 0 deletions kaval
Submodule kaval added at f01703
15 changes: 15 additions & 0 deletions label_propagation.suite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: label_propagation
executable: KaMPIngLabelPropagation
ncores: [1, 2, 4, 8, 16, 48, 192, 768, 3072]
time_limit: 60
threads_per_rank: [1]
graphs:
- generator: kagen
type: rgg2d
N: 20
M: 25
scale_weak: TRUE
config:
- preset: [mpi, kamping, kaminpar]
k: [16]
seed: [1, 2, 3]
30 changes: 30 additions & 0 deletions logs2results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
log_dir="${1:-"."}"

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

configs_for_algo() {
cat $log_dir/config.json | \
jq ' to_entries | group_by(.value.preset) | map({key: .[0].value.preset, value: [.[] | .key]}) | from_entries' | jq -r " .[\"$1\"] | join (\" \")"
}


parse_logs() {
gawk -f "$SCRIPT_DIR/parse_logfile.awk" <(
for x in $(configs_for_algo $1); do
for file in $log_dir/*-c$x-log.txt; do
# echo $file
echo "__BEGIN_FILE__" $(basename "$file")
cat "$file" | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g"
echo "__END_FILE__"
done
done
)
}

parse_logs "mpi" > PlainMPI.csv
parse_logs "kamping" > KaMPIngWrapper.csv
parse_logs "kaminpar" > dKaMinParWrapper.csv

exit 0

2 changes: 1 addition & 1 deletion main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ int main(int argc, char* argv[]) {
"kamping-dispatch", "kamping", "kamping-sparse",
"kaminpar"}))
->required();
cli.add_option("-G,--graph", app.graph_filename)->required();
cli.add_option("-G,--graph,--kagen_option_string", app.graph_filename)->required();

cli.add_option("-k,--k", app.k, "Number of blocks in the partition.")
->capture_default_str();
Expand Down
107 changes: 107 additions & 0 deletions parse_logfile.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# -*-awk-*-
BEGIN {
header()
reset()
}

/__BEGIN_FILE__/ {
sub(/__BEGIN_FILE__ /, "", $0)
split($0, parts, "___")
data["Graph"] = parts[1]

split(parts[2], parts, "_")
for (i in parts) {
if (match(parts[i], /k([0-9]+)/, m)) {
data["K"] = m[1]
} else if (match(parts[i], /P([0-9]+)x([0-9]+)x([0-9]+)/, m)) {
data["NumNodes"] = m[1]
data["NumMPIsPerNode"] = m[2]
data["NumThreadsPerMPI"] = m[3]
} else if (match(parts[i], /seed([0-9]+)/, m)) {
data["Seed"] = m[1]
} else if (match(parts[i], /eps([0-9\.\-e]+)/, m)) {
data["Epsilon"] = m[1]
}
}

level = 0
}

/__END_FILE__/ {
yield()
}

match($0, /Number of global nodes: *([0-9]+)/, m) {
data["N"] = m[1]
}

match($0, /Number of global edges: *([0-9]+)/, m) {
data["M"] = m[1]
}

match($0, /Seed: *([0-9]+)/, m) {
data["Seed"] = m[1]
}

match($0, /Partition summary:/, m) {
Summary = 1
}

match($0, /Imbalance: *([0-9\.\-e]+)/, m) {
data["Balance"] = m[1]
}

match($0, /Edge cut: *([0-9]+)/, m) {
data["Cut"] = m[1]
}

match($0, /\|- Partitioning: \.* ([0-9\.\-e]+) s/, m) {
data["Time"] = m[1]
}
match($0, /`- Partitioning: \.* ([0-9\.\-e]+) s/, m) {
data["Time"] = m[1]
}

match($0, /\|- Label propagation clustering: \.* ([0-9\.\-e]+) s/, m) {
data["LPTime"] = m[1]
}

END {
yield()
}

function header() {
printf "Graph,"
printf "K,"
printf "Seed,"
printf "Cut,"
printf "Epsilon,"
printf "Balance,"
printf "TotalTime,"
printf "LabelProbTime,"
printf "NumNodes"
printf "\n"
}

function yield() {
if (length(data) == 0) {
return
}

printf "%s,", data["Graph"]
printf "%d,", data["K"]
printf "%d,", data["Seed"]
printf "%d,", data["Cut"]
printf "%f,", data["Epsilon"]
printf "%f,", data["Balance"]
printf "%f,", data["Time"]
printf "%f,", data["LPTime"]
printf "%d", data["NumNodes"]
printf "\n"

reset()
}

function reset() {
split("", data)
}

0 comments on commit 62e3d75

Please sign in to comment.