mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Refactor deducing blocked state and task level.
- Do this with one helper function. Change-Id: I81dd3107a98db7e45a691ba6d5e708d98eabe3d2
This commit is contained in:
@@ -352,6 +352,9 @@ cl_int CommandQueue::enqueueReleaseSharedObjects(cl_uint numObjects, const cl_me
|
||||
}
|
||||
|
||||
void CommandQueue::updateFromCompletionStamp(const CompletionStamp &completionStamp) {
|
||||
DEBUG_BREAK_IF(this->taskLevel > completionStamp.taskLevel);
|
||||
DEBUG_BREAK_IF(this->taskCount > completionStamp.taskCount);
|
||||
|
||||
taskCount = completionStamp.taskCount;
|
||||
flushStamp->setStamp(completionStamp.flushStamp);
|
||||
this->taskLevel = completionStamp.taskLevel;
|
||||
|
||||
@@ -385,7 +385,7 @@ class CommandQueueHw : public CommandQueue {
|
||||
|
||||
private:
|
||||
bool isTaskLevelUpdateRequired(const uint32_t &taskLevel, const cl_event *eventWaitList, const cl_uint &numEventsInWaitList, unsigned int commandType);
|
||||
|
||||
void obtainTaskLevelAndBlockedStatus(unsigned int &taskLevel, cl_uint &numEventsInWaitList, const cl_event *&eventWaitList, bool &blockQueue, unsigned int commandType);
|
||||
void forceDispatchScheduler(OCLRT::MultiDispatchInfo &multiDispatchInfo);
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -38,7 +38,6 @@ void *CommandQueueHw<GfxFamily>::cpuDataTransferHandler(MemObj *memObj,
|
||||
cl_event *event,
|
||||
cl_int &retVal) {
|
||||
EventBuilder eventBuilder;
|
||||
bool blockQueue = false;
|
||||
bool eventCompleted = false;
|
||||
ErrorCodeHelper err(&retVal, CL_SUCCESS);
|
||||
|
||||
@@ -52,22 +51,16 @@ void *CommandQueueHw<GfxFamily>::cpuDataTransferHandler(MemObj *memObj,
|
||||
TakeOwnershipWrapper<Device> deviceOwnership(*device);
|
||||
TakeOwnershipWrapper<CommandQueueHw<GfxFamily>> queueOwnership(*this);
|
||||
|
||||
auto taskLevel = getTaskLevelFromWaitList(this->taskLevel, numEventsInWaitList, eventWaitList);
|
||||
auto updateTaskLevel = isTaskLevelUpdateRequired(taskLevel, eventWaitList, numEventsInWaitList, cmdType);
|
||||
auto blockQueue = false;
|
||||
auto taskLevel = 0u;
|
||||
obtainTaskLevelAndBlockedStatus(taskLevel, numEventsInWaitList, eventWaitList, blockQueue, cmdType);
|
||||
|
||||
DBG_LOG(LogTaskCounts, __FUNCTION__, "taskLevel", taskLevel);
|
||||
|
||||
if (updateTaskLevel) {
|
||||
taskLevel++;
|
||||
this->taskLevel = taskLevel;
|
||||
}
|
||||
|
||||
if (event) {
|
||||
eventBuilder.getEvent()->taskLevel = taskLevel;
|
||||
}
|
||||
|
||||
blockQueue = ((taskLevel == Event::eventNotReady) || isQueueBlocked());
|
||||
|
||||
if (blockQueue &&
|
||||
(cmdType == CL_COMMAND_MAP_BUFFER || cmdType == CL_COMMAND_UNMAP_MEM_OBJECT)) {
|
||||
|
||||
|
||||
@@ -182,17 +182,14 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
|
||||
bool slmUsed = false;
|
||||
TakeOwnershipWrapper<CommandQueueHw<GfxFamily>> queueOwnership(*this);
|
||||
|
||||
auto taskLevel = getTaskLevelFromWaitList(this->taskLevel, numEventsInWaitList, eventWaitList);
|
||||
auto blockQueue = (taskLevel == Event::eventNotReady) || isQueueBlocked();
|
||||
auto blockQueue = false;
|
||||
auto taskLevel = 0u;
|
||||
obtainTaskLevelAndBlockedStatus(taskLevel, numEventsInWaitList, eventWaitList, blockQueue, commandType);
|
||||
|
||||
// isQueueBlocked() may use commandStream resolving events tree, get start offset after the call
|
||||
auto &commandStream = getCommandStream<GfxFamily, commandType>(*this, profilingRequired, perfCountersRequired, multiDispatchInfo);
|
||||
auto commandStreamStart = commandStream.getUsed();
|
||||
auto &commandStreamReceiver = device->getCommandStreamReceiver();
|
||||
|
||||
// isQueueBlocked may unblock queue, get new taskLevel
|
||||
taskLevel = getTaskLevelFromWaitList(this->taskLevel, numEventsInWaitList, eventWaitList);
|
||||
|
||||
DBG_LOG(EventsDebugEnable, "blockQueue", blockQueue, "virtualEvent", virtualEvent, "taskLevel", taskLevel);
|
||||
|
||||
if (DebugManager.flags.MakeEachEnqueueBlocking.get()) {
|
||||
@@ -204,12 +201,6 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
|
||||
;
|
||||
}
|
||||
|
||||
auto updateTaskLevel = isTaskLevelUpdateRequired(taskLevel, eventWaitList, numEventsInWaitList, commandType);
|
||||
|
||||
if (updateTaskLevel) {
|
||||
taskLevel++;
|
||||
}
|
||||
|
||||
enqueueHandlerHook(commandType, multiDispatchInfo);
|
||||
|
||||
if (multiDispatchInfo.empty() == false) {
|
||||
@@ -423,6 +414,19 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void CommandQueueHw<GfxFamily>::obtainTaskLevelAndBlockedStatus(unsigned int &taskLevel, cl_uint &numEventsInWaitList, const cl_event *&eventWaitList, bool &blockQueue, unsigned int commandType) {
|
||||
auto isQueueBlockedStatus = isQueueBlocked();
|
||||
taskLevel = getTaskLevelFromWaitList(this->taskLevel, numEventsInWaitList, eventWaitList);
|
||||
blockQueue = (taskLevel == Event::eventNotReady) || isQueueBlockedStatus;
|
||||
|
||||
auto updateTaskLevel = isTaskLevelUpdateRequired(taskLevel, eventWaitList, numEventsInWaitList, commandType);
|
||||
if (updateTaskLevel) {
|
||||
taskLevel++;
|
||||
this->taskLevel = taskLevel;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
bool CommandQueueHw<GfxFamily>::isTaskLevelUpdateRequired(const uint32_t &taskLevel, const cl_event *eventWaitList, const cl_uint &numEventsInWaitList, unsigned int commandType) {
|
||||
bool updateTaskLevel = true;
|
||||
|
||||
@@ -39,7 +39,6 @@ void *CommandQueueHw<GfxFamily>::enqueueMapImage(cl_mem image, cl_bool blockingM
|
||||
size_t *imageSlicePitch, cl_uint numEventsInWaitList,
|
||||
const cl_event *eventWaitList, cl_event *event,
|
||||
cl_int &errcodeRet) {
|
||||
bool blockQueue = false;
|
||||
auto pImage = castToObject<Image>(image);
|
||||
void *ptrToReturn = nullptr;
|
||||
if (context->isProvidingPerformanceHints()) {
|
||||
@@ -93,16 +92,16 @@ void *CommandQueueHw<GfxFamily>::enqueueMapImage(cl_mem image, cl_bool blockingM
|
||||
EventBuilder eventBuilder;
|
||||
TakeOwnershipWrapper<Device> deviceOwnership(*device);
|
||||
TakeOwnershipWrapper<CommandQueueHw<GfxFamily>> queueOwnership(*this);
|
||||
auto blockQueue = false;
|
||||
auto taskLevel = 0u;
|
||||
obtainTaskLevelAndBlockedStatus(taskLevel, numEventsInWaitList, eventWaitList, blockQueue, CL_COMMAND_MAP_IMAGE);
|
||||
|
||||
auto taskLevel = getTaskLevelFromWaitList(this->taskLevel, numEventsInWaitList, eventWaitList);
|
||||
if (event) {
|
||||
eventBuilder.create<Event>(this, CL_COMMAND_MAP_IMAGE, taskLevel, Event::eventNotReady);
|
||||
*event = eventBuilder.getEvent();
|
||||
eventBuilder.getEvent()->setQueueTimeStamp();
|
||||
}
|
||||
|
||||
blockQueue = ((taskLevel == Event::eventNotReady) || isQueueBlocked());
|
||||
|
||||
if (blockQueue) {
|
||||
addMapUnmapToWaitlistEventsDependencies(eventWaitList,
|
||||
static_cast<size_t>(numEventsInWaitList),
|
||||
|
||||
@@ -149,11 +149,10 @@ class Event : public BaseObject<_cl_event>, public IDNode<Event> {
|
||||
static cl_int waitForEvents(cl_uint numEvents,
|
||||
const cl_event *eventList);
|
||||
|
||||
std::unique_ptr<Command> setCommand(std::unique_ptr<Command> newCmd) {
|
||||
void setCommand(std::unique_ptr<Command> newCmd) {
|
||||
UNRECOVERABLE_IF(cmdToSubmit.load());
|
||||
cmdToSubmit.exchange(newCmd.release());
|
||||
eventWithoutCommand = false;
|
||||
return nullptr;
|
||||
}
|
||||
Command *peekCommand() {
|
||||
return cmdToSubmit;
|
||||
|
||||
Reference in New Issue
Block a user