Skip to content

Commit 27118d6

Browse files
committed
ifdef header, add back includes in test files, with -i option, make verifier tests, and mark preview todos
1 parent d177ac0 commit 27118d6

12 files changed

Lines changed: 58 additions & 28 deletions

tools/clang/lib/Headers/hlsl/dx/linalg.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// Header for linear algebra APIs.
22

3+
#if ((__SHADER_TARGET_MAJOR > 6) || \
4+
(__SHADER_TARGET_MAJOR == 6 && __SHADER_TARGET_MINOR >= 9)) && \
5+
(__HLSL_VERSION >= 2021)
6+
37
namespace dx {
48
namespace linalg {
59

@@ -170,3 +174,5 @@ void VectorAccumulate(vector<ElTy, ElCount> InputVector,
170174

171175
} // namespace linalg
172176
} // namespace dx
177+
178+
#endif

tools/clang/test/CodeGenDXIL/hlsl/linalg/make-interp-vec-errors.hlsl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// RUN: not %dxc -T lib_6_9 %s 2>&1 | FileCheck %s
1+
// RUN: %dxc -I %hlsl_headers -T lib_6_9 %s -verify
22

3+
#include <dx/linalg.h>
34
ByteAddressBuffer Buf;
45

56
export float4 Test1(vector<float, 4> Input) {
@@ -9,8 +10,8 @@ export float4 Test1(vector<float, 4> Input) {
910
Buf, 0, 0};
1011

1112
// clang-format off
12-
// CHECK: error: no matching function for call to 'MakeInterpretedVector'
13-
// CHECK: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'DT'
13+
// expected-error@+3{{no matching function for call to 'MakeInterpretedVector'}}
14+
// expected-note@dx/linalg.h:93{{candidate template ignored: invalid explicitly-specified argument for template parameter 'DT'}}
1415
return Mul<float>(
1516
Matrix, MakeInterpretedVector<2>(Input));
1617
// clang-format on
@@ -27,8 +28,8 @@ export float4 Test2(vector<float, 4> Input) {
2728
Buf, 0, 0};
2829

2930
// clang-format off
30-
// CHECK: error: no matching function for call to 'MakeInterpretedVector'
31-
// CHECK: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'DT'
31+
// expected-error@+3{{no matching function for call to 'MakeInterpretedVector'}}
32+
// expected-note@dx/linalg.h:93{{candidate template ignored: invalid explicitly-specified argument for template parameter 'DT'}}
3233
return Mul<float>(
3334
Matrix, MakeInterpretedVector<DATA_TYPE_InvalidType>(Input));
3435
// clang-format on
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: not %dxc -T lib_6_9 %s 2>&1 | FileCheck %s
1+
// RUN: %dxc -I %hlsl_headers -T lib_6_9 %s -verify
2+
3+
#include <dx/linalg.h>
24

35
ByteAddressBuffer Buf;
46

@@ -9,8 +11,8 @@ vector<float, 128> MixUpVectorAndMatrixArguments(vector<float, 128> Input) {
911
Buf, 0, 0};
1012

1113
// clang-format off
12-
// CHECK: error: no matching function for call to 'Mul'
13-
// CHECK: note: candidate template ignored: could not match 'MatrixRefImpl' against 'InterpretedVector'
14+
// expected-error@+3{{no matching function for call to 'Mul'}}
15+
// expected-note@dx/linalg.h:107{{candidate template ignored: could not match 'MatrixRefImpl' against 'InterpretedVector'}}
1416
// clang-format on
1517
return Mul<float>(MakeInterpretedVector<DATA_TYPE_FLOAT16>(Input), Matrix);
1618
}

tools/clang/test/CodeGenDXIL/hlsl/linalg/mat-vec-mul-transpose-errors.hlsl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: %dxc -T lib_6_9 -enable-16bit-types %s | FileCheck %s
1+
// RUN: %dxc -I %hlsl_headers -T lib_6_9 -enable-16bit-types %s -verify
2+
3+
#include <dx/linalg.h>
24

35
ByteAddressBuffer Buf;
46

@@ -9,6 +11,7 @@ export float4 Test1(vector<float, 4> Input) {
911
Buf, 0, 0};
1012

1113
// clang-format off
14+
// PREVIEW CHECK TODO:
1215
// CHECK: error: something about transposing not supported for rowmajor / colmajor layouts
1316
return Mul<float>(
1417
Matrix, MakeInterpretedVector<DATA_TYPE_FLOAT16>(Input));
@@ -22,6 +25,7 @@ export vector<float, 8> Test2(vector<uint8_t4_packed, 6> Input) {
2225
Buf, 0, 0};
2326

2427
// clang-format off
28+
// PREVIEW CHECK TODO:
2529
// CHECK: error: something about transposing not supported for rowmajor / colmajor layouts
2630
// clang-format on
2731
return Mul<float>(Matrix,

tools/clang/test/CodeGenDXIL/hlsl/linalg/mat-vec-mul.hlsl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: %dxc -T lib_6_9 -enable-16bit-types %s | FileCheck %s
1+
// RUN: %dxc -I %hlsl_headers -T lib_6_9 -enable-16bit-types %s | FileCheck %s
2+
3+
#include <dx/linalg.h>
24

35
ByteAddressBuffer Buf;
46

@@ -30,7 +32,7 @@ export vector<float, 8> Test2(vector<uint8_t4_packed, 6> Input) {
3032
}
3133

3234
// test that "stride" isn't ignored in non-optimal layouts
33-
export vector<float, 8> Test2(vector<uint8_t4_packed, 6> Input) {
35+
export vector<float, 8> Test3(vector<uint8_t4_packed, 6> Input) {
3436
using namespace dx::linalg;
3537

3638
MatrixRef<DATA_TYPE_UINT8, 8, 6 * 4, MATRIX_LAYOUT_ROW_MAJOR> Matrix = {
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
// RUN: not %dxc -T lib_6_9 %s 2>&1 | FileCheck %s
1+
// RUN: %dxc -I %hlsl_headers -T lib_6_9 %s -verify
2+
3+
#include <dx/linalg.h>
24

35
ByteAddressBuffer Buf;
46

57
vector<float, 128> MixUpVectorAndMatrixArguments(vector<float, 128> Input) {
68
using namespace dx::linalg;
79

8-
MatrixRef<1, 128, 128, MATRIX_LAYOUT_MUL_OPTIMAL> Matrix = {
10+
MatrixRef<DATA_TYPE_SINT16, 128, 128, MATRIX_LAYOUT_MUL_OPTIMAL> Matrix = {
911
Buf, 0, 0};
1012

1113
// clang-format off
12-
// CHECK: error: no matching function for call to 'MulAdd'
13-
// CHECK: note: candidate template ignored: could not match 'MatrixRefImpl' against 'InterpretedVector'
14+
// expected-error@+3{{no matching function for call to 'MulAdd'}}
15+
// expected-note@dx/linalg.h:133{{candidate template ignored: could not match 'MatrixRefImpl' against 'InterpretedVector'}}
1416
// clang-format on
15-
return MulAdd<float>(MakeInterpretedVector<1>(Input), Matrix, MakeInterpretedVector<1>(Input));
17+
return MulAdd<float>(MakeInterpretedVector<DATA_TYPE_SINT16>(Input), Matrix, MakeInterpretedVector<DATA_TYPE_SINT16>(Input));
1618
}

tools/clang/test/CodeGenDXIL/hlsl/linalg/mat-vec-muladd.hlsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: %dxc -T lib_6_9 %s | FileCheck %s
1+
// RUN: %dxc -I %hlsl_headers -T lib_6_9 %s | FileCheck %s
2+
3+
#include <dx/linalg.h>
24

35
ByteAddressBuffer Buf;
46

tools/clang/test/CodeGenDXIL/hlsl/linalg/outerproductaccumulate-errors.hlsl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: not %dxc -T lib_6_9 -enable-16bit-types %s 2>&1 | FileCheck %s
1+
// RUN: %dxc -I %hlsl_headers -T lib_6_9 -enable-16bit-types %s -verify
2+
3+
#include <dx/linalg.h>
24

35
RWByteAddressBuffer RWBuf;
46

@@ -10,8 +12,8 @@ export void Test4(vector<half, 128> Input1, vector<half, 64> Input2) {
1012
matrix = {RWBuf, 0, 0};
1113

1214
// clang-format off
13-
// CHECK: error: no matching function for call to 'OuterProductAccumulate'
14-
// CHECK: note: candidate template ignored: could not match 0 against 1
15+
// expected-error@+5{{no matching function for call to 'OuterProductAccumulate'}}
16+
// expected-note@dx/linalg.h:157{{candidate template ignored: could not match 0 against 1}}
1517
// __builtin_OuterProductAccumulate(Input1, Input2, RWBuf, 0, DATA_TYPE_FLOAT16, MATRIX_LAYOUT_OUTER_PRODUCT_OPTIMAL, 0);
1618
// clang-format on
1719

@@ -26,8 +28,8 @@ export void Test5(vector<int, 128> Input1, vector<uint, 128> Input2) {
2628
matrix = {RWBuf, 0, 0};
2729

2830
// clang-format off
29-
// CHECK: error: no matching function for call to 'OuterProductAccumulate'
30-
// CHECK: note: candidate template ignored: could not match 0 against 1
31+
// expected-error@+5{{no matching function for call to 'OuterProductAccumulate'}}
32+
// expected-note@dx/linalg.h:157{{candidate template ignored: could not match 0 against 1}}
3133
// __builtin_OuterProductAccumulate(Input1, Input2, RWBuf, 0, DATA_TYPE_FLOAT16, MATRIX_LAYOUT_OUTER_PRODUCT_OPTIMAL, 0);
3234
// clang-format on
3335

@@ -42,8 +44,8 @@ export void Test4(vector<half, 64> Input1, vector<half, 64> Input2) {
4244
matrix = {RWBuf, 0, 0};
4345

4446
// clang-format off
45-
// CHECK: error: no matching function for call to 'OuterProductAccumulate'
46-
// CHECK: note: candidate template ignored: could not match 0 against 1
47+
// expected-error@+5{{no matching function for call to 'OuterProductAccumulate'}}
48+
// expected-note@dx/linalg.h:157{{candidate template ignored: deduced conflicting types for parameter 'ElTy' ('int' vs. 'unsigned int')}}
4749
// __builtin_OuterProductAccumulate(Input1, Input2, RWBuf, 0, DATA_TYPE_FLOAT16, MATRIX_LAYOUT_OUTER_PRODUCT_OPTIMAL, 0);
4850
// clang-format on
4951

tools/clang/test/CodeGenDXIL/hlsl/linalg/outerproductaccumulate.hlsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: %dxc -T lib_6_9 -enable-16bit-types %s | FileCheck %s
1+
// RUN: %dxc -I %hlsl_headers -T lib_6_9 -enable-16bit-types %s | FileCheck %s
2+
3+
#include <dx/linalg.h>
24

35
RWByteAddressBuffer RWBuf;
46

tools/clang/test/CodeGenDXIL/hlsl/linalg/vector-matrix-proposal.hlsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: %dxc -T lib_6_9 -enable-16bit-types %s
1+
// RUN: %dxc -I %hlsl_headers -T lib_6_9 -enable-16bit-types %s
2+
3+
#include "dx/linalg.h"
24

35
namespace code_example {
46
ByteAddressBuffer Model;

0 commit comments

Comments
 (0)