cublas

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 9 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 cublas provides Pure-Go (CGO_ENABLED=0) dynamic bindings to NVIDIA's cuBLAS library (libcublas.so.13 / libcublas.so.12 / libcublas.so) built on top of internal/dynlib.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("cuBLAS library unavailable")

ErrUnavailable is returned when libcublas cannot be loaded on the current host.

Functions

This section is empty.

Types

type API

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

API holds dynamically bound cuBLAS library function pointers.

func Load

func Load() (*API, error)

Load lazily opens libcublas and binds required cuBLAS symbols.

func (*API) Create

func (a *API) Create() (Handle, error)

Create creates a new cuBLAS handle bound to the current CUDA context.

func (*API) Destroy

func (a *API) Destroy(h Handle) error

Destroy destroys a cuBLAS handle.

func (*API) GemmEx

func (a *API) GemmEx(
	h Handle,
	transa, transb Operation,
	m, n, k int32,
	alpha unsafe.Pointer,
	A driver.DevicePtr, Atype DataType, lda int32,
	B driver.DevicePtr, Btype DataType, ldb int32,
	beta unsafe.Pointer,
	C driver.DevicePtr, Ctype DataType, ldc int32,
	computeType ComputeType,
	algo GemmAlgo,
) error

GemmEx executes C = alpha * op(A) * op(B) + beta * C in column-major layout.

func (*API) GemmStridedBatchedEx

func (a *API) GemmStridedBatchedEx(
	h Handle,
	transa, transb Operation,
	m, n, k int32,
	alpha unsafe.Pointer,
	A driver.DevicePtr, Atype DataType, lda int32, strideA int64,
	B driver.DevicePtr, Btype DataType, ldb int32, strideB int64,
	beta unsafe.Pointer,
	C driver.DevicePtr, Ctype DataType, ldc int32, strideC int64,
	batchCount int32,
	computeType ComputeType,
	algo GemmAlgo,
) error

GemmStridedBatchedEx executes a strided batch of GEMMs in column-major layout.

func (*API) LibraryPath

func (a *API) LibraryPath() string

LibraryPath returns the dynamic library path that was loaded.

func (*API) SetMathMode

func (a *API) SetMathMode(h Handle, mode MathMode) error

SetMathMode sets the cuBLAS math mode on the handle.

func (*API) SetStream

func (a *API) SetStream(h Handle, s driver.Stream) error

SetStream binds the cuBLAS handle to the given CUDA stream.

func (*API) Version

func (a *API) Version(h Handle) (int, error)

Version returns the cuBLAS version integer (e.g., 130600 for 13.6.0).

type ComputeType

type ComputeType int32

ComputeType represents cublasComputeType_t (from cublas_api.h).

const (
	Compute16F         ComputeType = 64
	Compute16FPedantic ComputeType = 65
	Compute32F         ComputeType = 68
	Compute32FPedantic ComputeType = 69
	Compute64F         ComputeType = 70
	Compute64FPedantic ComputeType = 71
	Compute32I         ComputeType = 72
	Compute32FFast16F  ComputeType = 74
	Compute32FFast16BF ComputeType = 75
	Compute32FFastTF32 ComputeType = 77
)

type DataType

type DataType int32

DataType represents cudaDataType_t (from library_types.h).

const (
	DataR32F  DataType = 0
	DataR64F  DataType = 1
	DataR16F  DataType = 2
	DataR8I   DataType = 3
	DataC32F  DataType = 4
	DataC64F  DataType = 5
	DataR8U   DataType = 8
	DataR32I  DataType = 10
	DataR16BF DataType = 14
)

type Error

type Error struct {
	Op     string
	Status Status
	Name   string
	Desc   string
}

Error represents a non-zero cublasStatus_t returned by a cuBLAS call.

func (*Error) Error

func (e *Error) Error() string

type GemmAlgo

type GemmAlgo int32

GemmAlgo represents cublasGemmAlgo_t.

const (
	GemmDefault         GemmAlgo = -1
	GemmDefaultTensorOp GemmAlgo = 99
)

type Handle

type Handle uintptr

Handle represents an opaque cublasHandle_t.

type MathMode

type MathMode int32

MathMode represents cublasMath_t.

const (
	DefaultMath  MathMode = 0
	TensorOpMath MathMode = 1
)

type Operation

type Operation int32

Operation represents cublasOperation_t.

const (
	OpN Operation = 0 // non-transpose
	OpT Operation = 1 // transpose
	OpC Operation = 2 // conjugate transpose
)

type Status

type Status int32

Status represents cublasStatus_t.

const (
	StatusSuccess        Status = 0
	StatusNotInitialized Status = 1
	StatusAllocFailed    Status = 3
	StatusInvalidValue   Status = 7
	StatusArchMismatch   Status = 8
	StatusMappingError   Status = 11
	StatusExecutionFail  Status = 13
	StatusInternalError  Status = 14
	StatusNotSupported   Status = 15
	StatusLicenseError   Status = 16
)

Jump to

Keyboard shortcuts

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