mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
Update FlushStamp for output Event on CPU data transfer operations
- Previously only taskCount was updated - This improves KMD notify usage for Events handled asynchronously Change-Id: I283982890579254033557de0e1cef2239c0035e2
This commit is contained in:
committed by
sys_ocldev
parent
a4fc00a78c
commit
94033a1c51
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -31,6 +31,7 @@
|
||||
namespace OCLRT {
|
||||
void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferProperties, EventsRequest &eventsRequest, cl_int &retVal) {
|
||||
MapInfo unmapInfo;
|
||||
Event *outEventObj = nullptr;
|
||||
void *returnPtr = nullptr;
|
||||
EventBuilder eventBuilder;
|
||||
bool eventCompleted = false;
|
||||
@@ -57,9 +58,10 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
|
||||
|
||||
if (eventsRequest.outEvent) {
|
||||
eventBuilder.create<Event>(this, transferProperties.cmdType, Event::eventNotReady, Event::eventNotReady);
|
||||
eventBuilder.getEvent()->setQueueTimeStamp();
|
||||
eventBuilder.getEvent()->setCPUProfilingPath(true);
|
||||
*eventsRequest.outEvent = eventBuilder.getEvent();
|
||||
outEventObj = eventBuilder.getEvent();
|
||||
outEventObj->setQueueTimeStamp();
|
||||
outEventObj->setCPUProfilingPath(true);
|
||||
*eventsRequest.outEvent = outEventObj;
|
||||
}
|
||||
|
||||
TakeOwnershipWrapper<Device> deviceOwnership(*device);
|
||||
@@ -71,8 +73,8 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
|
||||
|
||||
DBG_LOG(LogTaskCounts, __FUNCTION__, "taskLevel", taskLevel);
|
||||
|
||||
if (eventsRequest.outEvent) {
|
||||
eventBuilder.getEvent()->taskLevel = taskLevel;
|
||||
if (outEventObj) {
|
||||
outEventObj->taskLevel = taskLevel;
|
||||
}
|
||||
|
||||
if (blockQueue &&
|
||||
@@ -98,8 +100,8 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
|
||||
if (!blockQueue || transferProperties.blocking) {
|
||||
err.set(Event::waitForEvents(eventsRequest.numEventsInWaitList, eventsRequest.eventWaitList));
|
||||
|
||||
if (eventBuilder.getEvent()) {
|
||||
eventBuilder.getEvent()->setSubmitTimeStamp();
|
||||
if (outEventObj) {
|
||||
outEventObj->setSubmitTimeStamp();
|
||||
}
|
||||
//wait for the completness of previous commands
|
||||
if (transferProperties.cmdType != CL_COMMAND_UNMAP_MEM_OBJECT) {
|
||||
@@ -109,8 +111,8 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
|
||||
}
|
||||
}
|
||||
|
||||
if (eventBuilder.getEvent()) {
|
||||
eventBuilder.getEvent()->setStartTimeStamp();
|
||||
if (outEventObj) {
|
||||
outEventObj->setStartTimeStamp();
|
||||
}
|
||||
|
||||
switch (transferProperties.cmdType) {
|
||||
@@ -147,13 +149,15 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
|
||||
default:
|
||||
err.set(CL_INVALID_OPERATION);
|
||||
}
|
||||
if (eventBuilder.getEvent()) {
|
||||
eventBuilder.getEvent()->setEndTimeStamp();
|
||||
eventBuilder.getEvent()->updateTaskCount(this->taskCount);
|
||||
|
||||
if (outEventObj) {
|
||||
outEventObj->setEndTimeStamp();
|
||||
outEventObj->updateTaskCount(this->taskCount);
|
||||
outEventObj->flushStamp->setStamp(this->flushStamp->peekStamp());
|
||||
if (eventCompleted) {
|
||||
eventBuilder.getEvent()->setStatus(CL_COMPLETE);
|
||||
outEventObj->setStatus(CL_COMPLETE);
|
||||
} else {
|
||||
eventBuilder.getEvent()->updateExecutionStatus();
|
||||
outEventObj->updateExecutionStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_mdi.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/fixtures/image_fixture.h"
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include "test.h"
|
||||
@@ -1281,6 +1282,26 @@ TEST_F(EventTest, givenCmdQueueWithoutProfilingWhenIsCpuProfilingIsCalledThenFal
|
||||
EXPECT_FALSE(cpuProfiling);
|
||||
}
|
||||
|
||||
TEST_F(EventTest, givenOutEventWhenBlockingEnqueueHandledOnCpuThenUpdateTaskCountAndFlushStampFromCmdQ) {
|
||||
std::unique_ptr<Image> image(ImageHelper<Image1dDefaults>::create(&mockContext));
|
||||
EXPECT_TRUE(image->mappingOnCpuAllowed());
|
||||
|
||||
pCmdQ->flushStamp->setStamp(10);
|
||||
pCmdQ->taskCount = 11;
|
||||
|
||||
size_t origin[3] = {0, 0, 0};
|
||||
size_t region[3] = {1, 1, 1};
|
||||
|
||||
cl_int retVal;
|
||||
cl_event clEvent;
|
||||
pCmdQ->enqueueMapImage(image.get(), CL_TRUE, CL_MAP_READ, origin, region, nullptr, nullptr, 0, nullptr, &clEvent, retVal);
|
||||
|
||||
auto eventObj = castToObject<Event>(clEvent);
|
||||
EXPECT_EQ(pCmdQ->taskCount, eventObj->peekTaskCount());
|
||||
EXPECT_EQ(pCmdQ->flushStamp->peekStamp(), eventObj->flushStamp->peekStamp());
|
||||
eventObj->release();
|
||||
}
|
||||
|
||||
TEST_F(EventTest, givenCmdQueueWithProfilingWhenIsCpuProfilingIsCalledThenTrueIsReturned) {
|
||||
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0};
|
||||
std::unique_ptr<CommandQueue> pCmdQ(new CommandQueue(&mockContext, pDevice, props));
|
||||
|
||||
Reference in New Issue
Block a user