cublasmp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 18 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 cublasmp provides Go bindings for cuBLASMp, NVIDIA's multi-process, multi-GPU dense linear algebra library, libcublasmp.

The bound surface is the library handle, the NCCL-backed process grid, 2D block-cyclic matrix descriptors, the GEMM workspace query, and the distributed general matrix-matrix product. cuBLASMp's other level-3 routines and its descriptor-driven Matmul are declared in the pinned header but are not bound here.

Scalars, transpose modes, compute types, and streams use the types in github.com/tmc/lib/nvidia/cublas; the communicator uses github.com/tmc/lib/nvidia/nccl. This package loads and probes libcublasmp independently of both, and holds no reference to a cuBLAS or NCCL handle of its own.

Ownership

Device and rank mapping. A Handle is bound to the CUDA device and stream current when NewHandle is called; the caller sets the device before creating the handle and keeps it current for every later call on that handle. A Grid is bound to the NCCL communicator passed to NewGrid, which fixes the rank set; the caller owns the communicator and must keep it alive for the grid's whole lifetime and destroy it only after Grid.Destroy. cuBLASMp derives a rank's (row, column) position from its NCCL rank and the grid layout, so the caller is responsible for the rank-to-device assignment that makes that position meaningful.

Local tile layouts. A MatrixDescriptor describes a global matrix in 2D block-cyclic distribution; the local buffer it refers to is the caller's and is never allocated, freed, or bounds-checked by this package. The leading dimension must be at least the calling rank's local row count for the given grid and blocking. A descriptor borrows its grid: the grid must outlive every descriptor built from it.

Collective ordering. NewGrid, Grid.Destroy, Grid.Register, Grid.Deregister, Grid.Malloc, Grid.Free, and the GEMM entry points are collective over the grid's communicator. Every rank must call them in the same order with matching arguments; a rank that skips one or reorders two deadlocks the job. Calls are issued on the handle's stream, so a rank must not change the handle's stream between the ranks' entries into a collective.

Workspace lifetime. Handle.GemmBufferSize returns the device and host workspace sizes for one specific call shape. The workspaces are caller-allocated and caller-owned, must be at least the returned sizes, and must stay valid and unaliased until the work submitted to the stream has completed, not merely until Handle.Gemm returns. Registering the device workspace with Grid.Register (or allocating it with Grid.Malloc) is what makes the overlapping algorithms available; an unregistered workspace restricts the library to its non-overlapping path. Pin any Go memory the host workspace points into for that whole interval; a uintptr does not keep an allocation alive.

Coordinated cleanup. Destroy in reverse order of creation and collectively: complete or synchronize the stream, then [MatrixDescriptor.Destroy], then Grid.Deregister or Grid.Free for every buffer registered with the grid, then Grid.Destroy, then [Handle.Destroy], and only then destroy the NCCL communicator. Skipping a collective destroy on one rank hangs the others.

A call made when libcublasmp is missing, or when the loaded library predates a symbol, returns a structured error rather than panicking. See Load, Loaded, and SymbolError.

Argument meanings, distribution rules, and the algorithm descriptions summarized above are NVIDIA's; see the cuBLASMp documentation.

Process grid

  • Grid.Deregister: Deregisters a previously registered device memory buffer from NCCL symmetric memory.
  • Grid.Register: Registers a device memory buffer with NCCL symmetric memory for a process grid.
  • Grid.Free: Deregisters and frees device memory allocated with Grid.Malloc.
  • NewGrid: Creates and initializes a process grid.
  • Grid.Destroy: Destroys a process grid.
  • Grid.Malloc: Allocates and registers device memory with NCCL symmetric memory.

Library handle

  • NewHandle: Initializes the cuBLASMp library handle.
  • Handle.Close: Destroys the cuBLASMp library handle.
  • Handle.Stream: Gets the current CUDA stream used by the cuBLASMp library.
  • GetVersion: Returns the version number of the cuBLASMp library.
  • Handle.SetStream: Sets the CUDA stream for cuBLASMp computations.

Distributed GEMM

Matrix descriptors

Example

Example reports the version of the loaded library and compares it against the header these bindings were generated from. It returns early when libcublasmp is not installed.

package main

import (
	"fmt"

	"github.com/tmc/lib/nvidia/cublasmp"
)

func main() {
	version, err := cublasmp.GetVersion()
	if err != nil {
		fmt.Println("cuBLASMp unavailable:", err)
		return
	}
	fmt.Println("library version:", version)
	if version != cublasmp.HeaderVersion {
		fmt.Println("header version:", cublasmp.HeaderVersion)
	}
}

Index

Examples

Constants

View Source
const (
	// HeaderVersionMajor is CUBLASMP_VER_MAJOR from the pinned header.
	HeaderVersionMajor = 0
	// HeaderVersionMinor is CUBLASMP_VER_MINOR from the pinned header.
	HeaderVersionMinor = 10
	// HeaderVersionPatch is CUBLASMP_VER_PATCH from the pinned header.
	HeaderVersionPatch = 0
	// HeaderVersion is CUBLASMP_VERSION from the pinned header.
	HeaderVersion = 1000
)

Header version macros from the pinned cublasmp.h. GetVersion reports the version of the library actually loaded, which may differ.

Variables

This section is empty.

Functions

func BufferDeregister

func BufferDeregister(grid Grid, ptr uintptr) error

BufferDeregister deregisters a previously registered device memory buffer from NCCL symmetric memory.

This should be called before freeing the buffer with ncclMemFree. For buffers allocated with Grid.Malloc, use Grid.Free instead, which combines deregistration and freeing.

All ranks in the grid communicator must enter this function collectively.

  • grid: in Process grid the buffer was registered with
  • ptr: in Pointer to device memory buffer to deregister

Wraps cublasMpBufferDeregister.

func BufferRegister

func BufferRegister(grid Grid, ptr uintptr, size uint) error

BufferRegister registers a device memory buffer with NCCL symmetric memory for a process grid.

Registering the device workspace buffer (d_work) enables cublasMpMatmul to use the communication-computation overlap algorithms for AllGather+GEMM, GEMM+ReduceScatter, and GEMM+AllReduce operations. Without a registered workspace, the library falls back to the no_overlap algorithm when using the DEFAULT algorithm type, or returns ErrNotSupported for explicit pipelined algorithm requests. Input/output matrix buffers do not need to be registered; Matrix B buffer registration is optional and may only improve performance for the AllGather+GEMM algorithm.

The buffer must be allocated using ncclMemAlloc, CUDA Virtual Memory Management (VMM) APIs, or other VMM-compatible methods.

All ranks in the grid communicator must enter this function collectively.

  • grid: in Process grid to register the buffer with
  • ptr: in Pointer to device memory buffer to register
  • size: in Size of the buffer in bytes

Wraps cublasMpBufferRegister.

func Close

func Close() error

Close unloads the library and clears all bound function pointers.

The function pointers are package-level state, so Close must not be called concurrently with any other call into this package: doing so is a use-after-free. It is intended for test teardown, not for reclaiming a live library.

func Destroy

func Destroy(handle Handle) error

Destroy destroys the cuBLASMp library handle.

This function destroys the cuBLASMp library handle (Handle) which holds the cuBLASMp library context. The handle remains associated with the CUDA device that was current when NewHandle was called.

  • handle: in,out cuBLASMp library handle to destroy

Wraps cublasMpDestroy.

func Free

func Free(grid Grid, ptr uintptr) error

Free deregisters and frees device memory allocated with Grid.Malloc.

This is a convenience function that combines Grid.Deregister and ncclMemFree into a single call. It should only be used for buffers allocated with Grid.Malloc. For buffers allocated manually, use Grid.Deregister followed by the appropriate free function.

All ranks in the grid communicator must enter this function collectively.

  • grid: in Process grid the buffer was allocated with
  • ptr: in Pointer to device memory buffer to free

Wraps cublasMpFree.

func Gemm

func Gemm(handle Handle, transA cublas.Operation, transB cublas.Operation, m int64, n int64, k int64, alpha Scalar, a uintptr, ia int64, ja int64, descA MatrixDescriptor, b uintptr, ib int64, jb int64, descB MatrixDescriptor, beta Scalar, c uintptr, ic int64, jc int64, descC MatrixDescriptor, computeType cublas.ComputeType, dWork uintptr, workspaceSizeInBytesOnDevice uint, hWork unsafe.Pointer, workspaceSizeInBytesOnHost uint) error

Gemm performs a distributed matrix-matrix multiplication (C = alpha * op(A) * op(B) + beta * C).

This function performs the matrix-matrix multiplication: C = alpha * op(A) * op(B) + beta * C

where alpha and beta are scalars, and A, B and C are matrices stored in column-major format with dimensions op(A) m x k, op(B) k x n and C m x n. op(A) = A, A^T, or A^H depending on transA. op(B) = B, B^T, or B^H depending on transB.

This routine will internally call cublasMpMatmul() with d == c.

Contract:

  • Uses the same descriptor, offset, and block-size contract as

Handle.GemmBufferSize.

  • Matrix C is both input and output; unlike cublasMpMatmul(), Handle.Gemm always writes the result to C.

Workspace:

  • Call Handle.GemmBufferSize with the same arguments first, then pass device and host workspaces of the returned sizes.

Parameters:

  • handle: in cuBLASMp library handle
  • transA: in Operation op(A) that is non- or (conj.) transpose
  • transB: in Operation op(B) that is non- or (conj.) transpose
  • m: in Number of rows of op(A) and C
  • n: in Number of columns of op(B) and C
  • k: in Number of columns of op(A) and rows of op(B)
  • alpha: in Scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError.
  • a: in Pointer to local portion of global matrix A (device)
  • ia: in Row index of the first row of sub(A). ia - 1 must be a multiple of mbA
  • ja: in Column index of the first column of sub(A). ja - 1 must be a multiple of nbA
  • descA: in Matrix descriptor for global matrix A
  • b: in Pointer to local portion of global matrix B (device)
  • ib: in Row index of the first row of sub(B). ib - 1 must be a multiple of mbB
  • jb: in Column index of the first column of sub(B). jb - 1 must be a multiple of nbB
  • descB: in Matrix descriptor for global matrix B
  • beta: in Scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError.
  • c: in,out Pointer to local portion of global matrix C (device)
  • ic: in Row index of the first row of sub(C). ic - 1 must be a multiple of mbC
  • jc: in Column index of the first column of sub(C). jc - 1 must be a multiple of nbC
  • descC: in Matrix descriptor for global matrix C
  • computeType: in cuBLAS compute type for internal matrix-matrix multiplications
  • dWork: out Device workspace of size workspaceSizeInBytesOnDevice
  • workspaceSizeInBytesOnDevice: in Device workspace size as provided by Handle.GemmBufferSize
  • hWork: out Host workspace of size workspaceSizeInBytesOnHost
  • workspaceSizeInBytesOnHost: in Host workspace size as provided by Handle.GemmBufferSize

Wraps cublasMpGemm.

func GemmBufferSize

func GemmBufferSize(handle Handle, transA cublas.Operation, transB cublas.Operation, m int64, n int64, k int64, alpha Scalar, a uintptr, ia int64, ja int64, descA MatrixDescriptor, b uintptr, ib int64, jb int64, descB MatrixDescriptor, beta Scalar, c uintptr, ic int64, jc int64, descC MatrixDescriptor, computeType cublas.ComputeType) (uint, uint, error)

GemmBufferSize computes the workspace size required by Handle.Gemm.

This function returns the required buffer sizes to perform Handle.Gemm on the given input. Handle.Gemm uses cublasMpMatmul() semantics with D == C.

Contract:

  • Submatrix indices are 1-based and must be aligned to the corresponding descriptor block dimensions.
  • descA, descB, and descC must be non-NULL. Matrix C is both input and output; unlike cublasMpMatmul(), Handle.Gemm always writes the result to C.
  • Block-size compatibility follows op(A) and op(B): transA=N, transB=N: nbA == mbB, mbA == mbC, nbB == nbC. transA=N, transB=T/C: nbA == nbB, mbA == mbC, mbB == nbC. transA=T/C, transB=N: mbA == mbB, nbA == mbC, nbB == nbC. transA=T/C, transB=T/C: mbA == nbB, nbA == mbC, mbB == nbC.

Workspace:

  • Use the returned workspace sizes unchanged for the matching Handle.Gemm call.

Parameters:

  • handle: in cuBLASMp library handle
  • transA: in Operation op(A) that is non- or (conj.) transpose
  • transB: in Operation op(B) that is non- or (conj.) transpose
  • m: in Number of rows of op(A) and C
  • n: in Number of columns of op(B) and C
  • k: in Number of columns of op(A) and rows of op(B)
  • alpha: in Scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError.
  • a: in Pointer to local portion of global matrix A (device)
  • ia: in Row index of the first row of sub(A). ia - 1 must be a multiple of mbA
  • ja: in Column index of the first column of sub(A). ja - 1 must be a multiple of nbA
  • descA: in Matrix descriptor for global matrix A
  • b: in Pointer to local portion of global matrix B (device)
  • ib: in Row index of the first row of sub(B). ib - 1 must be a multiple of mbB
  • jb: in Column index of the first column of sub(B). jb - 1 must be a multiple of nbB
  • descB: in Matrix descriptor for global matrix B
  • beta: in Scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError.
  • c: in Pointer to local portion of global matrix C (device)
  • ic: in Row index of the first row of sub(C). ic - 1 must be a multiple of mbC
  • jc: in Column index of the first column of sub(C). jc - 1 must be a multiple of nbC
  • descC: in Matrix descriptor for global matrix C
  • computeType: in cuBLAS compute type for internal matrix-matrix multiplications

Wraps cublasMpGemm_bufferSize.

func GetStream

func GetStream(handle Handle) (driver.Stream, error)

GetStream gets the current CUDA stream used by the cuBLASMp library.

This function returns the current CUDA stream that is being used in the computations.

  • handle: in cuBLASMp library handle

Wraps cublasMpGetStream.

func GetVersion

func GetVersion() (int, error)

GetVersion returns the version number of the cuBLASMp library.

The version value is computed as CUBLASMP_VER_MAJOR * 10000 + CUBLASMP_VER_MINOR * 100 + CUBLASMP_VER_PATCH.

Wraps cublasMpGetVersion.

func GridDestroy

func GridDestroy(grid Grid) error

GridDestroy destroys a process grid.

This function destroys the given grid object. All ranks in the grid communicator must enter this function collectively.

  • grid: in,out Grid object to destroy

Wraps cublasMpGridDestroy.

func Has

func Has(symbol string) bool

Has reports whether the named C symbol resolved in the loaded library, loading it first if necessary. It returns false if the library failed to load. Use it to gate on capabilities before calling into them.

func HasBufferDeregister

func HasBufferDeregister() bool

HasBufferDeregister reports whether cublasMpBufferDeregister resolved in the loaded library.

func HasBufferRegister

func HasBufferRegister() bool

HasBufferRegister reports whether cublasMpBufferRegister resolved in the loaded library.

func HasCreate

func HasCreate() bool

HasCreate reports whether cublasMpCreate resolved in the loaded library.

func HasDestroy

func HasDestroy() bool

HasDestroy reports whether cublasMpDestroy resolved in the loaded library.

func HasFree

func HasFree() bool

HasFree reports whether cublasMpFree resolved in the loaded library.

func HasGemm

func HasGemm() bool

HasGemm reports whether cublasMpGemm resolved in the loaded library.

func HasGemmBufferSize

func HasGemmBufferSize() bool

HasGemmBufferSize reports whether cublasMpGemm_bufferSize resolved in the loaded library.

func HasGetStream

func HasGetStream() bool

HasGetStream reports whether cublasMpGetStream resolved in the loaded library.

func HasGetVersion

func HasGetVersion() bool

HasGetVersion reports whether cublasMpGetVersion resolved in the loaded library.

func HasGridCreate

func HasGridCreate() bool

HasGridCreate reports whether cublasMpGridCreate resolved in the loaded library.

func HasGridDestroy

func HasGridDestroy() bool

HasGridDestroy reports whether cublasMpGridDestroy resolved in the loaded library.

func HasMalloc

func HasMalloc() bool

HasMalloc reports whether cublasMpMalloc resolved in the loaded library.

func HasMatrixDescriptorCreate

func HasMatrixDescriptorCreate() bool

HasMatrixDescriptorCreate reports whether cublasMpMatrixDescriptorCreate resolved in the loaded library.

func HasMatrixDescriptorDestroy

func HasMatrixDescriptorDestroy() bool

HasMatrixDescriptorDestroy reports whether cublasMpMatrixDescriptorDestroy resolved in the loaded library.

func HasMatrixDescriptorInit

func HasMatrixDescriptorInit() bool

HasMatrixDescriptorInit reports whether cublasMpMatrixDescriptorInit resolved in the loaded library.

func HasSetStream

func HasSetStream() bool

HasSetStream reports whether cublasMpSetStream resolved in the loaded library.

func Load

func Load(path string) error

Load opens the shared library from path, or from the default search list when path is empty, and binds all symbols. Callers that need to direct loading should call Load before any other function; otherwise the first call loads from the default search list.

Load is idempotent: calling it again with the same path, or with an empty path, returns nil. Calling it with a different path after a successful load returns *LibraryConflictError rather than replacing the library. After a failed load, Load retries.

func Loaded

func Loaded() bool

Loaded reports whether the library is currently loaded. It does not trigger a load.

func Malloc

func Malloc(grid Grid, size uint) (uintptr, error)

Malloc allocates and registers device memory with NCCL symmetric memory.

This is a convenience function that combines ncclMemAlloc and Grid.Register into a single call. See Grid.Register for details on how workspace registration affects algorithm selection and optional matrix B registration.

All ranks in the grid communicator must enter this function collectively. Use Grid.Free to free buffers allocated with this function.

  • grid: in Process grid to allocate and register the buffer with
  • size: in Size of the buffer to allocate in bytes

Wraps cublasMpMalloc.

func MatrixDescriptorDestroy

func MatrixDescriptorDestroy(desc MatrixDescriptor) error

MatrixDescriptorDestroy destroys a matrix descriptor.

This function destroys a MatrixDescriptor object.

  • desc: in,out Matrix descriptor object to destroy

Wraps cublasMpMatrixDescriptorDestroy.

func MatrixDescriptorInit

func MatrixDescriptorInit(m int64, n int64, mb int64, nb int64, rsrc int64, csrc int64, lld int64, type_ cublas.DataType, grid Grid, desc MatrixDescriptor) error

MatrixDescriptorInit initializes the values of an existing matrix descriptor.

This function initializes the values of a MatrixDescriptor object. Unlike NewMatrixDescriptor, this function does not allocate additional memory. The same validity requirements apply: mb/nb/lld must be positive and, when grid is non-NULL, rsrc/csrc must be valid source coordinates for that grid. The grid object, when non-NULL, must outlive the descriptor. Redistribution routines (cublasMpGemr2D and cublasMpTrmr2D) also allow grid == NULL on ranks that do not participate in that matrix's process grid.

  • m: in Number of rows in the global matrix
  • n: in Number of columns in the global matrix
  • mb: in Positive blocking factor used to distribute the rows of the global matrix
  • nb: in Positive blocking factor used to distribute the columns of the global matrix
  • rsrc: in Row rank of the process that owns the first row block of the global matrix. When grid is non-NULL, must satisfy 0 <= rsrc < grid->nprow
  • csrc: in Column rank of the process that owns the first column block of the global matrix. When grid is non-NULL, must satisfy 0 <= csrc < grid->npcol
  • lld: in Positive leading dimension of the local matrix. It must be large enough for the local allocation on the calling rank
  • type_: in Data type of the matrix (e.g., CUDA_R_32F, CUDA_R_64F, CUDA_R_16F, CUDA_R_16BF, CUDA_R_8F_E4M3, CUDA_R_8F_E5M2, CUDA_R_4F_E2M1, CUDA_R_8I, CUDA_R_32I, CUDA_C_32F, CUDA_C_64F)
  • grid: in Grid object associated with the matrix descriptor, or NULL on redistribution-only ranks that do not participate in this matrix's grid
  • desc: in,out Matrix descriptor object to reinitialize

Wraps cublasMpMatrixDescriptorInit.

func Path

func Path() string

Path returns the path or name the loaded library was opened from, or the empty string if no library is loaded.

func SetStream

func SetStream(handle Handle, stream driver.Stream) error

SetStream sets the CUDA stream for cuBLASMp computations.

This function sets the CUDA stream to be used in the computations. The new stream must belong to the same CUDA context as the stream associated with the handle at creation time.

  • handle: in cuBLASMp library handle
  • stream: in CUDA stream to set. The stream must belong to the same CUDA context as the current handle stream

Wraps cublasMpSetStream.

Types

type BindFailure

type BindFailure struct {
	Symbol string
	Err    error
}

BindFailure names a symbol the loaded library exports but that could not be bound, and why.

func BindFailures

func BindFailures() []BindFailure

BindFailures returns the symbols the loaded library exports that could not be bound, sorted by symbol name, or nil if every exported symbol bound. Calling one of these reports *SymbolError with the same Err.

A load that reports no error can still leave symbols unbound: the library is fine and the signatures are not representable here. Call this after Load to find that out at once rather than one call site at a time. It does not trigger a load, and returns nil if none has happened.

type CallError

type CallError struct {
	Func   string // the C symbol called
	Result Result
}

CallError reports that a library call returned a failure result.

Unwrap returns Result, so errors.Is(err, c) reports whether the call returned the Result constant c, and errors.As(err, &r) with r of type Result recovers the code.

func (*CallError) Error

func (e *CallError) Error() string

Error reports the C symbol called and the result it returned.

func (*CallError) Unwrap

func (e *CallError) Unwrap() error

Unwrap returns the result the call reported.

type Grid

type Grid uintptr

Grid is an opaque handle for cublasMpGrid_t.

func GridCreate

func GridCreate(nprow int64, npcol int64, layout GridLayout, comm nccl.Comm) (Grid, error)

GridCreate creates and initializes a process grid.

This function initializes the Grid opaque data structure. It maps the given resources (communicator, grid dimensions and grid layout) to a grid object. The communicator must contain exactly nprow * npcol ranks, and all participating ranks must pass the same nprow, npcol, and layout values.

All ranks in the communicator must enter this function collectively.

  • nprow: in Number of row processes in the grid
  • npcol: in Number of column processes in the grid
  • layout: in Grid layout (GridLayout)
  • comm: in NCCL communicator associated with the grid

Wraps cublasMpGridCreate.

func NewGrid

func NewGrid(nprow int64, npcol int64, layout GridLayout, comm nccl.Comm) (Grid, error)

NewGrid creates and initializes a process grid.

This function initializes the Grid opaque data structure. It maps the given resources (communicator, grid dimensions and grid layout) to a grid object. The communicator must contain exactly nprow * npcol ranks, and all participating ranks must pass the same nprow, npcol, and layout values.

All ranks in the communicator must enter this function collectively.

  • nprow: in Number of row processes in the grid
  • npcol: in Number of column processes in the grid
  • layout: in Grid layout (GridLayout)
  • comm: in NCCL communicator associated with the grid

Wraps cublasMpGridCreate.

func (Grid) Deregister

func (g Grid) Deregister(ptr uintptr) error

Deregister deregisters a previously registered device memory buffer from NCCL symmetric memory.

This should be called before freeing the buffer with ncclMemFree. For buffers allocated with Grid.Malloc, use Grid.Free instead, which combines deregistration and freeing.

All ranks in the grid communicator must enter this function collectively.

  • ptr: in Pointer to device memory buffer to deregister

It is not named Close because Grid has other release methods, Destroy and Free.

Wraps cublasMpBufferDeregister.

func (Grid) Destroy

func (g Grid) Destroy() error

Destroy destroys a process grid.

This function destroys the given grid object. All ranks in the grid communicator must enter this function collectively.

It is not named Close because Grid has other release methods, Deregister and Free.

Wraps cublasMpGridDestroy.

func (Grid) Free

func (g Grid) Free(ptr uintptr) error

Free deregisters and frees device memory allocated with Grid.Malloc.

This is a convenience function that combines Grid.Deregister and ncclMemFree into a single call. It should only be used for buffers allocated with Grid.Malloc. For buffers allocated manually, use Grid.Deregister followed by the appropriate free function.

All ranks in the grid communicator must enter this function collectively.

  • ptr: in Pointer to device memory buffer to free

It is not named Close because Grid has other release methods, Deregister and Destroy.

Wraps cublasMpFree.

func (Grid) Malloc

func (g Grid) Malloc(size uint) (uintptr, error)

Malloc allocates and registers device memory with NCCL symmetric memory.

This is a convenience function that combines ncclMemAlloc and Grid.Register into a single call. See Grid.Register for details on how workspace registration affects algorithm selection and optional matrix B registration.

All ranks in the grid communicator must enter this function collectively. Use Grid.Free to free buffers allocated with this function.

  • size: in Size of the buffer to allocate in bytes

Wraps cublasMpMalloc.

func (Grid) Register

func (g Grid) Register(ptr uintptr, size uint) error

Register registers a device memory buffer with NCCL symmetric memory for a process grid.

Registering the device workspace buffer (d_work) enables cublasMpMatmul to use the communication-computation overlap algorithms for AllGather+GEMM, GEMM+ReduceScatter, and GEMM+AllReduce operations. Without a registered workspace, the library falls back to the no_overlap algorithm when using the DEFAULT algorithm type, or returns ErrNotSupported for explicit pipelined algorithm requests. Input/output matrix buffers do not need to be registered; Matrix B buffer registration is optional and may only improve performance for the AllGather+GEMM algorithm.

The buffer must be allocated using ncclMemAlloc, CUDA Virtual Memory Management (VMM) APIs, or other VMM-compatible methods.

All ranks in the grid communicator must enter this function collectively.

  • ptr: in Pointer to device memory buffer to register
  • size: in Size of the buffer in bytes

Wraps cublasMpBufferRegister.

type GridLayout

type GridLayout int32

GridLayout describes the ordering of the process grid.

const (
	ColMajor GridLayout = 0
	RowMajor GridLayout = 1
)

func (GridLayout) String

func (e GridLayout) String() string

String returns the constant name, or a numeric representation for unknown values.

type Handle

type Handle uintptr

Handle is an opaque handle for cublasMpHandle_t.

func Create

func Create(stream driver.Stream) (Handle, error)

Create initializes the cuBLASMp library handle.

This function initializes the cuBLASMp library handle (Handle) which holds the cuBLASMp library context. It allocates light hardware resources on the host, and must be called prior to making any other cuBLASMp library calls.

Calling any cuBLASMp function which uses Handle without a previous call of NewHandle will return an error.

The cuBLASMp library context is tied to the current CUDA device and the given CUDA stream. Sharing a device with multiple processes may result in undefined behavior.

  • stream: in Stream that will be assigned to the handle

Wraps cublasMpCreate.

func NewHandle

func NewHandle(stream driver.Stream) (Handle, error)

NewHandle initializes the cuBLASMp library handle.

This function initializes the cuBLASMp library handle (Handle) which holds the cuBLASMp library context. It allocates light hardware resources on the host, and must be called prior to making any other cuBLASMp library calls.

Calling any cuBLASMp function which uses Handle without a previous call of NewHandle will return an error.

The cuBLASMp library context is tied to the current CUDA device and the given CUDA stream. Sharing a device with multiple processes may result in undefined behavior.

  • stream: in Stream that will be assigned to the handle

Wraps cublasMpCreate.

func (*Handle) Close

func (h *Handle) Close() error

Close destroys the cuBLASMp library handle.

This function destroys the cuBLASMp library handle (Handle) which holds the cuBLASMp library context. The handle remains associated with the CUDA device that was current when NewHandle was called.

If h is zero, Close returns nil. Otherwise Close sets h to zero when the call succeeds and leaves it unchanged when it fails. Only h is zeroed: a copy of it still refers to the released object.

Wraps cublasMpDestroy.

func (Handle) Gemm

func (h Handle) Gemm(transA cublas.Operation, transB cublas.Operation, m int64, n int64, k int64, alpha Scalar, a uintptr, ia int64, ja int64, descA MatrixDescriptor, b uintptr, ib int64, jb int64, descB MatrixDescriptor, beta Scalar, c uintptr, ic int64, jc int64, descC MatrixDescriptor, computeType cublas.ComputeType, dWork uintptr, workspaceSizeInBytesOnDevice uint, hWork unsafe.Pointer, workspaceSizeInBytesOnHost uint) error

Gemm performs a distributed matrix-matrix multiplication (C = alpha * op(A) * op(B) + beta * C).

This function performs the matrix-matrix multiplication: C = alpha * op(A) * op(B) + beta * C

where alpha and beta are scalars, and A, B and C are matrices stored in column-major format with dimensions op(A) m x k, op(B) k x n and C m x n. op(A) = A, A^T, or A^H depending on transA. op(B) = B, B^T, or B^H depending on transB.

This routine will internally call cublasMpMatmul() with d == c.

Contract:

  • Uses the same descriptor, offset, and block-size contract as

Handle.GemmBufferSize.

  • Matrix C is both input and output; unlike cublasMpMatmul(), Handle.Gemm always writes the result to C.

Workspace:

  • Call Handle.GemmBufferSize with the same arguments first, then pass device and host workspaces of the returned sizes.

Parameters:

  • transA: in Operation op(A) that is non- or (conj.) transpose
  • transB: in Operation op(B) that is non- or (conj.) transpose
  • m: in Number of rows of op(A) and C
  • n: in Number of columns of op(B) and C
  • k: in Number of columns of op(A) and rows of op(B)
  • alpha: in Scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError.
  • a: in Pointer to local portion of global matrix A (device)
  • ia: in Row index of the first row of sub(A). ia - 1 must be a multiple of mbA
  • ja: in Column index of the first column of sub(A). ja - 1 must be a multiple of nbA
  • descA: in Matrix descriptor for global matrix A
  • b: in Pointer to local portion of global matrix B (device)
  • ib: in Row index of the first row of sub(B). ib - 1 must be a multiple of mbB
  • jb: in Column index of the first column of sub(B). jb - 1 must be a multiple of nbB
  • descB: in Matrix descriptor for global matrix B
  • beta: in Scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError.
  • c: in,out Pointer to local portion of global matrix C (device)
  • ic: in Row index of the first row of sub(C). ic - 1 must be a multiple of mbC
  • jc: in Column index of the first column of sub(C). jc - 1 must be a multiple of nbC
  • descC: in Matrix descriptor for global matrix C
  • computeType: in cuBLAS compute type for internal matrix-matrix multiplications
  • dWork: out Device workspace of size workspaceSizeInBytesOnDevice
  • workspaceSizeInBytesOnDevice: in Device workspace size as provided by Handle.GemmBufferSize
  • hWork: out Host workspace of size workspaceSizeInBytesOnHost
  • workspaceSizeInBytesOnHost: in Host workspace size as provided by Handle.GemmBufferSize

Wraps cublasMpGemm.

Example

ExampleHandle_Gemm shows the full call sequence for one distributed GEMM: communicator, process grid, matrix descriptors, workspace query, and the multiplication itself. Every rank of the job runs this same code with the same nprow, npcol, and layout, and enters each collective in the same order.

It returns early on the first error, which on a machine without a NCCL job is the communicator. comm, deviceA, deviceB, and deviceC stand for a communicator and device buffers the caller already owns; this package allocates none of them.

package main

import (
	"fmt"
	"unsafe"

	"github.com/tmc/lib/nvidia/cublas"
	"github.com/tmc/lib/nvidia/cublasmp"
	"github.com/tmc/lib/nvidia/driver"
	"github.com/tmc/lib/nvidia/nccl"
)

func main() {
	var (
		comm             nccl.Comm // from nccl.NewCommInitRank on this rank
		deviceA, deviceB uintptr   // local tiles of A and B, on this rank's device
		deviceC          uintptr   // local tile of C, written in place
		nprow, npcol               = int64(1), int64(1)
		m, n, k          int64     = 128, 128, 128
		mb, nb           int64     = 32, 32
	)

	grid, err := cublasmp.NewGrid(nprow, npcol, cublasmp.ColMajor, comm)
	if err != nil {
		fmt.Println("grid:", err)
		return
	}
	defer grid.Destroy()

	// The stream is bound at handle creation; every call on this handle is
	// ordered on it, and the caller synchronizes it before reading C.
	h, err := cublasmp.NewHandle(driver.Stream(0))
	if err != nil {
		fmt.Println("handle:", err)
		return
	}
	defer h.Close()

	descA, err := cublasmp.NewMatrixDescriptor(m, k, mb, nb, 0, 0, m, cublas.R32F, grid)
	if err != nil {
		fmt.Println("descriptor:", err)
		return
	}
	defer descA.Close()
	descB, err := cublasmp.NewMatrixDescriptor(k, n, mb, nb, 0, 0, k, cublas.R32F, grid)
	if err != nil {
		fmt.Println("descriptor:", err)
		return
	}
	defer descB.Close()
	descC, err := cublasmp.NewMatrixDescriptor(m, n, mb, nb, 0, 0, m, cublas.R32F, grid)
	if err != nil {
		fmt.Println("descriptor:", err)
		return
	}
	defer descC.Close()

	// alpha and beta are host pointers, so unsafe.Pointer, not a device
	// address. Their element type must match the compute type.
	alpha, beta := float32(1), float32(0)

	// Submatrix indices are one-based, as in ScaLAPACK.
	const ia, ja, ib, jb, ic, jc = 1, 1, 1, 1, 1, 1

	deviceBytes, hostBytes, err := h.GemmBufferSize(
		cublas.OpN, cublas.OpN, m, n, k,
		cublasmp.Float32Scalar(alpha), deviceA, ia, ja, descA,
		deviceB, ib, jb, descB,
		cublasmp.Float32Scalar(beta), deviceC, ic, jc, descC,
		cublas.Compute32F)
	if err != nil {
		fmt.Println("workspace:", err)
		return
	}

	// Registering the device workspace with the grid is what makes the
	// overlap algorithms selectable; NVIDIA documents this, and this package
	// does not measure it. Grid.Malloc allocates and registers in one call.
	deviceWork, err := grid.Malloc(deviceBytes)
	if err != nil {
		fmt.Println("workspace:", err)
		return
	}
	defer grid.Free(deviceWork)
	hostWork := make([]byte, hostBytes)

	if err := h.Gemm(
		cublas.OpN, cublas.OpN, m, n, k,
		cublasmp.Float32Scalar(alpha), deviceA, ia, ja, descA,
		deviceB, ib, jb, descB,
		cublasmp.Float32Scalar(beta), deviceC, ic, jc, descC,
		cublas.Compute32F,
		deviceWork, deviceBytes, unsafe.Pointer(&hostWork[0]), hostBytes); err != nil {
		fmt.Println("gemm:", err)
		return
	}
	// hostWork must stay live and unmoved until the stream is synchronized.
	fmt.Println("submitted")
}

func (Handle) GemmBufferSize

func (h Handle) GemmBufferSize(transA cublas.Operation, transB cublas.Operation, m int64, n int64, k int64, alpha Scalar, a uintptr, ia int64, ja int64, descA MatrixDescriptor, b uintptr, ib int64, jb int64, descB MatrixDescriptor, beta Scalar, c uintptr, ic int64, jc int64, descC MatrixDescriptor, computeType cublas.ComputeType) (uint, uint, error)

GemmBufferSize computes the workspace size required by Handle.Gemm.

This function returns the required buffer sizes to perform Handle.Gemm on the given input. Handle.Gemm uses cublasMpMatmul() semantics with D == C.

Contract:

  • Submatrix indices are 1-based and must be aligned to the corresponding descriptor block dimensions.
  • descA, descB, and descC must be non-NULL. Matrix C is both input and output; unlike cublasMpMatmul(), Handle.Gemm always writes the result to C.
  • Block-size compatibility follows op(A) and op(B): transA=N, transB=N: nbA == mbB, mbA == mbC, nbB == nbC. transA=N, transB=T/C: nbA == nbB, mbA == mbC, mbB == nbC. transA=T/C, transB=N: mbA == mbB, nbA == mbC, nbB == nbC. transA=T/C, transB=T/C: mbA == nbB, nbA == mbC, mbB == nbC.

Workspace:

  • Use the returned workspace sizes unchanged for the matching Handle.Gemm call.

Parameters:

  • transA: in Operation op(A) that is non- or (conj.) transpose
  • transB: in Operation op(B) that is non- or (conj.) transpose
  • m: in Number of rows of op(A) and C
  • n: in Number of columns of op(B) and C
  • k: in Number of columns of op(A) and rows of op(B)
  • alpha: in Scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError.
  • a: in Pointer to local portion of global matrix A (device)
  • ia: in Row index of the first row of sub(A). ia - 1 must be a multiple of mbA
  • ja: in Column index of the first column of sub(A). ja - 1 must be a multiple of nbA
  • descA: in Matrix descriptor for global matrix A
  • b: in Pointer to local portion of global matrix B (device)
  • ib: in Row index of the first row of sub(B). ib - 1 must be a multiple of mbB
  • jb: in Column index of the first column of sub(B). jb - 1 must be a multiple of nbB
  • descB: in Matrix descriptor for global matrix B
  • beta: in Scalar used for multiplication. Its kind must match computeType; a host Scalar of another kind is a *ScalarError.
  • c: in Pointer to local portion of global matrix C (device)
  • ic: in Row index of the first row of sub(C). ic - 1 must be a multiple of mbC
  • jc: in Column index of the first column of sub(C). jc - 1 must be a multiple of nbC
  • descC: in Matrix descriptor for global matrix C
  • computeType: in cuBLAS compute type for internal matrix-matrix multiplications

Wraps cublasMpGemm_bufferSize.

func (Handle) SetStream

func (h Handle) SetStream(stream driver.Stream) error

SetStream sets the CUDA stream for cuBLASMp computations.

This function sets the CUDA stream to be used in the computations. The new stream must belong to the same CUDA context as the stream associated with the handle at creation time.

  • stream: in CUDA stream to set. The stream must belong to the same CUDA context as the current handle stream

Wraps cublasMpSetStream.

func (Handle) Stream

func (h Handle) Stream() (driver.Stream, error)

Stream gets the current CUDA stream used by the cuBLASMp library.

This function returns the current CUDA stream that is being used in the computations.

Wraps cublasMpGetStream.

type LibraryAttempt

type LibraryAttempt struct {
	Name string // path or soname passed to dlopen
	Err  error
}

LibraryAttempt records one failed attempt to open the shared library.

type LibraryConflictError

type LibraryConflictError struct {
	Loaded    string
	Requested string

	// Implicit reports that the loaded library was opened lazily and no
	// successful Load has since acknowledged it. A
	// caller that sees this called some
	// other function first, and that call took the default search list.
	Implicit bool
}

LibraryConflictError reports a Load call naming a different library than the one already loaded. Only one library is loaded per process.

func (*LibraryConflictError) Error

func (e *LibraryConflictError) Error() string

Error reports the conflicting library paths, and whether the library that is already loaded got there without a Load call.

type LibraryError

type LibraryError struct {
	Library  string
	Env      string
	Path     string
	Attempts []LibraryAttempt
	Hint     string
}

LibraryError reports that libcublasmp could not be opened. Attempts lists every name tried in order. Path is set when an explicit path, from Load or CUBLASMP_LIB_PATH, was requested and failed. Hint reports pkg-config discovery results and query failures, when discovery ran.

func (*LibraryError) Error

func (e *LibraryError) Error() string

Error describes the library load attempts and their errors.

func (*LibraryError) Unwrap

func (e *LibraryError) Unwrap() []error

Unwrap returns the error from each attempt.

type MatrixDescriptor

type MatrixDescriptor uintptr

MatrixDescriptor is an opaque handle for cublasMpMatrixDescriptor_t.

func MatrixDescriptorCreate

func MatrixDescriptorCreate(m int64, n int64, mb int64, nb int64, rsrc int64, csrc int64, lld int64, type_ cublas.DataType, grid Grid) (MatrixDescriptor, error)

MatrixDescriptorCreate creates and initializes a matrix descriptor.

This function creates and initializes a new MatrixDescriptor object that describes a distributed matrix using 2D block-cyclic distribution. Parameters mb, nb, and lld are expressed in elements and must be positive. When grid is non-NULL, rsrc and csrc are zero-based source coordinates and must satisfy 0 <= rsrc < grid->nprow and 0 <= csrc < grid->npcol. The local leading dimension lld must be large enough for the local allocation on the calling rank. The grid object, when non-NULL, must outlive the descriptor. Redistribution routines (cublasMpGemr2D and cublasMpTrmr2D) also allow grid == NULL on ranks that do not participate in that matrix's process grid.

  • m: in Number of rows in the global matrix
  • n: in Number of columns in the global matrix
  • mb: in Positive blocking factor used to distribute the rows of the global matrix
  • nb: in Positive blocking factor used to distribute the columns of the global matrix
  • rsrc: in Row rank of the process that owns the first row block of the global matrix. When grid is non-NULL, must satisfy 0 <= rsrc < grid->nprow
  • csrc: in Column rank of the process that owns the first column block of the global matrix. When grid is non-NULL, must satisfy 0 <= csrc < grid->npcol
  • lld: in Positive leading dimension of the local matrix. It must be large enough for the local allocation on the calling rank
  • type_: in Data type of the matrix (e.g., CUDA_R_32F, CUDA_R_64F, CUDA_R_16F, CUDA_R_16BF, CUDA_R_8F_E4M3, CUDA_R_8F_E5M2, CUDA_R_4F_E2M1, CUDA_R_8I, CUDA_R_32I, CUDA_C_32F, CUDA_C_64F)
  • grid: in Grid object associated with the matrix descriptor, or NULL on redistribution-only ranks that do not participate in this matrix's grid

Wraps cublasMpMatrixDescriptorCreate.

func NewMatrixDescriptor

func NewMatrixDescriptor(m int64, n int64, mb int64, nb int64, rsrc int64, csrc int64, lld int64, type_ cublas.DataType, grid Grid) (MatrixDescriptor, error)

NewMatrixDescriptor creates and initializes a matrix descriptor.

This function creates and initializes a new MatrixDescriptor object that describes a distributed matrix using 2D block-cyclic distribution. Parameters mb, nb, and lld are expressed in elements and must be positive. When grid is non-NULL, rsrc and csrc are zero-based source coordinates and must satisfy 0 <= rsrc < grid->nprow and 0 <= csrc < grid->npcol. The local leading dimension lld must be large enough for the local allocation on the calling rank. The grid object, when non-NULL, must outlive the descriptor. Redistribution routines (cublasMpGemr2D and cublasMpTrmr2D) also allow grid == NULL on ranks that do not participate in that matrix's process grid.

  • m: in Number of rows in the global matrix
  • n: in Number of columns in the global matrix
  • mb: in Positive blocking factor used to distribute the rows of the global matrix
  • nb: in Positive blocking factor used to distribute the columns of the global matrix
  • rsrc: in Row rank of the process that owns the first row block of the global matrix. When grid is non-NULL, must satisfy 0 <= rsrc < grid->nprow
  • csrc: in Column rank of the process that owns the first column block of the global matrix. When grid is non-NULL, must satisfy 0 <= csrc < grid->npcol
  • lld: in Positive leading dimension of the local matrix. It must be large enough for the local allocation on the calling rank
  • type_: in Data type of the matrix (e.g., CUDA_R_32F, CUDA_R_64F, CUDA_R_16F, CUDA_R_16BF, CUDA_R_8F_E4M3, CUDA_R_8F_E5M2, CUDA_R_4F_E2M1, CUDA_R_8I, CUDA_R_32I, CUDA_C_32F, CUDA_C_64F)
  • grid: in Grid object associated with the matrix descriptor, or NULL on redistribution-only ranks that do not participate in this matrix's grid

Wraps cublasMpMatrixDescriptorCreate.

func (*MatrixDescriptor) Close

func (m *MatrixDescriptor) Close() error

Close destroys a matrix descriptor.

This function destroys a MatrixDescriptor object.

If m is zero, Close returns nil. Otherwise Close sets m to zero when the call succeeds and leaves it unchanged when it fails. Only m is zeroed: a copy of it still refers to the released object.

Wraps cublasMpMatrixDescriptorDestroy.

func (MatrixDescriptor) Init

func (md MatrixDescriptor) Init(m int64, n int64, mb int64, nb int64, rsrc int64, csrc int64, lld int64, type_ cublas.DataType, grid Grid) error

Init initializes the values of an existing matrix descriptor.

This function initializes the values of a MatrixDescriptor object. Unlike NewMatrixDescriptor, this function does not allocate additional memory. The same validity requirements apply: mb/nb/lld must be positive and, when grid is non-NULL, rsrc/csrc must be valid source coordinates for that grid. The grid object, when non-NULL, must outlive the descriptor. Redistribution routines (cublasMpGemr2D and cublasMpTrmr2D) also allow grid == NULL on ranks that do not participate in that matrix's process grid.

  • m: in Number of rows in the global matrix
  • n: in Number of columns in the global matrix
  • mb: in Positive blocking factor used to distribute the rows of the global matrix
  • nb: in Positive blocking factor used to distribute the columns of the global matrix
  • rsrc: in Row rank of the process that owns the first row block of the global matrix. When grid is non-NULL, must satisfy 0 <= rsrc < grid->nprow
  • csrc: in Column rank of the process that owns the first column block of the global matrix. When grid is non-NULL, must satisfy 0 <= csrc < grid->npcol
  • lld: in Positive leading dimension of the local matrix. It must be large enough for the local allocation on the calling rank
  • type_: in Data type of the matrix (e.g., CUDA_R_32F, CUDA_R_64F, CUDA_R_16F, CUDA_R_16BF, CUDA_R_8F_E4M3, CUDA_R_8F_E5M2, CUDA_R_4F_E2M1, CUDA_R_8I, CUDA_R_32I, CUDA_C_32F, CUDA_C_64F)
  • grid: in Grid object associated with the matrix descriptor, or NULL on redistribution-only ranks that do not participate in this matrix's grid

Wraps cublasMpMatrixDescriptorInit.

type Result

type Result int32

Result represents a cublasmp API error code (cublasMpStatus_t).

const (
	Success                 Result = 0
	ErrNotInitialized       Result = 1
	ErrAllocationFailed     Result = 2
	ErrInvalidValue         Result = 3
	ErrArchitectureMismatch Result = 4
	ErrExecutionFailed      Result = 5
	ErrInternalError        Result = 6
	ErrNotSupported         Result = 7
)

cublasmp error codes from cublasmp.h.

func (Result) Code

func (r Result) Code() int32

Code returns the underlying result code for programmatic error handling.

func (Result) Error

func (r Result) Error() string

Error implements the error interface.

func (Result) String

func (r Result) String() string

String returns the Go constant name of the result.

type Scalar

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

A Scalar is a value, such as the alpha and beta of a matrix product, that the library reads through a pointer. Make one for a value in host memory with Float16BitsScalar, Float32Scalar, Float64Scalar, Complex64Scalar, Complex128Scalar, or Int32Scalar.

A call copies a host value into memory of its own, passes the library a pointer to the copy, and reuses that memory once the call returns, so a Scalar never reaches the library and can live anywhere.

The cuBLASMp header says only that alpha and beta are host pointers, not when they are read. The call assumes what cuBLAS documents for itself: that the library reads them before the call returns, and that capture into a CUDA graph keeps the values (cuBLAS documentation, sections 2.1.5 and 2.1.12).

The kind of a host Scalar must be the type the library reads. Where a call names that type in another parameter, a Scalar of another kind is a *ScalarError; where the type is in a descriptor, the call cannot check it. The zero Scalar is a host zero of every kind.

func Complex64Scalar

func Complex64Scalar(x complex64) Scalar

Complex64Scalar returns a host Scalar holding the complex64 x.

func Complex128Scalar

func Complex128Scalar(x complex128) Scalar

Complex128Scalar returns a host Scalar holding the complex128 x.

func Float16BitsScalar

func Float16BitsScalar(b uint16) Scalar

Float16BitsScalar returns a host Scalar holding the IEEE 754 half-precision value with bit pattern b.

func Float32Scalar

func Float32Scalar(x float32) Scalar

Float32Scalar returns a host Scalar holding the float32 x.

func Float64Scalar

func Float64Scalar(x float64) Scalar

Float64Scalar returns a host Scalar holding the float64 x.

func Int32Scalar

func Int32Scalar(x int32) Scalar

Int32Scalar returns a host Scalar holding the int32 x.

type ScalarError

type ScalarError struct {
	Func  string // the C symbol called
	Param string // the scalar parameter
	Kind  string // the Scalar's kind, such as "float32"
	Want  string // the kinds the call allows, such as "float64 or complex128"
}

A ScalarError reports a host Scalar whose kind is not the type the call names for it in another parameter.

func (*ScalarError) Error

func (e *ScalarError) Error() string

type SymbolError

type SymbolError struct {
	Symbol string
	Err    error
}

SymbolError reports that a symbol is not callable.

Err distinguishes the two ways that happens. A nil Err means the loaded library does not export the symbol, which is what an installation older than the symbol looks like. A non-nil Err means the library does export it and the binding itself failed; the library is not at fault.

func (*SymbolError) Error

func (e *SymbolError) Error() string

Error reports the uncallable library symbol and, when the symbol was present but could not be bound, why.

func (*SymbolError) Unwrap

func (e *SymbolError) Unwrap() error

Unwrap returns the reason the symbol could not be bound, or nil when the loaded library does not export it.

Jump to

Keyboard shortcuts

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