Commit 0f5414f
Fix the grid problem with sparse permute 2d (V2: threshold-guarded) (#5898)
Summary:
Pull Request resolved: #5898
X-link: https://github.com/facebookresearch/FBGEMM/pull/2817
Migrates the four host-side cap sites in `sparse_permute_2d.cu` from
the unconditional ROCm cap pattern (V1) to the new
`fbgemm_gpu::utils::cuda::determine_grid_blocks` helper (introduced in
D106267802) with the default `BlockCapPolicy::OverflowOnly`.
Net behaviour change vs V1:
- ROCm small/medium grid (`blocks * threads_per_block <= UINT32_MAX`):
uncapped grid restored. Was: capped to
`MAX_THREAD_BLOCKS_FACTOR * #SMs` unconditionally. Now: passes
through unchanged (matches pre-D104903707 behaviour).
- ROCm large grid (`blocks * threads_per_block > UINT32_MAX`):
cap still applied. The kernel grid-strides over `b_t` so capping is
correctness-preserving, and this is the regime where the HIP
`2^32` thread-per-launch limit would otherwise fire.
- NVIDIA: bit-identical to V1 (the threshold check lives entirely
under `#ifdef USE_ROCM` inside the helper).
The four sites:
- `permute_2D_sparse_data_cuda` `blocks_1` (line ~223), `threads_1=256`.
- `permute_2D_sparse_data_cuda` `blocks_2` (line ~262), block size
`dim3(32, BT_blocks=32)` so threads_per_block = `32 * BT_blocks = 1024`.
- `permute_sparse_features_cuda` `blocks_1` (line ~439), `threads_1=256`.
- `permute_sparse_features_cuda` `blocks_2` (line ~486), block size
same as above (1024).
Drive-by: switches `cuda_calc_block_count` (y/z-dim 65535 cap) to
`determine_grid_blocks` (which uses `cuda_calc_xblock_count` internally
with the 2^31-1 x-dim cap). These launches are 1-D x-dim launches so
`cuda_calc_xblock_count` is the correct primitive; the kernels
grid-stride so any change in grid size is correctness-preserving.
Reviewed By: spcyppt
Differential Revision: D104937969
fbshipit-source-id: e7c89c0942c8665595772b58ca72c0bf88177a0b1 parent 57f3a8b commit 0f5414f
2 files changed
Lines changed: 179 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
225 | 230 | | |
226 | 231 | | |
227 | 232 | | |
| |||
250 | 255 | | |
251 | 256 | | |
252 | 257 | | |
253 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
254 | 267 | | |
255 | 268 | | |
256 | 269 | | |
| |||
415 | 428 | | |
416 | 429 | | |
417 | 430 | | |
418 | | - | |
419 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
420 | 437 | | |
421 | 438 | | |
422 | 439 | | |
| |||
452 | 469 | | |
453 | 470 | | |
454 | 471 | | |
455 | | - | |
456 | | - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
457 | 480 | | |
458 | 481 | | |
459 | 482 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
866 | 866 | | |
867 | 867 | | |
868 | 868 | | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
869 | 1019 | | |
870 | 1020 | | |
871 | 1021 | | |
| |||
0 commit comments