ffu

package
v0.0.0-...-4ddd2c0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AESCapability

type AESCapability struct {
	// Supported key sizes in bits
	KeySizes []int

	// Supported modes
	Modes []AESMode

	// Maximum throughput in MB/s
	ThroughputMBps map[AESMode]float64

	// Hardware acceleration available
	HardwareAccelerated bool

	// Supports parallel operations
	SupportsParallel bool

	// Maximum parallel operations
	MaxParallel int
}

AESCapability describes AES-specific capabilities

type AESMode

type AESMode int

AESMode represents AES encryption mode

const (
	AESModeECB AESMode = iota
	AESModeCBC
	AESModeCTR
	AESModeGCM
)

func (AESMode) String

func (m AESMode) String() string

type AESOperation

type AESOperation int

AESOperation represents the AES operation type

const (
	AESEncrypt AESOperation = iota
	AESDecrypt
)

type AESWorkload

type AESWorkload struct {
	Operation AESOperation
	Mode      AESMode
	Key       []byte // 128, 192, or 256 bit
	IV        []byte // Initialization vector (for modes that need it)
	Input     []byte // Plaintext or ciphertext
	Output    []byte // Result buffer (must be pre-allocated)

	// Optional: Additional authenticated data for GCM mode
	AAD []byte
}

AESWorkload represents an AES encryption/decryption workload

func (*AESWorkload) Size

func (w *AESWorkload) Size() int64

Size returns the size of the workload in bytes

func (*AESWorkload) Type

func (w *AESWorkload) Type() string

Type returns the workload type

func (*AESWorkload) Validate

func (w *AESWorkload) Validate() error

Validate checks if the workload is valid

type AMXCapability

type AMXCapability struct {
	// Supported data types
	SupportsInt8 bool
	SupportsBF16 bool
	SupportsFP16 bool

	// Tile configuration
	NumTiles     int
	MaxTileRows  int
	MaxTileCols  int
	MaxTileBytes int

	// Performance characteristics
	PeakInt8TOPS   float64 // Peak INT8 operations per second
	PeakBF16TFLOPS float64 // Peak BF16 operations per second

	// Constraints
	RequiresAlignment int // Byte alignment requirement
}

AMXCapability describes AMX-specific capabilities

type AMXDataType

type AMXDataType int

AMXDataType represents the data type for AMX operations

const (
	AMXInt8 AMXDataType = iota
	AMXBFloat16
	AMXFloat16 // Future
)

func (AMXDataType) String

func (t AMXDataType) String() string

type AMXOperation

type AMXOperation int

AMXOperation represents the type of AMX operation

const (
	AMXMatMul AMXOperation = iota
	AMXMatMulAccumulate
)

type AMXWorkload

type AMXWorkload struct {
	Operation AMXOperation
	DataType  AMXDataType

	// Matrix dimensions
	M int // Rows of A and C
	N int // Columns of B and C
	K int // Columns of A, Rows of B

	// Matrix data
	A []byte // M×K matrix (row-major)
	B []byte // K×N matrix (row-major)
	C []byte // M×N matrix (row-major)

	// Scaling factors for quantized operations
	ScaleA float32 // Scale factor for A
	ScaleB float32 // Scale factor for B
	ScaleC float32 // Scale factor for C

}

AMXWorkload represents a matrix operation workload for AMX

func (*AMXWorkload) Operations

func (w *AMXWorkload) Operations() int64

Operations returns the number of operations

func (*AMXWorkload) Size

func (w *AMXWorkload) Size() int64

Size returns the size of the workload in bytes

func (*AMXWorkload) Type

func (w *AMXWorkload) Type() string

Type returns the workload type

func (*AMXWorkload) Validate

func (w *AMXWorkload) Validate() error

Validate checks if the workload is valid

type Cost

type Cost struct {
	// Estimated execution time
	Duration time.Duration

	// Estimated energy usage in joules
	Energy float64

	// Estimated memory bandwidth usage in bytes
	MemoryBandwidth int64

	// Confidence level (0-1) in the estimate
	Confidence float64
}

Cost represents the estimated cost of executing a workload

type FFU

type FFU interface {
	// Name returns the FFU name
	Name() string

	// Type returns the FFU type
	Type() FFUType

	// CanHandle checks if this FFU can handle the workload
	CanHandle(workload Workload) bool

	// EstimateCost estimates the cost of executing the workload
	EstimateCost(workload Workload) Cost

	// Execute runs the workload on this FFU
	Execute(workload Workload) error

	// IsAvailable checks if the FFU is currently available
	IsAvailable() bool

	// Metrics returns performance metrics for this FFU
	Metrics() Metrics
}

FFU represents a Fixed-Function Unit

type FFUType

type FFUType int

FFUType represents the type of fixed-function unit

const (
	FFUTypeUnknown     FFUType = iota
	FFUTypeCPU                 // General purpose CPU
	FFUTypeAESNI               // AES New Instructions
	FFUTypeSHA                 // SHA extensions
	FFUTypeAVX512VNNI          // AVX-512 Vector Neural Network Instructions
	FFUTypeAMX                 // Intel Advanced Matrix Extensions
	FFUTypeGPU                 // General GPU compute
	FFUTypeVideoEncode         // Hardware video encoder
	FFUTypeVideoDecode         // Hardware video decoder
	FFUTypeNPU                 // Neural Processing Unit
	FFUTypeAVX2                // AVX2 SIMD
	FFUTypePCLMUL              // Polynomial multiplication
)

func (FFUType) String

func (t FFUType) String() string

type Metrics

type Metrics struct {
	// Total number of workloads executed
	WorkloadCount int64

	// Total bytes processed
	BytesProcessed int64

	// Total execution time
	TotalDuration time.Duration

	// Total energy consumed (if available)
	TotalEnergy float64

	// Number of errors
	ErrorCount int64

	// Last error (if any)
	LastError error

	// Timestamp of last use
	LastUsed time.Time
}

Metrics tracks FFU performance metrics

type PCLMULOperation

type PCLMULOperation int

PCLMULOperation represents different polynomial multiplication operations

const (
	PCLMULCRC32 PCLMULOperation = iota
	PCLMULGaloisMul
	PCLMULReedSolomon
)

type PCLMULWorkload

type PCLMULWorkload struct {
	Operation  PCLMULOperation
	Data       []byte    // Input data
	Output     []byte    // Output buffer
	Polynomial uint64    // For CRC32
	Result     uint64    // For CRC32 result
	RSConfig   *RSConfig // For Reed-Solomon
}

PCLMULWorkload represents polynomial multiplication workloads

func (*PCLMULWorkload) Size

func (w *PCLMULWorkload) Size() int64

Size returns the workload size in bytes

func (*PCLMULWorkload) Type

func (w *PCLMULWorkload) Type() string

Type returns the workload type

func (*PCLMULWorkload) Validate

func (w *PCLMULWorkload) Validate() error

Validate checks if the workload is valid

type RSConfig

type RSConfig struct {
	DataShards   int
	ParityShards int
}

RSConfig holds Reed-Solomon encoding parameters

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages available FFUs

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new FFU registry

func (*Registry) FindBest

func (r *Registry) FindBest(workload Workload) (FFU, *Cost)

FindBest returns the best FFU for a workload based on cost estimation

func (*Registry) Get

func (r *Registry) Get(name string) (FFU, bool)

Get returns an FFU by name

func (*Registry) List

func (r *Registry) List() []FFU

List returns all registered FFUs

func (*Registry) Register

func (r *Registry) Register(ffu FFU) error

Register adds an FFU to the registry

type SHAAlgorithm

type SHAAlgorithm int

SHAAlgorithm represents the SHA variant

const (
	SHA1 SHAAlgorithm = iota
	SHA256
	SHA512 // Not hardware accelerated, but for completeness
)

func (SHAAlgorithm) String

func (a SHAAlgorithm) String() string

type SHAWorkload

type SHAWorkload struct {
	Algorithm SHAAlgorithm
	Data      []byte
	Output    []byte // Pre-allocated output buffer
}

SHAWorkload represents a SHA hashing workload

func (*SHAWorkload) Size

func (w *SHAWorkload) Size() int64

Size returns the size of the workload in bytes

func (*SHAWorkload) Type

func (w *SHAWorkload) Type() string

Type returns the workload type

func (*SHAWorkload) Validate

func (w *SHAWorkload) Validate() error

Validate checks if the workload is valid

type VNNIOperation

type VNNIOperation int

VNNIOperation represents the type of VNNI operation

const (
	VNNIDotProduct VNNIOperation = iota
	VNNIMatMul
)

type VNNIWorkload

type VNNIWorkload struct {
	Operation VNNIOperation
	M, N, K   int     // Matrix dimensions
	A         []int8  // M×K matrix
	B         []int8  // K×N matrix
	C         []int32 // M×N matrix (output)
	Alpha     int32   // Scaling factor
}

VNNIWorkload represents a VNNI (Vector Neural Network Instructions) workload

func (*VNNIWorkload) Operations

func (w *VNNIWorkload) Operations() int64

Operations returns the number of operations

func (*VNNIWorkload) Size

func (w *VNNIWorkload) Size() int64

Size returns the size of the workload in bytes

func (*VNNIWorkload) Type

func (w *VNNIWorkload) Type() string

Type returns the workload type

func (*VNNIWorkload) Validate

func (w *VNNIWorkload) Validate() error

Validate checks if the workload is valid

type Workload

type Workload interface {
	// Type returns the workload type (e.g., "crypto_aes", "matmul_int8")
	Type() string

	// Size returns the size of the workload in bytes
	Size() int64

	// Validate checks if the workload is valid
	Validate() error
}

Workload represents a unit of work that can be executed on an FFU

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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