Files
compute-runtime/runtime/command_queue/hardware_interface_base.inl
Filip Hazubski b16bd14f37 Change virtual class HardwareInterface to static
Change-Id: I4f1f59ecb51b95041dc6dcc6c606b94595813f53
Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
2018-10-01 15:11:43 +02:00

107 lines
3.7 KiB
C++

/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "runtime/command_queue/hardware_interface.h"
namespace OCLRT {
template <typename GfxFamily>
inline void HardwareInterface<GfxFamily>::getDefaultDshSpace(
const size_t &offsetInterfaceDescriptorTable,
CommandQueue &commandQueue,
const MultiDispatchInfo &multiDispatchInfo,
size_t &totalInterfaceDescriptorTableSize,
Kernel *parentKernel,
IndirectHeap *dsh,
LinearStream *commandStream) {
size_t numDispatches = multiDispatchInfo.size();
totalInterfaceDescriptorTableSize *= numDispatches;
if (!parentKernel) {
dsh->getSpace(totalInterfaceDescriptorTableSize);
} else {
dsh->getSpace(commandQueue.getContext().getDefaultDeviceQueue()->getDshOffset() - dsh->getUsed());
}
}
template <typename GfxFamily>
inline typename HardwareInterface<GfxFamily>::INTERFACE_DESCRIPTOR_DATA *
HardwareInterface<GfxFamily>::obtainInterfaceDescriptorData(
WALKER_HANDLE pCmdData) {
return nullptr;
}
template <typename GfxFamily>
inline void HardwareInterface<GfxFamily>::setOffsetCrossThreadData(
WALKER_HANDLE pCmdData,
size_t &offsetCrossThreadData,
uint32_t &interfaceDescriptorIndex) {
WALKER_TYPE<GfxFamily> *pCmd = static_cast<WALKER_TYPE<GfxFamily> *>(pCmdData);
pCmd->setIndirectDataStartAddress(static_cast<uint32_t>(offsetCrossThreadData));
pCmd->setInterfaceDescriptorOffset(interfaceDescriptorIndex++);
}
template <typename GfxFamily>
inline void HardwareInterface<GfxFamily>::dispatchWorkarounds(
LinearStream *commandStream,
CommandQueue &commandQueue,
Kernel &kernel,
const bool &enable) {
if (enable) {
PreemptionHelper::applyPreemptionWaCmdsBegin<GfxFamily>(commandStream, commandQueue.getDevice());
// Implement enabling special WA DisableLSQCROPERFforOCL if needed
GpgpuWalkerHelper<GfxFamily>::applyWADisableLSQCROPERFforOCL(commandStream, kernel, enable);
} else {
// Implement disabling special WA DisableLSQCROPERFforOCL if needed
GpgpuWalkerHelper<GfxFamily>::applyWADisableLSQCROPERFforOCL(commandStream, kernel, enable);
PreemptionHelper::applyPreemptionWaCmdsEnd<GfxFamily>(commandStream, commandQueue.getDevice());
}
}
template <typename GfxFamily>
inline void HardwareInterface<GfxFamily>::dispatchProfilingPerfStartCommands(
const DispatchInfo &dispatchInfo,
const MultiDispatchInfo &multiDispatchInfo,
HwTimeStamps *hwTimeStamps,
HwPerfCounter *hwPerfCounter,
LinearStream *commandStream,
CommandQueue &commandQueue) {
if (&dispatchInfo == &*multiDispatchInfo.begin()) {
// If hwTimeStampAlloc is passed (not nullptr), then we know that profiling is enabled
if (hwTimeStamps != nullptr) {
GpgpuWalkerHelper<GfxFamily>::dispatchProfilingCommandsStart(*hwTimeStamps, commandStream);
}
if (hwPerfCounter != nullptr) {
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersCommandsStart(commandQueue, *hwPerfCounter, commandStream);
}
}
}
template <typename GfxFamily>
inline void HardwareInterface<GfxFamily>::dispatchProfilingPerfEndCommands(
HwTimeStamps *hwTimeStamps,
HwPerfCounter *hwPerfCounter,
LinearStream *commandStream,
CommandQueue &commandQueue) {
// If hwTimeStamps is passed (not nullptr), then we know that profiling is enabled
if (hwTimeStamps != nullptr) {
GpgpuWalkerHelper<GfxFamily>::dispatchProfilingCommandsEnd(*hwTimeStamps, commandStream);
}
if (hwPerfCounter != nullptr) {
GpgpuWalkerHelper<GfxFamily>::dispatchPerfCountersCommandsEnd(commandQueue, *hwPerfCounter, commandStream);
}
}
} // namespace OCLRT