Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions clean/dx12/hlsl/wg_platform.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ static uint wg_bid_; // workgroup index in the grid (HIP blockIdx.x)

#define WG_KERNEL(name) [numthreads(WG_BLOCK, 1, 1)] [WaveSize(WG_WAVE)] \
void name(uint wg_sv_tid_ : SV_GroupThreadID, uint wg_sv_gid_ : SV_GroupID)
#if WG_REV_ORDER // a kernel declared with WG_REV_ORDER=1: workgroup g does the work of workgroup G - 1 - g (the same
// bytes; the last-written part of its input, likelier still in the caches, first)
#define WG_SETUP() (wg_tid_ = wg_sv_tid_, wg_bid_ = wg_grid_ - 1u - (wg_sv_gid_ + wg_group_base_))
#else
#define WG_SETUP() (wg_tid_ = wg_sv_tid_, wg_bid_ = wg_sv_gid_ + wg_group_base_)
#endif

uint wg_lane_id() { return wg_tid_; } // HIP wg_lane_id(): the lane in the workgroup (0 .. WG_BLOCK - 1)
uint wg_block_id() { return wg_bid_; } // HIP wg_block_id(): grids above 65535 run as several dispatches
Expand Down
5 changes: 4 additions & 1 deletion clean/dx12/kernels/l_swin.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
// HIP's transcendental chain (SW_GELU 0).
// l_swin_block_c32_nc FP8 map in, FP8 out, mirror border (#117)
// l_swin_block_c32_enc_nc the encoder block: FP16 halo map [H + 4][W + 4][32] in (SW_SRC 1), FP8 out
// with its workgroups in reverse order (WG_REV_ORDER, wg_platform.hlsli; the same bytes): it
// reads first the rows of x2 the linears wrote last, and its last-written rows of x3 are the
// ones l_project_gather reads first (more cache hits at both hand-offs)
// l_swin_block_c32_dec_nc the decoder block: FP8 map in with the token-grid mirror (SW_SRC 2), FP16 out (SW_OUT_F16)
//
// @wg-kernel l_swin_block_c32_nc co=l_swin.co block=256 wave=32 args=p,p,p,p,u,u,u,u defines=SW_C=32,SW_HEADS=2,SW_MLP=128,SW_ADD=0,SW_SAFE=1,SW_ECL=0,SW_HPU=8,SW_GELU=0,SW_ENTRY_OVERRIDE=l_swin_block_c32_nc
// @wg-kernel l_swin_block_c32_enc_nc co=l_swin.co block=256 wave=32 args=p,p,p,p,u,u,u,u defines=SW_C=32,SW_HEADS=2,SW_MLP=128,SW_ADD=0,SW_SAFE=1,SW_ECL=0,SW_HPU=8,SW_GELU=3,SW_GELU_PAT=13333,SW_SRC=1,SW_ENTRY_OVERRIDE=l_swin_block_c32_enc_nc
// @wg-kernel l_swin_block_c32_enc_nc co=l_swin.co block=256 wave=32 args=p,p,p,p,u,u,u,u defines=SW_C=32,SW_HEADS=2,SW_MLP=128,SW_ADD=0,SW_SAFE=1,SW_ECL=0,SW_HPU=8,SW_GELU=3,SW_GELU_PAT=13333,SW_SRC=1,SW_ENTRY_OVERRIDE=l_swin_block_c32_enc_nc,WG_REV_ORDER=1
// @wg-kernel l_swin_block_c32_dec_nc co=l_swin.co block=256 wave=32 args=p,p,p,p,u,u,u,u defines=SW_C=32,SW_HEADS=2,SW_MLP=128,SW_ADD=0,SW_SAFE=1,SW_ECL=0,SW_HPU=8,SW_GELU=1,SW_SRC=2,SW_OUT_F16=1,SW_ENTRY_OVERRIDE=l_swin_block_c32_dec_nc
// l_swin_block_c32_dec_coef12_nc D3D12 only: the decoder block with l_coef_pack12 as its epilogue (SW_OUT_COEF12;
// byte for byte the pair _dec_nc -> l_coef_pack12, which stays the fallback route);
Expand Down
Loading