-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph.R
190 lines (165 loc) · 6.12 KB
/
graph.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
library(tidyr)
library(ggplot2)
library(ggthemes)
library(tibble)
library(dplyr)
library(patchwork)
library(scales)
library(forcats)
theme_set(theme_clean())
# theme_set(theme_pander())
data1 <- read.csv("./results_1.csv", header = TRUE)
data2 <- read.csv("./results_2.csv", header = TRUE)
raw_data <- rbind(data1, data2)
# data <- gather(threads, ) %>%
# data <- gather(data, variable, value, sddm_time, diag_max_time, create_time, b_min_reduce_time) %>%
# data <- pivot_longer(data, c(sddm_time, diag_max_time, create_time, b_min_reduce_time, b_min_critical_time, b_min_tree_time), names_to = "variable", values_to = "value") %>%
# threads <- gather(data, variable, value, sddm_time, diag_max_time, create_time, b_min_reduce_time) %>%
# data <- gather(data, variable, value, limit) %>%
# select(variable, value, threads)
# data <- data[data$elements > 10000, ]
facet_labs <- c(
"radix" = "Radix sort",
"bitonic" = "Bitonic sort",
"counting" = "Counting sort",
"1050ti" = "1050ti",
"TITAN RTX" = "TITAN RTX",
"16x16" = "16x16",
"8x32" = "8x32",
"16x64" = "16x64",
"8x128" = "8x128",
"96x128" = "96x128",
"192x128" = "192x128",
"1x256" = "1x256",
"4x256" = "4x256",
"1x1024" = "1x1024",
"4x1024" = "4x1024",
"192x1024" = "192x1024",
"2" = "2",
"16" = "16",
"64" = "64",
"256" = "256",
"1024" = "1024"
)
my_theme <- theme(legend.title = element_text(size=9))
x_theme <- theme(
axis.text.x = element_text(
angle = 45,
vjust = 1,
hjust = 1,
size = 7
)
# ,axis.title.y = element_text(
# size = 10
# vjust = 1.5
# )
)
x_scale <- scale_x_discrete(breaks = c("10", "100", "1000", "10000", "100000", "1000000", "10000000", "100000000"))
y_scale <- scale_y_continuous(trans = "log2", labels = scientific)
raw_data$method <- factor(raw_data$method)
raw_data$size <- factor(raw_data$size)
raw_data$blocks <- factor(raw_data$blocks)
raw_data$threads <- factor(raw_data$threads)
raw_data$gpu <- factor(raw_data$gpu)
raw_data$block_threads <- with(raw_data, interaction(blocks, threads, sep = "x"))
data1 <- raw_data[raw_data$max_value %in% c(256, -1), ]
data1$max_value <- factor(data1$max_value)
data1 <- data1[data1$block_threads %in% c("16x16", "8x32", "8x128", "96x128", "192x1024"), ]
graph_all <- ggplot(data = data1,
aes(x = size, y = time, color = method, group = method)) +
facet_grid(block_threads ~ gpu, labeller = as_labeller(facet_labs)) +
# facet_grid(gpu ~ block_threads) +
# geom_smooth(method = "glm") +
geom_line() +
geom_point() +
y_scale +
x_scale +
labs(y = "Time (s)", x = "Size of Array",
color = "Sorting algorithm", title = "GPUs vs Block and Thread count") +
my_theme + x_theme
data2 <- raw_data[raw_data$max_value %in% c(256, -1), ]
data2 <- data2[data2$block_threads %in% c("16x16", "192x1024"),]
graph_blocks <- ggplot(data = data2,
aes(x = size, y = time, color = method, group = method)) +
# facet_grid(block_threads ~ gpu) +
facet_grid(gpu ~ block_threads, labeller = as_labeller(facet_labs)) +
# geom_smooth(method = "glm") +
geom_line() +
geom_point() +
y_scale +
x_scale +
labs(y = "Time (s)", x = "Size of Array",
color = "Sorting algorithm", title = "Block and Thread count vs GPUs") +
my_theme + x_theme
data21 <- raw_data[raw_data$max_value %in% c(256, -1), ]
# data21 <- data21[data21$block_threads %in% c("16x16", "192x1024"),]
graph_blocks1 <- ggplot(data = data21,
aes(x = size, y = time, color = block_threads, group = block_threads)) +
# facet_grid(block_threads ~ gpu) +
facet_grid(method ~ gpu, labeller = as_labeller(facet_labs)) +
# geom_smooth(method = "glm") +
geom_line(size=0.2) +
geom_point(size=0.6) +
y_scale +
x_scale +
labs(y = "Time (s)", x = "Size of Array",
color = "Blocks x Threads", title = "Algorithms vs GPUs") +
my_theme + x_theme
data3 <- raw_data[raw_data$method == "radix", ]
data3 <- data3[data3$block_threads %in% c("16x16", "8x32", "8x128", "96x128", "192x1024"), ]
graph_radix <- ggplot(data = data3,
aes(x = size, y = time, color = gpu, group = gpu)) +
# facet_grid(block_threads ~ gpu) +
facet_grid(block_threads ~ ., labeller = as_labeller(facet_labs)) +
# geom_smooth(method = "glm") +
geom_line() +
geom_point() +
y_scale +
labs(y = "Time (s)", x = "Size of Array",
color = "GPU", title = "Radix sort") + my_theme + x_theme
data4 <- raw_data[raw_data$method == "counting", ]
data4$max_value <- factor(data4$max_value)
data4 <- data4[data4$block_threads %in% c("16x16", "8x32", "8x128", "96x128", "192x1024"), ]
graph_counting <- ggplot(data = data4,
aes(x = size, y = time, color = gpu, group = gpu)) +
# facet_grid(block_threads ~ gpu) +
facet_grid(block_threads ~ max_value, labeller = as_labeller(facet_labs)) +
# geom_smooth(method = "glm") +
geom_line(size=0.2) +
geom_point(size=0.6) +
y_scale +
x_scale +
labs(y = "Time (s)", x = "Size of Array",
color = "GPU", title = "Counting sort with different max values") +
theme(
axis.text.x = element_text(
angle = 90,
vjust = 0.5,
hjust = 1,
size = 7
)
) + my_theme
data5 <- raw_data[raw_data$method == "bitonic", ]
data5 <- data5[data5$block_threads %in% c("16x16", "8x32", "8x128", "96x128", "192x1024"), ]
graph_bitonic <- ggplot(data = data5,
aes(x = size, y = time, color = gpu, group = gpu)) +
# facet_grid(block_threads ~ gpu) +
facet_grid(block_threads ~ ., labeller = as_labeller(facet_labs)) +
# geom_smooth(method = "glm") +
geom_line() +
geom_point() +
y_scale +
labs(y = "Time (s)", x = "Size of Array",
color = "GPU", title = "Bitonic sort") + my_theme + x_theme
pdf <- FALSE
if (pdf) {
# pdf("graphs.pdf", width = 10, height = 10)
pdf("graphs.pdf")
print(graph_all)
print(graph_blocks)
print(graph_blocks1)
print(graph_radix)
print(graph_counting)
print(graph_bitonic)
dev.off()
}