Skip to content

[Unity][Dlight] Choose perfect spatial factor in reduction rule#16101

Merged
Hzfengsy merged 1 commit intoapache:unityfrom
vinx13:unity-dlight-reduction-factor
Nov 10, 2023
Merged

[Unity][Dlight] Choose perfect spatial factor in reduction rule#16101
Hzfengsy merged 1 commit intoapache:unityfrom
vinx13:unity-dlight-reduction-factor

Conversation

@vinx13
Copy link
Member

@vinx13 vinx13 commented Nov 10, 2023

Comment on lines +208 to +214
s_factor = [i.dom for i in block_info.iters if i.kind == "S"][-1]
# get perfect spatial factor, spatial factor should be divide the innermost spatial loop so
# that the block after r_factor and be reversed compute at the original scope
while len_tx > 1:
if s_factor % len_tx == 0:
break
len_tx -= 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if we have a util method _get_perfect_tile_factor instead of adding an extra block_info parameter

Copy link
Member

@junrushao junrushao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thanks for addressing this issue!

@Hzfengsy
Copy link
Member

A general question: Does "perfect tiling" work for all cases? Specifically, is it the best way for those kernels with prime extents?

@vinx13
Copy link
Member Author

vinx13 commented Nov 10, 2023

This is like a fallback solution. If the extent is prime number, thread size will be either the extent or 1.
This is a case where the access pattern is no longer pointwise for compute_at because of imperfect tiling. We may change the behavior of compute_at or rfactor to support this

@Hzfengsy Hzfengsy merged commit 7dd248b into apache:unity Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants