Skip to content
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
3dd5f58
Add HLSL validation to coopvec builtins
anupamachandra Apr 28, 2025
70119f8
Add more HLSL validation
anupamachandra Apr 29, 2025
737e65b
Add IsTransposable check for matrix layouts
anupamachandra Apr 29, 2025
e4eab81
Check validation of Bias Interpretation parameters
anupamachandra Apr 29, 2025
392322d
Add diagnostics for OuterProoductAccumulate
anupamachandra Apr 29, 2025
1831811
Updated error message
anupamachandra Apr 29, 2025
d1fe869
Minor Fixes
anupamachandra Apr 30, 2025
4d751a7
Clang Format
anupamachandra Apr 30, 2025
02cb085
Fix error location and add tests
anupamachandra May 2, 2025
969d7e6
More validation tests
anupamachandra May 4, 2025
f132c60
Check Matrix dimensions are not zero
anupamachandra May 4, 2025
3c19297
More tests
anupamachandra May 5, 2025
3da3872
Remove unnecessary space
anupamachandra May 5, 2025
16a5ab8
Fix run command
anupamachandra May 5, 2025
2132e01
Updated Comments
anupamachandra May 5, 2025
182baae
Update invalid checks for input interpretation
anupamachandra May 5, 2025
974f2d4
Fix Build errors
anupamachandra May 6, 2025
64a01e9
Fix Build failures: tests not per spec
anupamachandra May 6, 2025
f36758f
Fix build errors
anupamachandra May 7, 2025
9f24be7
Change linalg.h to use IsUnsigned type trait pattern than function te…
anupamachandra May 7, 2025
e715df4
chore: autopublish 2025-05-07T19:27:48Z
github-actions[bot] May 7, 2025
2d3f262
Remove/comment unused variables: build errors
anupamachandra May 7, 2025
bf5c62f
Use linalg headers in the hlsl validation tests
anupamachandra May 7, 2025
be4c02f
Ugh..line number change from updating the linalg headers
anupamachandra May 7, 2025
c4233f0
Update tools/clang/lib/Headers/hlsl/dx/linalg.h
anupamachandra May 7, 2025
4295c84
Update variable name missed
anupamachandra May 7, 2025
17b810e
Use ComponentType and MatrixLayout from DxilConstants.h
anupamachandra May 8, 2025
3cce131
Fix unsafe inmplicit cast
anupamachandra May 8, 2025
c9c1389
Add tests to mul_add_invalid for shared parameters
anupamachandra May 8, 2025
e870b99
Add validation and tests for packed input types
anupamachandra May 9, 2025
46c2caf
chore: autopublish 2025-05-09T16:56:52Z
github-actions[bot] May 9, 2025
99a9566
review feedback
anupamachandra May 9, 2025
2ab5c86
alignment
anupamachandra May 9, 2025
90fac97
Add Max Matrix Dim checks
anupamachandra May 9, 2025
62c31bc
Update diagnostics per review feedback
anupamachandra May 15, 2025
a8676ea
Per review feedback, change upper to lower case register/memory inter…
anupamachandra May 15, 2025
9045c82
Review feedback: Prefer 0 over zero in diagnostic messages to avoid l…
anupamachandra May 15, 2025
4fc747e
Updates based on review feedback: fix range specification
anupamachandra May 15, 2025
5650cf1
Change input/output vector allowed types from numeric to custom linal…
anupamachandra May 15, 2025
b845582
Update per feeback: refactor Matrix dimension check diagnostics
anupamachandra May 15, 2025
baa4bbc
Fix darker error
anupamachandra May 15, 2025
40a2311
Merge from main
anupamachandra May 15, 2025
5751f2b
Fix typo
anupamachandra May 15, 2025
c60bcba
Remove unused variable
anupamachandra May 15, 2025
1bbaa40
Add tests for IsUnsigned::value, remove uint64 case
anupamachandra May 15, 2025
de5d0ea
Replace explicit SM6.9 checks with intrinsic attribute
tex3d May 16, 2025
ffdb3d4
Add IsUnsigned template specializations for all allowed types
anupamachandra May 16, 2025
78e5268
Minor fixes
anupamachandra May 16, 2025
15d9177
Clang format plus test updates with linenum
anupamachandra May 16, 2025
1e4dfbc
Clang format fixes
anupamachandra May 16, 2025
a8fe58f
Update IsUnsigned specializations to use macros: better readability
anupamachandra May 16, 2025
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
48 changes: 48 additions & 0 deletions tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -8013,6 +8013,54 @@ def err_hlsl_reorder_unsupported_stage : Error<
"dx::MaybeReorderThread is unavailable in shader stage '%0' (requires 'raygeneration')">;
def err_hlsl_hitobject_unsupported_stage : Error<
"dx::HitObject is unavailable in shader stage '%0' (requires 'raygeneration', 'closesthit' or 'miss')">;

// Linear Algebra Operations
Comment thread
anupamachandra marked this conversation as resolved.
def err_hlsl_linalg_param_must_be_const : Error<
"'%0' must be a constant parameter">;
Comment thread
anupamachandra marked this conversation as resolved.
Outdated
def err_hlsl_linalg_vector_incorrect_type : Error<
Comment thread
anupamachandra marked this conversation as resolved.
Outdated
"%0 is incorrect type, must be 16-bit or 32-bit 'unsigned int', "
"'signed int' or 'float'">;
def err_hlsl_linalg_isunsigned_incorrect_for_given_type : Error<
"%0 must be %select{false|true}1 for a %2 vector type">;
Comment thread
anupamachandra marked this conversation as resolved.
Outdated
def err_hlsl_linalg_interpretation_value_incorrect : Error<
"%0 is an invalid %select{Memory|Register}1 Interpretation value">;
Comment thread
anupamachandra marked this conversation as resolved.
Outdated
def err_hlsl_linalg_matrix_layout_is_not_transposable : Error<
"RowMajor and ColumnMajor matrices are not transposable">;
def err_hlsl_linalg_optimal_matrix_layout_matrix_stride_must_be_zero : Error<
"for optimal matrix layout, matrix stride must be zero">;
Comment thread
anupamachandra marked this conversation as resolved.
Outdated
def err_hlsl_linalg_matrix_dim_must_not_be_zero: Error<
"matrix dimension must not be zero">;
Comment thread
anupamachandra marked this conversation as resolved.
Outdated
def err_hlsl_linalg_matrix_layout_invalid : Error<
"matrix layout %0 is not valid, must be in the range %1 - %2">;
Comment thread
anupamachandra marked this conversation as resolved.
Outdated
def err_hlsl_linalg_function_requires_shader_model_6_9_or_above : Error<
Comment thread
llvm-beanz marked this conversation as resolved.
Outdated
"intrinsic function %0 requires shader model 6.9 or greater">;

def err_hlsl_linalg_mul_muladd_output_vector_size_not_equal_to_matrix_M : Error<
"output vector length must be equal to Matrix M dimension in a linalg Mul/MulAdd operation">;
def err_hlsl_linalg_mul_muladd_unpacked_input_vector_size_not_equal_to_matrix_K : Error<
"unpacked input vector length must be equal to Matrix K dimension in a linalg Mul/MulAdd operation">;
def err_hlsl_linalg_mul_muladd_packed_input_vector_size_incorrect : Error<
"packed input vector length must be the smallest number that can hold matrix dim K values of the "
"packed(smaller) type in linalg mul/muladd operations">;
def err_hlsl_linalg_mul_muladd_isUnsigned_for_packed_input_must_be_true : Error<
"IsInputUnsigned must be true for packed input interpretations in linalg mul/muladd operations">;
def err_hlsl_linalg_mul_muladd_packed_input_vector_must_be_uint : Error<
"packed input vector type must be a 32-bit unsigned int in linalg mul/muladd operations, "
"packed formats uint8_t4_packed and sint8_t4_packed are not supported currently">;
def err_hlsl_linalg_mul_muladd_exceeds_max_matrix_dim_m: Error<
"matrix dimension M must be less than %0, in a linalg Mul/MulAdd operation">;
def err_hlsl_linalg_mul_muladd_exceeds_max_matrix_dim_k_unpacked_input: Error<
"matrix dimension K when using unpacked input vectors must be less than %0, in a "
"linalg Mul/MulAdd operation">;
def err_hlsl_linalg_mul_muladd_exceeds_max_matrix_dim_k_packed_input: Error<
"matrix dimension K when using packed input vectors must be less than %0, in a "
"linalg Mul/MulAdd operation">;
Comment thread
anupamachandra marked this conversation as resolved.
Outdated

def err_hlsl_linalg_outer_prod_acc_vector_type_mismatch : Error<
"input vectors of outerproductaccumulate must have the same element type">;
def err_hlsl_linalg_outer_prod_acc_matrix_layout_must_be_outer_prod_acc_optimal : Error<
"matrix layout for outerproductaccumulate must be %0">;

// HLSL Change Ends

// SPIRV Change Starts
Expand Down
40 changes: 25 additions & 15 deletions tools/clang/lib/Headers/hlsl/dx/linalg.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,24 @@ enum MatrixLayout {
// Helper for signedness
//
namespace details {
template <typename T> bool IsUnsigned() { return false; }

#ifdef __HLSL_ENABLE_16_BIT
template <> bool IsUnsigned<uint16_t>() { return true; }
#endif
template <typename T> struct IsUnsigned {
static const bool Value = false;
Comment thread
tex3d marked this conversation as resolved.
Outdated
};

template <> struct IsUnsigned<uint32_t> {
static const bool Value = true;
};

template <> bool IsUnsigned<uint32_t>() { return true; }
template <> bool IsUnsigned<uint64_t>() { return true; }
template <> struct IsUnsigned<uint64_t> {
static const bool value = true;
Comment thread
anupamachandra marked this conversation as resolved.
Outdated
};

#ifdef __HLSL_ENABLE_16_BIT
template <> struct IsUnsigned<uint16_t> {
static const bool value = true;
};
Comment thread
tex3d marked this conversation as resolved.
Outdated
#endif //__HLSL_ENABLE_16_BIT
} // namespace details

//
Expand Down Expand Up @@ -116,10 +126,10 @@ Mul(MatrixRefImpl<MatrixBufferTy, MatrixDT, MatrixM, MatrixK, MatrixLayout,
vector<OutputElTy, MatrixM> OutputVector;

__builtin_MatVecMul(
/*out*/ OutputVector, details::IsUnsigned<OutputElTy>(), InputVector.Data,
details::IsUnsigned<InputElTy>(), InputDT, Matrix.Buffer,
Matrix.StartOffset, MatrixDT, MatrixM, MatrixK, MatrixLayout,
MatrixTranspose, Matrix.Stride);
/*out*/ OutputVector, details::IsUnsigned<OutputElTy>::Value,
InputVector.Data, details::IsUnsigned<InputElTy>::Value, InputDT,
Matrix.Buffer, Matrix.StartOffset, MatrixDT, MatrixM, MatrixK,
MatrixLayout, MatrixTranspose, Matrix.Stride);

return OutputVector;
}
Expand All @@ -143,11 +153,11 @@ MulAdd(MatrixRefImpl<MatrixBufferTy, MatrixDT, MatrixM, MatrixK, MatrixLayout,
vector<OutputElTy, MatrixM> OutputVector;

__builtin_MatVecMulAdd(
/*out*/ OutputVector, details::IsUnsigned<OutputElTy>(), InputVector.Data,
details::IsUnsigned<InputElTy>(), InputDT, Matrix.Buffer,
Matrix.StartOffset, MatrixDT, MatrixM, MatrixK, MatrixLayout,
MatrixTranspose, Matrix.Stride, BiasVector.Buffer, BiasVector.StartOffset,
BiasVectorDT);
/*out*/ OutputVector, details::IsUnsigned<OutputElTy>::Value,
InputVector.Data, details::IsUnsigned<InputElTy>::Value, InputDT,
Matrix.Buffer, Matrix.StartOffset, MatrixDT, MatrixM, MatrixK,
MatrixLayout, MatrixTranspose, Matrix.Stride, BiasVector.Buffer,
BiasVector.StartOffset, BiasVectorDT);

return OutputVector;
}
Expand Down
Loading