Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions include/dxc/DXIL/DxilInstructions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10651,14 +10651,14 @@ struct DxilInst_LinAlgMatrixLoadFromMemory {
bool requiresUniformInputs() const { return false; }
// Operand indexes
enum OperandIdx {
arg_groupsharedArr = 1,
arg_memory = 1,
arg_offset = 2,
arg_stride = 3,
arg_layout = 4,
};
// Accessors
llvm::Value *get_groupsharedArr() const { return Instr->getOperand(1); }
void set_groupsharedArr(llvm::Value *val) { Instr->setOperand(1, val); }
llvm::Value *get_memory() const { return Instr->getOperand(1); }
void set_memory(llvm::Value *val) { Instr->setOperand(1, val); }
llvm::Value *get_offset() const { return Instr->getOperand(2); }
void set_offset(llvm::Value *val) { Instr->setOperand(2, val); }
llvm::Value *get_stride() const { return Instr->getOperand(3); }
Expand Down Expand Up @@ -10854,16 +10854,16 @@ struct DxilInst_LinAlgMatrixStoreToMemory {
// Operand indexes
enum OperandIdx {
arg_matrix = 1,
arg_groupsharedArr = 2,
arg_memory = 2,
arg_offset = 3,
arg_stride = 4,
arg_layout = 5,
};
// Accessors
llvm::Value *get_matrix() const { return Instr->getOperand(1); }
void set_matrix(llvm::Value *val) { Instr->setOperand(1, val); }
llvm::Value *get_groupsharedArr() const { return Instr->getOperand(2); }
void set_groupsharedArr(llvm::Value *val) { Instr->setOperand(2, val); }
llvm::Value *get_memory() const { return Instr->getOperand(2); }
void set_memory(llvm::Value *val) { Instr->setOperand(2, val); }
llvm::Value *get_offset() const { return Instr->getOperand(3); }
void set_offset(llvm::Value *val) { Instr->setOperand(3, val); }
llvm::Value *get_stride() const { return Instr->getOperand(4); }
Expand Down Expand Up @@ -11091,16 +11091,16 @@ struct DxilInst_LinAlgMatrixAccumulateToMemory {
// Operand indexes
enum OperandIdx {
arg_matrix = 1,
arg_groupsharedArr = 2,
arg_memory = 2,
arg_offset = 3,
arg_stride = 4,
arg_layout = 5,
};
// Accessors
llvm::Value *get_matrix() const { return Instr->getOperand(1); }
void set_matrix(llvm::Value *val) { Instr->setOperand(1, val); }
llvm::Value *get_groupsharedArr() const { return Instr->getOperand(2); }
void set_groupsharedArr(llvm::Value *val) { Instr->setOperand(2, val); }
llvm::Value *get_memory() const { return Instr->getOperand(2); }
void set_memory(llvm::Value *val) { Instr->setOperand(2, val); }
llvm::Value *get_offset() const { return Instr->getOperand(3); }
void set_offset(llvm::Value *val) { Instr->setOperand(3, val); }
llvm::Value *get_stride() const { return Instr->getOperand(4); }
Expand Down
1 change: 1 addition & 0 deletions include/dxc/DXIL/DxilOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class OP {
TS_UDT = 8, // Ex: %"struct.MyStruct" *
TS_Object = 9, // Ex: %"class.StructuredBuffer<Foo>"
TS_Vector = 10, // Ex: <8 x i16>
TS_Array = 11, // Ex: [8 x float]
TS_MaskBitCount, // Types used in Mask end here
// TS_Extended is only used to identify the unnamed struct type used to wrap
// multiple overloads when using GetTypeSlot.
Expand Down
46 changes: 32 additions & 14 deletions lib/DXIL/DxilOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2863,8 +2863,8 @@ static const OP::OpCodeProperty ExperimentalOps_OpCodeProps[] = {
"linAlgMatrixLoadFromMemory",
Attribute::None,
2,
{{0x200}, {0x63}},
{{0x0}, {0x0}}}, // Overloads: o,hfwi
{{0x200}, {0x800}},
{{0x0}, {0x0}}}, // Overloads: o,a
{OC::LinAlgMatrixLength,
"LinAlgMatrixLength",
OCC::LinAlgMatrixLength,
Expand Down Expand Up @@ -2911,8 +2911,8 @@ static const OP::OpCodeProperty ExperimentalOps_OpCodeProps[] = {
"linAlgMatrixStoreToMemory",
Attribute::None,
2,
{{0x200}, {0x63}},
{{0x0}, {0x0}}}, // Overloads: o,hfwi
{{0x200}, {0x800}},
{{0x0}, {0x0}}}, // Overloads: o,a
{OC::LinAlgMatrixQueryAccumulatorLayout,
"LinAlgMatrixQueryAccumulatorLayout",
OCC::LinAlgMatrixQueryAccumulatorLayout,
Expand Down Expand Up @@ -2967,8 +2967,8 @@ static const OP::OpCodeProperty ExperimentalOps_OpCodeProps[] = {
"linAlgMatrixAccumulateToMemory",
Attribute::None,
2,
{{0x200}, {0x63}},
{{0x0}, {0x0}}}, // Overloads: o,hfwi
{{0x200}, {0x800}},
{{0x0}, {0x0}}}, // Overloads: o,a
{OC::LinAlgMatrixOuterProduct,
"LinAlgMatrixOuterProduct",
OCC::LinAlgMatrixOuterProduct,
Expand Down Expand Up @@ -3152,6 +3152,8 @@ unsigned OP::GetTypeSlot(Type *pType) {
return TS_Extended;
case Type::VectorTyID:
return TS_Vector;
case Type::ArrayTyID:
return TS_Array;
default:
break;
}
Expand All @@ -3166,26 +3168,39 @@ const char *OP::GetOverloadTypeName(unsigned TypeSlot) {
StringRef OP::GetTypeName(Type *Ty, SmallVectorImpl<char> &Storage) {
DXASSERT(!Ty->isVoidTy(), "must not pass void type here");
unsigned TypeSlot = OP::GetTypeSlot(Ty);

if (TypeSlot < TS_BasicCount) {
return GetOverloadTypeName(TypeSlot);
} else if (TypeSlot == TS_UDT) {
}

switch (TypeSlot) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since this function no longer has any functional changes, this is now a pure refactor. In fact, there are no other changes in this file that are not a result of generated code changes.

That's fine, but I thought it might be good to call that out. Think of this as just a review note.

case TS_UDT: {
if (Ty->isPointerTy())
Ty = Ty->getPointerElementType();
StructType *ST = cast<StructType>(Ty);
return ST->getStructName();
} else if (TypeSlot == TS_Object) {
}
case TS_Object: {
StructType *ST = cast<StructType>(Ty);
if (dxilutil::IsHLSLLinAlgMatrixType(Ty))
return (Twine("m") + Twine(dxilutil::GetHLSLLinAlgMatrixTypeMangling(ST)))
.toStringRef(Storage);
return ST->getStructName();
} else if (TypeSlot == TS_Vector) {
}
case TS_Vector: {
VectorType *VecTy = cast<VectorType>(Ty);
return (Twine("v") + Twine(VecTy->getNumElements()) +
Twine(
GetOverloadTypeName(OP::GetTypeSlot(VecTy->getElementType()))))
.toStringRef(Storage);
} else if (TypeSlot == TS_Extended) {
}
case TS_Array: {
if (Ty->isPointerTy())
Ty = Ty->getPointerElementType();
ArrayType *ArrTy = cast<ArrayType>(Ty);
return GetOverloadTypeName(OP::GetTypeSlot(ArrTy->getArrayElementType()));
}
case TS_Extended: {
DXASSERT(isa<StructType>(Ty),
"otherwise, extended overload type not wrapped in struct type.");
StructType *ST = cast<StructType>(Ty);
Expand All @@ -3200,11 +3215,14 @@ StringRef OP::GetTypeName(Type *Ty, SmallVectorImpl<char> &Storage) {
OS << GetTypeName(ST->getElementType(I), TempStr);
}
return OS.str();
} else {
raw_svector_ostream OS(Storage);
Ty->print(OS);
return OS.str();
}
default:
break;
}

raw_svector_ostream OS(Storage);
Ty->print(OS);
return OS.str();
}

StringRef OP::ConstructOverloadName(Type *Ty, DXIL::OpCode opCode,
Expand Down
56 changes: 53 additions & 3 deletions lib/HLSL/HLOperationLower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7226,6 +7226,53 @@ Value *TranslateLinAlgCopyConvertMatrix(CallInst *CI, IntrinsicOp IOP,
return nullptr;
}

Value *TranslateLinAlgMatrixLoadFromMemory(
CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode,
HLOperationLowerHelper &Helper, HLObjectOperationLowerHelper *ObjHelper,
bool &Translated) {
hlsl::OP *HlslOp = &Helper.hlslOP;
IRBuilder<> Builder(CI);

Value *MatrixPtr = CI->getArgOperand(1);
DXASSERT_NOMSG(isa<PointerType>(MatrixPtr->getType()));
Type *MatrixType = MatrixPtr->getType()->getPointerElementType();

Value *Arr = CI->getArgOperand(2);
Value *Offset = CI->getArgOperand(3);
Value *Stride = CI->getArgOperand(4);
Value *Layout = CI->getArgOperand(5);

Constant *OpArg = HlslOp->GetU32Const((unsigned)OpCode);
Function *DxilFunc = HlslOp->GetOpFunc(OpCode, {MatrixType, Arr->getType()});

Value *Matrix =
Builder.CreateCall(DxilFunc, {OpArg, Arr, Offset, Stride, Layout});
Builder.CreateStore(Matrix, MatrixPtr);

return nullptr;
}

Value *TranslateLinAlgMatrixAccumStoreToMemory(
CallInst *CI, IntrinsicOp IOP, OP::OpCode OpCode,
HLOperationLowerHelper &Helper, HLObjectOperationLowerHelper *ObjHelper,
bool &Translated) {
hlsl::OP *HlslOp = &Helper.hlslOP;
IRBuilder<> Builder(CI);

Value *Matrix = CI->getArgOperand(1);
Value *Arr = CI->getArgOperand(2);
Value *Offset = CI->getArgOperand(3);
Value *Stride = CI->getArgOperand(4);
Value *Layout = CI->getArgOperand(5);

Constant *OpArg = HlslOp->GetU32Const((unsigned)OpCode);
Function *DxilFunc =
HlslOp->GetOpFunc(OpCode, {Matrix->getType(), Arr->getType()});

return Builder.CreateCall(DxilFunc,
{OpArg, Matrix, Arr, Offset, Stride, Layout});
}

} // namespace

// Lower table.
Expand Down Expand Up @@ -7989,14 +8036,16 @@ constexpr IntrinsicLower gLowerTable[] = {
{IntrinsicOp::IOP___builtin_LinAlg_MatrixLoadFromDescriptor,
TranslateLinAlgMatrixLoadFromDescriptor,
DXIL::OpCode::LinAlgMatrixLoadFromDescriptor},
{IntrinsicOp::IOP___builtin_LinAlg_MatrixLoadFromMemory, EmptyLower,
{IntrinsicOp::IOP___builtin_LinAlg_MatrixLoadFromMemory,
TranslateLinAlgMatrixLoadFromMemory,
DXIL::OpCode::LinAlgMatrixLoadFromMemory},
{IntrinsicOp::IOP___builtin_LinAlg_MatrixSetElement,
TranslateLinAlgMatrixSetElement, DXIL::OpCode::LinAlgMatrixSetElement},
{IntrinsicOp::IOP___builtin_LinAlg_MatrixStoreToDescriptor,
TranslateLinAlgMatrixAccumStoreToDescriptor,
DXIL::OpCode::LinAlgMatrixStoreToDescriptor},
{IntrinsicOp::IOP___builtin_LinAlg_MatrixStoreToMemory, EmptyLower,
{IntrinsicOp::IOP___builtin_LinAlg_MatrixStoreToMemory,
TranslateLinAlgMatrixAccumStoreToMemory,
DXIL::OpCode::LinAlgMatrixStoreToMemory},
{IntrinsicOp::IOP___builtin_LinAlg_MatrixAccumulate,
TranslateLinAlgMatrixAccumulate, DXIL::OpCode::LinAlgMatrixAccumulate},
Expand All @@ -8010,7 +8059,8 @@ constexpr IntrinsicLower gLowerTable[] = {
{IntrinsicOp::IOP___builtin_LinAlg_MatrixAccumulateToDescriptor,
TranslateLinAlgMatrixAccumStoreToDescriptor,
DXIL::OpCode::LinAlgMatrixAccumulateToDescriptor},
{IntrinsicOp::IOP___builtin_LinAlg_MatrixAccumulateToMemory, EmptyLower,
{IntrinsicOp::IOP___builtin_LinAlg_MatrixAccumulateToMemory,
TranslateLinAlgMatrixAccumStoreToMemory,
DXIL::OpCode::LinAlgMatrixAccumulateToMemory},
{IntrinsicOp::IOP___builtin_LinAlg_MatrixOuterProduct,
TranslateLinAlgMatrixOuterProduct, DXIL::OpCode::LinAlgMatrixOuterProduct},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// REQUIRES: dxil-1-10
// RUN: %dxc -T cs_6_10 -HV 202x -E main %s | FileCheck %s

// CHECK: @{{.*}} = external addrspace(3) global [64 x float]
groupshared float SharedArr[64];

[numthreads(4,1,1)]
void main() {
// CHECK-LABEL: define void @main()

// CHECK: call void @dx.op.linAlgMatrixAccumulateToMemory.mC4M5N4U1S2.f32(i32 -2147483620, %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, [64 x float] addrspace(3)* nonnull @{{.*}}, i32 1, i32 2, i32 3) ; LinAlgMatrixAccumulateToMemory(matrix,memory,offset,stride,layout)
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;
__builtin_LinAlg_MatrixAccumulateToMemory(mat, SharedArr, 1, 2, 3);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// REQUIRES: dxil-1-10
// RUN: %dxc -T cs_6_10 -HV 202x -E main %s | FileCheck %s

// CHECK: @{{.*}} = external addrspace(3) global [64 x float]
groupshared float SharedArr[64];

[numthreads(4,1,1)]
void main() {
// CHECK-LABEL: define void @main()

// CHECK: call %dx.types.LinAlgMatrixC4M5N4U1S2 @dx.op.linAlgMatrixLoadFromMemory.mC4M5N4U1S2.f32(i32 -2147483633, [64 x float] addrspace(3)* nonnull @{{.*}}, i32 1, i32 2, i32 3) ; LinAlgMatrixLoadFromMemory(memory,offset,stride,layout)
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;
__builtin_LinAlg_MatrixLoadFromMemory(mat, SharedArr, 1, 2, 3);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// REQUIRES: dxil-1-10
// RUN: %dxc -T cs_6_10 -HV 202x -E main %s | FileCheck %s

// CHECK: @{{.*}} = external addrspace(3) global [64 x float]
groupshared float SharedArr[64];

[numthreads(4,1,1)]
void main() {
// CHECK-LABEL: define void @main()

// CHECK: call void @dx.op.linAlgMatrixStoreToMemory.mC4M5N4U1S2.f32(i32 -2147483627, %dx.types.LinAlgMatrixC4M5N4U1S2 {{.*}}, [64 x float] addrspace(3)* nonnull @{{.*}}, i32 1, i32 2, i32 3) ; LinAlgMatrixStoreToMemory(matrix,memory,offset,stride,layout)
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;
__builtin_LinAlg_MatrixStoreToMemory(mat, SharedArr, 1, 2, 3);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// REQUIRES: dxil-1-10
// RUN: %dxc -T lib_6_10 -E main %s -ast-dump-implicit | FileCheck %s

// CHECK: FunctionDecl {{.*}} implicit used __builtin_LinAlg_MatrixAccumulateToMemory 'void (__builtin_LinAlgMatrix {{.*}}, float const __attribute__((address_space(3))) (&)[64], unsigned int, unsigned int, unsigned int)' extern
// CHECK-NEXT: ParmVarDecl {{.*}} matrix '__builtin_LinAlgMatrix {{.*}}'
// CHECK-NEXT: ParmVarDecl {{.*}} memory 'float const __attribute__((address_space(3))) (&)[64]'
// CHECK-NEXT: ParmVarDecl {{.*}} offset 'unsigned int'
// CHECK-NEXT: ParmVarDecl {{.*}} stride 'unsigned int'
// CHECK-NEXT: ParmVarDecl {{.*}} layout 'unsigned int'
// CHECK-NEXT: HLSLIntrinsicAttr {{.*}} Implicit "op" "" 420
// CHECK-NEXT: AvailabilityAttr {{.*}} Implicit 6.10 0 0 ""

groupshared float SharedArr[64];

[shader("compute")]
[numthreads(1,1,1)]
void main() {
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;
__builtin_LinAlg_MatrixAccumulateToMemory(mat, SharedArr, 0, 0, 0);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %dxc -T cs_6_9 -HV 202x -E main %s -verify

groupshared float SharedArr[64];

[numthreads(4,1,1)]
void main() {
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;

// expected-error@+1{{intrinsic __builtin_LinAlg_MatrixAccumulateToMemory potentially used by ''main'' requires shader model 6.10 or greater}}
__builtin_LinAlg_MatrixAccumulateToMemory(mat, SharedArr, 0, 0, 0);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// REQUIRES: dxil-1-10
// RUN: %dxc -T lib_6_10 -E main %s -ast-dump-implicit | FileCheck %s

// CHECK: FunctionDecl {{.*}} implicit used __builtin_LinAlg_MatrixLoadFromMemory 'void (__builtin_LinAlgMatrix {{.*}}, float const __attribute__((address_space(3))) (&)[64], unsigned int, unsigned int, unsigned int)' extern
// CHECK-NEXT: ParmVarDecl {{.*}} ret '__builtin_LinAlgMatrix {{.*}}'
// CHECK-NEXT: ParmVarDecl {{.*}} memory 'float const __attribute__((address_space(3))) (&)[64]'
// CHECK-NEXT: ParmVarDecl {{.*}} offset 'unsigned int'
// CHECK-NEXT: ParmVarDecl {{.*}} stride 'unsigned int'
// CHECK-NEXT: ParmVarDecl {{.*}} layout 'unsigned int'
// CHECK-NEXT: HLSLIntrinsicAttr {{.*}} Implicit "op" "" 411
// CHECK-NEXT: AvailabilityAttr {{.*}} Implicit 6.10 0 0 ""

groupshared float SharedArr[64];

[shader("compute")]
[numthreads(1,1,1)]
void main() {
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;
__builtin_LinAlg_MatrixLoadFromMemory(mat, SharedArr, 0, 0, 0);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %dxc -T cs_6_9 -HV 202x -E main %s -verify

groupshared float SharedArr[64];

[numthreads(4,1,1)]
void main() {
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;

// expected-error@+1{{intrinsic __builtin_LinAlg_MatrixLoadFromMemory potentially used by ''main'' requires shader model 6.10 or greater}}
__builtin_LinAlg_MatrixLoadFromMemory(mat, SharedArr, 0, 0, 0);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// REQUIRES: dxil-1-10
// RUN: %dxc -T lib_6_10 -E main %s -ast-dump-implicit | FileCheck %s

// CHECK: FunctionDecl {{.*}} implicit used __builtin_LinAlg_MatrixStoreToMemory 'void (__builtin_LinAlgMatrix {{.*}}, float const __attribute__((address_space(3))) (&)[64], unsigned int, unsigned int, unsigned int)' extern
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the const here reveals a problem from adding AR_QUAL_IN. I'd like to see the expansion of the SharedArr parameter passed to the function. Is there an RValue cast? I think this should be treated more like a reference, and there shouldn't be a const qualifier.

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.

Tried AR_QUAL_REF but that didn't change the const. Only diff is && became & is that what you expected?

 IN: memory 'float const __attribute__((address_space(3))) (&)[64]'
REF: memory 'float const __attribute__((address_space(3))) (&&)[64]'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, yeah that's strange. Now that I think about it, maybe the const refers to the address as opposed to the memory it references. Also, I think groupshared might be adding the reference elsewhere, and adding REF might double that up, which would be bad. I think that function just needs to be updated to handle groupshared. I think that function is only used for intrinsics, which would be why the earlier change that added groupshared support for user function parameters didn't update it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, I think const does apply to the elements. And (&&) is an rvalue reference, so I think that's wrong.

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.

What would you consider the "right" thing here? Happy to work on the function but I need to know what to work towards lol

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.

Maybe another question, is this particular issue something we can push off to an immediate follow up? Helena has a couple PRs blocked on this going in and I have some work that would be nice to build on top of Helena's PRs.

Getting this PR in unclogs the system, but I am committed to getting the signature right here.

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.

Okay here are all the breakdowns for current possible ParameterModifier::Kind values

IN: memory 'float const __attribute__((address_space(3))) (&)[64]'
INOUT: memory 'float const __attribute__((address_space(3))) (&&&__restrict)[64]'
INVALID: memory 'float const __attribute__((address_space(3))) (&)[64]'
OUT: memory 'float const __attribute__((address_space(3))) (&&&__restrict)[64]'
REF: memory 'float const __attribute__((address_space(3))) (&&)[64]'
UNIFORM: memory 'float const __attribute__((address_space(3))) (&)[64]'

None of them result in the const not being added so I'm not sure how to move forward here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's go with IN and file an issue for follow-up.

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.

// CHECK-NEXT: ParmVarDecl {{.*}} matrix '__builtin_LinAlgMatrix {{.*}}'
// CHECK-NEXT: ParmVarDecl {{.*}} memory 'float const __attribute__((address_space(3))) (&)[64]'
// CHECK-NEXT: ParmVarDecl {{.*}} offset 'unsigned int'
// CHECK-NEXT: ParmVarDecl {{.*}} stride 'unsigned int'
// CHECK-NEXT: ParmVarDecl {{.*}} layout 'unsigned int'
// CHECK-NEXT: HLSLIntrinsicAttr {{.*}} Implicit "op" "" 414
// CHECK-NEXT: AvailabilityAttr {{.*}} Implicit 6.10 0 0 ""

groupshared float SharedArr[64];

[shader("compute")]
[numthreads(1,1,1)]
void main() {
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;
__builtin_LinAlg_MatrixStoreToMemory(mat, SharedArr, 0, 0, 0);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %dxc -T cs_6_9 -HV 202x -E main %s -verify

groupshared float SharedArr[64];

[numthreads(4,1,1)]
void main() {
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat;

// expected-error@+1{{intrinsic __builtin_LinAlg_MatrixStoreToMemory potentially used by ''main'' requires shader model 6.10 or greater}}
__builtin_LinAlg_MatrixStoreToMemory(mat, SharedArr, 0, 0, 0);
}
Loading