Refactor CsrDependencies

Related-To: NEO-4175

Change-Id: If7e02235c1545e3e8ddf254c31523dd57286088d
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2020-01-22 16:22:30 +01:00
committed by sys_ocldev
parent 98ac4ca5fd
commit 915a6fa14f
16 changed files with 83 additions and 66 deletions

View File

@@ -199,7 +199,7 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
BlitPropertiesContainer blitPropertiesContainer;
if (getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) {
csrDeps.fillFromEventsRequest(eventsRequest, getGpgpuCommandStreamReceiver(), CsrDependencies::DependenciesType::OnCsr);
eventsRequest.fillCsrDependencies(csrDeps, getGpgpuCommandStreamReceiver(), CsrDependencies::DependenciesType::OnCsr);
size_t nodesCount = 0u;
if (blitEnqueue || isCacheFlushCommand(commandType)) {
@@ -458,8 +458,8 @@ BlitProperties CommandQueueHw<GfxFamily>::processDispatchForBlitEnqueue(const Mu
auto blitProperties = BlitProperties::constructProperties(blitDirection, *blitCommandStreamReceiver,
multiDispatchInfo.peekBuiltinOpParams());
if (!queueBlocked) {
blitProperties.csrDependencies.fillFromEventsRequest(eventsRequest, *blitCommandStreamReceiver,
CsrDependencies::DependenciesType::All);
eventsRequest.fillCsrDependencies(blitProperties.csrDependencies, *blitCommandStreamReceiver,
CsrDependencies::DependenciesType::All);
blitProperties.csrDependencies.push_back(&timestampPacketDependencies.previousEnqueueNodes);
blitProperties.csrDependencies.push_back(&timestampPacketDependencies.barrierNodes);
@@ -752,7 +752,7 @@ CompletionStamp CommandQueueHw<GfxFamily>::enqueueNonBlocked(
dispatchFlags.pipelineSelectArgs.specialPipelineSelectMode = specialPipelineSelectMode;
if (getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) {
dispatchFlags.csrDependencies.fillFromEventsRequest(eventsRequest, getGpgpuCommandStreamReceiver(), CsrDependencies::DependenciesType::OutOfCsr);
eventsRequest.fillCsrDependencies(dispatchFlags.csrDependencies, getGpgpuCommandStreamReceiver(), CsrDependencies::DependenciesType::OutOfCsr);
dispatchFlags.csrDependencies.makeResident(getGpgpuCommandStreamReceiver());
}
@@ -944,7 +944,7 @@ CompletionStamp CommandQueueHw<GfxFamily>::enqueueCommandWithoutKernel(
);
if (getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) {
dispatchFlags.csrDependencies.fillFromEventsRequest(eventsRequest, getGpgpuCommandStreamReceiver(), CsrDependencies::DependenciesType::OutOfCsr);
eventsRequest.fillCsrDependencies(dispatchFlags.csrDependencies, getGpgpuCommandStreamReceiver(), CsrDependencies::DependenciesType::OutOfCsr);
dispatchFlags.csrDependencies.makeResident(getGpgpuCommandStreamReceiver());
}
CompletionStamp completionStamp = getGpgpuCommandStreamReceiver().flushTask(

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -11,7 +11,6 @@
#include "core/helpers/options.h"
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/helpers/csr_deps.h"
#include "runtime/helpers/dirty_state_helpers.h"
namespace NEO {

View File

@@ -6,13 +6,13 @@
*/
#pragma once
#include "core/command_stream/csr_deps.h"
#include "core/command_stream/queue_throttle.h"
#include "core/command_stream/thread_arbitration_policy.h"
#include "core/helpers/hw_info.h"
#include "core/helpers/pipeline_select_args.h"
#include "core/kernel/grf_config.h"
#include "core/memory_manager/memory_constants.h"
#include "runtime/helpers/csr_deps.h"
#include <limits>

View File

@@ -16,8 +16,6 @@ set(RUNTIME_SRCS_HELPERS_BASE
${CMAKE_CURRENT_SOURCE_DIR}/built_ins_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/cl_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/convert_color.h
${CMAKE_CURRENT_SOURCE_DIR}/csr_deps.cpp
${CMAKE_CURRENT_SOURCE_DIR}/csr_deps.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/device_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dirty_state_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dirty_state_helpers.h

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Intel Corporation
* Copyright (C) 2019-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -197,8 +197,8 @@ void BlitProperties::setupDependenciesForAuxTranslation(BlitPropertiesContainer
// wait for barrier and events before AuxToNonAux
blitPropertiesContainer[0].csrDependencies.push_back(&timestampPacketDependencies.barrierNodes);
blitPropertiesContainer[0].csrDependencies.fillFromEventsRequest(eventsRequest, bcsCsr,
CsrDependencies::DependenciesType::All);
eventsRequest.fillCsrDependencies(blitPropertiesContainer[0].csrDependencies, bcsCsr,
CsrDependencies::DependenciesType::All);
// wait for NDR before NonAuxToAux
blitPropertiesContainer[numObjects].csrDependencies.push_back(&kernelTimestamps);

View File

@@ -1,14 +1,14 @@
/*
* Copyright (C) 2019 Intel Corporation
* Copyright (C) 2019-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "core/command_stream/csr_deps.h"
#include "core/memory_manager/memory_constants.h"
#include "core/utilities/stackvec.h"
#include "runtime/helpers/csr_deps.h"
#include "runtime/helpers/properties_helper.h"
#include <cstdint>

View File

@@ -1,41 +1,15 @@
/*
* Copyright (C) 2019 Intel Corporation
* Copyright (C) 2019-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/helpers/csr_deps.h"
#include "core/command_stream/csr_deps.h"
#include "runtime/command_queue/command_queue.h"
#include "runtime/event/event.h"
#include "runtime/helpers/properties_helper.h"
#include "runtime/helpers/timestamp_packet.h"
namespace NEO {
void CsrDependencies::fillFromEventsRequest(const EventsRequest &eventsRequest, CommandStreamReceiver &currentCsr,
DependenciesType depsType) {
for (cl_uint i = 0; i < eventsRequest.numEventsInWaitList; i++) {
auto event = castToObjectOrAbort<Event>(eventsRequest.eventWaitList[i]);
if (event->isUserEvent()) {
continue;
}
auto timestampPacketContainer = event->getTimestampPacketNodes();
if (!timestampPacketContainer || timestampPacketContainer->peekNodes().empty()) {
continue;
}
auto sameCsr = (&event->getCommandQueue()->getGpgpuCommandStreamReceiver() == &currentCsr);
bool pushDependency = (DependenciesType::OnCsr == depsType && sameCsr) ||
(DependenciesType::OutOfCsr == depsType && !sameCsr) ||
(DependenciesType::All == depsType);
if (pushDependency) {
this->push_back(timestampPacketContainer);
}
}
}
void CsrDependencies::makeResident(CommandStreamReceiver &commandStreamReceiver) const {
for (auto &timestampPacketContainer : *this) {

View File

@@ -1,30 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "core/utilities/stackvec.h"
namespace NEO {
class TimestampPacketContainer;
class CommandStreamReceiver;
struct EventsRequest;
class CsrDependencies : public StackVec<TimestampPacketContainer *, 32> {
public:
enum class DependenciesType {
OnCsr,
OutOfCsr,
All
};
void fillFromEventsRequest(const EventsRequest &eventsRequest, CommandStreamReceiver &currentCsr,
DependenciesType depsType);
void makeResident(CommandStreamReceiver &commandStreamReceiver) const;
};
} // namespace NEO

View File

@@ -17,7 +17,7 @@
#include <cstdint>
namespace NEO {
class CommandQueue;
class LinearStream;
class IndirectHeap;
struct CrossThreadInfo;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,12 +7,38 @@
#include "runtime/helpers/properties_helper.h"
#include "runtime/command_queue/command_queue.h"
#include "runtime/helpers/mipmap.h"
#include "runtime/helpers/timestamp_packet.h"
#include "runtime/mem_obj/image.h"
#include "runtime/mem_obj/mem_obj.h"
#include "runtime/memory_manager/memory_manager.h"
namespace NEO {
void EventsRequest::fillCsrDependencies(CsrDependencies &csrDeps, CommandStreamReceiver &currentCsr, CsrDependencies::DependenciesType depsType) const {
for (cl_uint i = 0; i < this->numEventsInWaitList; i++) {
auto event = castToObjectOrAbort<Event>(this->eventWaitList[i]);
if (event->isUserEvent()) {
continue;
}
auto timestampPacketContainer = event->getTimestampPacketNodes();
if (!timestampPacketContainer || timestampPacketContainer->peekNodes().empty()) {
continue;
}
auto sameCsr = (&event->getCommandQueue()->getGpgpuCommandStreamReceiver() == &currentCsr);
bool pushDependency = (CsrDependencies::DependenciesType::OnCsr == depsType && sameCsr) ||
(CsrDependencies::DependenciesType::OutOfCsr == depsType && !sameCsr) ||
(CsrDependencies::DependenciesType::All == depsType);
if (pushDependency) {
csrDeps.push_back(timestampPacketContainer);
}
}
}
TransferProperties::TransferProperties(MemObj *memObj, cl_command_type cmdType, cl_map_flags mapFlags, bool blocking,
size_t *offsetPtr, size_t *sizePtr, void *ptr, bool doTransferOnCpu)
: memObj(memObj), ptr(ptr), cmdType(cmdType), mapFlags(mapFlags), blocking(blocking), doTransferOnCpu(doTransferOnCpu) {

View File

@@ -7,6 +7,7 @@
#pragma once
#include "core/command_stream/csr_deps.h"
#include "core/command_stream/queue_throttle.h"
#include "runtime/api/cl_types.h"
@@ -21,7 +22,9 @@ struct EventsRequest {
EventsRequest() = delete;
EventsRequest(cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *outEvent)
: numEventsInWaitList(numEventsInWaitList), eventWaitList(eventWaitList), outEvent(outEvent){};
: numEventsInWaitList(numEventsInWaitList), eventWaitList(eventWaitList), outEvent(outEvent) {}
void fillCsrDependencies(CsrDependencies &csrDeps, CommandStreamReceiver &currentCsr, CsrDependencies::DependenciesType depsType) const;
cl_uint numEventsInWaitList;
const cl_event *eventWaitList;

View File

@@ -7,6 +7,7 @@
#include "runtime/helpers/task_information.h"
#include "core/command_stream/csr_deps.h"
#include "core/command_stream/linear_stream.h"
#include "core/command_stream/preemption.h"
#include "core/helpers/aligned_memory.h"
@@ -20,7 +21,6 @@
#include "runtime/device/device.h"
#include "runtime/device_queue/device_queue.h"
#include "runtime/gtpin/gtpin_notify.h"
#include "runtime/helpers/csr_deps.h"
#include "runtime/helpers/enqueue_properties.h"
#include "runtime/helpers/task_information.inl"
#include "runtime/mem_obj/mem_obj.h"
@@ -228,7 +228,7 @@ CompletionStamp &CommandComputeKernel::submit(uint32_t taskLevel, bool terminate
);
if (timestampPacketDependencies) {
dispatchFlags.csrDependencies.fillFromEventsRequest(eventsRequest, commandStreamReceiver, CsrDependencies::DependenciesType::OutOfCsr);
eventsRequest.fillCsrDependencies(dispatchFlags.csrDependencies, commandStreamReceiver, CsrDependencies::DependenciesType::OutOfCsr);
dispatchFlags.barrierTimestampPacketNodes = &timestampPacketDependencies->barrierNodes;
}
dispatchFlags.pipelineSelectArgs.specialPipelineSelectMode = kernel->requiresSpecialPipelineSelectMode();
@@ -275,7 +275,7 @@ void CommandWithoutKernel::dispatchBlitOperation() {
UNRECOVERABLE_IF(kernelOperation->blitPropertiesContainer.size() != 1);
auto &blitProperties = *kernelOperation->blitPropertiesContainer.begin();
blitProperties.csrDependencies.fillFromEventsRequest(eventsRequest, *bcsCsr, CsrDependencies::DependenciesType::All);
eventsRequest.fillCsrDependencies(blitProperties.csrDependencies, *bcsCsr, CsrDependencies::DependenciesType::All);
blitProperties.csrDependencies.push_back(&timestampPacketDependencies->previousEnqueueNodes);
blitProperties.csrDependencies.push_back(&timestampPacketDependencies->barrierNodes);
blitProperties.outputTimestampPacket = currentTimestampPacketNodes->peekNodes()[0];
@@ -334,8 +334,7 @@ CompletionStamp &CommandWithoutKernel::submit(uint32_t taskLevel, bool terminate
UNRECOVERABLE_IF(!commandStreamReceiver.peekTimestampPacketWriteEnabled());
dispatchFlags.csrDependencies.fillFromEventsRequest(eventsRequest, commandStreamReceiver, CsrDependencies::DependenciesType::OutOfCsr);
eventsRequest.fillCsrDependencies(dispatchFlags.csrDependencies, commandStreamReceiver, CsrDependencies::DependenciesType::OutOfCsr);
makeTimestampPacketsResident(commandStreamReceiver);
gtpinNotifyPreFlushTask(&commandQueue);

View File

@@ -7,8 +7,8 @@
#pragma once
#include "core/command_stream/csr_deps.h"
#include "core/helpers/non_copyable_or_moveable.h"
#include "runtime/helpers/csr_deps.h"
#include "runtime/helpers/hardware_commands_helper.h"
#include "runtime/utilities/tag_allocator.h"