-
Notifications
You must be signed in to change notification settings - Fork 758
Implement HLSL Diagnostics for LinAlg operations #7430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Implement HLSL Diagnostics for LinAlg operations #7430
Conversation
tools/clang/test/SemaHLSL/hlsl/linalg/builtins/mul_add_invalid.hlsl
Outdated
Show resolved
Hide resolved
Couple of items left to do here:
|
@anupamachandra - given that there's build errors and you have some more work planned, is it worth reviewing at this point? |
Yes please. I'm working on the build errors and missed item is marked with a //FIXME. It think it'll be good to get some eyes on it to check if the PR meets expectations in terms of scope and if any big issues/gaps stand out. |
Co-authored-by: Damyan Pepper <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits / questions
tools/clang/test/SemaHLSL/hlsl/linalg/builtins/mul_add_invalid.hlsl
Outdated
Show resolved
Hide resolved
tools/clang/test/SemaHLSL/hlsl/linalg/builtins/outer_product_accumulate_invalid.hlsl
Outdated
Show resolved
Hide resolved
def err_hlsl_linalg_isunsigned_incorrect_for_given_type : Error< | ||
"%0 must be %select{false|true}1 for a %2 vector type">; | ||
def err_hlsl_linalg_interpretation_value_incorrect : Error< | ||
"%0 is an invalid %select{Memory|Register}1 Interpretation value">; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"%0 is an invalid %select{Memory|Register}1 Interpretation value">; | |
"%0 is an invalid %select{memory|register}1 interpretation value">; |
def err_hlsl_linalg_optimal_matrix_layout_matrix_stride_must_be_zero : Error< | ||
"for optimal matrix layout, matrix stride must be zero">; | ||
def err_hlsl_linalg_matrix_dim_must_not_be_zero: Error< | ||
"matrix dimension must not be zero">; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"matrix dimension must not be zero">; | |
"matrix dimension must be greater than 0">; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, much better.
"matrix dimension must not be zero">; | ||
def err_hlsl_linalg_matrix_layout_invalid : Error< | ||
"matrix layout %0 is not valid, must be in the range %1 - %2">; | ||
def err_hlsl_linalg_function_requires_shader_model_6_9_or_above : Error< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use warn_hlsl_intrinsic_in_wrong_shader_model
(which is a default-error warning)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warnings can be overriden?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, and for all the availability warnings we allow them to be overridden because they might be valid if the compiler fully optimizes them away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remembered as I was modifying this per your feedback that I had originally tried to use warn_hlsl_intrinsic_in_wrong_shader_model
but that error prints out the entry function which is not available here. In my earlier PR I had added check to the DiagnoseReachableHLSLCall
in SemaHLSL.cpp, but that gets called after these intrinsics are processed. Is there a better place to move this diagnostic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple comments on linalg.h
API changes.
template <> bool IsUnsigned<uint16_t>() { return true; } | ||
#endif | ||
template <typename T> struct IsUnsigned { | ||
static const bool Value = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the default template shouldn't have any definition for Value
, if possible. That way, unsupported types trigger an error here instead of defaulting to signed. That would require specializations for float types and all supported signed int types, of course, but it would also prevent use of unexpected types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still want this, given the builtins are now updated to use only the allowed types?
template <> struct IsUnsigned<uint64_t> { | ||
static const bool value = true; | ||
}; | ||
|
||
#ifdef __HLSL_ENABLE_16_BIT | ||
template <> struct IsUnsigned<uint16_t> { | ||
static const bool value = true; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These specializations use a different casing for Value
.
template <> struct IsUnsigned<uint64_t> { | |
static const bool value = true; | |
}; | |
#ifdef __HLSL_ENABLE_16_BIT | |
template <> struct IsUnsigned<uint16_t> { | |
static const bool value = true; | |
}; | |
template <> struct IsUnsigned<uint64_t> { | |
static const bool Value = true; | |
}; | |
#ifdef __HLSL_ENABLE_16_BIT | |
template <> struct IsUnsigned<uint16_t> { | |
static const bool Value = true; | |
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - but this makes me concerned we have a test gap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is the issue Joshua mentioned in his review that I mentioned at today's morning meeting was a bug. I am adding high-level API tests that would have caught this.
…ocalization issues
…g component class and update tests
✅ With the latest revision this PR passed the Python code formatter. |
Implements #7336