Use 'RecordProperty' to record performance scores

For following test cases:
- KFDQMTest.QueueLatency
- KFDQMTest.BasicCuMaskingLinear
- KFDQMTest.BasicCuMaskingEven
- KFDMemoryTest.MMBandWidth
- KFDMemoryTest.MMapLarge
- KFDMemoryTest.MMBench

v2: xml element cannot start with a number, so change the key name of
    MMBandWidth and MMBench accordingly
    xml element cannot contain whitespaces, so trim whitespaces in "VRAM  "
v3: introduce KFDLog-like way to use KFDRecord

Change-Id: Ifc3ed5657621252a7b39dccf1ef4f50a92593f77
Signed-off-by: Xiaojie Yuan <xiaojie.yuan@amd.com>


[ROCm/ROCR-Runtime commit: 247fa9f1e0]
このコミットが含まれているのは:
Xiaojie Yuan
2018-09-12 17:30:42 +08:00
コミット ca0873a234
3個のファイルの変更56行の追加4行の削除
+21
ファイルの表示
@@ -42,6 +42,27 @@ std::ostream& operator << (KFDLog log, LOGTYPE level);
#define LOG() KFDLog() << LOGTYPE_INFO
#define WARN() KFDLog() << LOGTYPE_WARNING
class KFDRecord: public testing::Test {
public:
KFDRecord(const char *val): m_val(val) {}
KFDRecord(std::string &val): m_val(val) {}
KFDRecord(HSAint64 val): m_val(std::to_string(val)) {}
KFDRecord(HSAuint64 val): m_val(std::to_string(val)) {}
KFDRecord(double val): m_val(std::to_string(val)) {}
~KFDRecord() {
RecordProperty(m_key.str().c_str(), m_val.c_str());
}
std::stringstream &get_key_stream() {
return m_key;
}
virtual void TestBody() {};
private:
std::string m_val;
std::stringstream m_key;
};
#define RECORD(val) (KFDRecord(val).get_key_stream())
// All tests MUST be in a try catch since the gtest flag to throw an exception on any fatal failure is enabled
#define TEST_START(testProfile) if (Ok2Run(testProfile)) try {
#define TEST_END } catch (...) {}
+24 -4
ファイルの表示
@@ -176,6 +176,8 @@ TEST_F(KFDMemoryTest, MMapLarge) {
LOG() << "Successfully registered and mapped " << (i * s >> 30)
<< "GB system memory to gpu" << std::endl;
RECORD(i * s >> 30) << "Mmap-SysMem-Size";
while (i--) {
EXPECT_SUCCESS(hsaKmtUnmapMemoryToGPU(reinterpret_cast<void*>(AlternateVAGPU[i])));
EXPECT_SUCCESS(hsaKmtDeregisterMemory(reinterpret_cast<void*>(AlternateVAGPU[i])));
@@ -1020,6 +1022,16 @@ TEST_F(KFDMemoryTest, MMBench) {
<< std::setw(8) << mapAllTime
<< std::setw(8) << unmapAllTime
<< std::setw(8) << freeTime << std::endl;
#define MMBENCH_KEY_PREFIX memTypeStrings[memType] << "-" \
<< (interleaveSDMA ? "SDMA" : "noSDMA") << "-" \
<< (bufSize >> 10) << "K-"
RECORD(allocTime) << MMBENCH_KEY_PREFIX << "alloc";
RECORD(map1Time) << MMBENCH_KEY_PREFIX << "mapOne";
RECORD(unmap1Time) << MMBENCH_KEY_PREFIX << "unmapOne";
RECORD(mapAllTime) << MMBENCH_KEY_PREFIX << "mapAll";
RECORD(unmapAllTime) << MMBENCH_KEY_PREFIX << "unmapAll";
RECORD(freeTime) << MMBENCH_KEY_PREFIX << "free";
}
TEST_END
@@ -1551,7 +1563,7 @@ TEST_F(KFDMemoryTest, MMBandWidth) {
const unsigned nBufs = 1000; /* measure us, report ns */
unsigned testIndex, sizeIndex, memType;
const unsigned nMemTypes = 2;
const char *memTypeStrings[nMemTypes] = {"SysMem", "VRAM "};
const char *memTypeStrings[nMemTypes] = {"SysMem", "VRAM"};
const unsigned nSizes = 4;
const unsigned bufSizes[nSizes] = {PAGE_SIZE, PAGE_SIZE*4, PAGE_SIZE*16, PAGE_SIZE*64};
const unsigned nTests = nSizes * nMemTypes;
@@ -1641,14 +1653,22 @@ TEST_F(KFDMemoryTest, MMBandWidth) {
for (i = 0; i < nBufs; i++)
EXPECT_SUCCESS(hsaKmtFreeMemory(bufs[i], bufSize));
LOG() << std::dec << std::setiosflags(std::ios::right)
<< std::setw(3) << (bufSize >> 10) << "K-"
<< memTypeStrings[memType] << "\t"
LOG() << std::dec
<< std::right << std::setw(3) << (bufSize >> 10) << "K-"
<< std::left << std::setw(14) << memTypeStrings[memType]
<< std::right
<< std::setw(12) << mcpRTime
<< std::setw(12) << mcpWTime
<< std::setw(12) << accessRTime
<< std::setw(12) << accessWTime
<< std::endl;
#define MMBANDWIDTH_KEY_PREFIX memTypeStrings[memType] << "-" \
<< (bufSize >> 10) << "K" << "-"
RECORD(mcpRTime) << MMBANDWIDTH_KEY_PREFIX << "mcpRTime";
RECORD(mcpWTime) << MMBANDWIDTH_KEY_PREFIX << "mcpWTime";
RECORD(accessRTime) << MMBANDWIDTH_KEY_PREFIX << "accessRTime";
RECORD(accessWTime) << MMBANDWIDTH_KEY_PREFIX << "accessWTime";
}
munmap(tmp, tmpBufferSize);
+11
ファイルの表示
@@ -659,6 +659,8 @@ TEST_F(KFDQMTest, BasicCuMaskingLinear) {
<< ratio << " <= " << std::setprecision(2) << CuPosVariance << std::endl;
EXPECT_TRUE((ratio >= CuNegVariance) && (ratio <= CuPosVariance));
RECORD(ratio) << "Ratio-" << nCUs << "-CUs";
}
} else {
LOG() << "Skipping test: Test not supported for family ID 0x" << m_FamilyId << "." << std::endl;
@@ -730,6 +732,8 @@ TEST_F(KFDQMTest, BasicCuMaskingEven) {
<< ratio << " <= " << std::setprecision(2) << CuPosVariance << std::endl;
EXPECT_TRUE((ratio >= CuNegVariance) && (ratio <= CuPosVariance));
RECORD(ratio) << "Ratio-" << nCUs << "-CUs";
}
} else {
LOG() << "Skipping test: Test not supported for family ID 0x" << m_FamilyId << "." << std::endl;
@@ -1184,6 +1188,13 @@ TEST_F(KFDQMTest, QueueLatency) {
LOG() << "Queue Packet Workload: \t" << CounterToNanoSec(workload) << std::endl;
LOG() << "Get GpuCounter Overhead: \t" << CounterToNanoSec(overhead) << std::endl;
RECORD(CounterToNanoSec(queue_latency_avg)) << "Queue-Latency-Avg";
RECORD(CounterToNanoSec(queue_latency_min)) << "Queue-Latency-Min";
RECORD(CounterToNanoSec(queue_latency_med)) << "Queue-Latency-Med";
RECORD(CounterToNanoSec(queue_latency_max)) << "Queue-Latency-Max";
RECORD(CounterToNanoSec(workload)) << "Queue-Packet-Workload";
RECORD(CounterToNanoSec(overhead)) << "GpuCounter-Overhead";
TEST_END
}