Documentation
¶
Overview ¶
package matmul provides the base implementations of matrx multiply for DotGeneral. It includes a no-SIMD and various SIMD variations, support for "packing" for large matrices, and support for "non-transposed" ([N,K]x[K,M] -> [N,M]) and "transposed" ([N,K]x[M,K]->[N,M]) layouts.
Index ¶
Constants ¶
const ( PriorityNoSIMD = gobackend.PriorityTyped PriorityAVX2 = gobackend.PriorityArch PriorityAVX512 = gobackend.PriorityArch + 1 )
const ( // EnabledEnv is the environment variable that controls whether the default matmul // implementations are enabled. // It's on by default, and can be disabled by setting it to false. EnabledEnv = "GOMLX_DOT_MATMUL" )
Variables ¶
var ( // Used for tests only. ForceSmallVariant = false ForceLargeVariant = false )
var ( // NoSIMDParams are generic assumptions for L1/L2/L3 cache sizes -- it is optimized for 32 bits dtypes // but for now we use it for every type. // // These values are somewhat arbitrary, assuming "standard" modern cache sizes. // They are parameterized so they can be tuned or determined dynamically later. NoSIMDParams = CacheParams{ LHSL1KernelRows: 2, RHSL1KernelCols: 4, PanelContractingSize: 512, LHSPanelCrossSize: 2, RHSPanelCrossSize: 512, } )
Functions ¶
func GetBuffer ¶
func GetBuffer[T gotype.Supported](backend *gobackend.Backend, length int) (ref *gobackend.Buffer, flat []T, success bool)
GetBuffer simplifies the process of getting a buffer from a backend and getting the flat slice.
func RegisterNoSIMDForTests ¶
func RegisterNoSIMDForTests()
func ReleaseBuffer ¶
ReleaseBuffer releases a buffer obtained through GetBuffer.
Types ¶
type CacheParams ¶
type CacheParams struct {
// LHSL1KernelRows (or Mr), the number of lhs kernel rows going to registers.
// Set to 2, 4, or multiples of 4.
LHSL1KernelRows int
// RHSL1KernelCols (or Nr), the number of rhs kernel columns going to registers.
// For SIMD it will typically be large enough for one or two SIMD vector loads.
RHSL1KernelCols int
// PanelContractingSize (or Kc) is the largest size of the RHS and LHF panels (used when packing)
// on the contracting dimension.
// Selected to make the panel fit into L2/L3 caches.
PanelContractingSize int
// LHSPanelCrossSize (or Mc) is the "cross" size of the LHS and Output panels (used when packing).
// Selected to make the panel fit into L2/L3 caches.
LHSPanelCrossSize int // Mc: L2 rows
// RHSPanelCrossSize (or Mc) is the "cross" size of the RHS and Output panels (used when packing).
// Selected to make the panel fit into L2/L3 caches.
RHSPanelCrossSize int // Nc: L3 cols
}
Block/packs parameters for current architecture.