2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-01-10 20:57:40 +08:00
|
|
|
* Copyright (C) 2017-2019 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-09-14 20:31:37 +08:00
|
|
|
#include "runtime/aub_mem_dump/aub_mem_dump.h"
|
2018-11-22 22:16:20 +08:00
|
|
|
#include "runtime/execution_environment/execution_environment.h"
|
|
|
|
#include "runtime/gmm_helper/gmm.h"
|
|
|
|
#include "runtime/gmm_helper/gmm_helper.h"
|
|
|
|
#include "runtime/helpers/aligned_memory.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/helpers/hw_helper.h"
|
2018-02-19 16:50:17 +08:00
|
|
|
#include "runtime/helpers/hw_info.h"
|
2018-11-22 22:16:20 +08:00
|
|
|
#include "runtime/memory_manager/graphics_allocation.h"
|
2018-06-08 22:42:29 +08:00
|
|
|
#include "runtime/memory_manager/memory_constants.h"
|
2019-02-12 17:56:27 +08:00
|
|
|
#include "runtime/os_interface/os_interface.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2017-12-21 23:54:19 +08:00
|
|
|
namespace OCLRT {
|
2018-11-22 22:16:20 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename Family>
|
|
|
|
void HwHelperHw<Family>::setCapabilityCoherencyFlag(const HardwareInfo *pHwInfo, bool &coherencyFlag) {
|
|
|
|
coherencyFlag = true;
|
|
|
|
}
|
2018-01-09 21:25:30 +08:00
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
void HwHelperHw<Family>::adjustDefaultEngineType(HardwareInfo *pHwInfo) {
|
|
|
|
}
|
2018-02-19 16:50:17 +08:00
|
|
|
|
2018-09-06 22:41:50 +08:00
|
|
|
template <typename Family>
|
2019-02-12 17:56:27 +08:00
|
|
|
bool HwHelperHw<Family>::isLocalMemoryEnabled(const HardwareInfo &hwInfo) const {
|
2018-09-06 22:41:50 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-19 16:50:17 +08:00
|
|
|
template <typename Family>
|
2018-08-23 23:42:35 +08:00
|
|
|
void HwHelperHw<Family>::setupHardwareCapabilities(HardwareCapabilities *caps, const HardwareInfo &hwInfo) {
|
2018-02-19 16:50:17 +08:00
|
|
|
caps->image3DMaxHeight = 16384;
|
|
|
|
caps->image3DMaxWidth = 16384;
|
2018-06-08 22:42:29 +08:00
|
|
|
//With statefull messages we have an allocation cap of 4GB
|
|
|
|
//Reason to subtract 8KB is that driver may pad the buffer with addition pages for over fetching..
|
|
|
|
caps->maxMemAllocSize = (4ULL * MemoryConstants::gigaByte) - (8ULL * MemoryConstants::kiloByte);
|
2018-07-10 19:22:11 +08:00
|
|
|
caps->isStatelesToStatefullWithOffsetSupported = true;
|
2018-02-19 16:50:17 +08:00
|
|
|
}
|
|
|
|
|
2018-06-06 14:45:45 +08:00
|
|
|
template <typename Family>
|
|
|
|
uint32_t HwHelperHw<Family>::getComputeUnitsUsedForScratch(const HardwareInfo *pHwInfo) const {
|
|
|
|
return pHwInfo->pSysInfo->MaxSubSlicesSupported * pHwInfo->pSysInfo->MaxEuPerSubSlice *
|
|
|
|
pHwInfo->pSysInfo->ThreadCount / pHwInfo->pSysInfo->EUCount;
|
|
|
|
}
|
|
|
|
|
2018-04-06 20:25:22 +08:00
|
|
|
template <typename Family>
|
|
|
|
SipKernelType HwHelperHw<Family>::getSipKernelType(bool debuggingActive) {
|
|
|
|
if (!debuggingActive) {
|
|
|
|
return SipKernelType::Csr;
|
|
|
|
}
|
|
|
|
return SipKernelType::DbgCsr;
|
|
|
|
}
|
2018-07-10 19:22:11 +08:00
|
|
|
|
2018-08-23 17:29:39 +08:00
|
|
|
template <typename Family>
|
|
|
|
uint32_t HwHelperHw<Family>::getConfigureAddressSpaceMode() {
|
|
|
|
return 0u;
|
|
|
|
}
|
2018-09-06 22:41:50 +08:00
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
bool HwHelperHw<Family>::setupPreemptionRegisters(HardwareInfo *pHwInfo, bool enable) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
size_t HwHelperHw<Family>::getMaxBarrierRegisterPerSlice() const {
|
|
|
|
return 32;
|
|
|
|
}
|
2018-09-26 03:44:36 +08:00
|
|
|
|
|
|
|
template <typename Family>
|
2018-10-24 17:15:06 +08:00
|
|
|
const AubMemDump::LrcaHelper &HwHelperHw<Family>::getCsTraits(EngineInstanceT engineInstance) const {
|
|
|
|
return *AUBFamilyMapper<Family>::csTraits[engineInstance.type];
|
2018-09-26 03:44:36 +08:00
|
|
|
}
|
2018-10-03 01:10:29 +08:00
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
bool HwHelperHw<Family>::isPageTableManagerSupported(const HardwareInfo &hwInfo) const {
|
|
|
|
return false;
|
|
|
|
}
|
2018-09-24 16:36:29 +08:00
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
bool HwHelperHw<Family>::supportsYTiling() const {
|
|
|
|
return true;
|
|
|
|
}
|
2018-10-18 19:40:53 +08:00
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
bool HwHelperHw<Family>::timestampPacketWriteSupported() const {
|
|
|
|
return false;
|
|
|
|
}
|
2018-11-22 22:16:20 +08:00
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
void HwHelperHw<Family>::setRenderSurfaceStateForBuffer(ExecutionEnvironment &executionEnvironment,
|
|
|
|
void *surfaceStateBuffer,
|
|
|
|
size_t bufferSize,
|
|
|
|
uint64_t gpuVa,
|
|
|
|
size_t offset,
|
|
|
|
uint32_t pitch,
|
|
|
|
GraphicsAllocation *gfxAlloc,
|
|
|
|
cl_mem_flags flags,
|
|
|
|
uint32_t surfaceType,
|
|
|
|
bool forceNonAuxMode) {
|
|
|
|
using RENDER_SURFACE_STATE = typename Family::RENDER_SURFACE_STATE;
|
|
|
|
using SURFACE_FORMAT = typename RENDER_SURFACE_STATE::SURFACE_FORMAT;
|
|
|
|
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
|
|
|
|
|
|
|
|
auto gmmHelper = executionEnvironment.getGmmHelper();
|
|
|
|
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(surfaceStateBuffer);
|
2019-01-18 00:10:12 +08:00
|
|
|
*surfaceState = Family::cmdInitRenderSurfaceState;
|
2018-11-22 22:16:20 +08:00
|
|
|
auto surfaceSize = alignUp(bufferSize, 4);
|
|
|
|
|
|
|
|
SURFACE_STATE_BUFFER_LENGTH Length = {0};
|
|
|
|
Length.Length = static_cast<uint32_t>(surfaceSize - 1);
|
|
|
|
|
|
|
|
surfaceState->setWidth(Length.SurfaceState.Width + 1);
|
|
|
|
surfaceState->setHeight(Length.SurfaceState.Height + 1);
|
|
|
|
surfaceState->setDepth(Length.SurfaceState.Depth + 1);
|
|
|
|
if (pitch) {
|
|
|
|
surfaceState->setSurfacePitch(pitch);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The graphics allocation for Host Ptr surface will be created in makeResident call and GPU address is expected to be the same as CPU address
|
|
|
|
auto bufferStateAddress = (gfxAlloc != nullptr) ? gfxAlloc->getGpuAddress() : gpuVa;
|
|
|
|
bufferStateAddress += offset;
|
|
|
|
|
|
|
|
auto bufferStateSize = (gfxAlloc != nullptr) ? gfxAlloc->getUnderlyingBufferSize() : bufferSize;
|
|
|
|
|
|
|
|
surfaceState->setSurfaceType(static_cast<typename RENDER_SURFACE_STATE::SURFACE_TYPE>(surfaceType));
|
|
|
|
|
|
|
|
surfaceState->setSurfaceFormat(SURFACE_FORMAT::SURFACE_FORMAT_RAW);
|
|
|
|
surfaceState->setSurfaceVerticalAlignment(RENDER_SURFACE_STATE::SURFACE_VERTICAL_ALIGNMENT_VALIGN_4);
|
|
|
|
surfaceState->setSurfaceHorizontalAlignment(RENDER_SURFACE_STATE::SURFACE_HORIZONTAL_ALIGNMENT_HALIGN_4);
|
|
|
|
|
|
|
|
surfaceState->setTileMode(RENDER_SURFACE_STATE::TILE_MODE_LINEAR);
|
|
|
|
surfaceState->setVerticalLineStride(0);
|
|
|
|
surfaceState->setVerticalLineStrideOffset(0);
|
|
|
|
if ((isAligned<MemoryConstants::cacheLineSize>(bufferStateAddress) && isAligned<MemoryConstants::cacheLineSize>(bufferStateSize)) ||
|
|
|
|
((flags & CL_MEM_READ_ONLY)) != 0) {
|
|
|
|
surfaceState->setMemoryObjectControlState(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER));
|
|
|
|
} else {
|
|
|
|
surfaceState->setMemoryObjectControlState(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED));
|
|
|
|
}
|
|
|
|
|
|
|
|
surfaceState->setSurfaceBaseAddress(bufferStateAddress);
|
|
|
|
|
2019-03-12 20:24:58 +08:00
|
|
|
Gmm *gmm = gfxAlloc ? gfxAlloc->getDefaultGmm() : nullptr;
|
2018-11-22 22:16:20 +08:00
|
|
|
if (gmm && gmm->isRenderCompressed && !forceNonAuxMode &&
|
|
|
|
GraphicsAllocation::AllocationType::BUFFER_COMPRESSED == gfxAlloc->getAllocationType()) {
|
|
|
|
// Its expected to not program pitch/qpitch/baseAddress for Aux surface in CCS scenarios
|
|
|
|
surfaceState->setCoherencyType(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT);
|
|
|
|
surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
|
|
|
|
} else {
|
|
|
|
surfaceState->setCoherencyType(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT);
|
|
|
|
surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
size_t HwHelperHw<Family>::getScratchSpaceOffsetFor64bit() {
|
|
|
|
return 4096;
|
|
|
|
}
|
|
|
|
|
2019-01-10 20:57:40 +08:00
|
|
|
template <typename Family>
|
|
|
|
const std::vector<EngineInstanceT> HwHelperHw<Family>::getGpgpuEngineInstances() const {
|
|
|
|
constexpr std::array<EngineInstanceT, 2> gpgpuEngineInstances = {{{ENGINE_RCS, 0},
|
|
|
|
lowPriorityGpgpuEngine}};
|
|
|
|
return std::vector<EngineInstanceT>(gpgpuEngineInstances.begin(), gpgpuEngineInstances.end());
|
2019-02-12 17:56:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Family>
|
|
|
|
bool HwHelperHw<Family>::getEnableLocalMemory(const HardwareInfo &hwInfo) const {
|
|
|
|
if (DebugManager.flags.EnableLocalMemory.get() != -1) {
|
|
|
|
return DebugManager.flags.EnableLocalMemory.get();
|
|
|
|
} else if (DebugManager.flags.AUBDumpForceAllToLocalMemory.get()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OSInterface::osEnableLocalMemory && isLocalMemoryEnabled(hwInfo);
|
|
|
|
}
|
2019-01-10 20:57:40 +08:00
|
|
|
|
2017-12-21 23:54:19 +08:00
|
|
|
} // namespace OCLRT
|