3#include <nlohmann/json_fwd.hpp>
93 throw std::invalid_argument(
"invalid MMA fragment layout");
150 virtual std::vector<MmaBlockSize>
174 return !
rows.is_null() || !
cols.is_null();
183 [[nodiscard]] std::optional<math::tensor::TensorLayout>
The metadata associated with a addressing a tensor in elements Meant to be used with TensorNodes to d...
Definition tensor_layout.h:20
Represents the storage location and management characteristics of data.
Definition type.h:64
std::vector< Expression > MultiExpression
Vector of symbolic expressions for multi-dimensional operations.
Definition symbolic.h:89
SymEngine::RCP< const SymEngine::Basic > Expression
Reference-counted pointer to a symbolic expression (SymEngine Basic).
Definition symbolic.h:83
std::set< Symbol, SymEngine::RCPBasicKeyLess > SymbolSet
Ordered set of symbols.
Definition symbolic.h:95
SymEngine::map_basic_basic ExpressionMapping
Definition symbolic.h:109
Library node definitions for calling functions beyond simple instructions.
StringEnum ImplementationType
Implementation type identifier for library nodes.
Definition library_node.h:75
Definition cuda_arch.h:11
MmaFragmentLayout
Definition gpu_mma_fragment.h:78
@ MMA_LAYOUT_COL_MAJOR
Definition gpu_mma_fragment.h:81
@ MMA_LAYOUT_ROW_MAJOR
Definition gpu_mma_fragment.h:80
@ MMA_LAYOUT_UNSPECIFIED
Definition gpu_mma_fragment.h:79
GpuMmaFromMemoryLayout deserialize_mma_from_memory_layout(const nlohmann::json &j)
void serialize_mma_block_size(nlohmann::json &j, const MmaBlockSize &block_size)
void serialize_mma_from_memory_layout(nlohmann::json &j, const GpuMmaFromMemoryLayout &layout)
constexpr const char * mma_fragment_layout_to_string(MmaFragmentLayout layout)
Definition gpu_mma_fragment.h:84
std::ostream & operator<<(std::ostream &os, const MmaBlockSize &block_size)
MmaFragmentType
Definition gpu_mma_fragment.h:14
@ C
Definition gpu_mma_fragment.h:14
@ A
Definition gpu_mma_fragment.h:14
@ B
Definition gpu_mma_fragment.h:14
MmaBlockSize deserialize_mma_block_size(const nlohmann::json &j)
PrimitiveType
Enumeration of all primitive data types supported by sdfglib.
Definition type.h:35
@ Void
Void type (0 bits).
Definition type.h:36
Grouping of MMA blocks.
Definition gpu_mma_fragment.h:35
int total_blocks() const
Definition gpu_mma_fragment.h:39
int blocks_n
Definition gpu_mma_fragment.h:37
int blocks_m
Definition gpu_mma_fragment.h:36
Describes how a single MMA fragment maps to memory relative to a base pointer.
Definition gpu_mma_fragment.h:163
std::optional< math::tensor::TensorLayout > to_tensor_layout(const MmaBlockSize &block_size, MmaFragmentType frag) const
The accessed tile; a clipped fragment reports its clipped (in-bounds) extents min(block,...
MmaFragmentLayout layout
memory layout of the tile
Definition gpu_mma_fragment.h:166
symbolic::Expression rows
Clip of a ragged fragment: only logical rows r < rows and columns c < cols (from the fragment origin)...
Definition gpu_mma_fragment.h:170
bool matches_access_shape(const symbolic::MultiExpression &shape, const MmaBlockSize &block_size, MmaFragmentType frag) const
Whether shape is this fragment's block shape or its clipped shape (see to_tensor_layout).
symbolic::Expression ldstride
leading-dimension stride
Definition gpu_mma_fragment.h:165
symbolic::Expression cols
Definition gpu_mma_fragment.h:171
void replace(const symbolic::ExpressionMapping &replacements)
bool clipped() const
Definition gpu_mma_fragment.h:173
static std::optional< GpuMmaFromMemoryLayout > from_tensor_layout(const math::tensor::TensorLayout &layout)
symbolic::Expression offset
element offset added to the base pointer
Definition gpu_mma_fragment.h:164
void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression)
std::string toStr() const
void collect_symbols(symbolic::SymbolSet &syms) const
virtual std::optional< GpuMmaTiling > get_ragged_mma_tiling(const symbolic::MultiExpression &padded_shape, types::PrimitiveType input_type, types::PrimitiveType output_type, types::PrimitiveType acc_type, const MmaBlockSize *block_size_hint, const BlockCounts *wave_tile_hint) const
Tiling for a ragged problem: padded_shape is a constant upper bound of each extent that need not be a...
Definition gpu_mma_fragment.h:135
static int get_integer_block_count(const symbolic::Expression &size, uint16_t block_size)
virtual std::vector< MmaBlockSize > get_supported_block_sizes(types::PrimitiveType input_type, types::PrimitiveType acc_type) const =0
types::PrimitiveType get_accumulator_type(types::PrimitiveType input_type, types::PrimitiveType output_type) const
Definition gpu_mma_fragment.h:103
virtual std::optional< GpuMmaTiling > get_mma_tiling(const symbolic::MultiExpression &res_shape, types::PrimitiveType input_type, types::PrimitiveType acc_type, const MmaBlockSize *block_size_hint, const BlockCounts *wave_tile_hint) const =0
static int get_ceil_block_count(const symbolic::Expression &size, uint16_t block_size)
ceil(size / block_size) for a positive integer size, otherwise 0.
static int get_storage_type_arg_as_int(const types::StorageType &storage, int idx)
virtual bool is_valid_block_size(const MmaBlockSize &block_size, types::PrimitiveType input_type, types::PrimitiveType acc_type) const =0
virtual types::PrimitiveType get_accumulator_type(types::PrimitiveType input_type, types::PrimitiveType output_type, types::PrimitiveType desired_acc_type) const =0
virtual data_flow::ImplementationType get_mma_impl_type(const GpuMmaTiling &tiling) const =0
virtual void set_mma_fragment_storage_type(types::StorageType &storage_type, const GpuMmaTiling &tiling, MmaFragmentType type, MmaFragmentLayout layout) const =0
virtual bool supported_types(types::PrimitiveType input_type, types::PrimitiveType output_type) const =0
virtual ~GpuMmaSupport()=default
Definition gpu_mma_fragment.h:44
int get_mma_blocks_n_per_wavefront() const
static bool wave_tile_divides(const BlockCounts &wave_tiling, const BlockCounts ¯o_block)
Check that we can use the given wave tiling for the given macro block tiling, i.e.
types::PrimitiveType acc_type
The type used by the MMA hardware to accumulate the results of the MMA operation.
Definition gpu_mma_fragment.h:60
BlockCounts macro_tiling
How many MMA blocks will be grouped together in a macro block / on a SM or CU This controls how much ...
Definition gpu_mma_fragment.h:56
BlockCounts wave_tiling
How many MMA blocks will be grouped together in a single wavefront / warp.
Definition gpu_mma_fragment.h:52
int impl_details
implementation-specific details, e.g. for ROCm MFMA variant selection
Definition gpu_mma_fragment.h:63
MmaBlockSize mma_block_size
The MMA block size (m, n, k) in elements.
Definition gpu_mma_fragment.h:47
int get_mma_blocks_m_per_wavefront() const
int threads_per_mma_wavefront
How many threads will work together on 1 MMA block.
Definition gpu_mma_fragment.h:49
Definition gpu_mma_fragment.h:16
std::string dim_str(MmaFragmentType for_type) const
int k
Definition gpu_mma_fragment.h:19
int m
Definition gpu_mma_fragment.h:17
symbolic::MultiExpression get_shape(MmaFragmentType frag) const
static MmaBlockSize parse_block_size(const std::string &block_size_str)
std::string toStr() const
int n
Definition gpu_mma_fragment.h:18
Symbolic system for integer-based symbol analysis.
Core type system definitions for sdfglib.