-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tune and benchmark variables non intrusively
This piece of code integrates and shows how to tune some variables, namely the multiple used to decide on the number of warps used in COO. This is a suggestion of what I could find as the simplest and most versatile solution to this issue. If anyone has another idea I would be happy to try it out. How: This is integrated into the SPMV benchmarks for now and is entirely controlled with the new CMake option `GINKGO_BENCHMARK_ENABLE_TUNING`. The setup works through the use of (dynamic) global variables so that tuning is as little intrusive as possible. This should work even with the "implementation selection" since this also has a dynamic component which could use the same strategy as shown here. Caveat: With this setup, only benchmarks can be compiled, other executable codes such as tests would require to also add `benchmark/utils/tuning_variables.cpp` or equivalent. This option should of course not be turned on for general Ginkgo usage, but only for tuning. Related PR: #692
- Loading branch information
Showing
15 changed files
with
264 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*******************************<GINKGO LICENSE>****************************** | ||
Copyright (c) 2017-2021, the Ginkgo authors | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
******************************<GINKGO LICENSE>*******************************/ | ||
|
||
#include <ginkgo/core/base/types.hpp> | ||
|
||
|
||
#include "benchmark/utils/tuning_variables.hpp" | ||
|
||
|
||
namespace gko { | ||
|
||
|
||
bool _tuning_flag = false; | ||
|
||
|
||
size_type _tuned_value = 0; | ||
|
||
|
||
} // namespace gko |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/*******************************<GINKGO LICENSE>****************************** | ||
Copyright (c) 2017-2021, the Ginkgo authors | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
******************************<GINKGO LICENSE>*******************************/ | ||
|
||
#ifndef GKO_BENCHMARK_UTILS_TUNING_VARIABLES_HPP_ | ||
#define GKO_BENCHMARK_UTILS_TUNING_VARIABLES_HPP_ | ||
|
||
|
||
#include <ginkgo/core/base/types.hpp> | ||
|
||
|
||
namespace gko { | ||
|
||
|
||
extern bool _tuning_flag; | ||
|
||
|
||
extern size_type _tuned_value; | ||
|
||
|
||
} // namespace gko | ||
|
||
|
||
#endif // GKO_BENCHMARK_UTILS_TUNING_VARIABLES_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# These packages are required, to install them, use the package manager or open | ||
# an R session and type: | ||
# install.packages("jsonlite", "tidyr", "ggplot2", "scales") | ||
library(jsonlite) | ||
library(ggplot2) | ||
library(scales) | ||
library(tidyr) | ||
|
||
# Manage arguments | ||
args <- commandArgs(trailingOnly=TRUE) | ||
if (length(args)!=2) { | ||
stop("Usage: Rscript tuning_heatmap.R input_directory output_graphics_file\n", call=FALSE) | ||
} | ||
input <- args[1] | ||
output <- args[2] | ||
|
||
# Read the input json files into a dataframe | ||
files <- list.files(paste(input), recursive=TRUE, pattern = "*.json", full.names=TRUE) | ||
df_tmp <- list() | ||
count <- 1 | ||
for (i in files) | ||
{ | ||
tmp <-jsonlite::fromJSON(i,flatten=TRUE) | ||
df_tmp[[count]] <- as.data.frame(tmp)[,c("problem.name", "problem.nonzeros", | ||
"spmv.coo.time", "spmv.coo.tuning.values", | ||
"spmv.coo.tuning.time")] | ||
count <- count +1 | ||
} | ||
# Merge all the separate dataframes | ||
df_merged <- rbind_pages(df_tmp) | ||
# Unnest the two vectors | ||
df <- as.data.frame(unnest(df,spmv.coo.tuning.values,spmv.coo.tuning.time)) | ||
# Now that all columns are vectors, compute the speedup using vector operations | ||
df$spmv.coo.speedup <- df$spmv.coo.time/df$spmv.coo.tuning.time | ||
|
||
# Plot the values | ||
ggplot(df, aes(factor(problem.nonzeros), factor(spmv.coo.tuning.values), fill=spmv.coo.speedup)) + | ||
geom_tile() + | ||
scale_fill_gradientn( | ||
colours=c("red", "yellow", "skyblue", "darkblue"), | ||
values = rescale(c(min(df$speedup), | ||
1.0, | ||
1.11, | ||
max(df$speedup)))) + | ||
ggtitle("Speedup of tuned value against COO SpMV")+ xlab("nonzeros")+ ylab("tuned value (multiple)") + | ||
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1), plot.title = element_text(hjust=0.5)) | ||
|
||
# Save to the output file | ||
ggsave(paste(output), width=9, height=7) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.