matmul

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	PriorityNoSIMD = gobackend.PriorityTyped
	PriorityAVX2   = gobackend.PriorityArch
	PriorityAVX512 = gobackend.PriorityArch + 1
)
View Source
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

View Source
var (
	// Used for tests only.
	ForceSmallVariant = false
	ForceLargeVariant = false
)
View Source
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

func ReleaseBuffer(ref *gobackend.Buffer)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL