device_batched_gemm_multi_d_xdl.hpp Source File#
device_batched_gemm_multi_d_xdl.hpp
Go to the documentation of this file.
30 * strided batched, but we can easily extend to other layouts. The returned offset can be either \p
38 * \note Using \p ComputePtrOffsetOfBatch gives us the flexibility that 2 workgroups can compute 2
41 * impl/device_conv3d_fwd_xdl_ndhwc_kzyxc_ndhwk.hpp kernel_gemm_xdlops_v2r3_for_conv3d \endlink for
45 * \note \p Block2ETileMap allows customized mapping between a workgroup and the C-tile it computes.
46 * Together with \p ComputePtrOffsetOfBatch, we can reuse GridwiseGemm (and GridwiseGemm fusion ) to
float launch_and_time_kernel(const StreamConfig &stream_config, F kernel, dim3 grid_dim, dim3 block_dim, std::size_t lds_byte, Args... args)
Definition host_utility/kernel_launch.hpp:14
Definition convolution_backward_data_specialization.hpp:8
std::string getGemmSpecializationString(const GemmSpecialization &s)
Definition gemm_specialization.hpp:32
GemmSpecialization
Definition gemm_specialization.hpp:11
__global__ void kernel_batched_gemm_xdl(const ABDataType *__restrict__ p_a_grid, const ABDataType *__restrict__ p_b_grid, DsPointer p_ds_grid, EDataType *__restrict__ p_e_grid, const index_t batch_count, const AElementwiseOperation a_element_op, const BElementwiseOperation b_element_op, const CDEElementwiseOperation cde_element_op, const AGridDesc_AK0_M_AK1 a_grid_desc_k0_m_k1, const BGridDesc_BK0_N_BK1 b_grid_desc_k0_n_k1, const DsGridDescriptor_MBlock_MPerBlock_NBlock_NPerBlock ds_grid_desc_mblock_mperblock_nblock_nperblock, const EGridDesc_MBlock_MPerBlock_NBlock_NPerBlock e_grid_desc_mblock_mperblock_nblock_nperblock_, const ComputePtrOffsetOfBatch compute_ptr_offset_of_batch, const Block2ETileMap block_2_etile_map)
Definition device_batched_gemm_multi_d_xdl.hpp:68
Definition convolution_backward_data_specialization.hpp:7
Definition ck.hpp:268
__host__ __device__ constexpr auto make_naive_tensor_descriptor(const Tuple< Lengths... > &lengths, const Tuple< Strides... > &strides)
Definition tensor_descriptor_helper.hpp:49
typename tuple_element< I, TTuple >::type tuple_element_t
Definition utility/tuple.hpp:208
__host__ __device__ constexpr auto generate_tuple(F &&f, Number< N >)
Definition tuple_helper.hpp:21
__host__ __device__ constexpr auto make_tuple(Xs &&... xs)
Definition utility/tuple.hpp:211
constexpr LoopScheduler make_default_loop_scheduler()
Definition loop_scheduler.hpp:20
Definition ck/stream_config.hpp:10
Definition gridwise_gemm_multiple_d_xdl_cshuffle.hpp:78
__host__ static __device__ constexpr auto MakeDefaultBGridDescriptor_BK0_N_BK1(const BGridDesc_N_K &b_grid_desc_n_k)
Definition gridwise_gemm_multiple_d_xdl_cshuffle.hpp:207
__host__ static __device__ constexpr auto MakeDefaultAGridDescriptor_AK0_M_AK1(const AGridDesc_M_K &a_grid_desc_m_k)
Definition gridwise_gemm_multiple_d_xdl_cshuffle.hpp:190
__host__ static __device__ constexpr bool CheckValidity(const AGridDesc_M_K &a_grid_desc_m_k, const BGridDesc_N_K &b_grid_desc_n_k, const DsGridDesc_M_N &ds_grid_desc_m_n, const EGridDesc_M_N &e_grid_desc_m_n, const Block2ETileMap &, index_t k_batch=1)
Definition gridwise_gemm_multiple_d_xdl_cshuffle.hpp:334
__host__ static __device__ constexpr auto MakeEGridDescriptor_MBlock_MPerBlock_NBlock_NPerBlock(const EGridDesc_M_N &e_grid_desc_m_n)
Definition gridwise_gemm_multiple_d_xdl_cshuffle.hpp:224
__host__ static __device__ constexpr auto MakeDefaultBlock2ETileMap(const EGridDesc_M_N &e_grid_desc_m_n)
Definition gridwise_gemm_multiple_d_xdl_cshuffle.hpp:257
__host__ static __device__ constexpr auto MakeDsGridDescriptor_MBlock_MPerBlock_NBlock_NPerBlock(const DsGridDesc_M_N &ds_grid_desc_m_n)
Definition gridwise_gemm_multiple_d_xdl_cshuffle.hpp:245
Definition utility/integral_constant.hpp:20
Definition functional2.hpp:33
Definition device_base.hpp:197
BaseArgument()=default
BaseInvoker()=default
Definition device_batched_gemm_multi_d_xdl.hpp:403
index_t Batch_
Definition device_batched_gemm_multi_d_xdl.hpp:509
EDataType * p_e_grid_
Definition device_batched_gemm_multi_d_xdl.hpp:506
DsGridDesc_MBlock_MPerBlock_NBlock_NPerBlock ds_grid_desc_mblock_mperblock_nblock_nperblock_
Definition device_batched_gemm_multi_d_xdl.hpp:521
AGridDesc_AK0_M_AK1 a_grid_desc_ak0_m_ak1_
Definition device_batched_gemm_multi_d_xdl.hpp:518
void Print() const
Definition device_batched_gemm_multi_d_xdl.hpp:492
const BDataType * p_b_grid_
Definition device_batched_gemm_multi_d_xdl.hpp:504
ComputePtrOffsetOfStridedBatch compute_ptr_offset_of_batch_
Definition device_batched_gemm_multi_d_xdl.hpp:525
Block2ETileMap block_2_etile_map_
Definition device_batched_gemm_multi_d_xdl.hpp:528
DsGridDesc_M_N ds_grid_desc_m_n_
Definition device_batched_gemm_multi_d_xdl.hpp:514
CDEElementwiseOperation cde_element_op_
Definition device_batched_gemm_multi_d_xdl.hpp:533
void init_ds_e_grid_desc()
Definition device_batched_gemm_multi_d_xdl.hpp:405
const ADataType * p_a_grid_
Definition device_batched_gemm_multi_d_xdl.hpp:503
EGridDesc_MBlock_MPerBlock_NBlock_NPerBlock e_grid_desc_mblock_mperblock_nblock_nperblock_
Definition device_batched_gemm_multi_d_xdl.hpp:522
Argument(const void *p_a_grid, const void *p_b_grid, std::array< const void *, NumDTensor > p_ds_grid, void *p_e_grid, index_t MRaw, index_t NRaw, index_t KRaw, index_t Batch, index_t StrideA, index_t StrideB, const std::array< ck::index_t, NumDTensor > &StrideDs, index_t StrideE, index_t BatchStrideA, index_t BatchStrideB, const std::array< ck::index_t, NumDTensor > &BatchStrideDs, index_t BatchStrideE, AElementwiseOperation a_element_op, BElementwiseOperation b_element_op, CDEElementwiseOperation cde_element_op)
Definition device_batched_gemm_multi_d_xdl.hpp:422
GridwiseGemm64::DsGridPointer p_ds_grid_
Definition device_batched_gemm_multi_d_xdl.hpp:505
AElementwiseOperation a_element_op_
Definition device_batched_gemm_multi_d_xdl.hpp:531
EGridDesc_M_N e_grid_desc_m_n_
Definition device_batched_gemm_multi_d_xdl.hpp:515
AGridDesc_M_K a_grid_desc_m_k_
Definition device_batched_gemm_multi_d_xdl.hpp:512
BElementwiseOperation b_element_op_
Definition device_batched_gemm_multi_d_xdl.hpp:532
BGridDesc_BK0_N_BK1 b_grid_desc_bk0_n_bk1_
Definition device_batched_gemm_multi_d_xdl.hpp:519
BGridDesc_N_K b_grid_desc_n_k_
Definition device_batched_gemm_multi_d_xdl.hpp:513
Definition device_batched_gemm_multi_d_xdl.hpp:291
__host__ __device__ constexpr auto GetDsPtrOffset(index_t g_idx) const
Definition device_batched_gemm_multi_d_xdl.hpp:313
__host__ __device__ constexpr long_index_t GetBPtrOffset(index_t g_idx) const
Definition device_batched_gemm_multi_d_xdl.hpp:308
ComputePtrOffsetOfStridedBatch(index_t BatchStrideA, index_t BatchStrideB, std::array< ck::index_t, NumDTensor > BatchStrideDs, index_t BatchStrideE)
Definition device_batched_gemm_multi_d_xdl.hpp:292
__host__ __device__ constexpr long_index_t GetAPtrOffset(index_t g_idx) const
Definition device_batched_gemm_multi_d_xdl.hpp:303
__host__ __device__ constexpr long_index_t GetEPtrOffset(index_t g_idx) const
Definition device_batched_gemm_multi_d_xdl.hpp:322
Definition device_batched_gemm_multi_d_xdl.hpp:538
DeviceBatchedGemmMultiD_Xdl::Argument Argument
Definition device_batched_gemm_multi_d_xdl.hpp:539
INVOKER_RUN_IMPL float Run(const BaseArgument *p_arg, const StreamConfig &stream_config=StreamConfig{}) override
Definition device_batched_gemm_multi_d_xdl.hpp:612
float RunImp(const Argument &arg, const StreamConfig &stream_config=StreamConfig{})
Definition device_batched_gemm_multi_d_xdl.hpp:542
Definition device_batched_gemm_multi_d_xdl.hpp:200
remove_cvref_t< decltype(GridwiseGemm64::MakeDefaultAGridDescriptor_AK0_M_AK1( AGridDesc_M_K{}))> AGridDesc_AK0_M_AK1
Definition device_batched_gemm_multi_d_xdl.hpp:384
static constexpr auto NXdlPerWave32
Definition device_batched_gemm_multi_d_xdl.hpp:205
static constexpr index_t NumDTensor
Definition device_batched_gemm_multi_d_xdl.hpp:207
static auto MakeAGridDescriptor_M_K(index_t MRaw, index_t KRaw, index_t StrideA)
Definition device_batched_gemm_multi_d_xdl.hpp:217
GridwiseGemmMultipleD_xdl_cshuffle< ADataType, BDataType, ComputeDataType, AccDataType, CShuffleDataType, DsDataType, EDataType, AElementwiseOperation, BElementwiseOperation, CDEElementwiseOperation, NumGemmKPrefetchStage, BlockSize, MPerBlock, NPerBlock, KPerBlock, AK1, BK1, MPerXDL, NPerXDL, MXdlPerWave, NXdlPerWave_, ABlockTransferThreadClusterLengths_AK0_M_AK1, ABlockTransferThreadClusterArrangeOrder, ABlockTransferSrcAccessOrder, ABlockTransferSrcVectorDim, ABlockTransferSrcScalarPerVector, ABlockTransferDstScalarPerVector_AK1, false, ABlockLdsExtraM, BBlockTransferThreadClusterLengths_BK0_N_BK1, BBlockTransferThreadClusterArrangeOrder, BBlockTransferSrcAccessOrder, BBlockTransferSrcVectorDim, BBlockTransferSrcScalarPerVector, BBlockTransferDstScalarPerVector_BK1, false, BBlockLdsExtraN, CShuffleMXdlPerWavePerShuffle, CShuffleNXdlPerWavePerShuffle, CDEBlockTransferClusterLengths_MBlock_MPerBlock_NBlock_NPerBlock, CDEBlockTransferScalarPerVector_NPerBlock, LoopSched > GridwiseGemmBase
Definition device_batched_gemm_multi_d_xdl.hpp:337
GridwiseGemmBase< math::max(NXdlPerWave64, 1)> GridwiseGemm64
Definition device_batched_gemm_multi_d_xdl.hpp:380
static auto MakeInvoker()
Definition device_batched_gemm_multi_d_xdl.hpp:697
static constexpr auto I3
Definition device_batched_gemm_multi_d_xdl.hpp:212
remove_cvref_t< decltype(GridwiseGemm64::MakeDefaultBlock2ETileMap(EGridDesc_M_N{}))> Block2ETileMap
Definition device_batched_gemm_multi_d_xdl.hpp:398
remove_cvref_t< decltype(GridwiseGemm64::MakeDefaultBGridDescriptor_BK0_N_BK1( BGridDesc_N_K{}))> BGridDesc_BK0_N_BK1
Definition device_batched_gemm_multi_d_xdl.hpp:387
static constexpr auto I2
Definition device_batched_gemm_multi_d_xdl.hpp:211
ADataType ComputeDataType
Definition device_batched_gemm_multi_d_xdl.hpp:334
static auto MakeEGridDescriptor_M_N(index_t MRaw, index_t NRaw, index_t StrideE)
Definition device_batched_gemm_multi_d_xdl.hpp:254
static constexpr auto I1
Definition device_batched_gemm_multi_d_xdl.hpp:210
std::unique_ptr< BaseArgument > MakeArgumentPointer(const void *p_a, const void *p_b, const std::array< const void *, NumDTensor > &p_ds, void *p_e, index_t M, index_t N, index_t K, index_t Batch, index_t StrideA, index_t StrideB, const std::array< ck::index_t, NumDTensor > &StrideDs, index_t StrideE, index_t BatchStrideA, index_t BatchStrideB, const std::array< ck::index_t, NumDTensor > &BatchStrideDs, index_t BatchStrideE, AElementwiseOperation a_element_op, BElementwiseOperation b_element_op, CDEElementwiseOperation cde_element_op) override
Definition device_batched_gemm_multi_d_xdl.hpp:701
remove_cvref_t< decltype(MakeDsGridDescriptor_M_N({}, {}, {}))> DsGridDesc_M_N
Definition device_batched_gemm_multi_d_xdl.hpp:287
static GET_NXDL_PER_WAVE_IMPL constexpr auto NXdlPerWave64
Definition device_batched_gemm_multi_d_xdl.hpp:204
GridwiseGemmBase< NXdlPerWave32 > GridwiseGemm32
Definition device_batched_gemm_multi_d_xdl.hpp:381
static auto MakeArgument(const void *p_a, const void *p_b, const std::array< const void *, NumDTensor > &p_ds, void *p_e, index_t M, index_t N, index_t K, index_t Batch, index_t StrideA, index_t StrideB, const std::array< index_t, NumDTensor > &StrideDs, index_t StrideE, index_t BatchStrideA, index_t BatchStrideB, const std::array< ck::index_t, NumDTensor > &BatchStrideDs, index_t BatchStrideE, AElementwiseOperation a_element_op, BElementwiseOperation b_element_op, CDEElementwiseOperation cde_element_op)
Definition device_batched_gemm_multi_d_xdl.hpp:656
static auto MakeDsGridDescriptor_M_N(const std::array< index_t, NumDTensor > &MRaws, const std::array< index_t, NumDTensor > &NRaws, const std::array< index_t, NumDTensor > &DsStride)
Definition device_batched_gemm_multi_d_xdl.hpp:272
decltype(MakeBGridDescriptor_N_K(1, 1, 1)) BGridDesc_N_K
Definition device_batched_gemm_multi_d_xdl.hpp:286
decltype(MakeAGridDescriptor_M_K(1, 1, 1)) AGridDesc_M_K
Definition device_batched_gemm_multi_d_xdl.hpp:285
std::unique_ptr< BaseInvoker > MakeInvokerPointer() override
Definition device_batched_gemm_multi_d_xdl.hpp:743
decltype(MakeEGridDescriptor_M_N< ELayout >(1, 1, 1)) EGridDesc_M_N
Definition device_batched_gemm_multi_d_xdl.hpp:288
static auto MakeBGridDescriptor_N_K(index_t KRaw, index_t NRaw, index_t StrideB)
Definition device_batched_gemm_multi_d_xdl.hpp:235
bool IsSupportedArgument(const BaseArgument *p_arg) override
Definition device_batched_gemm_multi_d_xdl.hpp:651
std::string GetTypeString() const override
Definition device_batched_gemm_multi_d_xdl.hpp:749
DeviceBatchedGemmMultiD_Xdl DeviceOp
Definition device_batched_gemm_multi_d_xdl.hpp:201
remove_cvref_t< decltype(GridwiseGemm64::MakeEGridDescriptor_MBlock_MPerBlock_NBlock_NPerBlock( EGridDesc_M_N{}))> EGridDesc_MBlock_MPerBlock_NBlock_NPerBlock
Definition device_batched_gemm_multi_d_xdl.hpp:393
static bool IsSupportedArgument(const Argument &arg)
Definition device_batched_gemm_multi_d_xdl.hpp:619
remove_cvref_t< decltype(GridwiseGemm64::MakeDsGridDescriptor_MBlock_MPerBlock_NBlock_NPerBlock( DsGridDesc_M_N{}))> DsGridDesc_MBlock_MPerBlock_NBlock_NPerBlock
Definition device_batched_gemm_multi_d_xdl.hpp:390
static constexpr auto I0
Definition device_batched_gemm_multi_d_xdl.hpp:209
static constexpr auto matrix_padder
Definition device_batched_gemm_multi_d_xdl.hpp:214
Definition device_batched_gemm_multi_d.hpp:27
Definition matrix_padder.hpp:180