[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
Этот коммит содержится в:
Evgeny Mankov
2018-11-01 16:57:57 +03:00
родитель 9fdc1cb875
Коммит 48abb4a36b
4 изменённых файлов: 14 добавлений и 14 удалений
+6 -6
Просмотреть файл
@@ -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);
}
+6 -6
Просмотреть файл
@@ -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);
};
+1 -1
Просмотреть файл
@@ -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;
}
+1 -1
Просмотреть файл
@@ -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);