support

package
v0.1.33 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 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 support and its subpackages contains various supporting functionality for gomlx/compute that may be also useful for other users or GoMLX projects, as well as to other compute.Backend implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CPUTime added in v0.1.26

func CPUTime() time.Duration

CPUTime returns the cumulative CPU time (user + system) consumed by the current process across all threads, with nanosecond precision (as a time.Duration, where 1 unit == 1 nanosecond) and the highest resolution supported by the underlying OS/architecture:

  • Linux (amd64, arm64, riscv64, ppc64le, s390x, loong64): Queries the kernel scheduler's per-process high-resolution CPU clock via clock_gettime(CLOCK_PROCESS_CPUTIME_ID). This accounts for both user and system (kernel) execution time across all threads of the process (sum_exec_runtime) with nanosecond (1 ns) resolution. Falls back to getrusage(RUSAGE_SELF) if the syscall fails.
  • macOS (Darwin), FreeBSD, OpenBSD, NetBSD, DragonFly, and 32-bit Linux: Queries getrusage(RUSAGE_SELF) and sums ru_utime + ru_stime across all threads of the process, providing microsecond (1 µs = 1,000 ns) resolution.
  • Windows: Queries GetProcessTimes(GetCurrentProcess(), ...) and sums KernelTime + UserTime across all threads of the process, providing 100-nanosecond (100 ns) resolution.
  • Other platforms (e.g., WebAssembly / WASI, Plan 9): Falls back to the monotonic wall-clock elapsed time since the process started (time.Since(processStartTime)).

Typical usage to measure CPU time of a section of code:

startCPU := support.CPUTime()
... do work ...
cpuElapsed := support.CPUTime() - startCPU

func DotGeneralFLOPs

func DotGeneralFLOPs(lhsShape shapes.Shape, lhsContractingAxes, lhsBatchAxes []int,
	rhsShape shapes.Shape, rhsContractingAxes, rhsBatchAxes []int) int

DotGeneralFLOPs estimates the number of FLOPs (Floating Point Operations) for a DotGeneral operation. It assumes that the operation is implemented as a matrix multiplication.

func DotGeneralFindSizes

func DotGeneralFindSizes(shape shapes.Shape, contractingAxes, batchAxes []int) (
	batchSize, crossSize, contractingSize int, crossDims []int)

DotGeneralFindSizes finds the combined sizes of the 3 types of axes that matter: batch, cross, and contracting dimensions for a DotGeneral operation

func TwoBitBucketLen

func TwoBitBucketLen(unpaddedLen int) int

TwoBitBucketLen returns the smallest size >= unpaddedLen that uses only the two highest bits (either 2^n or 1.5 * 2^n).

This is a more granular version of a NextPowerOfTwo function to use for bucketing strategies.

Types

This section is empty.

Directories

Path Synopsis
Package backendparser parses the compute interfaces (Backend, Builder, Function, etc.) and enumerate their methods.
Package backendparser parses the compute interfaces (Backend, Builder, Function, etc.) and enumerate their methods.
Package envutil provides utility functions for working with environment variables.
Package envutil provides utility functions for working with environment variables.
Package humanize provides human-readable representations of numbers, bytes, durations, speed (units/sec), etc.
Package humanize provides human-readable representations of numbers, bytes, durations, speed (units/sec), etc.
Package sets implement a set type as a `map[T]struct{}` but with better ergonomics.
Package sets implement a set type as a `map[T]struct{}` but with better ergonomics.
Package simdmath provides vector SIMD approximations of mathematical operations (Exp, Tanh, Erf, Sqrt, Inv, Sigmoid, Gelu) across floating-point data types using Go's portable simd package.
Package simdmath provides vector SIMD approximations of mathematical operations (Exp, Tanh, Erf, Sqrt, Inv, Sigmoid, Gelu) across floating-point data types using Go's portable simd package.
Package testutil provides utilities for testing a compute.Backend.
Package testutil provides utilities for testing a compute.Backend.
Package xslices provide missing functionality to the slices package.
Package xslices provide missing functionality to the slices package.
Package xsync implements some extra synchronization tools.
Package xsync implements some extra synchronization tools.

Jump to

Keyboard shortcuts

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