|
31 | 31 | #include "runtime/utilities/tag_allocator.h" |
32 | 32 |
|
33 | 33 | #include "unit_tests/command_queue/command_enqueue_fixture.h" |
| 34 | +#include "unit_tests/helpers/debug_manager_state_restore.h" |
34 | 35 | #include "unit_tests/fixtures/device_fixture.h" |
35 | 36 | #include "unit_tests/mocks/mock_command_queue.h" |
36 | 37 | #include "unit_tests/mocks/mock_context.h" |
@@ -462,6 +463,58 @@ TEST(EventProfilingTest, givenEventWhenCompleteIsZeroThenCalcProfilingDataSetsEn |
462 | 463 | cmdQ.device = nullptr; |
463 | 464 | } |
464 | 465 |
|
| 466 | +TEST(EventProfilingTest, givenRawTimestampsDebugModeWhenDataIsQueriedThenRawDataIsReturned) { |
| 467 | + DebugManagerStateRestore stateRestore; |
| 468 | + DebugManager.flags.ReturnRawGpuTimestamps.set(1); |
| 469 | + std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr)); |
| 470 | + MyOSTime::instanceNum = 0; |
| 471 | + device->setOSTime(new MyOSTime()); |
| 472 | + EXPECT_EQ(1, MyOSTime::instanceNum); |
| 473 | + MockContext context; |
| 474 | + cl_command_queue_properties props[5] = {0, 0, 0, 0, 0}; |
| 475 | + MockCommandQueue cmdQ(&context, device.get(), props); |
| 476 | + cmdQ.setProfilingEnabled(); |
| 477 | + cmdQ.device = device.get(); |
| 478 | + |
| 479 | + HwTimeStamps timestamp; |
| 480 | + timestamp.GlobalStartTS = 10; |
| 481 | + timestamp.ContextStartTS = 20; |
| 482 | + timestamp.GlobalEndTS = 80; |
| 483 | + timestamp.ContextEndTS = 56; |
| 484 | + timestamp.GlobalCompleteTS = 0; |
| 485 | + timestamp.ContextCompleteTS = 70; |
| 486 | + |
| 487 | + MockTagNode<HwTimeStamps> timestampNode; |
| 488 | + timestampNode.tag = ×tamp; |
| 489 | + |
| 490 | + MockEvent<Event> event(&cmdQ, CL_COMPLETE, 0, 0); |
| 491 | + cl_event clEvent = &event; |
| 492 | + |
| 493 | + event.queueTimeStamp.CPUTimeinNS = 1; |
| 494 | + event.queueTimeStamp.GPUTimeStamp = 2; |
| 495 | + |
| 496 | + event.submitTimeStamp.CPUTimeinNS = 3; |
| 497 | + event.submitTimeStamp.GPUTimeStamp = 4; |
| 498 | + |
| 499 | + event.setCPUProfilingPath(false); |
| 500 | + event.timeStampNode = ×tampNode; |
| 501 | + event.calcProfilingData(); |
| 502 | + |
| 503 | + cl_ulong queued, submited, start, end, complete; |
| 504 | + |
| 505 | + clGetEventProfilingInfo(clEvent, CL_PROFILING_COMMAND_QUEUED, sizeof(cl_ulong), &queued, nullptr); |
| 506 | + clGetEventProfilingInfo(clEvent, CL_PROFILING_COMMAND_SUBMIT, sizeof(cl_ulong), &submited, nullptr); |
| 507 | + clGetEventProfilingInfo(clEvent, CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &start, nullptr); |
| 508 | + clGetEventProfilingInfo(clEvent, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &end, nullptr); |
| 509 | + clGetEventProfilingInfo(clEvent, CL_PROFILING_COMMAND_COMPLETE, sizeof(cl_ulong), &complete, nullptr); |
| 510 | + |
| 511 | + EXPECT_EQ(timestamp.ContextCompleteTS, complete); |
| 512 | + EXPECT_EQ(timestamp.ContextEndTS, end); |
| 513 | + EXPECT_EQ(timestamp.ContextStartTS, start); |
| 514 | + EXPECT_EQ(event.submitTimeStamp.GPUTimeStamp, submited); |
| 515 | + EXPECT_EQ(event.queueTimeStamp.GPUTimeStamp, queued); |
| 516 | +} |
| 517 | + |
465 | 518 | struct ProfilingWithPerfCountersTests : public ProfilingTests, |
466 | 519 | public PerformanceCountersFixture { |
467 | 520 | void SetUp() override { |
|
0 commit comments