2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-05-17 02:51:16 +08:00
|
|
|
* Copyright (C) 2019-2021 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 20:10:44 +08:00
|
|
|
#include "shared/source/built_ins/built_ins.h"
|
2021-09-30 17:04:25 +08:00
|
|
|
#include "shared/source/helpers/per_thread_data.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/kernel/kernel.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2018-04-18 20:59:28 +08:00
|
|
|
#include <algorithm>
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <cstddef>
|
2019-02-27 18:39:32 +08:00
|
|
|
#include <cstdint>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2020-01-22 23:22:30 +08:00
|
|
|
class CommandQueue;
|
2017-12-21 07:45:38 +08:00
|
|
|
class LinearStream;
|
|
|
|
class IndirectHeap;
|
|
|
|
struct CrossThreadInfo;
|
|
|
|
struct MultiDispatchInfo;
|
|
|
|
|
2018-09-28 22:16:18 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
using WALKER_TYPE = typename GfxFamily::WALKER_TYPE;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
2019-06-12 15:13:06 +08:00
|
|
|
struct HardwareCommandsHelper : public PerThreadDataHelper {
|
2018-05-11 19:33:16 +08:00
|
|
|
using BINDING_TABLE_STATE = typename GfxFamily::BINDING_TABLE_STATE;
|
|
|
|
using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE;
|
|
|
|
using INTERFACE_DESCRIPTOR_DATA = typename GfxFamily::INTERFACE_DESCRIPTOR_DATA;
|
2018-09-26 06:44:43 +08:00
|
|
|
using MI_ATOMIC = typename GfxFamily::MI_ATOMIC;
|
2020-01-09 00:42:14 +08:00
|
|
|
using COMPARE_OPERATION = typename GfxFamily::MI_SEMAPHORE_WAIT::COMPARE_OPERATION;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-10-04 21:01:52 +08:00
|
|
|
static INTERFACE_DESCRIPTOR_DATA *getInterfaceDescriptor(
|
|
|
|
const IndirectHeap &indirectHeap,
|
|
|
|
uint64_t offsetInterfaceDescriptor,
|
|
|
|
INTERFACE_DESCRIPTOR_DATA *inlineInterfaceDescriptor);
|
|
|
|
|
2020-04-03 16:50:54 +08:00
|
|
|
static void setGrfInfo(
|
2018-10-04 21:01:52 +08:00
|
|
|
INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor,
|
2019-09-20 20:55:06 +08:00
|
|
|
const Kernel &kernel,
|
2018-10-04 21:01:52 +08:00
|
|
|
const size_t &sizeCrossThreadData,
|
2021-03-22 23:26:03 +08:00
|
|
|
const size_t &sizePerThreadData);
|
2020-04-03 16:50:54 +08:00
|
|
|
|
2018-10-04 21:01:52 +08:00
|
|
|
inline static uint32_t additionalSizeRequiredDsh();
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
static size_t sendInterfaceDescriptorData(
|
|
|
|
const IndirectHeap &indirectHeap,
|
|
|
|
uint64_t offsetInterfaceDescriptor,
|
|
|
|
uint64_t kernelStartOffset,
|
|
|
|
size_t sizeCrossThreadData,
|
|
|
|
size_t sizePerThreadData,
|
|
|
|
size_t bindingTablePointer,
|
|
|
|
size_t offsetSamplerState,
|
|
|
|
uint32_t numSamplers,
|
2020-04-07 20:07:31 +08:00
|
|
|
uint32_t numThreadsPerThreadGroup,
|
2019-09-20 20:55:06 +08:00
|
|
|
const Kernel &kernel,
|
2018-08-13 21:05:59 +08:00
|
|
|
uint32_t bindingTablePrefetchSize,
|
2018-05-11 19:33:16 +08:00
|
|
|
PreemptionMode preemptionMode,
|
2020-11-13 18:41:45 +08:00
|
|
|
INTERFACE_DESCRIPTOR_DATA *inlineInterfaceDescriptor,
|
2020-12-07 22:41:52 +08:00
|
|
|
const Device &device);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
static void sendMediaStateFlush(
|
|
|
|
LinearStream &commandStream,
|
|
|
|
size_t offsetInterfaceDescriptorData);
|
|
|
|
|
|
|
|
static void sendMediaInterfaceDescriptorLoad(
|
|
|
|
LinearStream &commandStream,
|
|
|
|
size_t offsetInterfaceDescriptorData,
|
|
|
|
size_t sizeInterfaceDescriptorData);
|
|
|
|
|
|
|
|
static size_t sendCrossThreadData(
|
|
|
|
IndirectHeap &indirectHeap,
|
2018-10-18 12:38:18 +08:00
|
|
|
Kernel &kernel,
|
|
|
|
bool inlineDataProgrammingRequired,
|
|
|
|
WALKER_TYPE<GfxFamily> *walkerCmd,
|
2021-03-22 19:06:23 +08:00
|
|
|
uint32_t &sizeCrossThreadData);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
static size_t sendIndirectState(
|
|
|
|
LinearStream &commandStream,
|
|
|
|
IndirectHeap &dsh,
|
|
|
|
IndirectHeap &ioh,
|
|
|
|
IndirectHeap &ssh,
|
2018-03-14 18:07:51 +08:00
|
|
|
Kernel &kernel,
|
2020-01-23 22:52:49 +08:00
|
|
|
uint64_t kernelStartOffset,
|
2017-12-21 07:45:38 +08:00
|
|
|
uint32_t simd,
|
|
|
|
const size_t localWorkSize[3],
|
|
|
|
const uint64_t offsetInterfaceDescriptorTable,
|
2018-09-28 22:16:18 +08:00
|
|
|
uint32_t &interfaceDescriptorIndex,
|
2018-05-11 19:33:16 +08:00
|
|
|
PreemptionMode preemptionMode,
|
2018-09-28 22:16:18 +08:00
|
|
|
WALKER_TYPE<GfxFamily> *walkerCmd,
|
2018-09-25 02:53:35 +08:00
|
|
|
INTERFACE_DESCRIPTOR_DATA *inlineInterfaceDescriptor,
|
2020-11-13 18:41:45 +08:00
|
|
|
bool localIdsGenerationByRuntime,
|
2020-11-19 02:39:32 +08:00
|
|
|
const Device &device);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-10-04 21:01:52 +08:00
|
|
|
static void programPerThreadData(
|
|
|
|
size_t &sizePerThreadData,
|
|
|
|
const bool &localIdsGenerationByRuntime,
|
|
|
|
LinearStream &ioh,
|
|
|
|
uint32_t &simd,
|
|
|
|
uint32_t &numChannels,
|
|
|
|
const size_t localWorkSize[3],
|
|
|
|
Kernel &kernel,
|
|
|
|
size_t &sizePerThreadDataTotal,
|
2020-12-07 22:41:52 +08:00
|
|
|
size_t &localWorkItems,
|
|
|
|
uint32_t rootDeviceIndex);
|
2018-10-04 21:01:52 +08:00
|
|
|
|
|
|
|
static void updatePerThreadDataTotal(
|
|
|
|
size_t &sizePerThreadData,
|
|
|
|
uint32_t &simd,
|
|
|
|
uint32_t &numChannels,
|
|
|
|
size_t &sizePerThreadDataTotal,
|
|
|
|
size_t &localWorkItems);
|
|
|
|
|
|
|
|
inline static bool resetBindingTablePrefetch(Kernel &kernel);
|
|
|
|
|
2021-03-26 22:32:49 +08:00
|
|
|
static size_t getSizeRequiredCS();
|
2019-06-27 19:58:18 +08:00
|
|
|
static size_t getSizeRequiredForCacheFlush(const CommandQueue &commandQueue, const Kernel *kernel, uint64_t postSyncAddress);
|
2020-10-06 00:32:55 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
static size_t getSizeRequiredDSH(
|
|
|
|
const Kernel &kernel);
|
|
|
|
static size_t getSizeRequiredIOH(
|
|
|
|
const Kernel &kernel,
|
|
|
|
size_t localWorkSize = 256);
|
|
|
|
static size_t getSizeRequiredSSH(
|
2021-03-22 23:26:03 +08:00
|
|
|
const Kernel &kernel);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
static size_t getTotalSizeRequiredDSH(
|
|
|
|
const MultiDispatchInfo &multiDispatchInfo);
|
|
|
|
static size_t getTotalSizeRequiredIOH(
|
2018-02-13 22:43:33 +08:00
|
|
|
const MultiDispatchInfo &multiDispatchInfo);
|
2017-12-21 07:45:38 +08:00
|
|
|
static size_t getTotalSizeRequiredSSH(
|
|
|
|
const MultiDispatchInfo &multiDispatchInfo);
|
|
|
|
|
2021-03-22 23:26:03 +08:00
|
|
|
static size_t getSshSizeForExecutionModel(const Kernel &kernel);
|
2018-10-04 21:01:52 +08:00
|
|
|
static void setInterfaceDescriptorOffset(
|
|
|
|
WALKER_TYPE<GfxFamily> *walkerCmd,
|
|
|
|
uint32_t &interfaceDescriptorIndex);
|
|
|
|
|
2019-06-27 14:52:04 +08:00
|
|
|
static void programCacheFlushAfterWalkerCommand(LinearStream *commandStream, const CommandQueue &commandQueue, const Kernel *kernel, uint64_t postSyncAddress);
|
2018-09-11 16:15:54 +08:00
|
|
|
|
2021-03-22 23:26:03 +08:00
|
|
|
static bool inlineDataProgrammingRequired(const Kernel &kernel);
|
|
|
|
static bool kernelUsesLocalIds(const Kernel &kernel);
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|