2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2019-01-21 11:44:56 +01:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-08-02 13:25:45 -07:00
|
|
|
#include "core/helpers/aligned_memory.h"
|
2019-05-28 19:09:40 -07:00
|
|
|
#include "core/helpers/ptr_math.h"
|
2019-09-11 09:26:24 +02:00
|
|
|
#include "core/unit_tests/utilities/base_object_utils.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "runtime/command_queue/command_queue.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "runtime/event/user_event.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "unit_tests/command_queue/command_queue_fixture.h"
|
|
|
|
#include "unit_tests/command_stream/command_stream_fixture.h"
|
|
|
|
#include "unit_tests/fixtures/device_fixture.h"
|
2019-02-06 08:49:35 +01:00
|
|
|
#include "unit_tests/fixtures/hello_world_fixture.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "unit_tests/mocks/mock_buffer.h"
|
|
|
|
#include "unit_tests/mocks/mock_context.h"
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
using namespace NEO;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
struct EventTest
|
|
|
|
: public DeviceFixture,
|
|
|
|
public CommandQueueFixture,
|
|
|
|
public CommandStreamFixture,
|
|
|
|
public ::testing::Test {
|
|
|
|
|
|
|
|
using CommandQueueFixture::SetUp;
|
|
|
|
|
|
|
|
void SetUp() override {
|
|
|
|
DeviceFixture::SetUp();
|
|
|
|
CommandQueueFixture::SetUp(&mockContext, pDevice, 0);
|
|
|
|
CommandStreamFixture::SetUp(pCmdQ);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
|
|
|
CommandStreamFixture::TearDown();
|
|
|
|
CommandQueueFixture::TearDown();
|
|
|
|
DeviceFixture::TearDown();
|
|
|
|
}
|
|
|
|
MockContext mockContext;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct InternalsEventTest
|
|
|
|
: public DeviceFixture,
|
|
|
|
public ::testing::Test {
|
|
|
|
|
|
|
|
InternalsEventTest() {
|
|
|
|
}
|
|
|
|
|
2018-03-29 19:44:20 +02:00
|
|
|
void SetUp() {
|
2017-12-21 00:45:38 +01:00
|
|
|
DeviceFixture::SetUp();
|
|
|
|
mockContext = new MockContext(pDevice);
|
|
|
|
}
|
|
|
|
|
2018-03-29 19:44:20 +02:00
|
|
|
void TearDown() {
|
2017-12-21 00:45:38 +01:00
|
|
|
delete mockContext;
|
|
|
|
DeviceFixture::TearDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
MockContext *mockContext;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MyUserEvent : public VirtualEvent {
|
2018-03-21 10:00:49 +01:00
|
|
|
bool wait(bool blocking, bool quickKmdSleep) override {
|
|
|
|
return VirtualEvent::wait(blocking, quickKmdSleep);
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
uint32_t getTaskLevel() override {
|
|
|
|
return VirtualEvent::getTaskLevel();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MyEvent : public Event {
|
|
|
|
MyEvent(CommandQueue *cmdQueue, cl_command_type cmdType, uint32_t taskLevel, uint32_t taskCount)
|
|
|
|
: Event(cmdQueue, cmdType, taskLevel, taskCount) {
|
|
|
|
}
|
|
|
|
TimeStampData getQueueTimeStamp() {
|
|
|
|
return this->queueTimeStamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
TimeStampData getSubmitTimeStamp() {
|
|
|
|
return this->submitTimeStamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint64_t getStartTimeStamp() {
|
|
|
|
return this->startTimeStamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint64_t getEndTimeStamp() {
|
|
|
|
return this->endTimeStamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint64_t getCompleteTimeStamp() {
|
|
|
|
return this->completeTimeStamp;
|
|
|
|
}
|
2019-01-21 11:44:56 +01:00
|
|
|
|
|
|
|
uint64_t getGlobalStartTimestamp() const {
|
|
|
|
return this->globalStartTimestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool getDataCalcStatus() const {
|
|
|
|
return this->dataCalculated;
|
|
|
|
}
|
|
|
|
|
2019-01-31 13:32:02 +01:00
|
|
|
void calculateProfilingDataInternal(uint64_t contextStartTS, uint64_t contextEndTS, uint64_t *contextCompleteTS, uint64_t globalStartTS) override {
|
2019-01-21 11:44:56 +01:00
|
|
|
if (DebugManager.flags.ReturnRawGpuTimestamps.get()) {
|
|
|
|
globalStartTimestamp = globalStartTS;
|
|
|
|
}
|
2019-01-31 13:32:02 +01:00
|
|
|
Event::calculateProfilingDataInternal(contextStartTS, contextEndTS, contextCompleteTS, globalStartTS);
|
2019-01-21 11:44:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t globalStartTimestamp;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
2019-02-06 08:49:35 +01:00
|
|
|
|
|
|
|
class MockEventTests : public HelloWorldTest<HelloWorldFixtureFactory> {
|
|
|
|
public:
|
|
|
|
void TearDown() {
|
|
|
|
uEvent->setStatus(-1);
|
|
|
|
uEvent.reset();
|
|
|
|
HelloWorldFixture::TearDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ReleaseableObjectPtr<UserEvent> uEvent;
|
|
|
|
};
|