summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJerry James <loganjerry@gmail.com>2021-01-20 10:21:36 -0700
committerJerry James <loganjerry@gmail.com>2021-01-20 10:21:36 -0700
commitdc82a1fbc89ada39f80513a2ce97ce62ebb1e9ec (patch)
tree7444f022d3eb82f9263eaf6f524ee731e9cb00d0 /src
parent70016e869881df837402def4904b2888247e02d9 (diff)
Use reference types to prevent unnecessary copying
Diffstat (limited to 'src')
-rw-r--r--src/kernel_preprocessor.cpp2
-rw-r--r--src/tuning/tuning.cpp8
-rw-r--r--src/tuning/tuning_api.cpp2
3 files changed, 6 insertions, 6 deletions
diff --git a/src/kernel_preprocessor.cpp b/src/kernel_preprocessor.cpp
index bc2ab540..abe0cd76 100644
--- a/src/kernel_preprocessor.cpp
+++ b/src/kernel_preprocessor.cpp
@@ -218,7 +218,7 @@ void ArrayToRegister(std::string &source_line, const DefinesIntMap& defines,
const std::unordered_map<std::string, size_t>& arrays_to_registers,
const size_t num_brackets) {
- for (const auto array_name_map : arrays_to_registers) { // only if marked to be promoted
+ for (const auto& array_name_map : arrays_to_registers) { // only if marked to be promoted
// Outside of a function
if (num_brackets == 0) {
diff --git a/src/tuning/tuning.cpp b/src/tuning/tuning.cpp
index be6b233e..4160faf7 100644
--- a/src/tuning/tuning.cpp
+++ b/src/tuning/tuning.cpp
@@ -62,7 +62,7 @@ void PrintTimingsToFileAsJSON(const std::string &filename,
fprintf(file, " \"parameters\": {");
auto num_configs = result.config.size();
auto p = size_t{0};
- for (const auto parameter : result.config) {
+ for (const auto& parameter : result.config) {
fprintf(file, "\"%s\": %zu", parameter.first.c_str(), parameter.second);
if (p < num_configs -1 ) { fprintf(file, ","); }
++p;
@@ -336,7 +336,7 @@ void Tuner(int argc, char* argv[], const int V,
printf(" %6.1lf |", settings.metric_amount / (time_ms * 1.0e6));
printf(" %sresults match%s |\n", kPrintSuccess.c_str(), kPrintEnd.c_str());
}
- catch (CLCudaAPIBuildError) {
+ catch (CLCudaAPIBuildError&) {
const auto status_code = DispatchExceptionCatchAll(true);
printf(" %scompilation error: %5d%s |",
kPrintError.c_str(), static_cast<int>(status_code), kPrintEnd.c_str());
@@ -365,7 +365,7 @@ void Tuner(int argc, char* argv[], const int V,
// Computes and prints some other statistics
auto average_ms = 0.0;
- for (const auto result : results) { average_ms += result.score; }
+ for (const auto& result : results) { average_ms += result.score; }
average_ms /= results.size();
printf("\n");
printf("* Got average result of %.2lf ms", average_ms);
@@ -380,7 +380,7 @@ void Tuner(int argc, char* argv[], const int V,
printf("* Best parameters: ");
auto best_string = std::string{""};
auto i = size_t{0};
- for (const auto config : best_configuration->config) {
+ for (const auto& config : best_configuration->config) {
best_string += "" + config.first + "=" + ToString(config.second);
if (i < best_configuration->config.size() - 1) { best_string += " "; }
++i;
diff --git a/src/tuning/tuning_api.cpp b/src/tuning/tuning_api.cpp
index 2cc9b786..8c83409c 100644
--- a/src/tuning/tuning_api.cpp
+++ b/src/tuning/tuning_api.cpp
@@ -374,7 +374,7 @@ StatusCode TunerAPI(Queue &queue, const Arguments<T> &args, const int V,
if (best_time_ms == 0.0) { return StatusCode::kUnexpectedError; }
// Stores the best parameters
- for (const auto config : best_configuration->config) {
+ for (const auto& config : best_configuration->config) {
parameters[config.first] = config.second;
}
return StatusCode::kSuccess;