-
Notifications
You must be signed in to change notification settings - Fork 270
[CK_TILE] Stream-K XCD remapping #3652
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
Draft
arai713
wants to merge
1
commit into
develop
Choose a base branch
from
arai/ck_tile/streamk_xcd_remap
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+137
−7
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -673,10 +673,12 @@ struct StreamKKernel | |
| __shared__ char smem_ptr_0[UniversalGemmKernel::GetSmemSize()]; | ||
|
|
||
| index_t block_idx = ck_tile::get_block_1d_id(); | ||
| index_t grid_size = kargs.tile_partitioner.grid_size().x; | ||
| index_t dp_num_loop = kargs.tile_partitioner.get_iters_per_tile(); | ||
| index_t dp_ctas = kargs.tile_partitioner.get_dp_ctas(); | ||
| bool is_dp_ctas = block_idx < kargs.tile_partitioner.get_dp_ctas(); | ||
|
|
||
| block_idx = kargs.tile_partitioner.RemapXCD(block_idx, grid_size); | ||
| // Check if at the data parallel section | ||
| if(is_dp_ctas) | ||
| { | ||
|
|
@@ -706,11 +708,14 @@ struct StreamKKernel | |
| __shared__ char smem_ptr_0[UniversalGemmKernel::GetSmemSize()]; | ||
|
|
||
| index_t block_idx = ck_tile::get_block_1d_id(); | ||
| index_t grid_size = kargs.tile_partitioner.grid_size().x; | ||
| index_t dp_num_loop = kargs.tile_partitioner.get_iters_per_tile(); | ||
|
|
||
| // Data-parallel section | ||
| for(index_t tile_idx = block_idx; tile_idx < kargs.tile_partitioner.get_dp_tiles(); | ||
| tile_idx += kargs.tile_partitioner.get_grid()) | ||
| block_idx = | ||
| kargs.tile_partitioner.RemapXCD(block_idx, grid_size) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment about how we shouldn't do this on all architectures. (See above) |
||
| // Data-parallel section | ||
| for(index_t tile_idx = block_idx; tile_idx < kargs.tile_partitioner.get_dp_tiles(); | ||
| tile_idx += kargs.tile_partitioner.get_grid()) | ||
| { | ||
| BaseGemm(kargs, tile_idx, dp_num_loop, 0, 0, kargs.K, smem_ptr_0); | ||
| block_sync_lds(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -421,6 +421,23 @@ void test_get_tile_local_cta_idx(ck_tile::index_t tile_iter_start, | |
| EXPECT_EQ(tile_local_cta_idx, expected_tile_local_cta_idx); | ||
| } | ||
|
|
||
| template <typename GemmShape> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also add a test for when we don't use the default number of XCDs? |
||
| void test_remap_xcd( | ||
| const std::vector<ck_tile::index_t>& initial_values, | ||
| const std::vector<ck_tile::index_t>& expected_values, | ||
| ck_tile::StreamKTilePartitioner_v2<GemmShape, ck_tile::StreamKReductionStrategy::Atomic, true>& | ||
| tile_partitioner) | ||
| { | ||
| // ck_tile::index_t grid_size = tile_partitioner.grid_size().x; | ||
| std::vector<ck_tile::index_t> remapped_values(initial_values.size()); | ||
| for(std::size_t i = 0; i < initial_values.size(); ++i) | ||
| { | ||
| remapped_values[i] = tile_partitioner.RemapXCD(initial_values[i], initial_values.size()); | ||
| } | ||
|
|
||
| EXPECT_EQ(remapped_values, expected_values); | ||
| } | ||
|
|
||
| // Configs for TilePartitioner Child structs | ||
| struct StreamKTilePartitionerV2PersistentExpected | ||
| { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since this change should only apply to gfx942 and gfx950, we likely need some kind of logic to determine whether we want to apply the remap or not. Also, depending on the variant of gfx942 there may be fewer than 8 XCDs, so I think some additional logic will be required to determine what value for
num_xcdswe want to use (rather than solely relying on the default of 8).We want to avoid using preprocessor macros, so depending on what there is available in the HIP api, maybe we can query the number of XCDs from the device?
If not, we may need to consider other options. Perhaps we could consider some logic that follows a similar pattern to: include/ck_tile/ops/gemm/kernel/streamk_gemm/streamk_gemm_coherency.hpp.