2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-09-18 15:11:08 +08:00
|
|
|
* Copyright (C) 2018 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
|
|
|
|
#include "runtime/command_stream/linear_stream.h"
|
|
|
|
#include "runtime/helpers/hw_helper.h"
|
|
|
|
|
|
|
|
namespace OCLRT {
|
|
|
|
class Kernel;
|
|
|
|
class Device;
|
|
|
|
class GraphicsAllocation;
|
|
|
|
struct MultiDispatchInfo;
|
|
|
|
|
|
|
|
class PreemptionHelper {
|
|
|
|
public:
|
2018-03-02 05:43:04 +08:00
|
|
|
template <typename CmdFamily>
|
|
|
|
using INTERFACE_DESCRIPTOR_DATA = typename CmdFamily::INTERFACE_DESCRIPTOR_DATA;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
static PreemptionMode taskPreemptionMode(Device &device, Kernel *kernel);
|
|
|
|
static PreemptionMode taskPreemptionMode(Device &device, const MultiDispatchInfo &multiDispatchInfo);
|
|
|
|
static bool allowThreadGroupPreemption(Kernel *kernel, const WorkaroundTable *waTable);
|
|
|
|
static bool allowMidThreadPreemption(Kernel *kernel, Device &device);
|
|
|
|
static void adjustDefaultPreemptionMode(RuntimeCapabilityTable &deviceCapabilities, bool allowMidThread, bool allowThreadGroup, bool allowMidBatch);
|
|
|
|
|
2018-01-08 22:58:02 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
static size_t getRequiredPreambleSize(const Device &device);
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-29 15:06:33 +08:00
|
|
|
static void programPreamble(LinearStream &preambleCmdStream, Device &device, const GraphicsAllocation *preemptionCsr);
|
2018-01-08 22:58:02 +08:00
|
|
|
|
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,
|
2018-03-27 15:58:00 +08:00
|
|
|
GraphicsAllocation *preemptionCsr, Device &device);
|
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 maskVal;
|
|
|
|
static const uint32_t maskShift;
|
|
|
|
static const uint32_t mask;
|
|
|
|
|
|
|
|
static const uint32_t threadGroupVal;
|
|
|
|
static const uint32_t cmdLevelVal;
|
|
|
|
static const uint32_t midThreadVal;
|
|
|
|
};
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
} // namespace OCLRT
|