2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2024-01-19 11:22:14 +00:00
|
|
|
* Copyright (C) 2018-2024 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2023-01-09 15:02:00 +00:00
|
|
|
#include <cstddef>
|
|
|
|
|
#include <cstdint>
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2023-01-09 15:02:00 +00:00
|
|
|
class LinearStream;
|
|
|
|
|
enum PreemptionMode : uint32_t;
|
|
|
|
|
struct HardwareInfo;
|
|
|
|
|
struct RootDeviceEnvironment;
|
2017-12-21 00:45:38 +01:00
|
|
|
class Device;
|
|
|
|
|
class GraphicsAllocation;
|
2021-09-23 13:06:18 +00:00
|
|
|
struct KernelDescriptor;
|
2022-11-10 09:37:42 +00:00
|
|
|
struct RuntimeCapabilityTable;
|
2023-03-27 12:03:02 +00:00
|
|
|
class OsContext;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-11-25 16:45:52 +01: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;
|
2022-01-10 18:55:21 +00:00
|
|
|
uint32_t reserved : 26;
|
2019-11-25 16:45:52 +01:00
|
|
|
} flags;
|
|
|
|
|
uint32_t data;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
class PreemptionHelper {
|
|
|
|
|
public:
|
2018-03-01 22:43:04 +01:00
|
|
|
template <typename CmdFamily>
|
|
|
|
|
using INTERFACE_DESCRIPTOR_DATA = typename CmdFamily::INTERFACE_DESCRIPTOR_DATA;
|
|
|
|
|
|
2019-11-27 12:59:47 +01:00
|
|
|
static PreemptionMode taskPreemptionMode(PreemptionMode devicePreemptionMode, const PreemptionFlags &flags);
|
2019-11-25 16:45:52 +01:00
|
|
|
static bool allowThreadGroupPreemption(const PreemptionFlags &flags);
|
|
|
|
|
static bool allowMidThreadPreemption(const PreemptionFlags &flags);
|
2017-12-21 00:45:38 +01:00
|
|
|
static void adjustDefaultPreemptionMode(RuntimeCapabilityTable &deviceCapabilities, bool allowMidThread, bool allowThreadGroup, bool allowMidBatch);
|
2022-01-10 18:55:21 +00:00
|
|
|
static PreemptionFlags createPreemptionLevelFlags(Device &device, const KernelDescriptor *kernelDescriptor);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-01-08 15:58:02 +01:00
|
|
|
template <typename GfxFamily>
|
|
|
|
|
static size_t getRequiredPreambleSize(const Device &device);
|
2018-11-05 11:52:19 +01:00
|
|
|
template <typename GfxFamily>
|
2021-10-17 12:21:29 +00:00
|
|
|
static size_t getRequiredStateSipCmdSize(Device &device, bool isRcs);
|
2018-11-05 11:52:19 +01:00
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2023-09-12 17:51:43 +00:00
|
|
|
static void programCsrBaseAddress(LinearStream &preambleCmdStream, Device &device, const GraphicsAllocation *preemptionCsr);
|
2018-01-08 15:58:02 +01:00
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2023-09-12 17:51:43 +00:00
|
|
|
static void programStateSip(LinearStream &preambleCmdStream, Device &device, OsContext *context);
|
2018-01-08 15:58:02 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
template <typename GfxFamily>
|
2018-01-08 15:58:02 +01:00
|
|
|
static size_t getRequiredCmdStreamSize(PreemptionMode newPreemptionMode, PreemptionMode oldPreemptionMode);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-01-08 15:58:02 +01:00
|
|
|
static void programCmdStream(LinearStream &cmdStream, PreemptionMode newPreemptionMode, PreemptionMode oldPreemptionMode,
|
2019-07-31 08:57:00 +02:00
|
|
|
GraphicsAllocation *preemptionCsr);
|
2018-01-02 12:10:34 +01:00
|
|
|
|
2018-02-06 11:58:05 +01:00
|
|
|
static PreemptionMode getDefaultPreemptionMode(const HardwareInfo &hwInfo);
|
2018-03-01 22:43:04 +01:00
|
|
|
|
2023-11-23 13:58:58 +00:00
|
|
|
template <typename GfxFamily, typename InterfaceDescriptorType>
|
|
|
|
|
static void programInterfaceDescriptorDataPreemption(InterfaceDescriptorType *idd, PreemptionMode preemptionMode);
|
2022-06-21 10:28:33 +00:00
|
|
|
|
|
|
|
|
protected:
|
2022-06-22 12:10:21 +00:00
|
|
|
template <typename GfxFamily>
|
2023-09-12 17:51:43 +00:00
|
|
|
static void programCsrBaseAddressCmd(LinearStream &preambleCmdStream, const GraphicsAllocation *preemptionCsr);
|
2022-06-22 12:10:21 +00:00
|
|
|
|
2022-06-21 10:28:33 +00:00
|
|
|
template <typename GfxFamily>
|
2024-01-19 11:22:14 +00:00
|
|
|
static void programStateSipCmd(LinearStream &preambleCmdStream, GraphicsAllocation *sipAllocation, bool useFullAddress);
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
2018-02-12 13:41:08 +01: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 11:59:46 +01:00
|
|
|
} // namespace NEO
|