2019-05-13 14:15:03 +02:00
|
|
|
/*
|
2021-05-16 20:51:16 +02:00
|
|
|
* Copyright (C) 2019-2021 Intel Corporation
|
2019-05-13 14:15:03 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2020-10-05 18:32:55 +02:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2021-12-22 14:11:05 +00:00
|
|
|
#include "shared/source/helpers/pipe_control_args.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/simd_helper.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2020-03-20 11:15:25 +01:00
|
|
|
#include "opencl/source/cl_device/cl_device.h"
|
2020-02-22 22:50:57 +01:00
|
|
|
#include "opencl/source/command_queue/gpgpu_walker_base.inl"
|
2019-05-13 14:15:03 +02:00
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
|
inline size_t GpgpuWalkerHelper<GfxFamily>::setGpgpuWalkerThreadData(
|
2021-11-04 15:40:13 +00:00
|
|
|
WALKER_TYPE *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,
|
2019-05-13 14:15:03 +02:00
|
|
|
const size_t globalOffsets[3],
|
|
|
|
|
const size_t startWorkGroups[3],
|
|
|
|
|
const size_t numWorkGroups[3],
|
|
|
|
|
const size_t localWorkSizesIn[3],
|
|
|
|
|
uint32_t simd,
|
|
|
|
|
uint32_t workDim,
|
|
|
|
|
bool localIdsGenerationByRuntime,
|
|
|
|
|
bool inlineDataProgrammingRequired,
|
2019-07-02 12:58:22 +02:00
|
|
|
uint32_t requiredWorkgroupOrder) {
|
2019-05-13 14:15:03 +02:00
|
|
|
auto localWorkSize = localWorkSizesIn[0] * localWorkSizesIn[1] * localWorkSizesIn[2];
|
|
|
|
|
|
|
|
|
|
auto threadsPerWorkGroup = getThreadsPerWG(simd, localWorkSize);
|
|
|
|
|
walkerCmd->setThreadWidthCounterMaximum(static_cast<uint32_t>(threadsPerWorkGroup));
|
|
|
|
|
|
|
|
|
|
walkerCmd->setThreadGroupIdXDimension(static_cast<uint32_t>(numWorkGroups[0]));
|
|
|
|
|
walkerCmd->setThreadGroupIdYDimension(static_cast<uint32_t>(numWorkGroups[1]));
|
|
|
|
|
walkerCmd->setThreadGroupIdZDimension(static_cast<uint32_t>(numWorkGroups[2]));
|
|
|
|
|
|
|
|
|
|
// compute executionMask - to tell which SIMD lines are active within thread
|
|
|
|
|
auto remainderSimdLanes = localWorkSize & (simd - 1);
|
2019-11-27 18:00:52 +01:00
|
|
|
uint64_t executionMask = maxNBitValue(remainderSimdLanes);
|
2019-05-13 14:15:03 +02:00
|
|
|
if (!executionMask)
|
|
|
|
|
executionMask = ~executionMask;
|
|
|
|
|
|
2021-11-04 15:40:13 +00:00
|
|
|
using SIMD_SIZE = typename WALKER_TYPE::SIMD_SIZE;
|
2019-05-13 14:15:03 +02:00
|
|
|
|
|
|
|
|
walkerCmd->setRightExecutionMask(static_cast<uint32_t>(executionMask));
|
|
|
|
|
walkerCmd->setBottomExecutionMask(static_cast<uint32_t>(0xffffffff));
|
2021-11-04 15:40:13 +00:00
|
|
|
walkerCmd->setSimdSize(getSimdConfig<WALKER_TYPE>(simd));
|
2019-05-13 14:15:03 +02:00
|
|
|
|
|
|
|
|
walkerCmd->setThreadGroupIdStartingX(static_cast<uint32_t>(startWorkGroups[0]));
|
|
|
|
|
walkerCmd->setThreadGroupIdStartingY(static_cast<uint32_t>(startWorkGroups[1]));
|
|
|
|
|
walkerCmd->setThreadGroupIdStartingResumeZ(static_cast<uint32_t>(startWorkGroups[2]));
|
|
|
|
|
|
|
|
|
|
return localWorkSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
|
void GpgpuWalkerHelper<GfxFamily>::setupTimestampPacket(
|
|
|
|
|
LinearStream *cmdStream,
|
2021-11-04 15:40:13 +00:00
|
|
|
WALKER_TYPE *walkerCmd,
|
2021-03-24 18:21:13 +00:00
|
|
|
TagNodeBase *timestampPacketNode,
|
2020-02-05 13:53:29 +01:00
|
|
|
const RootDeviceEnvironment &rootDeviceEnvironment) {
|
2019-05-13 14:15:03 +02:00
|
|
|
|
2020-11-24 14:20:25 +00:00
|
|
|
uint64_t address = TimestampPacketHelper::getContextEndGpuAddress(*timestampPacketNode);
|
|
|
|
|
PipeControlArgs args;
|
|
|
|
|
MemorySynchronizationCommands<GfxFamily>::addPipeControlAndProgramPostSyncOperation(
|
|
|
|
|
*cmdStream,
|
|
|
|
|
PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA,
|
|
|
|
|
address,
|
|
|
|
|
0,
|
|
|
|
|
*rootDeviceEnvironment.getHardwareInfo(),
|
|
|
|
|
args);
|
|
|
|
|
|
|
|
|
|
EncodeDispatchKernel<GfxFamily>::adjustTimestampPacket(*walkerCmd, *rootDeviceEnvironment.getHardwareInfo());
|
2019-05-13 14:15:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2021-03-03 17:29:32 +00:00
|
|
|
size_t EnqueueOperation<GfxFamily>::getSizeRequiredCSKernel(bool reserveProfilingCmdsSpace, bool reservePerfCounters, CommandQueue &commandQueue, const Kernel *pKernel, const DispatchInfo &dispatchInfo) {
|
2021-03-26 14:32:49 +00:00
|
|
|
size_t size = sizeof(typename GfxFamily::GPGPU_WALKER) + HardwareCommandsHelper<GfxFamily>::getSizeRequiredCS() +
|
2020-11-13 11:41:45 +01:00
|
|
|
sizeof(PIPE_CONTROL) * (MemorySynchronizationCommands<GfxFamily>::isPipeControlWArequired(commandQueue.getDevice().getHardwareInfo()) ? 2 : 1);
|
2019-06-27 13:58:18 +02:00
|
|
|
size += HardwareCommandsHelper<GfxFamily>::getSizeRequiredForCacheFlush(commandQueue, pKernel, 0U);
|
2019-05-13 14:15:03 +02:00
|
|
|
size += PreemptionHelper::getPreemptionWaCsSize<GfxFamily>(commandQueue.getDevice());
|
|
|
|
|
if (reserveProfilingCmdsSpace) {
|
|
|
|
|
size += 2 * sizeof(PIPE_CONTROL) + 2 * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
|
}
|
2021-10-06 19:04:45 +00:00
|
|
|
size += PerformanceCounters::getGpuCommandsSize(commandQueue.getPerfCounters(), commandQueue.getGpgpuEngine().osContext->getEngineType(), reservePerfCounters);
|
2019-05-13 14:15:03 +02:00
|
|
|
size += GpgpuWalkerHelper<GfxFamily>::getSizeForWADisableLSQCROPERFforOCL(pKernel);
|
2021-03-22 15:26:03 +00:00
|
|
|
size += GpgpuWalkerHelper<GfxFamily>::getSizeForWaDisableRccRhwoOptimization(pKernel);
|
2019-05-13 14:15:03 +02:00
|
|
|
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
|
size_t EnqueueOperation<GfxFamily>::getSizeRequiredForTimestampPacketWrite() {
|
|
|
|
|
return sizeof(PIPE_CONTROL);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-13 16:48:45 +02:00
|
|
|
template <typename GfxFamily>
|
|
|
|
|
void GpgpuWalkerHelper<GfxFamily>::adjustMiStoreRegMemMode(MI_STORE_REG_MEM<GfxFamily> *storeCmd) {
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-14 09:59:16 +02:00
|
|
|
template <typename GfxFamily>
|
|
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchProfilingCommandsStart(
|
2021-03-24 18:21:13 +00:00
|
|
|
TagNodeBase &hwTimeStamps,
|
2020-07-14 09:59:16 +02:00
|
|
|
LinearStream *commandStream,
|
|
|
|
|
const HardwareInfo &hwInfo) {
|
|
|
|
|
using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM;
|
|
|
|
|
|
|
|
|
|
// PIPE_CONTROL for global timestamp
|
|
|
|
|
uint64_t timeStampAddress = hwTimeStamps.getGpuAddress() + offsetof(HwTimeStamps, GlobalStartTS);
|
|
|
|
|
PipeControlArgs args;
|
|
|
|
|
MemorySynchronizationCommands<GfxFamily>::addPipeControlAndProgramPostSyncOperation(
|
|
|
|
|
*commandStream,
|
|
|
|
|
PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_TIMESTAMP,
|
|
|
|
|
timeStampAddress,
|
|
|
|
|
0llu,
|
|
|
|
|
hwInfo,
|
|
|
|
|
args);
|
|
|
|
|
|
2020-12-04 12:53:01 +01:00
|
|
|
if (!HwHelper::get(hwInfo.platform.eRenderCoreFamily).useOnlyGlobalTimestamps()) {
|
|
|
|
|
//MI_STORE_REGISTER_MEM for context local timestamp
|
|
|
|
|
timeStampAddress = hwTimeStamps.getGpuAddress() + offsetof(HwTimeStamps, ContextStartTS);
|
|
|
|
|
|
|
|
|
|
//low part
|
|
|
|
|
auto pMICmdLow = commandStream->getSpaceForCmd<MI_STORE_REGISTER_MEM>();
|
|
|
|
|
MI_STORE_REGISTER_MEM cmd = GfxFamily::cmdInitStoreRegisterMem;
|
|
|
|
|
adjustMiStoreRegMemMode(&cmd);
|
|
|
|
|
cmd.setRegisterAddress(GP_THREAD_TIME_REG_ADDRESS_OFFSET_LOW);
|
|
|
|
|
cmd.setMemoryAddress(timeStampAddress);
|
|
|
|
|
*pMICmdLow = cmd;
|
|
|
|
|
}
|
2020-07-14 09:59:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
|
void GpgpuWalkerHelper<GfxFamily>::dispatchProfilingCommandsEnd(
|
2021-03-24 18:21:13 +00:00
|
|
|
TagNodeBase &hwTimeStamps,
|
2020-09-03 09:06:11 +02:00
|
|
|
LinearStream *commandStream,
|
|
|
|
|
const HardwareInfo &hwInfo) {
|
2020-07-14 09:59:16 +02:00
|
|
|
using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM;
|
|
|
|
|
|
|
|
|
|
// PIPE_CONTROL for global timestamp
|
2020-12-04 12:53:01 +01:00
|
|
|
uint64_t timeStampAddress = hwTimeStamps.getGpuAddress() + offsetof(HwTimeStamps, GlobalEndTS);
|
|
|
|
|
PipeControlArgs args;
|
|
|
|
|
MemorySynchronizationCommands<GfxFamily>::addPipeControlAndProgramPostSyncOperation(
|
|
|
|
|
*commandStream,
|
|
|
|
|
PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_TIMESTAMP,
|
|
|
|
|
timeStampAddress,
|
|
|
|
|
0llu,
|
|
|
|
|
hwInfo,
|
|
|
|
|
args);
|
|
|
|
|
|
|
|
|
|
if (!HwHelper::get(hwInfo.platform.eRenderCoreFamily).useOnlyGlobalTimestamps()) {
|
|
|
|
|
//MI_STORE_REGISTER_MEM for context local timestamp
|
|
|
|
|
uint64_t timeStampAddress = hwTimeStamps.getGpuAddress() + offsetof(HwTimeStamps, ContextEndTS);
|
|
|
|
|
|
|
|
|
|
//low part
|
|
|
|
|
auto pMICmdLow = commandStream->getSpaceForCmd<MI_STORE_REGISTER_MEM>();
|
|
|
|
|
MI_STORE_REGISTER_MEM cmd = GfxFamily::cmdInitStoreRegisterMem;
|
|
|
|
|
adjustMiStoreRegMemMode(&cmd);
|
|
|
|
|
cmd.setRegisterAddress(GP_THREAD_TIME_REG_ADDRESS_OFFSET_LOW);
|
|
|
|
|
cmd.setMemoryAddress(timeStampAddress);
|
|
|
|
|
*pMICmdLow = cmd;
|
|
|
|
|
}
|
2020-07-14 09:59:16 +02:00
|
|
|
}
|
|
|
|
|
|
2020-08-19 11:06:01 +02:00
|
|
|
template <typename GfxFamily>
|
|
|
|
|
size_t EnqueueOperation<GfxFamily>::getSizeForCacheFlushAfterWalkerCommands(const Kernel &kernel, const CommandQueue &commandQueue) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-13 14:15:03 +02:00
|
|
|
} // namespace NEO
|