Commit 995128e0 authored by Justin Borromeo's avatar Justin Borromeo
Browse files

Cleaned-up square partitioning results

parent af78ed2d
---
title: "Untitled"
author: "Justin Borromeo"
date: "06/12/2020"
output: pdf_document
---
```{r}
knitr::opts_chunk$set(echo = TRUE)
library("dplyr")
library("stringr")
library("ggplot2")
rm(list = ls())
```
```{r}
linear_results = read.csv('../resulting_csv/cma.csv', header=TRUE, sep=',')
# Filter out squeezenet results
linear_results = filter(linear_results, !grepl('squeeze', topology))
# Filter out infeasible solns
linear_results_filtered = filter(linear_results, feasable==1) %>%
arrange(desc(time_taken)) %>%
subset(select=c(time_taken, topology, partitions, evo_counter))
head(linear_results_filtered, n=20)
```
```{r}
packing_results = read.csv('../resulting_csv/cma_logmore_sq_full_evo_packing.csv',
header=FALSE,
sep=',')
names(packing_results) = c('target',
'evo_counter',
'partitions',
'topology',
'feasible',
'tp_partition',
'latency_partition',
'tp_fullmap',
'latency_fm',
'tp_gain',
'latency_penalty',
'best_layer_partition',
'best_resource_partition',
'time_taken',
'sigma',
'seed',
'valid_sampling_percentage',
'trial',
'popsize',
'res_unit',
'seeding_type',
'packing_strategy',
'png_filename')
packing_results_filtered = filter(packing_results, feasible==1) %>%
arrange(desc(time_taken)) %>%
subset(select=c(time_taken, topology, partitions, evo_counter))
head(packing_results_filtered, n=10)
```
```{r}
linear_results_feasible = filter(linear_results, feasable==1)
# Greedy partition sizing, penalty
packing_results_penalty = filter(packing_results, packing_strategy=='overflow_penalty') %>% filter(feasible==1)
```
```{r}
packing_runtimes = filter(packing_results_penalty,
topology=="googlenet.csv" |
topology == 'resnet_50_v1.csv') %>%
group_by(topology, partitions) %>%
summarize(max_runtime = max(time_taken))
linear_runtimes = filter(linear_results_feasible,
topology=='googlenet.csv' |
topology == 'resnet_50_v1.csv') %>%
group_by(topology, partitions) %>%
summarize(max_runtime = max(time_taken))
```
```{r}
linear_runtimes_copy = cbind(linear_runtimes)
linear_runtimes_copy[c("topology")] <- lapply(linear_runtimes_copy[c("topology")], function(x) paste(str_replace(x, ".csv", ""), "9x1920"))
packing_runtimes_copy = cbind(packing_runtimes)
packing_runtimes_copy[c("topology")] <- lapply(packing_runtimes_copy[c("topology")], function(x) paste(str_replace(x, ".csv", ""), "129x129"))
new <- rbind(packing_runtimes_copy, linear_runtimes_copy)
ggplot(new, aes(partitions, max_runtime, colour=topology)) +
geom_line() +
geom_point() +
xlab("K = number of partitions") +
ylab("Runtime (s)") +
ggtitle("Partitioning Algorithm Runtime vs. K") +
theme(plot.title = element_text(hjust = 0.5)) +
ylim(c(0, 1500))
```
```{r}
# Greedy partition sizing, penalty
packing_results_penalty = filter(packing_results, packing_strategy=='overflow_penalty')
linear_runtimes_copy = cbind(linear_runtimes)
linear_runtimes_copy[c("topology")] <- lapply(linear_runtimes_copy[c("topology")], function(x) paste(x, "(Linear)"))
packing_runtimes_copy = cbind(packing_runtimes)
packing_runtimes_copy[c("topology")] <- lapply(packing_runtimes_copy[c("topology")], function(x) paste(x, "(Packed)"))
packing_max_evo = packing_results_penalty %>% group_by(topology, partitions) %>% summarize(max_evo = max(evo_counter)) %>% filter(topology == 'googlenet.csv' | topology == 'resnet_50_v1.csv')
linear_max_evo = linear_results %>% group_by(topology, partitions) %>% summarize(max_evo = max(evo_counter)) %>% filter(topology == 'googlenet.csv' | topology == 'resnet_50_v1.csv')
linear_max_evo[c("topology")] <- lapply(linear_max_evo[c("topology")], function(x) paste(str_replace(x, ".csv", ""), "9x1920"))
packing_max_evo[c("topology")] <- lapply(packing_max_evo[c("topology")], function(x) paste(str_replace(x, ".csv", ""), "129x129"))
max_evos = rbind(linear_max_evo, packing_max_evo)
ggplot(max_evos, aes(partitions, max_evo, colour=topology)) +
geom_line() +
geom_point() +
xlab("K = number of partitions") +
ylab("Max Evolution Number") +
ggtitle("Max Evolution Num. vs. K") +
theme(plot.title = element_text(hjust = 0.5)) +
ylim(c(0, 300))
```
\ No newline at end of file
---
title: "Square Partitioning Results"
author: "Justin Borromeo"
date: "21/12/2020"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library("dplyr")
library("stringr")
library("ggplot2")
rm(list = ls())
```
```{r}
packing_output_cols = c('target',
'evo_counter',
'partitions',
'topology',
'feasible',
'tp_partition',
'latency_partition',
'tp_fullmap',
'latency_fm',
'tp_gain',
'latency_penalty',
'best_layer_partition',
'best_resource_partition',
'time_taken',
'sigma',
'seed',
'valid_sampling_percentage',
'trial',
'popsize',
'res_unit',
'seeding_type',
'packing_strategy',
'png_filename')
```
```{r}
# Parses the partition string and sums the squares of each partition size
partitionResourcesToTotalUnitsSq = function(resources_str) {
resources_str = substr(resources_str, 2, nchar(resources_str) - 1)
resources_list = as.list(strsplit(resources_str, ","))
resources_list = lapply(resources_list, function(x) strtoi(x))[[1]]
resources_list_sq = resources_list^2
return(sum(resources_list_sq)[[1]])
}
# Test (expect 1400)
partitionResourcesToTotalUnitsSq("[10, 20, 30]")
```
latency_partition: end-to-end latency [Cycles]
tp_partition: slowest partition throughput [1/Cycles]
```{r}
# Filter out squeezenet results and infeasible solns
# Mobilenet in another script
linear_results = read.csv('../resulting_csv/cma.csv', header=TRUE, sep=',') %>%
rename(feasible=feasable) %>%
filter(feasible==1 & target=='DRAM_cycle' & !grepl('squeeze', topology))
packing_results_sans_mobilenet =
read.csv('../resulting_csv/cma_logmore_sq_full_evo_packing.csv',
header=FALSE, sep=',')
names(packing_results_sans_mobilenet) = packing_output_cols
packing_results_sans_mobilenet =
packing_results_sans_mobilenet %>%
filter(feasible==1 & target=='DRAM_cycle' & !grepl('mobilenet', topology))
packing_results_mobilenet =
read.csv('../resulting_csv/cma_logmore_sq_full_evo_packing_mobile.csv',
header=FALSE, sep=',')
names(packing_results_mobilenet) = packing_output_cols
packing_results_mobilenet =
packing_results_mobilenet %>%
filter(feasible==1 & target=='DRAM_cycle')
packing_results =
rbind(packing_results_sans_mobilenet, packing_results_mobilenet)
# Clean the .csvs
linear_results[c("topology")] <- lapply(linear_results[c("topology")],
function(x) str_replace(x, ".csv", ""))
packing_results[c("topology")] <- lapply(packing_results[c("topology")],
function(x) str_replace(x, ".csv", ""))
linear_results$packing_strategy='1D'
linear_results$png_filename=''
linear_results$units_used=17280
# Full 17280 is allocated
linear_results$percentage_wasted=0
packing_results$units_used=
sapply(packing_results$best_resource_partition,
function(x) partitionResourcesToTotalUnitsSq(x))
# This excludes quantization (17280-129^2) wastage; it only includes
# wastage due to packing.
packing_results$percentage_wasted=100*(129^2 - packing_results$units_used)/(129^2)
```
Square full-map baseline grouped by (partition, topology)
```{r}
fullmap_square_baseline = packing_results %>%
group_by(topology, partitions) %>%
summarize(max_tp_fm=max(tp_fullmap),
min_latency_fm=min(latency_fm))
```
Combine square baseline with approach results. Both packing_results and
linear_results now have columns max_tp_fm and min_latency_fm.
```{r}
linear_results = linear_results %>%
left_join(fullmap_square_baseline, by=c("topology", "partitions"))
packing_results = packing_results %>%
left_join(fullmap_square_baseline, by=c("topology", "partitions"))
```
We now calculate the throughput gain of the solutions with respect to the
square array baseline (every layer is assigned to the full 129x129 array).
Calculate latency penalty and throughput gain vs. square baseline
```{r}
linear_results$latency_penalty =
linear_results$latency_partition/linear_results$min_latency_fm
packing_results$latency_penalty =
packing_results$latency_partition/packing_results$min_latency_fm
linear_results$tp_gain = linear_results$tp_partition/linear_results$max_tp_fm
packing_results$tp_gain = packing_results$tp_partition/packing_results$max_tp_fm
```
```{r}
results = rbind(linear_results, packing_results)
```
What is the tradeoff between throughput and latency?
At what point does partitioning stop helping?
Plot latency penalty vs. throughput gain at the highest throughput gain partition for each (topology, partition count) pair for all topologies with no penalty.
```{r}
getLatencyPenaltyVsThroughputGain <- function(results_df) {
return(results_df %>% group_by(topology, partitions, packing_strategy) %>%
slice(which.max(tp_gain)))
}
lp_vs_tg_no_penalty = getLatencyPenaltyVsThroughputGain(
results %>% filter(packing_strategy=='no_penalty'))
ggplot(lp_vs_tg_no_penalty, aes(tp_gain, latency_penalty, color=topology)) +
geom_line() +
geom_point() +
xlab("Throughput Gain") +
ylab("Latency Penalty")
```
How much improvement does square offer over 9x1920?
How much performance do we lose because of packing?
Does penalty for wastage improve solution quality?
Comparison of throughput-latency curves between approaches for GoogleNet
```{r}
lp_vs_tg_goog = getLatencyPenaltyVsThroughputGain(
results %>% filter(topology=='googlenet'))
ggplot(lp_vs_tg_goog, aes(tp_gain, latency_penalty, color=packing_strategy)) +
geom_line() +
geom_point() +
xlab("Throughput Gain") +
ylab("Latency Penalty") +
expand_limits(x=0, y=0)
```
Comparison of throughput-latency curves between approaches for Mobilenet
```{r}
lp_vs_tg_mob = getLatencyPenaltyVsThroughputGain(
results %>% filter(topology=='mobilenet'))
ggplot(lp_vs_tg_mob, aes(tp_gain, latency_penalty, color=packing_strategy)) +
geom_line() +
geom_point() +
xlab("Throughput Gain") +
ylab("Latency Penalty") +
expand_limits(x=0, y=0)
```
Resource usage vs. K for GoogleNet and MobileNet by approach
```{r}
getResourceUsageVsK = function(results_df) {
return(results_df %>%
group_by(topology, partitions, packing_strategy) %>%
slice(which.max(tp_gain)))
}
resource_usage_vs_k_goog = getResourceUsageVsK(
results %>% filter((topology=='googlenet'|topology=='mobilenet') & (
packing_strategy=='no_penalty'|packing_strategy=='overflow_penalty')))
ggplot(resource_usage_vs_k_goog, aes(partitions,
percentage_wasted,
color=topology,
linetype=packing_strategy,
shape=packing_strategy)) +
geom_line() +
geom_point() +
xlab("Num. Partitions") +
ylab("% Array Units Wasted") +
expand_limits(x=0, y=0)
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment