2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-01-29 01:30:56 +08:00
|
|
|
* Copyright (C) 2018-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 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/linear_stream.h"
|
|
|
|
#include "shared/source/command_stream/preemption_mode.h"
|
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2019-02-13 00:27:13 +08:00
|
|
|
#include "sku_info.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
class Device;
|
|
|
|
class GraphicsAllocation;
|
2021-09-23 21:06:18 +08:00
|
|
|
struct KernelDescriptor;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-11-25 23:45:52 +08:00
|
|
|
struct PreemptionFlags {
|
|
|
|
PreemptionFlags() {
|
|
|
|
data = 0;
|
|
|
|
}
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint32_t disabledMidThreadPreemptionKernel : 1;
|
|
|
|
uint32_t vmeKernel : 1;
|
|
|
|
uint32_t deviceSupportsVmePreemption : 1;
|
|
|
|
uint32_t disablePerCtxtPreemptionGranularityControl : 1;
|
|
|
|
uint32_t usesFencesForReadWriteImages : 1;
|
|
|
|
uint32_t disableLSQCROPERFforOCL : 1;
|
|
|
|
uint32_t schedulerKernel : 1;
|
|
|
|
uint32_t reserved : 25;
|
|
|
|
} flags;
|
|
|
|
uint32_t data;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
class PreemptionHelper {
|
|
|
|
public:
|
2018-03-02 05:43:04 +08:00
|
|
|
template <typename CmdFamily>
|
|
|
|
using INTERFACE_DESCRIPTOR_DATA = typename CmdFamily::INTERFACE_DESCRIPTOR_DATA;
|
|
|
|
|
2019-11-27 19:59:47 +08:00
|
|
|
static PreemptionMode taskPreemptionMode(PreemptionMode devicePreemptionMode, const PreemptionFlags &flags);
|
2019-11-25 23:45:52 +08:00
|
|
|
static bool allowThreadGroupPreemption(const PreemptionFlags &flags);
|
|
|
|
static bool allowMidThreadPreemption(const PreemptionFlags &flags);
|
2017-12-21 07:45:38 +08:00
|
|
|
static void adjustDefaultPreemptionMode(RuntimeCapabilityTable &deviceCapabilities, bool allowMidThread, bool allowThreadGroup, bool allowMidBatch);
|
2021-09-23 21:06:18 +08:00
|
|
|
static PreemptionFlags createPreemptionLevelFlags(Device &device, const KernelDescriptor *kernelDescriptor, bool schedulerKernel);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-01-08 22:58:02 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
static size_t getRequiredPreambleSize(const Device &device);
|
2018-11-05 18:52:19 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
static size_t getRequiredStateSipCmdSize(const Device &device);
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
static void programCsrBaseAddress(LinearStream &preambleCmdStream, Device &device, const GraphicsAllocation *preemptionCsr);
|
2018-01-08 22:58:02 +08:00
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-11-05 18:52:19 +08:00
|
|
|
static void programStateSip(LinearStream &preambleCmdStream, Device &device);
|
2018-01-08 22:58:02 +08:00
|
|
|
|
2021-01-29 01:30:56 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
static void programStateSipEndWa(LinearStream &cmdStream, Device &device);
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
2018-01-08 22:58:02 +08:00
|
|
|
static size_t getRequiredCmdStreamSize(PreemptionMode newPreemptionMode, PreemptionMode oldPreemptionMode);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-01-08 22:58:02 +08:00
|
|
|
static void programCmdStream(LinearStream &cmdStream, PreemptionMode newPreemptionMode, PreemptionMode oldPreemptionMode,
|
2019-07-31 14:57:00 +08:00
|
|
|
GraphicsAllocation *preemptionCsr);
|
2018-01-02 19:10:34 +08:00
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
static size_t getPreemptionWaCsSize(const Device &device);
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
static void applyPreemptionWaCmdsBegin(LinearStream *pCommandStream, const Device &device);
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
static void applyPreemptionWaCmdsEnd(LinearStream *pCommandStream, const Device &device);
|
2018-02-06 18:58:05 +08:00
|
|
|
|
|
|
|
static PreemptionMode getDefaultPreemptionMode(const HardwareInfo &hwInfo);
|
2018-03-02 05:43:04 +08:00
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
static void programInterfaceDescriptorDataPreemption(INTERFACE_DESCRIPTOR_DATA<GfxFamily> *idd, PreemptionMode preemptionMode);
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2018-02-12 20:41:08 +08:00
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
struct PreemptionConfig {
|
|
|
|
static const uint32_t mmioAddress;
|
|
|
|
static const uint32_t mask;
|
|
|
|
|
|
|
|
static const uint32_t threadGroupVal;
|
|
|
|
static const uint32_t cmdLevelVal;
|
|
|
|
static const uint32_t midThreadVal;
|
|
|
|
};
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|