Skip to content

[DRAFT] Ignore this - LinAlg PSV0 WIP - #8875

Draft
Ashley Coleman (V-FEXrt) wants to merge 2 commits into
microsoft:mainfrom
V-FEXrt:linalg-psv0
Draft

[DRAFT] Ignore this - LinAlg PSV0 WIP#8875
Ashley Coleman (V-FEXrt) wants to merge 2 commits into
microsoft:mainfrom
V-FEXrt:linalg-psv0

Conversation

@V-FEXrt

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread include/dxc/DxilContainer/DxilPipelineStateValidation.h
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

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.cpp
View 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
  • Check this box to apply formatting changes to this branch.

Comment thread include/dxc/DxilContainer/DxilPipelineStateValidation.h
Comment thread include/dxc/DxilContainer/DxilPipelineStateValidation.h
Comment thread include/dxc/DxilContainer/DxilPipelineStateValidation.h
std::vector<PSVLinAlgAccumulateStore0> m_LinAlgAccumulateStores;
unsigned EntryFunctionName = 0;

static bool GetLinAlgMatrixInfo(Type *Ty, LinAlgMatrixInfo &Info) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

@V-FEXrt Ashley Coleman (V-FEXrt) Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::set?

continue;
if (CallInst *CI = dyn_cast<CallInst>(V)) {
DXIL::OpCode OpCode = OP::getOpCode(CI);
if (OpCode == DXIL::OpCode::LinAlgMatrixLoadFromDescriptor) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • switch statements
  • Use the generated DXIL types here

auto CollectConstruction = [&](Type *Ty) {
LinAlgMatrixInfo Matrix;
if (!GetLinAlgMatrixInfo(Ty, Matrix) ||
Matrix.Scope == DXIL::MatrixScope::Thread)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated DXIL type

if (!GetLinAlgMatrixInfo(CI->getArgOperand(1)->getType(), Matrix))
break;
bool IsSigned =
cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue() != 0;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) ||

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated DXIL type

Comment thread lib/DxilContainer/DxilPipelineStateValidation.cpp
Comment thread lib/DxilValidation/DxilContainerValidation.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant