Skip to content

Commit f8f91b7

Browse files
Added limitation for b16 type
1 parent 8078cee commit f8f91b7

2 files changed

Lines changed: 37 additions & 23 deletions

File tree

clang/lib/DPCT/RulesAsm/AsmMigration.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,11 @@ class SYCLGen : public SYCLGenBase {
13151315
bool handle_ldmatrix(const InlineAsmInstruction *Inst) override {
13161316
if (Inst->getNumInputOperands() != 1)
13171317
return SYCLGenError();
1318+
1319+
const auto *Type = dyn_cast<InlineAsmBuiltinType>(Inst->getType(0));
1320+
1321+
if (!Type || Type->getKind() != InlineAsmBuiltinType::b16)
1322+
return SYCLGenError();
13181323

13191324
const InlineAsmVectorExpr *VE;
13201325
if (VE = dyn_cast<InlineAsmVectorExpr>(Inst->getOutputOperand())) {

clang/runtime/dpct-rt/include/dpct/math.hpp

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,14 +2056,16 @@ class joint_matrix {
20562056
const size_t num_elements;
20572057
};
20582058

2059-
/// Loads 1 8x8 b16 (128 bytes) matrix from private memory to local memory per
2060-
/// sub-group. Requires the sub-group size of kernel calling this function to
2061-
/// be 32. 'mat' specifies the matrix index to be loaded. The first '(mat + 1) *
2062-
/// 8' work items of sub-group contain the starting address of their respective
2063-
/// matrix row in 'addr'. After distributing addresses to other work items, each
2064-
/// of the 32 work items load 32-bits (2 packed 16-bit data) into 'm' for a
2065-
/// total of 128 bytes. 'trans' specifies to perform a transposed/non-transposed
2066-
/// load by each work item like below
2059+
/// Collectively loads 1 8x8 b16 (128 bytes) matrix from private memory to local
2060+
/// memory per sub-group. Requires the sub-group size of kernel calling this
2061+
/// function to be 32.
2062+
/// 'mat' specifies the matrix index to be loaded. The first '(mat + 1) * 8'
2063+
/// work items of sub-group contain the starting address of their respective
2064+
/// matrix row in 'addr'.
2065+
/// After distributing addresses to other work items, each of the 32 work items
2066+
/// load 32-bits (2 packed 16-bit data) into 'm' for a total of 128 bytes.
2067+
/// 'trans' specifies to perform a transposed/non-transposed load by each work
2068+
/// item like below
20672069
/// Row Major: Each row of the matrix is loaded by a group of 4 work items(wi)
20682070
/// row-0: wi0 wi0 wi1 wi1 ... wi3 wi3
20692071
/// row-1: wi4 wi4 wi5 wi5 ... wi7 wi7
@@ -2077,7 +2079,8 @@ class joint_matrix {
20772079
/// row-6: wi3 wi7 wi11 ... wi31
20782080
/// row-7: wi3 wi7 wi11 ... wi31
20792081
/// \tparam [in] T The type of result variable
2080-
/// \param [in] addr The address of the matrix in local memory
2082+
/// \param [in] addr The starting address of corresponding matrix row for a work
2083+
/// item in local memory
20812084
/// \param [in] m The private memory to store the matrix
20822085
/// \param [in] trans Indicates whether the matrix to be loaded transposed
20832086
/// \param [in] mat The matrix index to be loaded
@@ -2129,13 +2132,15 @@ void ldmatrix(uintptr_t addr, T *m, bool trans = false, unsigned mat = 0) {
21292132
}
21302133
}
21312134

2132-
/// Loads 2 8x8 b16 (256 bytes) matrix from private memory to local memory per
2133-
/// sub-group. Requires the sub-group size of kernel calling this function to
2134-
/// be 32. The first 16 work items of sub-group contain the starting address of
2135-
/// their respective matrix row in 'addr'. After distributing addresses to other
2136-
/// work items, each of the 32 work items load 64-bits (32-bits per matrix) into
2137-
/// 'm1' & 'm2' for a total of 256 bytes. 'trans' specifies to perform a
2138-
/// transposed/non-transposed load by each work item like below
2135+
/// Collectively loads 2 8x8 b16 (256 bytes) matrix from private memory to local
2136+
/// memory per sub-group. Requires the sub-group size of kernel calling this
2137+
/// function to be 32.
2138+
/// The first 16 work items of sub-group contain the starting address of their
2139+
/// respective matrix row in 'addr'.
2140+
/// After distributing addresses to other work items, each of the 32 work items
2141+
/// load 64-bits (32-bits per matrix) into 'm1' & 'm2' for a total of 256 bytes.
2142+
/// 'trans' specifies to perform a transposed/non-transposed load by each work
2143+
/// item like below
21392144
/// Row Major: Each row of the matrices is loaded by a group of 4 work items(wi)
21402145
/// row-0: wi0 wi0 wi1 wi1 ... wi3 wi3
21412146
/// row-1: wi4 wi4 wi5 wi5 ... wi7 wi7
@@ -2149,7 +2154,8 @@ void ldmatrix(uintptr_t addr, T *m, bool trans = false, unsigned mat = 0) {
21492154
/// row-6: wi3 wi7 wi11 ... wi31
21502155
/// row-7: wi3 wi7 wi11 ... wi31
21512156
/// \tparam [in] T The type of result variable
2152-
/// \param [in] addr The address of the matrix in local memory
2157+
/// \param [in] addr The starting address of corresponding matrix row for a work
2158+
/// item in local memory
21532159
/// \param [in] m1 The private memory to store data of 1st matrix
21542160
/// \param [in] m2 The private memory to store data of 2nd matrix
21552161
/// \param [in] trans Indicates whether the matrix to be loaded transposed
@@ -2161,14 +2167,16 @@ void ldmatrix(uintptr_t addr, T *m1, T *m2, bool trans = false) {
21612167
ldmatrix(addr, m2, trans, 1);
21622168
}
21632169

2164-
/// Loads 4 8x8 b16 (512 bytes) matrix from private memory to local memory per
2165-
/// sub-group. Requires the sub-group size of kernel calling this function to
2166-
/// be 32. Each work item of sub-group contains the starting address of their
2170+
/// Collectively loads 4 8x8 b16 (512 bytes) matrix from private memory to local
2171+
/// memory per sub-group. Requires the sub-group size of kernel calling this
2172+
/// function to be 32.
2173+
/// Each work item of sub-group contains the starting address of their
21672174
/// respective matrix row in 'addr'.
21682175
/// After distributing addresses to other work items, each of the 32 work items
21692176
/// load 128-bits (32-bits per matrix) into 'm1', 'm2', 'm3' & 'm4' for a total
2170-
/// of 512 bytes. 'trans' specifies to perform a transposed/non-transposed load
2171-
/// by each work item like below
2177+
/// of 512 bytes.
2178+
/// 'trans' specifies to perform a transposed/non-transposed load by each work
2179+
/// item like below
21722180
/// Row Major: Each row of the matrices is loaded by a group of 4 work items(wi)
21732181
/// row-0: wi0 wi0 wi1 wi1 ... wi3 wi3
21742182
/// row-1: wi4 wi4 wi5 wi5 ... wi7 wi7
@@ -2182,7 +2190,8 @@ void ldmatrix(uintptr_t addr, T *m1, T *m2, bool trans = false) {
21822190
/// row-6: wi3 wi7 wi11 ... wi31
21832191
/// row-7: wi3 wi7 wi11 ... wi31
21842192
/// \tparam [in] T The type of result variable
2185-
/// \param [in] addr The address of the matrix in local memory
2193+
/// \param [in] addr The starting address of corresponding matrix row for a work
2194+
/// item in local memory
21862195
/// \param [in] m1 The private memory to store data of 1st matrix
21872196
/// \param [in] m2 The private memory to store data of 2nd matrix
21882197
/// \param [in] m3 The private memory to store data of 3rd matrix

0 commit comments

Comments
 (0)