2018-03-30 17:57:51 +02:00
|
|
|
/*
|
2021-03-03 17:29:32 +00:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2018-03-30 17:57:51 +02:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2018-03-30 17:57:51 +02:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-02-24 13:10:44 +01:00
|
|
|
#include "shared/source/built_ins/built_ins.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/command_stream/linear_stream.h"
|
|
|
|
|
#include "shared/source/command_stream/preemption.h"
|
|
|
|
|
#include "shared/source/helpers/register_offsets.h"
|
|
|
|
|
#include "shared/source/helpers/timestamp_packet.h"
|
|
|
|
|
#include "shared/source/helpers/vec.h"
|
|
|
|
|
#include "shared/source/indirect_heap/indirect_heap.h"
|
|
|
|
|
#include "shared/source/utilities/tag_allocator.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2020-02-22 22:50:57 +01:00
|
|
|
#include "opencl/source/command_queue/command_queue.h"
|
|
|
|
|
#include "opencl/source/context/context.h"
|
|
|
|
|
#include "opencl/source/device_queue/device_queue_hw.h"
|
|
|
|
|
#include "opencl/source/event/hw_timestamps.h"
|
|
|
|
|
#include "opencl/source/event/perf_counter.h"
|
|
|
|
|
#include "opencl/source/helpers/dispatch_info.h"
|
|
|
|
|
#include "opencl/source/helpers/hardware_commands_helper.h"
|
|
|
|
|
#include "opencl/source/helpers/task_information.h"
|
|
|
|
|
#include "opencl/source/kernel/kernel.h"
|
|
|
|
|
#include "opencl/source/program/kernel_info.h"
|
2018-03-30 17:57:51 +02:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2018-03-30 17:57:51 +02:00
|
|
|
|
2020-02-05 13:53:29 +01:00
|
|
|
struct RootDeviceEnvironment;
|
|
|
|
|
|
2018-08-24 15:53:33 +02:00
|
|
|
template <typename GfxFamily>
|
|
|
|
|
using WALKER_TYPE = typename GfxFamily::WALKER_TYPE;
|
2018-12-27 16:01:22 +01:00
|
|
|
template <typename GfxFamily>
|
|
|
|
|
using MI_STORE_REG_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM_CMD;
|
2018-08-24 15:53:33 +02:00
|
|
|
|
2018-03-30 17:57:51 +02:00
|
|
|
void computeWorkgroupSize1D(
|
|
|
|
|
uint32_t maxWorkGroupSize,
|
|
|
|
|
size_t workGroupSize[3],
|
|
|
|
|
const size_t workItems[3],
|
|
|
|
|
size_t simdSize);
|
|
|
|
|
|
|
|
|
|
void computeWorkgroupSizeND(
|
|
|
|
|
WorkSizeInfo wsInfo,
|
|
|
|
|
size_t workGroupSize[3],
|
|
|
|
|
const size_t workItems[3],
|
|
|
|
|
const uint32_t workDim);
|
|
|
|
|
|
|
|
|
|
void computeWorkgroupSize2D(
|
|
|
|
|
uint32_t maxWorkGroupSize,
|
|
|
|
|
size_t workGroupSize[3],
|
|
|
|
|
const size_t workItems[3],
|
|
|
|
|
size_t simdSize);
|
|
|
|
|
|
|
|
|
|
void computeWorkgroupSizeSquared(
|
|
|
|
|
uint32_t maxWorkGroupSize,
|
|
|
|
|
size_t workGroupSize[3],
|
|
|
|
|
const size_t workItems[3],
|
|
|
|
|
size_t simdSize,
|
|
|
|
|
const uint32_t workDim);
|
|
|
|
|
|
|
|
|
|
Vec3<size_t> computeWorkgroupSize(
|
|
|
|
|
const DispatchInfo &dispatchInfo);
|
|
|
|
|
|
|
|
|
|
Vec3<size_t> generateWorkgroupSize(
|
|
|
|
|
const DispatchInfo &dispatchInfo);
|
|
|
|
|
|
|
|
|
|
Vec3<size_t> computeWorkgroupsNumber(
|
|
|
|
|
const Vec3<size_t> gws,
|
|
|
|
|
const Vec3<size_t> lws);
|
|
|
|
|
|
|
|
|
|
Vec3<size_t> generateWorkgroupsNumber(
|
|
|
|
|
const Vec3<size_t> gws,
|
|
|
|
|
const Vec3<size_t> lws);
|
|
|
|
|
|
|
|
|
|
Vec3<size_t> generateWorkgroupsNumber(
|
|
|
|
|
const DispatchInfo &dispatchInfo);
|
|
|
|
|
|
|
|
|
|
inline uint32_t calculateDispatchDim(Vec3<size_t> dispatchSize, Vec3<size_t> dispatchOffset) {
|
|
|
|
|
return std::max(1U, std::max(dispatchSize.getSimplifiedDim(), dispatchOffset.getSimplifiedDim()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vec3<size_t> canonizeWorkgroup(
|
|
|
|
|
Vec3<size_t> workgroup);
|
|
|
|
|
|
2019-09-13 13:41:40 +02:00
|
|
|
void provideLocalWorkGroupSizeHints(Context *context, DispatchInfo dispatchInfo);
|
2018-03-30 17:57:51 +02:00
|
|
|
|
2020-05-07 13:51:31 +02:00
|
|
|
void setSpecialWorkgroupSize(size_t workgroupSize[3]);
|
|
|
|
|
|
2018-03-30 17:57:51 +02:00
|
|
|
inline cl_uint computeDimensions(const size_t workItems[3]) {
|
2021-03-03 17:29:32 +00:00
|
|
|
return (workItems[2] > 1) ? 3 : (workItems[1] > 1) ? 2
|
|
|
|
|
: 1;
|
2018-03-30 17:57:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
|
class GpgpuWalkerHelper {
|
|
|
|
|
public:
|
|
|
|
|
static void applyWADisableLSQCROPERFforOCL(LinearStream *pCommandStream,
|
|
|
|
|
const Kernel &kernel,
|
|
|
|
|
bool disablePerfMode);
|
|
|
|
|
|
|
|
|
|
static size_t getSizeForWADisableLSQCROPERFforOCL(const Kernel *pKernel);
|
2021-03-22 15:26:03 +00:00
|
|
|
static size_t getSizeForWaDisableRccRhwoOptimization(const Kernel *pKernel);
|
2018-03-30 17:57:51 +02:00
|
|
|
|
|
|
|
|
static size_t setGpgpuWalkerThreadData(
|
2018-09-28 16:16:18 +02:00
|
|
|
WALKER_TYPE<GfxFamily> *walkerCmd,
|
Remove PatchTokens from KernelInfo
Use KernelDescriptor instead of patchTokens stored in KernelInfo's
patchInfo.
Removed: SPatchMediaInterfaceDescriptorLoad, SPatchAllocateLocalSurface,
SPatchMediaVFEState(slot 0), SPatchMediaVFEState(slot 1),
SPatchInterfaceDescriptorData, SPatchSamplerStateArray,
SPatchBindingTableState, SPatchDataParameterBuffer,
SPatchDataParameterStream, SPatchThreadPayload,
SPatchKernelAttributesInfo, SPatchAllocateStatelessPrivateSurface,
SPatchAllocateSyncBuffer,
SPatchAllocateStatelessConstantMemorySurfaceWithInitialization,
SPatchAllocateStatelessGlobalMemorySurfaceWithInitialization,
SPatchAllocateSystemThreadSurface.
Related-To: NEO-4729
Signed-off-by: Krystian Chmielewski <krystian.chmielewski@intel.com>
2021-03-04 10:14:23 +01:00
|
|
|
const KernelDescriptor &kernelDescriptor,
|
2018-03-30 17:57:51 +02:00
|
|
|
const size_t globalOffsets[3],
|
|
|
|
|
const size_t startWorkGroups[3],
|
|
|
|
|
const size_t numWorkGroups[3],
|
|
|
|
|
const size_t localWorkSizesIn[3],
|
2018-09-26 14:56:01 +02:00
|
|
|
uint32_t simd,
|
|
|
|
|
uint32_t workDim,
|
2018-10-03 15:13:54 +02:00
|
|
|
bool localIdsGenerationByRuntime,
|
2018-10-17 21:38:18 -07:00
|
|
|
bool inlineDataProgrammingRequired,
|
2019-07-02 12:58:22 +02:00
|
|
|
uint32_t requiredWorkgroupOrder);
|
2018-03-30 17:57:51 +02:00
|
|
|
|
|
|
|
|
static void dispatchProfilingCommandsStart(
|
2021-03-24 18:21:13 +00:00
|
|
|
TagNodeBase &hwTimeStamps,
|
2019-08-14 09:33:51 +02:00
|
|
|
LinearStream *commandStream,
|
|
|
|
|
const HardwareInfo &hwInfo);
|
2018-03-30 17:57:51 +02:00
|
|
|
|
|
|
|
|
static void dispatchProfilingCommandsEnd(
|
2021-03-24 18:21:13 +00:00
|
|
|
TagNodeBase &hwTimeStamps,
|
2020-09-03 09:06:11 +02:00
|
|
|
LinearStream *commandStream,
|
|
|
|
|
const HardwareInfo &hwInfo);
|
2018-03-30 17:57:51 +02:00
|
|
|
|
|
|
|
|
static void dispatchPerfCountersCommandsStart(
|
|
|
|
|
CommandQueue &commandQueue,
|
2021-03-24 18:21:13 +00:00
|
|
|
TagNodeBase &hwPerfCounter,
|
2019-04-18 12:25:29 +02:00
|
|
|
LinearStream *commandStream);
|
2018-03-30 17:57:51 +02:00
|
|
|
|
|
|
|
|
static void dispatchPerfCountersCommandsEnd(
|
|
|
|
|
CommandQueue &commandQueue,
|
2021-03-24 18:21:13 +00:00
|
|
|
TagNodeBase &hwPerfCounter,
|
2019-04-18 12:25:29 +02:00
|
|
|
LinearStream *commandStream);
|
2018-03-30 17:57:51 +02:00
|
|
|
|
2018-08-24 08:48:59 +02:00
|
|
|
static void setupTimestampPacket(
|
|
|
|
|
LinearStream *cmdStream,
|
2018-09-28 16:16:18 +02:00
|
|
|
WALKER_TYPE<GfxFamily> *walkerCmd,
|
2021-03-24 18:21:13 +00:00
|
|
|
TagNodeBase *timestampPacketNode,
|
2020-02-05 13:53:29 +01:00
|
|
|
const RootDeviceEnvironment &rootDeviceEnvironment);
|
2018-08-24 08:48:59 +02:00
|
|
|
|
2018-03-30 17:57:51 +02:00
|
|
|
static void dispatchScheduler(
|
2019-02-25 09:42:15 +01:00
|
|
|
LinearStream &commandStream,
|
2018-03-30 17:57:51 +02:00
|
|
|
DeviceQueueHw<GfxFamily> &devQueueHw,
|
|
|
|
|
PreemptionMode preemptionMode,
|
2018-04-05 15:12:28 +02:00
|
|
|
SchedulerKernel &scheduler,
|
|
|
|
|
IndirectHeap *ssh,
|
2019-11-13 15:37:52 +01:00
|
|
|
IndirectHeap *dsh,
|
|
|
|
|
bool isCcsUsed);
|
2018-09-07 09:09:24 +02:00
|
|
|
|
2018-12-27 16:01:22 +01:00
|
|
|
static void adjustMiStoreRegMemMode(MI_STORE_REG_MEM<GfxFamily> *storeCmd);
|
2019-04-18 12:25:29 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
|
|
|
|
|
|
|
|
|
|
static void addAluReadModifyWriteRegister(
|
|
|
|
|
LinearStream *pCommandStream,
|
|
|
|
|
uint32_t aluRegister,
|
2020-02-25 10:23:04 -08:00
|
|
|
AluRegisters operation,
|
2019-04-18 12:25:29 +02:00
|
|
|
uint32_t mask);
|
2018-03-30 17:57:51 +02:00
|
|
|
};
|
|
|
|
|
|
2018-04-09 16:39:32 +02:00
|
|
|
template <typename GfxFamily>
|
2018-03-30 17:57:51 +02:00
|
|
|
struct EnqueueOperation {
|
2018-08-24 08:48:59 +02:00
|
|
|
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
|
2019-07-03 09:30:30 +02:00
|
|
|
static size_t getTotalSizeRequiredCS(uint32_t eventType, const CsrDependencies &csrDeps, bool reserveProfilingCmdsSpace, bool reservePerfCounters, bool blitEnqueue, CommandQueue &commandQueue, const MultiDispatchInfo &multiDispatchInfo);
|
2021-03-03 17:29:32 +00:00
|
|
|
static size_t getSizeRequiredCS(uint32_t cmdType, bool reserveProfilingCmdsSpace, bool reservePerfCounters, CommandQueue &commandQueue, const Kernel *pKernel, const DispatchInfo &dispatchInfo);
|
2018-09-06 10:01:51 +02:00
|
|
|
static size_t getSizeRequiredForTimestampPacketWrite();
|
2020-08-19 11:06:01 +02:00
|
|
|
static size_t getSizeForCacheFlushAfterWalkerCommands(const Kernel &kernel, const CommandQueue &commandQueue);
|
2018-03-30 17:57:51 +02:00
|
|
|
|
2018-04-09 16:39:32 +02:00
|
|
|
private:
|
2021-03-03 17:29:32 +00:00
|
|
|
static size_t getSizeRequiredCSKernel(bool reserveProfilingCmdsSpace, bool reservePerfCounters, CommandQueue &commandQueue, const Kernel *pKernel, const DispatchInfo &dispatchInfo);
|
2018-04-09 16:39:32 +02:00
|
|
|
static size_t getSizeRequiredCSNonKernel(bool reserveProfilingCmdsSpace, bool reservePerfCounters, CommandQueue &commandQueue);
|
2018-03-30 17:57:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename GfxFamily, uint32_t eventType>
|
2019-07-18 16:14:41 +02:00
|
|
|
LinearStream &getCommandStream(CommandQueue &commandQueue, const CsrDependencies &csrDeps, bool reserveProfilingCmdsSpace,
|
|
|
|
|
bool reservePerfCounterCmdsSpace, bool blitEnqueue, const MultiDispatchInfo &multiDispatchInfo,
|
|
|
|
|
Surface **surfaces, size_t numSurfaces) {
|
2019-07-03 09:30:30 +02:00
|
|
|
size_t expectedSizeCS = EnqueueOperation<GfxFamily>::getTotalSizeRequiredCS(eventType, csrDeps, reserveProfilingCmdsSpace, reservePerfCounterCmdsSpace, blitEnqueue, commandQueue, multiDispatchInfo);
|
2018-03-30 17:57:51 +02:00
|
|
|
return commandQueue.getCS(expectedSizeCS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename GfxFamily, IndirectHeap::Type heapType>
|
|
|
|
|
IndirectHeap &getIndirectHeap(CommandQueue &commandQueue, const MultiDispatchInfo &multiDispatchInfo) {
|
|
|
|
|
size_t expectedSize = 0;
|
|
|
|
|
IndirectHeap *ih = nullptr;
|
|
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
|
switch (heapType) {
|
2019-06-12 09:13:06 +02:00
|
|
|
case IndirectHeap::DYNAMIC_STATE: expectedSize = HardwareCommandsHelper<GfxFamily>::getTotalSizeRequiredDSH(multiDispatchInfo); break;
|
|
|
|
|
case IndirectHeap::INDIRECT_OBJECT: expectedSize = HardwareCommandsHelper<GfxFamily>::getTotalSizeRequiredIOH(multiDispatchInfo); break;
|
|
|
|
|
case IndirectHeap::SURFACE_STATE: expectedSize = HardwareCommandsHelper<GfxFamily>::getTotalSizeRequiredSSH(multiDispatchInfo); break;
|
2018-03-30 17:57:51 +02:00
|
|
|
}
|
|
|
|
|
// clang-format on
|
|
|
|
|
|
2018-08-16 15:47:25 +02:00
|
|
|
if (Kernel *parentKernel = multiDispatchInfo.peekParentKernel()) {
|
2018-03-30 17:57:51 +02:00
|
|
|
if (heapType == IndirectHeap::SURFACE_STATE) {
|
2021-03-22 15:26:03 +00:00
|
|
|
expectedSize += HardwareCommandsHelper<GfxFamily>::getSshSizeForExecutionModel(*parentKernel);
|
2018-03-30 17:57:51 +02:00
|
|
|
} else //if (heapType == IndirectHeap::DYNAMIC_STATE || heapType == IndirectHeap::INDIRECT_OBJECT)
|
|
|
|
|
{
|
|
|
|
|
DeviceQueueHw<GfxFamily> *pDevQueue = castToObject<DeviceQueueHw<GfxFamily>>(commandQueue.getContext().getDefaultDeviceQueue());
|
|
|
|
|
DEBUG_BREAK_IF(pDevQueue == nullptr);
|
|
|
|
|
ih = pDevQueue->getIndirectHeap(IndirectHeap::DYNAMIC_STATE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ih == nullptr)
|
|
|
|
|
ih = &commandQueue.getIndirectHeap(heapType, expectedSize);
|
|
|
|
|
|
|
|
|
|
return *ih;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|