Skip to content

Commit 285af96

Browse files
getCpuGpuTime to return false when unavailable
This commit addresses crash issue in AUB standalone mode when queue profiling is enabled on Linux platform. Change-Id: Ie2d02093d3628efac3a8925890f22afd6a49469d
1 parent 4afa8fb commit 285af96

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

runtime/os_interface/linux/os_time_linux.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ bool OSTimeLinux::getGpuTimeSplitted(uint64_t *timestamp) {
125125
}
126126

127127
bool OSTimeLinux::getCpuGpuTime(TimeStampData *pGpuCpuTime) {
128+
if (nullptr == this->getGpuTime) {
129+
return false;
130+
}
128131
if (!(this->*getGpuTime)(&pGpuCpuTime->GPUTimeStamp)) {
129132
return false;
130133
}

runtime/os_interface/linux/os_time_linux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class OSTimeLinux : public OSTime {
3838
bool getCpuGpuTime(TimeStampData *pGpuCpuTime) override;
3939
typedef bool (OSTimeLinux::*TimestampFunction)(uint64_t *);
4040
void timestampTypeDetect();
41-
TimestampFunction getGpuTime;
41+
TimestampFunction getGpuTime = nullptr;
4242
bool getGpuTime32(uint64_t *timestamp);
4343
bool getGpuTime36(uint64_t *timestamp);
4444
bool getGpuTimeSplitted(uint64_t *timestamp);

unit_tests/os_interface/linux/os_time_test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ TEST_F(DrmTimeTest, GIVENDrmWHENGetCpuGpuTimeTHENPassed) {
148148
delete pDrm;
149149
}
150150

151+
TEST_F(DrmTimeTest, givenGetCpuGpuTimeWhenItIsUnavailableThenReturnFalse) {
152+
TimeStampData CPUGPUTime = {0, 0};
153+
auto error = osTime->getCpuGpuTime(&CPUGPUTime);
154+
EXPECT_FALSE(error);
155+
}
156+
151157
TEST_F(DrmTimeTest, GetCpuGpuTimeFails) {
152158
TimeStampData CPUGPUTime01 = {0, 0};
153159
auto pDrm = new DrmMockFail();

0 commit comments

Comments
 (0)