Horrible performance compiling zero-initialization of large arrays
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- cpp
- Lĩnh vực
- compilers, performance
Hướng nghiên cứu
Start by compiling the two provided HLSL shaders with DXC at -O3 and compare their timings. Follow the main entry point and the zero-initialization path through the optimizer to identify where the large-array case expands; done means the slow shader no longer exhibits the reported optimizer slowdown while preserving its behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
See https://github.com/gfx-rs/wgpu/pull/10314.
When trying to compile shaders which zero-initialize large multi-dimensional arrays, dxc's optimizer goes absolutely crazy and spends huge amounts of time. On my M4 mac, I experienced 1.4s compilation times for a simple shader which only zero initializes a single structure.
Steps to Reproduce
Use DXC with -O3 on the following shaders:
// Slow compilation
groupshared float4 inp[4][18][18];
RWByteAddressBuffer output : register(u0);
uint naga_div(uint lhs, uint rhs) {
return lhs / (rhs == 0u ? 1u : rhs);
}
uint naga_mod(uint lhs, uint rhs) {
return lhs % (rhs == 0u ? 1u : rhs);
}
[numthreads(16, 16, 1)]
void main(uint index : SV_GroupIndex)
{
if (index == 0) {
inp = (float4[4][18][18])0;
}
GroupMemoryBarrierWithGroupSync();
float4 _e15 = inp[min(uint(naga_div(index, 324u)), 3u)][min(uint(naga_mod(naga_div(index, 18u), 18u)), 17u)][min(uint(naga_mod(index, 18u)), 17u)];
output.Store4(index*16, asuint(_e15));
return;
}
// Fast compilation
groupshared float4 inp[4][18][18];
RWByteAddressBuffer output : register(u0);
uint naga_div(uint lhs, uint rhs) {
return lhs / (rhs == 0u ? 1u : rhs);
}
uint naga_mod(uint lhs, uint rhs) {
return lhs % (rhs == 0u ? 1u : rhs);
}
[numthreads(16, 16, 1)]
void main(uint index : SV_GroupIndex)
{
[loop]
for (uint zero_flat_index = index; zero_flat_index < 1296u; zero_flat_index += 256u) {
uint zero_index = (zero_flat_index / 324u) % 4u;
uint zero_index_1 = (zero_flat_index / 18u) % 18u;
uint zero_index_2 = (zero_flat_index / 1u) % 18u;
inp[zero_index][zero_index_1][zero_index_2] = (float4)0;
}
GroupMemoryBarrierWithGroupSync();
float4 _e15 = inp[min(uint(naga_div(index, 324u)), 3u)][min(uint(naga_mod(naga_div(index, 18u), 18u)), 17u)][min(uint(naga_mod(index, 18u)), 17u)];
output.Store4(index*16, asuint(_e15));
return;
}
Actual Behavior
Slow perf, 1.4s vs 8ms on my Mac.
Environment
- DXC version libdxcompiler.dylib: 1.10(5180-e3554182)(1.9.0.5180)
- Host Operating System macOS 26.5.1
- Ngôn ngữ chính
- C++
- Star
- 3.7k
- Fork
- 926
- Merge trung bình
- 3 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 45
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/DirectXShaderCompiler
-
bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/DirectXShaderCompiler#9173 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
microsoft/DirectXShaderCompiler#9155 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/DirectXShaderCompiler#9135 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
DXC emits DW_LANG_C_plus_plus instead of DW_LANG_HLSL for HLSLCó thể đã có người làm @rj123-nv đã nhận 18 ngày trước. Đang mởbug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
microsoft/DirectXShaderCompiler#9087 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
microsoft/DirectXShaderCompiler#9086 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của microsoft/DirectXShaderCompiler
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
feature:config kind:docs os:windows toolchain:cmake triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
arch-based bug niri
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
noctalia-dev/noctalia#5552 ·
Maintainer thường phản hồi trong vòng 1 ngày