1 /*========================== begin_copyright_notice ============================ 2 3 Copyright (C) 2019-2021 Intel Corporation 4 5 SPDX-License-Identifier: MIT 6 7 ============================= end_copyright_notice ===========================*/ 8 9 #include "common/LLVMWarningsPush.hpp" 10 #include <llvm/Support/ScaledNumber.h> 11 #include "common/LLVMWarningsPop.hpp" 12 #include "Compiler/CISACodeGen/ComputeShaderBase.hpp" 13 #include "Compiler/CISACodeGen/messageEncoding.hpp" 14 #include "common/allocator.h" 15 #include "common/secure_mem.h" 16 #include <iStdLib/utility.h> 17 #include <algorithm> 18 #include "Probe/Assertion.h" 19 20 using namespace llvm; 21 22 namespace IGC 23 { CComputeShaderBase(llvm::Function * pFunc,CShaderProgram * pProgram)24 CComputeShaderBase::CComputeShaderBase(llvm::Function* pFunc, CShaderProgram* pProgram) 25 : CShader(pFunc, pProgram) {} 26 ~CComputeShaderBase()27 CComputeShaderBase::~CComputeShaderBase() {} 28 selectWalkOrder(bool useLinearWalk,uint numberOfTypedAccess,uint numberOfUntypedAccess,uint num1DAccesses,uint threadGroupSize_X,uint threadGroupSize_Y,uint threadGroupSize_Z)29 void CComputeShaderBase::selectWalkOrder( 30 bool useLinearWalk, 31 uint numberOfTypedAccess, 32 uint numberOfUntypedAccess, 33 uint num1DAccesses, 34 uint threadGroupSize_X, 35 uint threadGroupSize_Y, 36 uint threadGroupSize_Z) 37 { 38 const CodeGenContext* pCtx = GetContext(); 39 const ModuleMetaData* MMD = pCtx->getModuleMetaData(); 40 41 if (MMD->csInfo.neededThreadIdLayout == ThreadIDLayout::QuadTile) 42 { 43 m_ThreadIDLayout = ThreadIDLayout::QuadTile; 44 return; 45 } 46 47 if ((numberOfTypedAccess >= numberOfUntypedAccess) && 48 threadGroupSize_Y % 4 == 0 && 49 !MMD->csInfo.disableLocalIdOrderOptimizations && 50 IGC_IS_FLAG_ENABLED(UseTiledCSThreadOrder)) { 51 m_ThreadIDLayout = ThreadIDLayout::TileY; 52 m_walkOrder = WO_YXZ; 53 } 54 55 bool needsLinearWalk = 56 MMD->csInfo.neededThreadIdLayout == ThreadIDLayout::X; 57 if (needsLinearWalk) 58 { 59 m_ThreadIDLayout = ThreadIDLayout::X; 60 m_walkOrder = WO_XYZ; 61 } 62 } 63 } 64