Skip to content
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

Fix Metal accuracy problem caused by <dtype>3 vectors usage #7830

Merged
merged 1 commit into from
Apr 13, 2021
Merged
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions src/target/source/codegen_metal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,17 @@ void CodeGenMetal::PrintType(DataType t, std::ostream& os) { // NOLINT(*)
}
bool fail = false;
if (t.is_float()) {
// Need to care about sizes and alignment of half3/float3 because tir representation might not
// be aware of Metal half3/float3 details and can treat them as just three elements,
// while sizes and alignmnents of half3/float3 are one element more (half3-8 bytes/
// float13 - 16bytes).
// Example of problematic pattern: filling of threadgroup packed array using float3 elements
// by threads concurrently can lead to datarace and wrong data in threadgroup shared array.
// packed_(half3/float3) are exactly datatypes dealing with 3 elements and per-element
// alignment
if (lanes == 3) {
os << "packed_";
}
switch (t.bits()) {
case 16:
os << "half";
Expand Down