[DRAFT] Ignore this - LinAlg PSV0 WIP - #8875
Conversation
You can test this locally with the following command:git-clang-format --diff 61d3e61e5f0c8106a815d4936d8877047b302a00 23419e28bf7583dad7c9f64fce38e7d50028380b -- include/dxc/DXIL/DxilConstants.h include/dxc/DXIL/DxilOperations.h include/dxc/DXIL/DxilShaderFlags.h include/dxc/DxilContainer/DxilPipelineStateValidation.h lib/DXIL/DxilOperations.cpp lib/DXIL/DxilShaderFlags.cpp lib/DxilContainer/DxilContainerAssembler.cpp lib/DxilContainer/DxilPipelineStateValidation.cpp lib/DxilValidation/DxilContainerValidation.cpp lib/HLSL/DxilPreparePasses.cppView the diff from clang-format here.diff --git a/lib/DxilContainer/DxilContainerAssembler.cpp b/lib/DxilContainer/DxilContainerAssembler.cpp
index 9d1a9bb8..5c3baaac 100644
--- a/lib/DxilContainer/DxilContainerAssembler.cpp
+++ b/lib/DxilContainer/DxilContainerAssembler.cpp
@@ -931,8 +931,8 @@ private:
auto *TargetType = dyn_cast<ConstantInt>(CI->getArgOperand(3));
if (!TargetType)
break;
- AccumulatorType = static_cast<DXIL::ComponentType>(
- TargetType->getZExtValue());
+ AccumulatorType =
+ static_cast<DXIL::ComponentType>(TargetType->getZExtValue());
}
uint8_t Flag =
OpCode == DXIL::OpCode::LinAlgMatrixAccumulateToDescriptor
|
| std::vector<PSVLinAlgAccumulateStore0> m_LinAlgAccumulateStores; | ||
| unsigned EntryFunctionName = 0; | ||
|
|
||
| static bool GetLinAlgMatrixInfo(Type *Ty, LinAlgMatrixInfo &Info) { |
There was a problem hiding this comment.
std::optional
| StringRef Mangling = | ||
| dxilutil::GetHLSLLinAlgMatrixTypeMangling(cast<StructType>(Ty)); | ||
| unsigned TypeValue, UseValue, ScopeValue; | ||
| if (sscanf(Mangling.str().c_str(), "C%uM%uN%uU%uS%u", &TypeValue, &Info.M, |
There was a problem hiding this comment.
scanf is bad. Can we not use the metadata from the module?
| case 16: | ||
| return IsSigned ? DXIL::ComponentType::I16 : DXIL::ComponentType::U16; | ||
| case 32: | ||
| return IsSigned ? DXIL::ComponentType::I32 : DXIL::ComponentType::U32; |
There was a problem hiding this comment.
Need to poke at the use case but this is lossy. ComponentType::F8_E4M3FN is also a 32bit width integer
| } | ||
|
|
||
| uint32_t AddShapeIndexArray(ArrayRef<uint32_t> ShapeIndexes) { | ||
| for (uint32_t Offset = 0; |
There was a problem hiding this comment.
this seems to be checking if its already been added before. Is that actually necessary?
| return Offset; | ||
| } | ||
|
|
||
| static void AddUniqueIndex(std::vector<uint32_t> &Indexes, uint32_t Index) { |
There was a problem hiding this comment.
std::set?
| continue; | ||
| if (CallInst *CI = dyn_cast<CallInst>(V)) { | ||
| DXIL::OpCode OpCode = OP::getOpCode(CI); | ||
| if (OpCode == DXIL::OpCode::LinAlgMatrixLoadFromDescriptor) { |
There was a problem hiding this comment.
- switch statements
- Use the generated DXIL types here
| auto CollectConstruction = [&](Type *Ty) { | ||
| LinAlgMatrixInfo Matrix; | ||
| if (!GetLinAlgMatrixInfo(Ty, Matrix) || | ||
| Matrix.Scope == DXIL::MatrixScope::Thread) |
There was a problem hiding this comment.
The || here is because of
Thread-scope matrices are excluded from MatrixConstruction gathering, because runtime feature info query is defined only for wave/group scope matrices.
it should be its only arm with a comment
| if (!GetLinAlgMatrixInfo(Ty, Matrix) || | ||
| Matrix.Scope == DXIL::MatrixScope::Thread) | ||
| return; | ||
| uint32_t M = Matrix.Use == DXIL::MatrixUse::B ? 0 : Matrix.M; |
There was a problem hiding this comment.
its probably clearer to just switch over the use here instead of having so many ternary's
| switch (OpCode) { | ||
| case DXIL::OpCode::LinAlgMatVecMul: | ||
| case DXIL::OpCode::LinAlgMatVecMulAdd: { | ||
| LinAlgMatrixInfo Matrix; |
There was a problem hiding this comment.
Generated DXIL type
| if (!GetLinAlgMatrixInfo(CI->getArgOperand(1)->getType(), Matrix)) | ||
| break; | ||
| bool IsSigned = | ||
| cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue() != 0; |
There was a problem hiding this comment.
all the casts need to be confirmed as allowed
| DXIL::ComponentType InputType = static_cast<DXIL::ComponentType>( | ||
| cast<ConstantInt>(CI->getArgOperand(4))->getZExtValue()); | ||
| uint8_t Flags = GetMatVecLayoutFlags(CI->getArgOperand(1)); | ||
| auto It = std::find_if( |
There was a problem hiding this comment.
another slightly different spelling of the "add or create" shape
| case DXIL::OpCode::LinAlgMatrixMultiply: | ||
| case DXIL::OpCode::LinAlgMatrixMultiplyAccumulate: { | ||
| LinAlgMatrixInfo Result, A, B; | ||
| if (!GetLinAlgMatrixInfo(CI->getType(), Result) || |
There was a problem hiding this comment.
Generated DXIL type
No description provided.