From 48abb4a36b437700682cbac81d1cf3834aa74653 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 1 Nov 2018 16:57:57 +0300 Subject: [PATCH] [HIPIFY][fix] Fix typo and functions' string arguments + Fix typo with missing comma in counterNames array + Change std::string argument to const std::string& argument in all functions --- hipamd/hipify-clang/src/Statistics.cpp | 12 ++++++------ hipamd/hipify-clang/src/Statistics.h | 12 ++++++------ hipamd/hipify-clang/src/StringUtils.cpp | 2 +- hipamd/hipify-clang/src/StringUtils.h | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/hipamd/hipify-clang/src/Statistics.cpp b/hipamd/hipify-clang/src/Statistics.cpp index 86eb7c753c..2d37c3156c 100644 --- a/hipamd/hipify-clang/src/Statistics.cpp +++ b/hipamd/hipify-clang/src/Statistics.cpp @@ -14,7 +14,7 @@ const char *counterNames[NUM_CONV_TYPES] = { "addressing", // CONV_ADDRESSING "stream", // CONV_STREAM "event", // CONV_EVENT - "external_resource_interop" // CONV_EXT_RES + "external_resource_interop", // CONV_EXT_RES "stream_memory", // CONV_STREAM_MEMORY "execution", // CONV_EXECUTION "graph", // CONV_GRAPH @@ -74,7 +74,7 @@ void printStat(std::ostream *csv, llvm::raw_ostream* printOut, const std::string } // Anonymous namespace -void StatCounter::incrementCounter(const hipCounter& counter, std::string name) { +void StatCounter::incrementCounter(const hipCounter& counter, const std::string& name) { counters[name]++; apiCounters[(int) counter.apiType]++; convTypeCounters[(int) counter.type]++; @@ -100,7 +100,7 @@ int StatCounter::getConvSum() { return acc; } -void StatCounter::print(std::ostream* csv, llvm::raw_ostream* printOut, std::string prefix) { +void StatCounter::print(std::ostream* csv, llvm::raw_ostream* printOut, const std::string& prefix) { conditionalPrint(csv, printOut, "\nCUDA ref type;Count\n", "[HIPIFY] info: " + prefix + " refs by type:\n"); for (int i = 0; i < NUM_CONV_TYPES; i++) { if (convTypeCounters[i] > 0) { @@ -117,7 +117,7 @@ void StatCounter::print(std::ostream* csv, llvm::raw_ostream* printOut, std::str } } -Statistics::Statistics(std::string name): fileName(name) { +Statistics::Statistics(const std::string& name): fileName(name) { // Compute the total bytes/lines in the input file. std::ifstream src_file(name, std::ios::binary | std::ios::ate); src_file.clear(); @@ -129,7 +129,7 @@ Statistics::Statistics(std::string name): fileName(name) { ///////// Counter update routines ////////// -void Statistics::incrementCounter(const hipCounter &counter, std::string name) { +void Statistics::incrementCounter(const hipCounter &counter, const std::string& name) { if (counter.unsupported) { unsupported.incrementCounter(counter, name); } else { @@ -218,7 +218,7 @@ Statistics& Statistics::current() { return *Statistics::currentStatistics; } -void Statistics::setActive(std::string name) { +void Statistics::setActive(const std::string& name) { stats.emplace(std::make_pair(name, Statistics{name})); Statistics::currentStatistics = &stats.at(name); } diff --git a/hipamd/hipify-clang/src/Statistics.h b/hipamd/hipify-clang/src/Statistics.h index 53d017b1a3..0ce8e0de67 100644 --- a/hipamd/hipify-clang/src/Statistics.h +++ b/hipamd/hipify-clang/src/Statistics.h @@ -22,7 +22,7 @@ enum ConvTypes { // Driver API : 5.5. Device Management, 5.6. Device Management [DEPRECATED] // Runtime API: 5.1. Device Management CONV_DEVICE, - // Driver API : 5.8.Context Management, 5.9. Context Management [DEPRECATED] + // Driver API : 5.7. Primary Context Management, 5.8.Context Management, 5.9. Context Management [DEPRECATED] CONV_CONTEXT, // Driver API : 5.10. Module Management CONV_MODULE, @@ -134,11 +134,11 @@ private: int convTypeCounters[NUM_CONV_TYPES] = {}; public: - void incrementCounter(const hipCounter& counter, std::string name); + void incrementCounter(const hipCounter& counter, const std::string& name); // Add the counters from `other` onto the counters of this object. void add(const StatCounter& other); int getConvSum(); - void print(std::ostream* csv, llvm::raw_ostream* printOut, std::string prefix); + void print(std::ostream* csv, llvm::raw_ostream* printOut, const std::string& prefix); }; /** @@ -156,8 +156,8 @@ class Statistics { chr::steady_clock::time_point completionTime; public: - Statistics(std::string name); - void incrementCounter(const hipCounter &counter, std::string name); + Statistics(const std::string& name); + void incrementCounter(const hipCounter &counter, const std::string& name); // Add the counters from `other` onto the counters of this object. void add(const Statistics &other); void lineTouched(int lineNumber); @@ -192,5 +192,5 @@ public: * Set the active Statistics object to the named one, creating it if necessary, and write the completion * timestamp into the currently active one. */ - static void setActive(std::string name); + static void setActive(const std::string& name); }; diff --git a/hipamd/hipify-clang/src/StringUtils.cpp b/hipamd/hipify-clang/src/StringUtils.cpp index 6504d39010..3aaa4d7909 100644 --- a/hipamd/hipify-clang/src/StringUtils.cpp +++ b/hipamd/hipify-clang/src/StringUtils.cpp @@ -7,7 +7,7 @@ llvm::StringRef unquoteStr(llvm::StringRef s) { return s; } -void removePrefixIfPresent(std::string &s, std::string prefix) { +void removePrefixIfPresent(std::string &s, const std::string& prefix) { if (s.find(prefix) != 0) { return; } diff --git a/hipamd/hipify-clang/src/StringUtils.h b/hipamd/hipify-clang/src/StringUtils.h index c0be9f6227..8c5bf58da8 100644 --- a/hipamd/hipify-clang/src/StringUtils.h +++ b/hipamd/hipify-clang/src/StringUtils.h @@ -11,4 +11,4 @@ llvm::StringRef unquoteStr(llvm::StringRef s); /** * If `s` starts with `prefix`, remove it. Otherwise, does nothing. */ -void removePrefixIfPresent(std::string &s, std::string prefix); +void removePrefixIfPresent(std::string &s, const std::string& prefix);