1
- // ==---------------- dpas_utils .hpp - DPC++ ESIMD on-device test - ---------==//
1
+ // ==---------------- dpas_common .hpp - DPC++ ESIMD on-device test ---------==//
2
2
//
3
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
4
// See https://llvm.org/LICENSE.txt for license information.
@@ -28,6 +28,7 @@ constexpr dpas_argument_type s8 = dpas_argument_type::s8;
28
28
constexpr dpas_argument_type u8 = dpas_argument_type::u8 ;
29
29
30
30
constexpr dpas_argument_type fp16 = dpas_argument_type::fp16;
31
+ constexpr dpas_argument_type bf16 = dpas_argument_type::bf16 ;
31
32
32
33
std::string toString (dpas_argument_type T) {
33
34
switch (T) {
@@ -192,8 +193,8 @@ ReadT readFromHorizontallyPackedMatrix(void *VVec, int Row, int Col) {
192
193
unsigned int Mask = (static_cast <uint64_t >(1 ) << ElemBitSize) - 1 ;
193
194
ElemT Value = (TargetElem >> Offset) & Mask;
194
195
if constexpr (std::is_signed_v<ElemT>) {
195
- Value <<= (32 - ElemBitSize);
196
- Value >>= (32 - ElemBitSize);
196
+ Value <<= (( sizeof (ElemT) * 8 ) - ElemBitSize);
197
+ Value >>= (( sizeof (ElemT) * 8 ) - ElemBitSize);
197
198
}
198
199
return Value;
199
200
}
@@ -257,7 +258,7 @@ template <int M, int N, dpas_argument_type ArgPrecision, typename ReadT,
257
258
bool IsHorizontalPack>
258
259
void printMatrix (void *Vec, std::string Msg) {
259
260
std::cout << Msg << " (" << M << " x" << N
260
- << " ), element bit size = " << toString (ArgPrecision) << std::endl;
261
+ << " ), element precision = " << toString (ArgPrecision) << std::endl;
261
262
for (int I = 0 ; I < M; I++) {
262
263
for (int J = 0 ; J < N; J++) {
263
264
@@ -316,12 +317,10 @@ bool test(queue &Q, bool Print) {
316
317
auto BPacked = aligned_alloc_shared<BNaturalType>(128 , BPackedSize, Q);
317
318
auto Res = aligned_alloc_shared<ResNaturalType>(128 , M * N, Q);
318
319
// Init APacked;
319
- int VVV = 0 ;
320
+ int Value = 0 ;
320
321
for (int II = 0 ; II < M; II++) {
321
322
for (int JJ = 0 ; JJ < K; JJ++) {
322
- // int Value = VVV++;
323
- // int Value = JJ == 1 ? 1 : 0;
324
- int Value = 1 ;
323
+ Value++;
325
324
writeToHorizontallyPackedMatrix<M, K, APrec>(
326
325
APacked, II, JJ, static_cast <ANaturalType>(Value));
327
326
}
@@ -332,10 +331,7 @@ bool test(queue &Q, bool Print) {
332
331
// Init BPacked;
333
332
for (int II = 0 ; II < K; II++) {
334
333
for (int JJ = 0 ; JJ < N; JJ++) {
335
- // int Value = (II+JJ % 4) == 0 ? 1 : (2 + II + JJ) % 3;
336
- // int Value = 2;
337
- // int Value = JJ == 1 ? ((II+JJ % 4) == 0 ? 1 : (2 + II + JJ) % 3) : 0;
338
- int Value = JJ == 1 ? 1 : 0 ;
334
+ int Value = (II + JJ % 4 ) == 0 ? 1 : (2 + II + JJ) % 3 ;
339
335
writeToVerticallyPackedMatrix<K, N, BPrec>(
340
336
BPacked, II, JJ, static_cast <BNaturalType>(Value));
341
337
assert (Value == (int )(static_cast <BNaturalType>(Value)) && " ERROR" );
@@ -345,7 +341,7 @@ bool test(queue &Q, bool Print) {
345
341
printMatrix<K, N, BPrec, BPrintT, false /* vertical-pack*/ >(BPacked, " B" );
346
342
347
343
Q.single_task ([=]() SYCL_ESIMD_KERNEL {
348
- simd<BNaturalType , APackedSize> A (APacked, overaligned_tag<16 >{});
344
+ simd<ANaturalType , APackedSize> A (APacked, overaligned_tag<16 >{});
349
345
simd<BNaturalType, BPackedSize> B (BPacked, overaligned_tag<16 >{});
350
346
simd<ResNaturalType, M * N> C;
351
347
0 commit comments