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 ¶
- Variables
- type API
- func (a *API) Create() (Handle, error)
- func (a *API) Destroy(h Handle) error
- func (a *API) GemmEx(h Handle, transa, transb Operation, m, n, k int32, alpha unsafe.Pointer, ...) error
- func (a *API) GemmStridedBatchedEx(h Handle, transa, transb Operation, m, n, k int32, alpha unsafe.Pointer, ...) error
- func (a *API) HasSetWorkspace() bool
- func (a *API) LibraryPath() string
- func (a *API) SetMathMode(h Handle, mode MathMode) error
- func (a *API) SetStream(h Handle, s driver.Stream) error
- func (a *API) SetWorkspace(h Handle, workspace driver.DevicePtr, sizeBytes uintptr) error
- func (a *API) Version(h Handle) (int, error)
- type ComputeType
- type DataType
- type Error
- type GemmAlgo
- type Handle
- type LtAPI
- func (a *LtAPI) Create() (LtHandle, error)
- func (a *LtAPI) CreatePlan(h LtHandle, key LtPlanKey, maxWorkspaceBytes uintptr) (*LtPlan, error)
- func (a *LtAPI) Destroy(h LtHandle) error
- func (a *LtAPI) DestroyPlan(p *LtPlan)
- func (a *LtAPI) ExecutePlan(h LtHandle, p *LtPlan, alpha, beta unsafe.Pointer, ...) error
- type LtEpilogue
- type LtHandle
- type LtMatmulAlgo
- type LtMatmulDesc
- type LtMatmulDescAttr
- type LtMatmulHeuristicResult
- type LtMatmulPrefAttr
- type LtMatmulPreference
- type LtMatrixLayout
- type LtPlan
- type LtPlanKey
- type MathMode
- type Operation
- type Status
Constants ¶
This section is empty.
Variables ¶
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 (*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) HasSetWorkspace ¶ added in v0.1.1
HasSetWorkspace reports whether cublasSetWorkspace_v2 is available in the loaded cuBLAS library.
func (*API) LibraryPath ¶
LibraryPath returns the dynamic library path that was loaded.
func (*API) SetMathMode ¶
SetMathMode sets the cuBLAS math mode on the handle.
func (*API) SetWorkspace ¶ added in v0.1.1
SetWorkspace attaches a user-managed device workspace buffer to the cuBLAS handle (NVIDIA recommends 32 MiB on Hopper/Blackwell for optimal Tensor Core / split-K heuristics). No-op if cublasSetWorkspace_v2 is not present in the loaded library.
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 LtAPI ¶ added in v0.1.1
type LtAPI struct {
// contains filtered or unexported fields
}
LtAPI holds dynamically bound libcublasLt symbols.
func (*LtAPI) CreatePlan ¶ added in v0.1.1
CreatePlan builds descriptors and queries cuBLASLt's heuristic for key within maxWorkspaceBytes. Returns (nil, nil) if cuBLASLt reports no supported algorithm for this configuration.
func (*LtAPI) DestroyPlan ¶ added in v0.1.1
DestroyPlan releases cuBLASLt descriptors held by plan.
func (*LtAPI) ExecutePlan ¶ added in v0.1.1
func (a *LtAPI) ExecutePlan( h LtHandle, p *LtPlan, alpha, beta unsafe.Pointer, A, B, D, bias driver.DevicePtr, workspace driver.DevicePtr, workspaceBytes uintptr, stream driver.Stream, ) error
ExecutePlan runs D = epilogue(alpha * op(A) * op(B) + bias) using a cached LtPlan.
type LtEpilogue ¶ added in v0.1.1
type LtEpilogue uint32
LtEpilogue matches cublasLtEpilogue_t.
const ( LtEpilogueDefault LtEpilogue = 1 LtEpilogueRelu LtEpilogue = 2 LtEpilogueBias LtEpilogue = 4 LtEpilogueReluBias LtEpilogue = LtEpilogueRelu | LtEpilogueBias LtEpilogueGelu LtEpilogue = 32 LtEpilogueGeluBias LtEpilogue = LtEpilogueGelu | LtEpilogueBias )
type LtMatmulAlgo ¶ added in v0.1.1
type LtMatmulAlgo struct {
Data [8]uint64
}
LtMatmulAlgo matches cublasLtMatmulAlgo_t (64 bytes, 8-byte aligned).
type LtMatmulDesc ¶ added in v0.1.1
type LtMatmulDesc uintptr
LtMatmulDesc is an opaque cublasLtMatmulDesc_t.
type LtMatmulDescAttr ¶ added in v0.1.1
type LtMatmulDescAttr int32
LtMatmulDescAttr matches cublasLtMatmulDescAttributes_t.
type LtMatmulHeuristicResult ¶ added in v0.1.1
type LtMatmulHeuristicResult struct {
Algo LtMatmulAlgo
WorkspaceSize uintptr
State Status
WavesCount float32
Reserved [4]int32
}
LtMatmulHeuristicResult matches cublasLtMatmulHeuristicResult_t (96 bytes, 8-byte aligned).
type LtMatmulPrefAttr ¶ added in v0.1.1
type LtMatmulPrefAttr int32
LtMatmulPrefAttr matches cublasLtMatmulPreferenceAttributes_t.
type LtMatmulPreference ¶ added in v0.1.1
type LtMatmulPreference uintptr
LtMatmulPreference is an opaque cublasLtMatmulPreference_t.
type LtMatrixLayout ¶ added in v0.1.1
type LtMatrixLayout uintptr
LtMatrixLayout is an opaque cublasLtMatrixLayout_t.
type LtPlan ¶ added in v0.1.1
type LtPlan struct {
Desc LtMatmulDesc
ADesc LtMatrixLayout
BDesc LtMatrixLayout
DDesc LtMatrixLayout
Algo LtMatmulAlgo
WorkspaceSize uintptr
HasBias bool
}
LtPlan holds pre-created cuBLASLt descriptors and heuristic algorithm for a fixed GEMM shape/epilogue. Not safe for concurrent mutation of its bias pointer; callers synchronize per-handle.
type LtPlanKey ¶ added in v0.1.1
type LtPlanKey struct {
M, N, K int32 // column-major dims: D[M, N] = op(A)[M, K] * op(B)[K, N]
TransA Operation
TransB Operation
AType DataType
BType DataType
DType DataType
BiasType DataType
ComputeType ComputeType
Epilogue LtEpilogue
}
LtPlanKey uniquely identifies a cached cuBLASLt matmul plan (excluding runtime pointers).
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 )