MCPcopy Create free account
hub / github.com/ROCm/clr / populateFormatStringHashMap

Function populateFormatStringHashMap

rocclr/device/devhcprintf.cpp:257–273  ·  view source on GitHub ↗

Extract the format string hash and the format string. The compiler generates the amdhsa.printf metadata in following format for HIP nonhostcall case. "0:0: , " i.e the hash is part of the format string itself delimited by character ','.

Source from the content-addressed store, hash-verified

255// i.e the hash is part of the format string itself
256// delimited by character ','.
257bool populateFormatStringHashMap(const std::vector<device::PrintfInfo>& printfInfo,
258 std::map<uint64_t, std::string>& strMap) {
259 for (auto it : printfInfo) {
260 auto Delim = it.fmtString_.find_first_of(',');
261 auto HashStr = it.fmtString_.substr(0, Delim);
262
263 static_assert(sizeof(long long) == sizeof(uint64_t), "unexpected long long type width");
264 auto HashVal = std::strtoull(HashStr.c_str(), NULL, 16);
265 if (strMap.find(HashVal) != strMap.end()) {
266 LogError("Hash value collision detected, printf buffer ill formed");
267 return false;
268 }
269 strMap[HashVal] = it.fmtString_.substr(Delim + 1, it.fmtString_.size());
270 }
271
272 return true;
273}
274
275void handlePrintfDelayed(const uint64_t* input, uint64_t len, uint64_t control) {
276 auto end = input + len;

Callers 2

outputMethod · 0.85
outputMethod · 0.85

Calls 2

endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected