mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Fix profiling calculation logic
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
493a96b308
commit
8a4d28ef8b
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -40,7 +40,7 @@ cl_int ProfilingInfo[] = {
|
||||
CL_PROFILING_COMMAND_COMPLETE};
|
||||
|
||||
TEST_F(clEventProfilingTests, GivenInvalidParamNameWhenGettingEventProfilingInfoThenInvalidValueErrorIsReturned) {
|
||||
Event *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
Event *pEvent = new Event(pCommandQueue, 0, 0, 0);
|
||||
pEvent->setStatus(CL_COMPLETE);
|
||||
size_t param_value_size = sizeof(cl_ulong);
|
||||
cl_ulong param_value;
|
||||
@ -60,7 +60,7 @@ TEST_F(clEventProfilingTests, GivenInvalidParamNameWhenGettingEventProfilingInfo
|
||||
}
|
||||
|
||||
TEST_F(clEventProfilingTests, GivenInvalidParametersWhenGettingEventProfilingInfoThenValueSizeRetIsNotUpdated) {
|
||||
Event event{nullptr, 0, 0, 0};
|
||||
Event event{pCommandQueue, 0, 0, 0};
|
||||
event.setStatus(CL_COMPLETE);
|
||||
size_t paramValueSize = sizeof(cl_ulong);
|
||||
cl_ulong paramValue;
|
||||
@ -78,7 +78,7 @@ TEST_F(clEventProfilingTests, GivenInvalidParametersWhenGettingEventProfilingInf
|
||||
}
|
||||
|
||||
TEST_F(clEventProfilingTests, GivenInvalidParamValueSizeWhenGettingEventProfilingInfoThenInvalidValueErrorIsReturned) {
|
||||
Event *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
Event *pEvent = new Event(pCommandQueue, 0, 0, 0);
|
||||
pEvent->setStatus(CL_COMPLETE);
|
||||
size_t param_value_size = sizeof(cl_ulong);
|
||||
cl_ulong param_value;
|
||||
@ -98,7 +98,7 @@ TEST_F(clEventProfilingTests, GivenInvalidParamValueSizeWhenGettingEventProfilin
|
||||
}
|
||||
|
||||
TEST_F(clEventProfilingTests, GivenValidParametersWhenGettingEventProfilingInfoThenSuccessIsReturned) {
|
||||
Event *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
Event *pEvent = new Event(pCommandQueue, 0, 0, 0);
|
||||
pEvent->setStatus(CL_COMPLETE);
|
||||
size_t param_value_size = sizeof(cl_ulong);
|
||||
cl_ulong param_value;
|
||||
@ -119,7 +119,7 @@ TEST_F(clEventProfilingTests, GivenValidParametersWhenGettingEventProfilingInfoT
|
||||
}
|
||||
|
||||
TEST_F(clEventProfilingTests, GivenNullParamValueSizeRetWhenGettingEventProfilingInfoThenSuccessIsReturned) {
|
||||
Event *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
Event *pEvent = new Event(pCommandQueue, 0, 0, 0);
|
||||
pEvent->setStatus(CL_COMPLETE);
|
||||
size_t param_value_size = sizeof(cl_ulong);
|
||||
cl_ulong param_value;
|
||||
@ -143,8 +143,8 @@ TEST_F(clEventProfilingTests, GivenNullEventWhenGettingEventProfilingInfoThenInv
|
||||
EXPECT_EQ(CL_INVALID_EVENT, retVal);
|
||||
}
|
||||
|
||||
TEST(clGetEventProfilingInfo, GivenNullParamValueAndZeroParamValueSizeWhenGettingEventProfilingInfoThenSuccessIsReturned) {
|
||||
Event *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
TEST_F(clEventProfilingTests, GivenNullParamValueAndZeroParamValueSizeWhenGettingEventProfilingInfoThenSuccessIsReturned) {
|
||||
Event *pEvent = new Event(pCommandQueue, 0, 0, 0);
|
||||
size_t param_value_size = 0;
|
||||
|
||||
pEvent->setStatus(CL_COMPLETE);
|
||||
@ -162,8 +162,8 @@ TEST(clGetEventProfilingInfo, GivenNullParamValueAndZeroParamValueSizeWhenGettin
|
||||
delete pEvent;
|
||||
}
|
||||
|
||||
TEST(clGetEventProfilingInfo, GivenNullParamValueAndCorrectParamValueSizeWhenGettingEventProfilingInfoThenSuccessIsReturned) {
|
||||
Event *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
TEST_F(clEventProfilingTests, GivenNullParamValueAndCorrectParamValueSizeWhenGettingEventProfilingInfoThenSuccessIsReturned) {
|
||||
Event *pEvent = new Event(pCommandQueue, 0, 0, 0);
|
||||
size_t param_value_size = sizeof(cl_ulong);
|
||||
|
||||
pEvent->setStatus(CL_COMPLETE);
|
||||
@ -181,7 +181,7 @@ TEST(clGetEventProfilingInfo, GivenNullParamValueAndCorrectParamValueSizeWhenGet
|
||||
delete pEvent;
|
||||
}
|
||||
|
||||
TEST(clGetEventProfilingInfo, GivenUserEventWhenGettingEventProfilingInfoThenProfilingInfoNotAvailableErrorIsReturned) {
|
||||
TEST_F(clEventProfilingTests, GivenUserEventWhenGettingEventProfilingInfoThenProfilingInfoNotAvailableErrorIsReturned) {
|
||||
UserEvent *ue = new UserEvent();
|
||||
size_t param_value_size = sizeof(cl_ulong);
|
||||
cl_ulong param_value;
|
||||
@ -199,8 +199,8 @@ TEST(clGetEventProfilingInfo, GivenUserEventWhenGettingEventProfilingInfoThenPro
|
||||
delete ue;
|
||||
}
|
||||
|
||||
TEST(clGetEventProfilingInfo, GivenStartAndEndTimeWhenGettingDeltaThenCorrectDeltaIsReturned) {
|
||||
Event *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
TEST_F(clEventProfilingTests, GivenStartAndEndTimeWhenGettingDeltaThenCorrectDeltaIsReturned) {
|
||||
Event *pEvent = new Event(pCommandQueue, 0, 0, 0);
|
||||
cl_ulong startTime = 1;
|
||||
cl_ulong endTime = 2;
|
||||
cl_ulong delta = 0;
|
||||
@ -211,21 +211,21 @@ TEST(clGetEventProfilingInfo, GivenStartAndEndTimeWhenGettingDeltaThenCorrectDel
|
||||
delete pEvent;
|
||||
}
|
||||
|
||||
TEST(clGetEventProfilingInfo, GivenStartTimeGreaterThenEndTimeWhenGettingDeltaThenCorrectDeltaIsReturned) {
|
||||
Event *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
TEST_F(clEventProfilingTests, GivenStartTimeGreaterThenEndTimeWhenGettingDeltaThenCorrectDeltaIsReturned) {
|
||||
Event *pEvent = new Event(pCommandQueue, 0, 0, 0);
|
||||
cl_ulong startTime = 2;
|
||||
cl_ulong endTime = 1;
|
||||
cl_ulong delta = 0;
|
||||
cl_ulong timeMax = 0xffffffffULL;
|
||||
cl_ulong timeMax = maxNBitValue(pDevice->getHardwareInfo().capabilityTable.kernelTimestampValidBits);
|
||||
|
||||
delta = pEvent->getDelta(startTime, endTime);
|
||||
EXPECT_EQ((timeMax + (endTime - startTime)), delta);
|
||||
delete pEvent;
|
||||
}
|
||||
|
||||
TEST(clGetEventProfilingInfo, givenTimestampThatOverlapWhenGetDeltaIsCalledThenProperDeltaIsComputed) {
|
||||
Event *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
cl_ulong TimeMax = 0xffffffffULL;
|
||||
TEST_F(clEventProfilingTests, givenTimestampThatOverlapWhenGetDeltaIsCalledThenProperDeltaIsComputed) {
|
||||
Event *pEvent = new Event(pCommandQueue, 0, 0, 0);
|
||||
cl_ulong TimeMax = maxNBitValue(pDevice->getHardwareInfo().capabilityTable.kernelTimestampValidBits);
|
||||
cl_ulong realDelta = 10;
|
||||
|
||||
cl_ulong startTime = TimeMax - realDelta;
|
||||
@ -236,14 +236,14 @@ TEST(clGetEventProfilingInfo, givenTimestampThatOverlapWhenGetDeltaIsCalledThenP
|
||||
delete pEvent;
|
||||
}
|
||||
|
||||
TEST(clGetEventProfilingInfo, GivenProfilingDisabledWhenCalculatingProfilingDataThenFalseIsReturned) {
|
||||
TEST_F(clEventProfilingTests, GivenProfilingDisabledWhenCalculatingProfilingDataThenFalseIsReturned) {
|
||||
auto *pEvent = new MockEvent<Event>(nullptr, 0, 0, 0);
|
||||
EXPECT_FALSE(pEvent->calcProfilingData());
|
||||
delete pEvent;
|
||||
}
|
||||
|
||||
TEST(clGetEventProfilingInfo, GivenProfilingEnabledWhenCalculatingProfilingDataThenFalseIsNotReturned) {
|
||||
Event *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
TEST_F(clEventProfilingTests, GivenProfilingEnabledWhenCalculatingProfilingDataThenFalseIsNotReturned) {
|
||||
Event *pEvent = new Event(pCommandQueue, 0, 0, 0);
|
||||
cl_bool Result = pEvent->isProfilingEnabled();
|
||||
EXPECT_EQ(((cl_bool)CL_FALSE), Result);
|
||||
pEvent->setProfilingEnabled(true);
|
||||
@ -252,15 +252,15 @@ TEST(clGetEventProfilingInfo, GivenProfilingEnabledWhenCalculatingProfilingDataT
|
||||
delete pEvent;
|
||||
}
|
||||
|
||||
TEST(clGetEventProfilingInfo, GivenProfilingEnabledAndUserEventsWhenCalculatingProfilingDataThenFalseIsReturned) {
|
||||
TEST_F(clEventProfilingTests, GivenProfilingEnabledAndUserEventsWhenCalculatingProfilingDataThenFalseIsReturned) {
|
||||
Event *pEvent = new UserEvent();
|
||||
cl_bool Result = pEvent->isProfilingEnabled();
|
||||
EXPECT_EQ(((cl_bool)CL_FALSE), Result);
|
||||
delete pEvent;
|
||||
}
|
||||
|
||||
TEST(clGetEventProfilingInfo, GivenPerfCountersEnabledWhenCheckingPerfCountersThenTrueIsReturned) {
|
||||
Event *pEvent = new Event(nullptr, 0, 0, 0);
|
||||
TEST_F(clEventProfilingTests, GivenPerfCountersEnabledWhenCheckingPerfCountersThenTrueIsReturned) {
|
||||
Event *pEvent = new Event(pCommandQueue, 0, 0, 0);
|
||||
bool Result = pEvent->isPerfCountersEnabled();
|
||||
EXPECT_FALSE(Result);
|
||||
pEvent->setPerfCountersEnabled(true);
|
||||
|
Reference in New Issue
Block a user