kfdtest: Use GetSystemTickCountInMicroSec() as much as possible
GetSystemTickCountInMicroSec() wraps the function gettimeofday().
Change-Id: I7b767a6efdd1db491fc8113313945b578ac69382
Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
[ROCm/ROCR-Runtime commit: 174484aac3]
Этот коммит содержится в:
@@ -640,14 +640,13 @@ HSAint64 KFDQMTest::TimeConsumedwithCUMask(int node, uint32_t* mask, uint32_t ma
|
||||
EXPECT_SUCCESS(queue.SetCUMask(mask, mask_count));
|
||||
queue.SetSkipWaitConsump(true);
|
||||
|
||||
struct timeval start, now;
|
||||
gettimeofday(&start, NULL);
|
||||
HSAuint64 startTime = GetSystemTickCountInMicroSec();
|
||||
dispatch.Submit(queue);
|
||||
dispatch.Sync();
|
||||
gettimeofday(&now, NULL);
|
||||
HSAuint64 endTime = GetSystemTickCountInMicroSec();
|
||||
|
||||
EXPECT_SUCCESS(queue.Destroy());
|
||||
return (now.tv_sec *1000LL + now.tv_usec/1000LL - start.tv_sec * 1000LL - start.tv_usec/1000LL);
|
||||
return endTime - startTime;
|
||||
}
|
||||
|
||||
/* To cover for outliers, allow us to get the Average time based on a specified number of iterations */
|
||||
@@ -831,7 +830,7 @@ TEST_F(KFDQMTest, QueuePriorityOnDifferentPipe) {
|
||||
};
|
||||
|
||||
int activeTaskBitmap = 0x3;
|
||||
struct timeval start, end[2];
|
||||
HSAuint64 startTime, endTime[2];
|
||||
HsaEvent *pHsaEvent[2];
|
||||
int numEvent = 2;
|
||||
PM4Queue queue[2];
|
||||
@@ -850,7 +849,7 @@ TEST_F(KFDQMTest, QueuePriorityOnDifferentPipe) {
|
||||
dispatch[i].SetDim(1024, 16, 16);
|
||||
}
|
||||
|
||||
gettimeofday(&start, NULL);
|
||||
startTime = GetSystemTickCountInMicroSec();
|
||||
for (i = 0; i < 2; i++)
|
||||
dispatch[i].Submit(queue[i]);
|
||||
|
||||
@@ -858,7 +857,7 @@ TEST_F(KFDQMTest, QueuePriorityOnDifferentPipe) {
|
||||
hsaKmtWaitOnMultipleEvents(pHsaEvent, numEvent, false, g_TestTimeOut);
|
||||
for (i = 0; i < 2; i++) {
|
||||
if ((activeTaskBitmap & (1 << i)) && (syncBuffer[i] == pHsaEvent[i]->EventId)) {
|
||||
gettimeofday(&end[i], NULL);
|
||||
endTime[i] = GetSystemTickCountInMicroSec();
|
||||
activeTaskBitmap &= ~(1 << i);
|
||||
}
|
||||
}
|
||||
@@ -866,9 +865,9 @@ TEST_F(KFDQMTest, QueuePriorityOnDifferentPipe) {
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
EXPECT_SUCCESS(queue[i].Destroy());
|
||||
int ms = end[i].tv_sec *1000LL + end[i].tv_usec/1000LL - start.tv_sec * 1000LL - start.tv_usec/1000LL;
|
||||
int usecs = endTime[i] - startTime;
|
||||
LOG() << "Task priority: " << std::dec << priority[i] << "\t";
|
||||
LOG() << "Task duration: " << std::dec << ms << "ms" << std::endl;
|
||||
LOG() << "Task duration: " << std::dec << usecs << "usecs" << std::endl;
|
||||
}
|
||||
|
||||
TEST_END
|
||||
@@ -896,7 +895,7 @@ TEST_F(KFDQMTest, QueuePriorityOnSamePipe) {
|
||||
};
|
||||
|
||||
int activeTaskBitmap = 0x3;
|
||||
struct timeval start, end[2];
|
||||
HSAuint64 startTime, endTime[2];
|
||||
HsaEvent *pHsaEvent[2];
|
||||
int numEvent = 2;
|
||||
PM4Queue queue[13];
|
||||
@@ -924,7 +923,7 @@ TEST_F(KFDQMTest, QueuePriorityOnSamePipe) {
|
||||
dispatch[i].SetDim(1024, 16, 16);
|
||||
}
|
||||
|
||||
gettimeofday(&start, NULL);
|
||||
startTime = GetSystemTickCountInMicroSec();
|
||||
for (i = 0; i < 2; i++)
|
||||
dispatch[i].Submit(queue[i]);
|
||||
|
||||
@@ -932,16 +931,16 @@ TEST_F(KFDQMTest, QueuePriorityOnSamePipe) {
|
||||
hsaKmtWaitOnMultipleEvents(pHsaEvent, numEvent, false, g_TestTimeOut);
|
||||
for (i = 0; i < 2; i++) {
|
||||
if ((activeTaskBitmap & (1 << i)) && (syncBuffer[i] == pHsaEvent[i]->EventId)) {
|
||||
gettimeofday(&end[i], NULL);
|
||||
endTime[i] = GetSystemTickCountInMicroSec();
|
||||
activeTaskBitmap &= ~(1 << i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
int ms = end[i].tv_sec *1000LL + end[i].tv_usec/1000LL - start.tv_sec * 1000LL - start.tv_usec/1000LL;
|
||||
int usecs = endTime[i] - startTime;
|
||||
LOG() << "Task priority: " << std::dec << priority[i] << "\t";
|
||||
LOG() << "Task duration: " << std::dec << ms << "ms" << std::endl;
|
||||
LOG() << "Task duration: " << std::dec << usecs << "usecs" << std::endl;
|
||||
}
|
||||
|
||||
for (i = 0; i <= 12; i++) {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "KFDTestUtil.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include "BaseQueue.hpp"
|
||||
@@ -171,6 +172,12 @@ bool isTonga(const HsaNodeProperties *props) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HSAuint64 GetSystemTickCountInMicroSec() {
|
||||
struct timeval t;
|
||||
gettimeofday(&t, 0);
|
||||
return t.tv_sec * 1000000ULL + t.tv_usec;
|
||||
}
|
||||
|
||||
const HsaMemoryBuffer HsaMemoryBuffer::Null;
|
||||
|
||||
HsaMemoryBuffer::HsaMemoryBuffer(HSAuint64 size, unsigned int node, bool zero, bool isLocal, bool isExec,
|
||||
|
||||
@@ -56,6 +56,8 @@ void GetSdmaInfo(const HsaNodeProperties *props,
|
||||
unsigned int *p_num_sdma_xgmi_engines,
|
||||
unsigned int *p_num_sdma_queues_per_engine);
|
||||
|
||||
HSAuint64 GetSystemTickCountInMicroSec();
|
||||
|
||||
class HsaMemoryBuffer {
|
||||
public:
|
||||
static const HsaMemoryBuffer Null;
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
static int protection_flags[8] = {PROT_NONE, PROT_READ, PROT_WRITE, PROT_READ | PROT_WRITE,
|
||||
PROT_EXEC, PROT_EXEC | PROT_READ, PROT_EXEC | PROT_WRITE,
|
||||
@@ -80,12 +79,6 @@ bool MultiProcessTest(const char *testToRun, int numOfProcesses, int runsPerProc
|
||||
return false;
|
||||
}
|
||||
|
||||
HSAuint64 GetSystemTickCountInMicroSec() {
|
||||
struct timeval t;
|
||||
gettimeofday(&t, 0);
|
||||
return t.tv_sec * 1000000ULL + t.tv_usec;
|
||||
}
|
||||
|
||||
bool SuspendAndWakeUp() {
|
||||
printf("Please press any key after the system suspends....\n");
|
||||
|
||||
|
||||
@@ -95,8 +95,6 @@ void MemoryBarrier();
|
||||
*/
|
||||
bool MultiProcessTest(const char *testToRun, int numOfProcesses, int runsPerProcess = 1);
|
||||
|
||||
HSAuint64 GetSystemTickCountInMicroSec();
|
||||
|
||||
/* Put the system to S3/S4 power state and bring it back to S0.
|
||||
* @return 'true' on success, 'false' on failure.
|
||||
*/
|
||||
|
||||
Ссылка в новой задаче
Block a user