/* * Copyright (C) 2018-2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once #include "shared/source/command_stream/command_stream_receiver.h" #include "shared/source/command_stream/linear_stream.h" #include "shared/source/command_stream/preemption_mode.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/os_interface/hw_info_config.h" #include "sku_info.h" namespace NEO { class Device; class GraphicsAllocation; struct KernelDescriptor; 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; }; }; class PreemptionHelper { public: template using INTERFACE_DESCRIPTOR_DATA = typename CmdFamily::INTERFACE_DESCRIPTOR_DATA; static PreemptionMode taskPreemptionMode(PreemptionMode devicePreemptionMode, const PreemptionFlags &flags); static bool allowThreadGroupPreemption(const PreemptionFlags &flags); static bool allowMidThreadPreemption(const PreemptionFlags &flags); static void adjustDefaultPreemptionMode(RuntimeCapabilityTable &deviceCapabilities, bool allowMidThread, bool allowThreadGroup, bool allowMidBatch); static PreemptionFlags createPreemptionLevelFlags(Device &device, const KernelDescriptor *kernelDescriptor, bool schedulerKernel); template static size_t getRequiredPreambleSize(const Device &device); template static size_t getRequiredStateSipCmdSize(Device &device, bool isRcs); template static void programCsrBaseAddress(LinearStream &preambleCmdStream, Device &device, const GraphicsAllocation *preemptionCsr); template static void programStateSip(LinearStream &preambleCmdStream, Device &device); template static void programStateSipEndWa(LinearStream &cmdStream, Device &device); template static size_t getRequiredCmdStreamSize(PreemptionMode newPreemptionMode, PreemptionMode oldPreemptionMode); template static void programCmdStream(LinearStream &cmdStream, PreemptionMode newPreemptionMode, PreemptionMode oldPreemptionMode, GraphicsAllocation *preemptionCsr); template static size_t getPreemptionWaCsSize(const Device &device); template static void applyPreemptionWaCmdsBegin(LinearStream *pCommandStream, const Device &device); template static void applyPreemptionWaCmdsEnd(LinearStream *pCommandStream, const Device &device); static PreemptionMode getDefaultPreemptionMode(const HardwareInfo &hwInfo); template static void programInterfaceDescriptorDataPreemption(INTERFACE_DESCRIPTOR_DATA *idd, PreemptionMode preemptionMode); }; template 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; }; } // namespace NEO