Skip to content

Commit 8e2e899

Browse files
authored
[SM6.10] Reserve LinAlg DXIL Opcodes (#8015)
This PR reserves the DXIL opcodes needed for the SM6.10 LinAlg feature. `dx.types.MatrixRef` and `$vec2` are intentionally not yet added to the PR so those have a placeholder `i32` type. Three opcodes were reserved in case any new LinAlg operations come up later. Only `utils/hct/hctdb.py` was manually edited, all other changes are generated code.
1 parent 240d6a3 commit 8e2e899

5 files changed

Lines changed: 1542 additions & 7 deletions

File tree

docs/DXIL.rst

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3062,9 +3062,9 @@ Given width, offset:
30623062
30633063
Opcode Table ExperimentalOps, id=32768: Experimental DXIL operations
30643064

3065-
========== ======================================== ==================================================================
3065+
========== ======================================== ===================================================================================================================
30663066
ID Name Description
3067-
========== ======================================== ==================================================================
3067+
========== ======================================== ===================================================================================================================
30683068
2147483648 ExperimentalNop nop does nothing
30693069
2147483649 GetGroupWaveIndex returns the index of the wave in the thread group
30703070
2147483650 GetGroupWaveCount returns the number of waves in the thread group
@@ -3076,7 +3076,29 @@ ID Name Description
30763076
2147483656 RayQuery_CandidateTriangleObjectPosition returns candidate triangle vertices in object space as <9 x float>
30773077
2147483657 RayQuery_CommittedTriangleObjectPosition returns committed triangle vertices in object space as <9 x float>
30783078
2147483658 HitObject_TriangleObjectPosition returns triangle vertices in object space as <9 x float>
3079-
========== ======================================== ==================================================================
3079+
2147483659 CreateMatrix creates a handle to a Matrix
3080+
2147483660 FillMatrix fills a matrix with a scalar value
3081+
2147483661 CopyConvertMatrix Converts and copies the element and use type of the source matrix to the destination matrix with optional transpose
3082+
2147483662 MatrixLoadFromDescriptor fills a matrix with data from a [RW]ByteAddressBuffer
3083+
2147483663 MatrixLoadFromMemory fills a matrix with data from a groupshared array
3084+
2147483664 MatrixLength returns the number of elements stored in thread-local storage on the active thread for the provided matrix
3085+
2147483665 MatrixGetCoordinate returns a two element vector containing the column and row of the matrix that the thread-local index corresponds to
3086+
2147483666 MatrixGetElement returns the element of the matrix corresponding to the provided thread-local index
3087+
2147483667 MatrixSetElement sets the element of the matrix corresponding to the provided thread-local index
3088+
2147483668 MatrixStoreToDescriptor stores a matrix to a RWByteAddressBuffer
3089+
2147483669 MatrixStoreToMemory stores a matrix to groupshared memory
3090+
2147483670 MatrixQueryAccumulatorLayout returns comptime 0 when accumulator matrix are A layout, 1 when B layout
3091+
2147483671 MatrixMulOp applies a multiplication op to matrix C using A and B as parameters
3092+
2147483672 MatrixAccumulate accumulate A or B matrix into Accumulator matrix following LHS += RHS
3093+
2147483673 MatrixVecMul Multiplies a MxK dimension matrix and a K sized input vector
3094+
2147483674 MatrixVecMulAdd Multiplies a MxK dimension matrix and a K sized input vector then adds a M sized bias vector
3095+
2147483675 MatrixAccumulateToDescriptor accumulates a matrix to a RWByteAddressBuffer
3096+
2147483676 MatrixAccumulateToMemory accumulates a matrix to groupshared memory
3097+
2147483677 MatrixOuterProduct Outer products an M sized vector and a K sized vector producing an MxK matrix
3098+
2147483678 LinAlgMatrixReserved0 reserved
3099+
2147483679 LinAlgMatrixReserved1 reserved
3100+
2147483680 LinAlgMatrixReserved2 reserved
3101+
========== ======================================== ===================================================================================================================
30803102

30813103

30823104
.. OPCODES-RST:END

include/dxc/DXIL/DxilConstants.h

Lines changed: 123 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,11 @@ namespace ExperimentalOps {
511511
static const OpCodeTableID TableID = OpCodeTableID::ExperimentalOps;
512512
// Enumeration for ExperimentalOps DXIL operations
513513
enum class OpCode : unsigned {
514+
//
515+
LinAlgMatrixReserved0 = 30, // reserved
516+
LinAlgMatrixReserved1 = 31, // reserved
517+
LinAlgMatrixReserved2 = 32, // reserved
518+
514519
// Group Wave Ops
515520
GetGroupWaveCount = 2, // returns the number of waves in the thread group
516521
GetGroupWaveIndex = 1, // returns the index of the wave in the thread group
@@ -523,6 +528,43 @@ enum class OpCode : unsigned {
523528
RayQuery_CommittedTriangleObjectPosition =
524529
9, // returns committed triangle vertices in object space as <9 x float>
525530

531+
// Linear Algebra Operations
532+
CopyConvertMatrix =
533+
13, // Converts and copies the element and use type of the source matrix
534+
// to the destination matrix with optional transpose
535+
CreateMatrix = 11, // creates a handle to a Matrix
536+
FillMatrix = 12, // fills a matrix with a scalar value
537+
MatrixAccumulate = 24, // accumulate A or B matrix into Accumulator matrix
538+
// following LHS += RHS
539+
MatrixAccumulateToDescriptor =
540+
27, // accumulates a matrix to a RWByteAddressBuffer
541+
MatrixAccumulateToMemory = 28, // accumulates a matrix to groupshared memory
542+
MatrixGetCoordinate =
543+
17, // returns a two element vector containing the column and row of the
544+
// matrix that the thread-local index corresponds to
545+
MatrixGetElement = 18, // returns the element of the matrix corresponding to
546+
// the provided thread-local index
547+
MatrixLength = 16, // returns the number of elements stored in thread-local
548+
// storage on the active thread for the provided matrix
549+
MatrixLoadFromDescriptor =
550+
14, // fills a matrix with data from a [RW]ByteAddressBuffer
551+
MatrixLoadFromMemory =
552+
15, // fills a matrix with data from a groupshared array
553+
MatrixMulOp =
554+
23, // applies a multiplication op to matrix C using A and B as parameters
555+
MatrixOuterProduct = 29, // Outer products an M sized vector and a K sized
556+
// vector producing an MxK matrix
557+
MatrixQueryAccumulatorLayout = 22, // returns comptime 0 when accumulator
558+
// matrix are A layout, 1 when B layout
559+
MatrixSetElement = 19, // sets the element of the matrix corresponding to the
560+
// provided thread-local index
561+
MatrixStoreToDescriptor = 20, // stores a matrix to a RWByteAddressBuffer
562+
MatrixStoreToMemory = 21, // stores a matrix to groupshared memory
563+
MatrixVecMul =
564+
25, // Multiplies a MxK dimension matrix and a K sized input vector
565+
MatrixVecMulAdd = 26, // Multiplies a MxK dimension matrix and a K sized input
566+
// vector then adds a M sized bias vector
567+
526568
// No-op
527569
ExperimentalNop = 0, // nop does nothing
528570

@@ -538,7 +580,7 @@ enum class OpCode : unsigned {
538580
HitObject_TriangleObjectPosition =
539581
10, // returns triangle vertices in object space as <9 x float>
540582

541-
NumOpCodes = 11, // exclusive last value of enumeration
583+
NumOpCodes = 33, // exclusive last value of enumeration
542584
};
543585
} // namespace ExperimentalOps
544586
static const unsigned NumOpCodeTables = 2;
@@ -1187,6 +1229,66 @@ enum class OpCode : unsigned {
11871229
EXP_OPCODE(ExperimentalOps,
11881230
HitObject_TriangleObjectPosition), // returns triangle vertices in
11891231
// object space as <9 x float>
1232+
EXP_OPCODE(ExperimentalOps, CreateMatrix), // creates a handle to a Matrix
1233+
EXP_OPCODE(ExperimentalOps, FillMatrix), // fills a matrix with a scalar value
1234+
EXP_OPCODE(ExperimentalOps,
1235+
CopyConvertMatrix), // Converts and copies the element and use type
1236+
// of the source matrix to the destination
1237+
// matrix with optional transpose
1238+
EXP_OPCODE(ExperimentalOps,
1239+
MatrixLoadFromDescriptor), // fills a matrix with data from a
1240+
// [RW]ByteAddressBuffer
1241+
EXP_OPCODE(ExperimentalOps, MatrixLoadFromMemory), // fills a matrix with data
1242+
// from a groupshared array
1243+
EXP_OPCODE(
1244+
ExperimentalOps,
1245+
MatrixLength), // returns the number of elements stored in thread-local
1246+
// storage on the active thread for the provided matrix
1247+
EXP_OPCODE(ExperimentalOps,
1248+
MatrixGetCoordinate), // returns a two element vector containing
1249+
// the column and row of the matrix that the
1250+
// thread-local index corresponds to
1251+
EXP_OPCODE(
1252+
ExperimentalOps,
1253+
MatrixGetElement), // returns the element of the matrix corresponding to
1254+
// the provided thread-local index
1255+
EXP_OPCODE(ExperimentalOps,
1256+
MatrixSetElement), // sets the element of the matrix corresponding
1257+
// to the provided thread-local index
1258+
EXP_OPCODE(
1259+
ExperimentalOps,
1260+
MatrixStoreToDescriptor), // stores a matrix to a RWByteAddressBuffer
1261+
EXP_OPCODE(ExperimentalOps,
1262+
MatrixStoreToMemory), // stores a matrix to groupshared memory
1263+
EXP_OPCODE(
1264+
ExperimentalOps,
1265+
MatrixQueryAccumulatorLayout), // returns comptime 0 when accumulator
1266+
// matrix are A layout, 1 when B layout
1267+
EXP_OPCODE(ExperimentalOps,
1268+
MatrixMulOp), // applies a multiplication op to matrix C using A
1269+
// and B as parameters
1270+
EXP_OPCODE(ExperimentalOps,
1271+
MatrixAccumulate), // accumulate A or B matrix into Accumulator
1272+
// matrix following LHS += RHS
1273+
EXP_OPCODE(ExperimentalOps,
1274+
MatrixVecMul), // Multiplies a MxK dimension matrix and a K sized
1275+
// input vector
1276+
EXP_OPCODE(
1277+
ExperimentalOps,
1278+
MatrixVecMulAdd), // Multiplies a MxK dimension matrix and a K sized input
1279+
// vector then adds a M sized bias vector
1280+
EXP_OPCODE(ExperimentalOps,
1281+
MatrixAccumulateToDescriptor), // accumulates a matrix to a
1282+
// RWByteAddressBuffer
1283+
EXP_OPCODE(
1284+
ExperimentalOps,
1285+
MatrixAccumulateToMemory), // accumulates a matrix to groupshared memory
1286+
EXP_OPCODE(ExperimentalOps,
1287+
MatrixOuterProduct), // Outer products an M sized vector and a K
1288+
// sized vector producing an MxK matrix
1289+
EXP_OPCODE(ExperimentalOps, LinAlgMatrixReserved0), // reserved
1290+
EXP_OPCODE(ExperimentalOps, LinAlgMatrixReserved1), // reserved
1291+
EXP_OPCODE(ExperimentalOps, LinAlgMatrixReserved2), // reserved
11901292
};
11911293
// OPCODE-ENUM:END
11921294
#undef EXP_OPCODE
@@ -1342,8 +1444,27 @@ enum class OpCodeClass : unsigned {
13421444
CreateHandleForLib,
13431445

13441446
// Linear Algebra Operations
1447+
CopyConvertMatrix,
1448+
CreateMatrix,
1449+
FillMatrix,
13451450
MatVecMul,
13461451
MatVecMulAdd,
1452+
MatrixAccumulate,
1453+
MatrixAccumulateToDescriptor,
1454+
MatrixAccumulateToMemory,
1455+
MatrixGetCoordinate,
1456+
MatrixGetElement,
1457+
MatrixLength,
1458+
MatrixLoadFromDescriptor,
1459+
MatrixLoadFromMemory,
1460+
MatrixMulOp,
1461+
MatrixOuterProduct,
1462+
MatrixQueryAccumulatorLayout,
1463+
MatrixSetElement,
1464+
MatrixStoreToDescriptor,
1465+
MatrixStoreToMemory,
1466+
MatrixVecMul,
1467+
MatrixVecMulAdd,
13471468
OuterProductAccumulate,
13481469
VectorAccumulate,
13491470

@@ -1532,7 +1653,7 @@ enum class OpCodeClass : unsigned {
15321653
NodeOutputIsValid,
15331654
OutputComplete,
15341655

1535-
NumOpClasses = 204, // exclusive last value of enumeration
1656+
NumOpClasses = 223, // exclusive last value of enumeration
15361657
};
15371658
// OPCODECLASS-ENUM:END
15381659

0 commit comments

Comments
 (0)