Documentation
¶
Overview ¶
Package nccl provides low-level Go bindings for the NVIDIA Collective Communications Library (NCCL).
NCCL provides optimized primitives for multi-GPU and multi-node collective communication: Comm.AllReduce, Comm.Broadcast, Comm.ReduceScatter, Comm.AllGather, Comm.AlltoAll, Comm.Send/Comm.Recv, and one-sided Window.PutSignal/Comm.Signal/Comm.WaitSignal operations.
This package provides bindings generated from nccl.h using github.com/ebitengine/purego for cgo-free dynamic loading of libnccl. Functions returning a C status report errors wrapping ncclResult_t with descriptive messages from ncclGetErrorString.
The host-side NCCL device communicator and GIN setup APIs are also exposed. Device-side GIN entry points are CUDA-kernel-only and cannot be called through purego; kernels using those entry points must be compiled separately and launched by the host application.
Threads ¶
NCCL keeps group state per OS thread, and the CUDA context it uses is the one current on the calling thread. A goroutine that calls GroupStart must stay on one OS thread, using runtime.LockOSThread, until its matching GroupEnd returns; otherwise the calls between them can join another thread's group or none.
Quick Start ¶
// Initialize communicators across GPUs. id, _ := nccl.GetUniqueId() comm, _ := nccl.CommInitRank(nranks, id, rank) defer nccl.CommDestroy(comm) // AllReduce on a CUDA stream. nccl.AllReduce(sendBuf, recvBuf, count, nccl.Float32, nccl.Sum, comm, stream)
Collective Operations ¶
- Comm.AllGather: Gathers sendcount values from all GPUs and leaves identical copies of the result in each recvbuff, receiving data from rank i at offset i*sendcount.
- Comm.AllGatherConfig: Configurable variant of Comm.AllGather.
- Comm.AllReduce: Reduces data arrays of length count in sendbuff using the op operation and leaves identical copies of the result in each recvbuff.
- Comm.AllReduceConfig: Configurable variant of Comm.AllReduce.
- Comm.AlltoAll: Each rank sends count values to all other ranks and receives count values from all other ranks.
- Comm.AlltoAllConfig: Configurable variant of Comm.AlltoAll.
- Comm.Broadcast: Copies count elements from sendbuff on the root rank to all ranks’ recvbuff.
- Comm.BroadcastConfig: Configurable variant of Comm.Broadcast.
- Comm.Gather: Each rank sends count elements from sendbuff to the root rank.
- Comm.GatherConfig: Configurable variant of Comm.Gather.
- Comm.Reduce: Reduce data arrays of length count in sendbuff into recvbuff on the root rank using the op operation.
- Comm.ReduceConfig: Configurable variant of Comm.Reduce.
- Comm.ReduceScatter: Reduce data in sendbuff from all GPUs using the op operation and leave the reduced result scattered over the devices so that the recvbuff on rank i will contain the i-th block of the result.
- Comm.ReduceScatterConfig: Configurable variant of Comm.ReduceScatter.
- Comm.Scatter: Each rank receives count elements from the root rank.
- Comm.ScatterConfig: Configurable variant of Comm.Scatter.
Communicator Lifecycle ¶
- Comm.Abort: Comm.Abort frees resources that are allocated to a communicator object comm and aborts any uncompleted operations before destroying the communicator.
- Comm.Destroy: Destroy a communicator object comm.
- Comm.Finalize: Finalize a communicator object comm.
- Comm.Resume: Resume all previously suspended resources on communicator comm.
- Comm.Revoke: Revokes in-flight operations on a communicator without destroying resources.
- Comm.Suspend: Suspend communicator operations to free resources.
Communicator Queries ¶
- Comm.Count: Returns in count the number of ranks in the NCCL communicator comm.
- Comm.CuDevice: Returns in device the CUDA device associated with the NCCL communicator comm.
- Comm.AsyncError: Queries the progress and potential errors of asynchronous NCCL operations.
- Comm.UniqueId: The Comm.UniqueId function generates a unique identifier for growing an existing communicator exactly once.
- Comm.MemStats: Query communicator memory statistics.
- Comm.UserRank: Returns in rank the rank of the caller in the NCCL communicator comm.
Buffer Registration ¶
- Comm.Deregister: Deregister buffer represented by handle under communicator comm.
- Comm.Register: Registers the buffer buff with size under communicator comm for zero-copy communication; handle is returned for future deregistration.
Communicator Management ¶
- Comm.Grow: The Comm.Grow function creates a new communicator by adding new ranks to an existing communicator.
- Comm.Shrink: The Comm.Shrink function creates a new communicator by removing specified ranks from an existing communicator.
- Comm.Split: The Comm.Split is a collective function and creates a set of new communicators from an existing one.
Communicator Setup ¶
- CommInitAll: Creates a clique of communicators (single process version) in a blocking way.
- CommInitRank: Creates a new communicator (multi thread/process version).
- CommInitRankConfig: works the same way as CommInitRank but accepts a configuration argument of extra attributes for the communicator.
- CommInitRankScalable: works the same way as CommInitRankConfig but accepts a list of ncclUniqueIds instead of a single one.
- GetUniqueId: Generates an Id to be used in CommInitRank.
Window Registration ¶
- Comm.WindowDeregister: Deregister NCCL window represented by win under communicator comm.
- Comm.WindowRegister: Collectively register local buffer buff with size under communicator comm into NCCL window.
Error Handling ¶
- Comm.LastError: Returns a human-readable string corresponding to the last error that occurred in NCCL.
Version ¶
- GetVersion: The GetVersion function returns the version number of the currently linked NCCL library.
Group Semantics ¶
- GroupEnd: End a group call.
- GroupSimulateEnd: Simulate a GroupEnd call and return NCCL’s simulation info in a structure passed as an argument.
- GroupStart: Start a group call.
Memory Management ¶
One-Sided Communication ¶
- Window.PutSignal: Write data from localbuff to rank peer’s registered memory window peerWin at offset peerWinOffset and subsequently updating a remote signal.
- Comm.Signal: Send a signal to rank peer without transferring data.
- Comm.WaitSignal: Wait for signals as described in the signal descriptor array.
Point-to-Point ¶
- Comm.Recv: Receive data from rank peer into recvbuff.
- Comm.Send: Send data from sendbuff to rank peer.
Reduction Operations ¶
- Comm.RedOpCreatePreMulSum: Creates a new reduction operator which pre-multiplies input values by a given scalar locally before reducing them with peer values via summation.
- Comm.RedOpDestroy: Destroys the reduction operator op.
Other ¶
- [Bcast]: Legacy in-place version of Comm.Broadcast in a similar fashion to MPI_Bcast.
- Comm.QueryProperties: Exposes communicator properties by filling in props.
- Comm.DevCommCreate: Creates a new device communicator (see ncclDevComm) corresponding to the supplied host-side communicator comm.
- Comm.DevCommDestroy: Destroys a device communicator (see ncclDevComm) previously created using Comm.DevCommCreate and releases any allocated resources.
- Window.CftDeviceLeInfo: Host-side query for the logical endpoint leId and leOffset corresponding to window, byte offset, and peerCft within cftTeam.
- Window.LsaDevicePointer: Returns a load/store accessible pointer to the memory buffer of a specific LSA peer within the window.
- Window.LsaMultimemDevicePointer: Returns a multimem base pointer for the LSA team associated with the given window.
- Window.MultimemDeviceLeInfo: Host-side query for the multicast logical endpoint leId and leOffset corresponding to window and byte offset.
- Window.MultimemDevicePointer: Returns a multimem base pointer using a provided multimem handle instead of the window’s internal multimem.
- Window.PeerDeviceLeInfo: Host-side query for the logical endpoint leId and leOffset corresponding to window, byte offset and peerWorld within the world team.
- Window.PeerDevicePointer: Returns a load/store accessible pointer to the memory buffer of a specific world rank peer within the window.
- ParamBind: Look up the parameter identified by key and store a handle to it in *out.
- ParamDumpAll: Write the key and current value of every registered parameter to the NCCL log output.
- ParamHandle.Get: Copy the raw binary representation of the parameter bound to h into the caller-allocated buffer out.
- ParamGetAllParameterKeys: Return a pointer to the internal table of all registered parameter keys.
- ParamHandle.I16: Read the value of the parameter bound to h as the type T and store it in *out.
- ParamHandle.I32: Read the value of the parameter bound to h as the type T and store it in *out.
- ParamHandle.I64: Read the value of the parameter bound to h as the type T and store it in *out.
- ParamHandle.I8: Read the value of the parameter bound to h as the type T and store it in *out.
- ParamGetParameter: Look up the parameter identified by key and return its value as a null-terminated string.
- ParamHandle.Str: Return a C-style string representation of the parameter bound to h.
- ParamHandle.U16: Read the value of the parameter bound to h as the type T and store it in *out.
- ParamHandle.U32: Read the value of the parameter bound to h as the type T and store it in *out.
- ParamHandle.U64: Read the value of the parameter bound to h as the type T and store it in *out.
- ParamHandle.U8: Read the value of the parameter bound to h as the type T and store it in *out.
- Comm.TeamCft: Returns the host-side unicast CFT team containing ranks that are part of the CFT unicast group.
- Comm.TeamCftMultimem: Returns the host-side multicast CFT team containing all the ranks that are part of the CFT multicast group.
Example ¶
Example queries the NCCL version and creates a single-process communicator spanning the local GPUs. It returns early when the NCCL library is not available.
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/nccl"
)
func main() {
version, err := nccl.GetVersion()
if err != nil {
fmt.Println("NCCL unavailable:", err)
return
}
fmt.Println("NCCL version:", version)
devs := []int32{0}
comms := make([]nccl.Comm, len(devs))
err = nccl.CommInitAll(&comms[0], int32(len(devs)), &devs[0])
if err != nil {
fmt.Println("comm init:", err)
return
}
defer comms[0].Destroy()
n, _ := comms[0].Count()
fmt.Println("communicator ranks:", n)
}
Output:
Example (AllReduce) ¶
Example_allReduce sums a float32 buffer across a one-rank communicator on the first CUDA device, in place. With one rank the sum is the input. It returns early when the CUDA driver or NCCL is not available. It has no Output comment, so it is compiled but not run: it needs a CUDA device.
package main
import (
"fmt"
"runtime"
"unsafe"
"github.com/tmc/lib/nvidia/driver"
"github.com/tmc/lib/nvidia/nccl"
)
func main() {
// A CUDA context is current on an OS thread, not on a goroutine.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := driver.Init(0); err != nil {
fmt.Println("CUDA driver unavailable:", err)
return
}
dev, err := driver.DeviceGet(0)
if err != nil {
fmt.Println("device:", err)
return
}
ctx, err := dev.PrimaryCtxRetain()
if err != nil {
fmt.Println("context:", err)
return
}
defer dev.PrimaryCtxRelease()
if err := ctx.SetCurrent(); err != nil {
fmt.Println("set context:", err)
return
}
devs := []int32{0}
comms := make([]nccl.Comm, len(devs))
if err := nccl.CommInitAll(&comms[0], int32(len(devs)), &devs[0]); err != nil {
fmt.Println("comm init:", err)
return
}
defer comms[0].Destroy()
values := []float32{3, 5, 7, 11}
size := uint(len(values)) * uint(unsafe.Sizeof(values[0]))
p, err := driver.MemAllocBytes(size)
if err != nil {
fmt.Println("alloc:", err)
return
}
defer p.Free()
if err := p.CopyFromHost(values); err != nil {
fmt.Println("copy in:", err)
return
}
err = comms[0].AllReduce(p, p, uint(len(values)), nccl.Float32, nccl.Sum, 0)
if err != nil {
fmt.Println("all-reduce:", err)
return
}
if err := p.CopyToHost(values); err != nil {
fmt.Println("copy out:", err)
return
}
fmt.Println("all-reduce =", values)
}
Output:
Index ¶
- Constants
- func CftBarrierCreateRequirement(team Team, nBarriers int32, outHandle *CftBarrierHandle, ...) error
- func Close() error
- func CommInitAll(comm *Comm, ndev int32, devlist *int32) error
- func GetVersion() (int32, error)
- func GroupEnd() error
- func GroupSimulateEnd(simInfo *SimInfo) error
- func GroupStart() error
- func Has(symbol string) bool
- func HasAllGather() bool
- func HasAllGatherConfig() bool
- func HasAllReduce() bool
- func HasAllReduceConfig() bool
- func HasAlltoAll() bool
- func HasAlltoAllConfig() bool
- func HasBroadcast() bool
- func HasBroadcastConfig() bool
- func HasCftBarrierCreateRequirement() bool
- func HasCommAbort() bool
- func HasCommCount() bool
- func HasCommCuDevice() bool
- func HasCommDeregister() bool
- func HasCommDestroy() bool
- func HasCommFinalize() bool
- func HasCommGetAsyncError() bool
- func HasCommGetUniqueId() bool
- func HasCommGrow() bool
- func HasCommInitAll() bool
- func HasCommInitRank() bool
- func HasCommInitRankConfig() bool
- func HasCommInitRankScalable() bool
- func HasCommMemStats() bool
- func HasCommQueryProperties() bool
- func HasCommRegister() bool
- func HasCommResume() bool
- func HasCommRevoke() bool
- func HasCommShrink() bool
- func HasCommSplit() bool
- func HasCommSuspend() bool
- func HasCommUserRank() bool
- func HasCommWindowDeregister() bool
- func HasCommWindowRegister() bool
- func HasDevCommCreate() bool
- func HasDevCommDestroy() bool
- func HasGather() bool
- func HasGatherConfig() bool
- func HasGetCftDeviceLeInfo() bool
- func HasGetErrorString() bool
- func HasGetLastError() bool
- func HasGetLsaDevicePointer() bool
- func HasGetLsaMultimemDevicePointer() bool
- func HasGetMultimemDeviceLeInfo() bool
- func HasGetMultimemDevicePointer() bool
- func HasGetPeerDeviceLeInfo() bool
- func HasGetPeerDevicePointer() bool
- func HasGetUniqueId() bool
- func HasGetVersion() bool
- func HasGinBarrierCreateRequirement() bool
- func HasGroupEnd() bool
- func HasGroupSimulateEnd() bool
- func HasGroupStart() bool
- func HasLLA2ACalcSlots() bool
- func HasLLA2ACreateRequirement() bool
- func HasLsaBarrierCreateRequirement() bool
- func HasMemAlloc() bool
- func HasMemFree() bool
- func HasParamBind() bool
- func HasParamDumpAll() bool
- func HasParamGet() bool
- func HasParamGetAllParameterKeys() bool
- func HasParamGetI8() bool
- func HasParamGetI16() bool
- func HasParamGetI32() bool
- func HasParamGetI64() bool
- func HasParamGetParameter() bool
- func HasParamGetStr() bool
- func HasParamGetU8() bool
- func HasParamGetU16() bool
- func HasParamGetU32() bool
- func HasParamGetU64() bool
- func HasPutSignal() bool
- func HasRecv() bool
- func HasRedOpCreatePreMulSum() bool
- func HasRedOpDestroy() bool
- func HasReduce() bool
- func HasReduceConfig() bool
- func HasReduceScatter() bool
- func HasReduceScatterConfig() bool
- func HasScatter() bool
- func HasScatterConfig() bool
- func HasSend() bool
- func HasSignal() bool
- func HasTeamCft() bool
- func HasTeamCftMultimem() bool
- func HasTeamLsa() bool
- func HasTeamRail() bool
- func HasTeamRankToLsa() bool
- func HasTeamRankToWorld() bool
- func HasTeamWorld() bool
- func HasWaitSignal() bool
- func HasWinGetUserPtr() bool
- func LLA2ACalcSlots(maxElts int32, maxEltSize int32) (int32, error)
- func LLA2ACreateRequirement(nBlocks int32, nSlots int32, outHandle *LLA2AHandle, ...) error
- func Load(path string) error
- func Loaded() bool
- func LsaBarrierCreateRequirement(team Team, nBarriers int32, outHandle *LsaBarrierHandle, ...) error
- func MemAlloc(size uint) (driver.DevicePtr, error)
- func MemFree(ptr driver.DevicePtr) error
- func ParamDumpAll() error
- func ParamGetAllParameterKeys() ([]string, error)
- func ParamGetParameter(key string) (string, error)
- func Path() string
- type BindFailure
- type Buffer
- type CPtr
- type CString
- type CallError
- type CftBarrierHandle
- type CftCap
- type CftLeId
- type CftTeamMode
- type CollConfig
- type Comm
- func CommInitRank(nranks int32, commId UniqueId, rank int32) (Comm, error)
- func CommInitRankConfig(nranks int32, commId UniqueId, rank int32, config *Config) (Comm, error)
- func CommInitRankScalable(nranks int32, myrank int32, nId int32, commIds *UniqueId, config *Config) (Comm, error)
- func InitAll(devices []int32) ([]Comm, error)
- func (c Comm) Abort() error
- func (c Comm) AllGather(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, sendcount uint, ...) error
- func (c Comm) AllGatherConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, sendcount uint, ...) error
- func (c Comm) AllReduce(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, ...) error
- func (c Comm) AllReduceConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, ...) error
- func (c Comm) AlltoAll(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, ...) error
- func (c Comm) AlltoAllConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, ...) error
- func (c Comm) AsyncError() (Result, error)
- func (c Comm) Broadcast(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, ...) error
- func (c Comm) BroadcastConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, ...) error
- func (c Comm) Count() (int32, error)
- func (c Comm) CuDevice() (int32, error)
- func (c Comm) Deregister(handle Registration) error
- func (c Comm) Destroy() error
- func (c Comm) DevCommCreate(reqs *DevCommRequirements, outDevComm *DevComm) error
- func (c Comm) DevCommDestroy(devComm *DevComm) error
- func (c Comm) Finalize() error
- func (c Comm) Gather(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, ...) error
- func (c Comm) GatherConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, ...) error
- func (c Comm) GinBarrierCreateRequirement(team Team, nBarriers int32, outHandle *GinBarrierHandle, ...) error
- func (c Comm) Grow(nRanks int32, uniqueId *UniqueId, rank int32, newcomm *Comm, config *Config) error
- func (c Comm) LastError() (string, error)
- func (c Comm) MemStats(stat CommMemStat) (uint64, error)
- func (c Comm) QueryProperties(props *CommProperties) error
- func (c Comm) Recv(recvbuff driver.DevicePtr, count uint, datatype DataType, peer int32, ...) error
- func (c Comm) RedOpCreatePreMulSum(scalar Buffer, datatype DataType, residence ScalarResidence) (RedOp, error)
- func (c Comm) RedOpDestroy(op RedOp) error
- func (c Comm) Reduce(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, ...) error
- func (c Comm) ReduceConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, ...) error
- func (c Comm) ReduceScatter(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, recvcount uint, ...) error
- func (c Comm) ReduceScatterConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, recvcount uint, ...) error
- func (c Comm) Register(buff driver.DevicePtr, size uint) (Registration, error)
- func (c Comm) Resume() error
- func (c Comm) Revoke(revokeFlags int32) error
- func (c Comm) Scatter(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, ...) error
- func (c Comm) ScatterConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, ...) error
- func (c Comm) Send(sendbuff driver.DevicePtr, count uint, datatype DataType, peer int32, ...) error
- func (c Comm) Shrink(excludeRanksList *int32, excludeRanksCount int32, newcomm *Comm, ...) error
- func (c Comm) Signal(peer int32, sigIdx int32, ctx int32, flags uint32, stream driver.Stream) error
- func (c Comm) Split(color int32, key int32, newcomm *Comm, config *Config) error
- func (c Comm) Suspend(flags int32) error
- func (c Comm) TeamCft(mode CftTeamMode) (Team, error)
- func (c Comm) TeamCftMultimem() (Team, error)
- func (c Comm) TeamLsa() (Team, error)
- func (c Comm) TeamRail() (Team, error)
- func (c Comm) TeamRankToLsa(team Team, rank int32) (int32, error)
- func (c Comm) TeamRankToWorld(team Team, rank int32) (int32, error)
- func (c Comm) TeamWorld() (Team, error)
- func (c Comm) UniqueId() (UniqueId, error)
- func (c Comm) UserRank() (int32, error)
- func (c Comm) WaitSignal(nDesc int32, signalDescs *WaitSignalDesc, stream driver.Stream) error
- func (c Comm) WinGetUserPtr(win Window) (driver.DevicePtr, error)
- func (c Comm) WindowDeregister(win Window) error
- func (c Comm) WindowRegister(buff driver.DevicePtr, size uint, win *Window, winFlags WinFlags) error
- type CommMemStat
- type CommProperties
- type Config
- type ConfigExt
- type DataType
- type DevComm
- type DevCommRequirements
- type DevCommWindowTable
- type DevResourceHandle
- type DevResourceRequirements
- type GinBarrierHandle
- type GinConnectionType
- type GinCounter
- type GinRequest
- type GinSignal
- type GinType
- type GinWindow
- type HostCftMode
- type LLA2AHandle
- type LibraryAttempt
- type LibraryConflictError
- type LibraryError
- type LsaBarrierHandle
- type MemLocationType
- type MultimemHandle
- type ParamHandle
- func (p ParamHandle) Get(out unsafe.Pointer, maxLen int32, len_ *int32) error
- func (p ParamHandle) I8() (int8, error)
- func (p ParamHandle) I16() (int16, error)
- func (p ParamHandle) I32() (int32, error)
- func (p ParamHandle) I64() (int64, error)
- func (p ParamHandle) Str() (string, error)
- func (p ParamHandle) U8() (uint8, error)
- func (p ParamHandle) U16() (uint16, error)
- func (p ParamHandle) U32() (uint32, error)
- func (p ParamHandle) U64() (uint64, error)
- type RedOp
- type Registration
- type ResourcewindowVidmem
- type Result
- type ScalarResidence
- type SegmentWindow
- type SimInfo
- type SymbolError
- type Team
- type TeamRequirements
- type UniqueId
- type WaitSignalDesc
- type WinFlags
- type Window
- func (w Window) CftDeviceLeInfo(offset uint, peerCft int32, cftTeam Team) (leId CftLeId, leOffset uint, err error)
- func (w Window) LsaDevicePointer(offset uint, lsaRank int32) (driver.DevicePtr, error)
- func (w Window) LsaMultimemDevicePointer(offset uint) (driver.DevicePtr, error)
- func (w Window) MultimemDeviceLeInfo(offset uint) (leId CftLeId, leOffset uint, err error)
- func (w Window) MultimemDevicePointer(offset uint, multimem MultimemHandle) (driver.DevicePtr, error)
- func (w Window) PeerDeviceLeInfo(offset uint, peerWorld int32) (leId CftLeId, leOffset uint, err error)
- func (w Window) PeerDevicePointer(offset uint, peer int32) (driver.DevicePtr, error)
- func (w Window) PutSignal(localbuff driver.DevicePtr, count uint, datatype DataType, peer int32, ...) error
- type WindowVidmem
Examples ¶
Constants ¶
const (
WinRequiredAlignment = 4096
)
WinRequiredAlignment is the buffer alignment, in bytes, nccl.h specifies for window registration.
Variables ¶
This section is empty.
Functions ¶
func CftBarrierCreateRequirement ¶
func CftBarrierCreateRequirement(team Team, nBarriers int32, outHandle *CftBarrierHandle, outReq *DevResourceRequirements) error
CftBarrierCreateRequirement wraps ncclCftBarrierCreateRequirement.
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 CommInitAll ¶
CommInitAll creates a clique of communicators (single process version) in a blocking way.
This is a convenience function to create a single-process communicator clique. Returns an array of ndev newly initialized communicators in comms. comms should be pre-allocated with size at least ndev*sizeof( Comm). devlist defines the CUDA devices associated with each rank. If devlist is NULL, the first ndev CUDA devices are used, in order.
Wraps ncclCommInitAll.
func GetVersion ¶
GetVersion returns the version number of the currently linked NCCL library.
The NCCL version number is returned and encoded as an integer which includes the NCCL_MAJOR, NCCL_MINOR and NCCL_PATCH levels. The version number returned will be the same as the NCCL_VERSION_CODE defined in nccl.h. NCCL version numbers can be compared using the supplied macro NCCL_VERSION as NCCL_VERSION(MAJOR,MINOR,PATCH)
Wraps ncclGetVersion.
func GroupEnd ¶
func GroupEnd() error
GroupEnd ends a group call.
Returns when all operations since GroupStart have been processed. This means the communication primitives have been enqueued to the provided streams, but are not necessarily complete. When used with the CommInitRank call, the GroupEnd call waits for all communicators to be initialized.
Wraps ncclGroupEnd.
func GroupSimulateEnd ¶
GroupSimulateEnd simulates a GroupEnd call and returns NCCL’s simulation info in a structure passed as an argument.
Wraps ncclGroupSimulateEnd.
func GroupStart ¶
func GroupStart() error
GroupStart starts a group call.
All subsequent calls to NCCL until GroupEnd will not block due to inter-CPU synchronization.
Wraps ncclGroupStart.
func Has ¶
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 HasAllGather ¶
func HasAllGather() bool
HasAllGather reports whether ncclAllGather resolved in the loaded library.
func HasAllGatherConfig ¶
func HasAllGatherConfig() bool
HasAllGatherConfig reports whether ncclAllGatherConfig resolved in the loaded library.
func HasAllReduce ¶
func HasAllReduce() bool
HasAllReduce reports whether ncclAllReduce resolved in the loaded library.
func HasAllReduceConfig ¶
func HasAllReduceConfig() bool
HasAllReduceConfig reports whether ncclAllReduceConfig resolved in the loaded library.
func HasAlltoAll ¶
func HasAlltoAll() bool
HasAlltoAll reports whether ncclAlltoAll resolved in the loaded library.
func HasAlltoAllConfig ¶
func HasAlltoAllConfig() bool
HasAlltoAllConfig reports whether ncclAlltoAllConfig resolved in the loaded library.
func HasBroadcast ¶
func HasBroadcast() bool
HasBroadcast reports whether ncclBroadcast resolved in the loaded library.
func HasBroadcastConfig ¶
func HasBroadcastConfig() bool
HasBroadcastConfig reports whether ncclBroadcastConfig resolved in the loaded library.
func HasCftBarrierCreateRequirement ¶
func HasCftBarrierCreateRequirement() bool
HasCftBarrierCreateRequirement reports whether ncclCftBarrierCreateRequirement resolved in the loaded library.
func HasCommAbort ¶
func HasCommAbort() bool
HasCommAbort reports whether ncclCommAbort resolved in the loaded library.
func HasCommCount ¶
func HasCommCount() bool
HasCommCount reports whether ncclCommCount resolved in the loaded library.
func HasCommCuDevice ¶
func HasCommCuDevice() bool
HasCommCuDevice reports whether ncclCommCuDevice resolved in the loaded library.
func HasCommDeregister ¶
func HasCommDeregister() bool
HasCommDeregister reports whether ncclCommDeregister resolved in the loaded library.
func HasCommDestroy ¶
func HasCommDestroy() bool
HasCommDestroy reports whether ncclCommDestroy resolved in the loaded library.
func HasCommFinalize ¶
func HasCommFinalize() bool
HasCommFinalize reports whether ncclCommFinalize resolved in the loaded library.
func HasCommGetAsyncError ¶
func HasCommGetAsyncError() bool
HasCommGetAsyncError reports whether ncclCommGetAsyncError resolved in the loaded library.
func HasCommGetUniqueId ¶
func HasCommGetUniqueId() bool
HasCommGetUniqueId reports whether ncclCommGetUniqueId resolved in the loaded library.
func HasCommGrow ¶
func HasCommGrow() bool
HasCommGrow reports whether ncclCommGrow resolved in the loaded library.
func HasCommInitAll ¶
func HasCommInitAll() bool
HasCommInitAll reports whether ncclCommInitAll resolved in the loaded library.
func HasCommInitRank ¶
func HasCommInitRank() bool
HasCommInitRank reports whether ncclCommInitRank resolved in the loaded library.
func HasCommInitRankConfig ¶
func HasCommInitRankConfig() bool
HasCommInitRankConfig reports whether ncclCommInitRankConfig resolved in the loaded library.
func HasCommInitRankScalable ¶
func HasCommInitRankScalable() bool
HasCommInitRankScalable reports whether ncclCommInitRankScalable resolved in the loaded library.
func HasCommMemStats ¶
func HasCommMemStats() bool
HasCommMemStats reports whether ncclCommMemStats resolved in the loaded library.
func HasCommQueryProperties ¶
func HasCommQueryProperties() bool
HasCommQueryProperties reports whether ncclCommQueryProperties resolved in the loaded library.
func HasCommRegister ¶
func HasCommRegister() bool
HasCommRegister reports whether ncclCommRegister resolved in the loaded library.
func HasCommResume ¶
func HasCommResume() bool
HasCommResume reports whether ncclCommResume resolved in the loaded library.
func HasCommRevoke ¶
func HasCommRevoke() bool
HasCommRevoke reports whether ncclCommRevoke resolved in the loaded library.
func HasCommShrink ¶
func HasCommShrink() bool
HasCommShrink reports whether ncclCommShrink resolved in the loaded library.
func HasCommSplit ¶
func HasCommSplit() bool
HasCommSplit reports whether ncclCommSplit resolved in the loaded library.
func HasCommSuspend ¶
func HasCommSuspend() bool
HasCommSuspend reports whether ncclCommSuspend resolved in the loaded library.
func HasCommUserRank ¶
func HasCommUserRank() bool
HasCommUserRank reports whether ncclCommUserRank resolved in the loaded library.
func HasCommWindowDeregister ¶
func HasCommWindowDeregister() bool
HasCommWindowDeregister reports whether ncclCommWindowDeregister resolved in the loaded library.
func HasCommWindowRegister ¶
func HasCommWindowRegister() bool
HasCommWindowRegister reports whether ncclCommWindowRegister resolved in the loaded library.
func HasDevCommCreate ¶
func HasDevCommCreate() bool
HasDevCommCreate reports whether ncclDevCommCreate resolved in the loaded library.
func HasDevCommDestroy ¶
func HasDevCommDestroy() bool
HasDevCommDestroy reports whether ncclDevCommDestroy resolved in the loaded library.
func HasGather ¶
func HasGather() bool
HasGather reports whether ncclGather resolved in the loaded library.
func HasGatherConfig ¶
func HasGatherConfig() bool
HasGatherConfig reports whether ncclGatherConfig resolved in the loaded library.
func HasGetCftDeviceLeInfo ¶
func HasGetCftDeviceLeInfo() bool
HasGetCftDeviceLeInfo reports whether ncclGetCftDeviceLeInfo resolved in the loaded library.
func HasGetErrorString ¶
func HasGetErrorString() bool
HasGetErrorString reports whether ncclGetErrorString resolved in the loaded library.
func HasGetLastError ¶
func HasGetLastError() bool
HasGetLastError reports whether ncclGetLastError resolved in the loaded library.
func HasGetLsaDevicePointer ¶
func HasGetLsaDevicePointer() bool
HasGetLsaDevicePointer reports whether ncclGetLsaDevicePointer resolved in the loaded library.
func HasGetLsaMultimemDevicePointer ¶
func HasGetLsaMultimemDevicePointer() bool
HasGetLsaMultimemDevicePointer reports whether ncclGetLsaMultimemDevicePointer resolved in the loaded library.
func HasGetMultimemDeviceLeInfo ¶
func HasGetMultimemDeviceLeInfo() bool
HasGetMultimemDeviceLeInfo reports whether ncclGetMultimemDeviceLeInfo resolved in the loaded library.
func HasGetMultimemDevicePointer ¶
func HasGetMultimemDevicePointer() bool
HasGetMultimemDevicePointer reports whether ncclGetMultimemDevicePointer resolved in the loaded library.
func HasGetPeerDeviceLeInfo ¶
func HasGetPeerDeviceLeInfo() bool
HasGetPeerDeviceLeInfo reports whether ncclGetPeerDeviceLeInfo resolved in the loaded library.
func HasGetPeerDevicePointer ¶
func HasGetPeerDevicePointer() bool
HasGetPeerDevicePointer reports whether ncclGetPeerDevicePointer resolved in the loaded library.
func HasGetUniqueId ¶
func HasGetUniqueId() bool
HasGetUniqueId reports whether ncclGetUniqueId resolved in the loaded library.
func HasGetVersion ¶
func HasGetVersion() bool
HasGetVersion reports whether ncclGetVersion resolved in the loaded library.
func HasGinBarrierCreateRequirement ¶
func HasGinBarrierCreateRequirement() bool
HasGinBarrierCreateRequirement reports whether ncclGinBarrierCreateRequirement resolved in the loaded library.
func HasGroupEnd ¶
func HasGroupEnd() bool
HasGroupEnd reports whether ncclGroupEnd resolved in the loaded library.
func HasGroupSimulateEnd ¶
func HasGroupSimulateEnd() bool
HasGroupSimulateEnd reports whether ncclGroupSimulateEnd resolved in the loaded library.
func HasGroupStart ¶
func HasGroupStart() bool
HasGroupStart reports whether ncclGroupStart resolved in the loaded library.
func HasLLA2ACalcSlots ¶
func HasLLA2ACalcSlots() bool
HasLLA2ACalcSlots reports whether ncclLLA2ACalcSlots resolved in the loaded library.
func HasLLA2ACreateRequirement ¶
func HasLLA2ACreateRequirement() bool
HasLLA2ACreateRequirement reports whether ncclLLA2ACreateRequirement resolved in the loaded library.
func HasLsaBarrierCreateRequirement ¶
func HasLsaBarrierCreateRequirement() bool
HasLsaBarrierCreateRequirement reports whether ncclLsaBarrierCreateRequirement resolved in the loaded library.
func HasMemAlloc ¶
func HasMemAlloc() bool
HasMemAlloc reports whether ncclMemAlloc resolved in the loaded library.
func HasMemFree ¶
func HasMemFree() bool
HasMemFree reports whether ncclMemFree resolved in the loaded library.
func HasParamBind ¶
func HasParamBind() bool
HasParamBind reports whether ncclParamBind resolved in the loaded library.
func HasParamDumpAll ¶
func HasParamDumpAll() bool
HasParamDumpAll reports whether ncclParamDumpAll resolved in the loaded library.
func HasParamGet ¶
func HasParamGet() bool
HasParamGet reports whether ncclParamGet resolved in the loaded library.
func HasParamGetAllParameterKeys ¶
func HasParamGetAllParameterKeys() bool
HasParamGetAllParameterKeys reports whether ncclParamGetAllParameterKeys resolved in the loaded library.
func HasParamGetI8 ¶
func HasParamGetI8() bool
HasParamGetI8 reports whether ncclParamGetI8 resolved in the loaded library.
func HasParamGetI16 ¶
func HasParamGetI16() bool
HasParamGetI16 reports whether ncclParamGetI16 resolved in the loaded library.
func HasParamGetI32 ¶
func HasParamGetI32() bool
HasParamGetI32 reports whether ncclParamGetI32 resolved in the loaded library.
func HasParamGetI64 ¶
func HasParamGetI64() bool
HasParamGetI64 reports whether ncclParamGetI64 resolved in the loaded library.
func HasParamGetParameter ¶
func HasParamGetParameter() bool
HasParamGetParameter reports whether ncclParamGetParameter resolved in the loaded library.
func HasParamGetStr ¶
func HasParamGetStr() bool
HasParamGetStr reports whether ncclParamGetStr resolved in the loaded library.
func HasParamGetU8 ¶
func HasParamGetU8() bool
HasParamGetU8 reports whether ncclParamGetU8 resolved in the loaded library.
func HasParamGetU16 ¶
func HasParamGetU16() bool
HasParamGetU16 reports whether ncclParamGetU16 resolved in the loaded library.
func HasParamGetU32 ¶
func HasParamGetU32() bool
HasParamGetU32 reports whether ncclParamGetU32 resolved in the loaded library.
func HasParamGetU64 ¶
func HasParamGetU64() bool
HasParamGetU64 reports whether ncclParamGetU64 resolved in the loaded library.
func HasPutSignal ¶
func HasPutSignal() bool
HasPutSignal reports whether ncclPutSignal resolved in the loaded library.
func HasRedOpCreatePreMulSum ¶
func HasRedOpCreatePreMulSum() bool
HasRedOpCreatePreMulSum reports whether ncclRedOpCreatePreMulSum resolved in the loaded library.
func HasRedOpDestroy ¶
func HasRedOpDestroy() bool
HasRedOpDestroy reports whether ncclRedOpDestroy resolved in the loaded library.
func HasReduce ¶
func HasReduce() bool
HasReduce reports whether ncclReduce resolved in the loaded library.
func HasReduceConfig ¶
func HasReduceConfig() bool
HasReduceConfig reports whether ncclReduceConfig resolved in the loaded library.
func HasReduceScatter ¶
func HasReduceScatter() bool
HasReduceScatter reports whether ncclReduceScatter resolved in the loaded library.
func HasReduceScatterConfig ¶
func HasReduceScatterConfig() bool
HasReduceScatterConfig reports whether ncclReduceScatterConfig resolved in the loaded library.
func HasScatter ¶
func HasScatter() bool
HasScatter reports whether ncclScatter resolved in the loaded library.
func HasScatterConfig ¶
func HasScatterConfig() bool
HasScatterConfig reports whether ncclScatterConfig resolved in the loaded library.
func HasSignal ¶
func HasSignal() bool
HasSignal reports whether ncclSignal resolved in the loaded library.
func HasTeamCft ¶
func HasTeamCft() bool
HasTeamCft reports whether ncclTeamCft resolved in the loaded library.
func HasTeamCftMultimem ¶
func HasTeamCftMultimem() bool
HasTeamCftMultimem reports whether ncclTeamCftMultimem resolved in the loaded library.
func HasTeamLsa ¶
func HasTeamLsa() bool
HasTeamLsa reports whether ncclTeamLsa resolved in the loaded library.
func HasTeamRail ¶
func HasTeamRail() bool
HasTeamRail reports whether ncclTeamRail resolved in the loaded library.
func HasTeamRankToLsa ¶
func HasTeamRankToLsa() bool
HasTeamRankToLsa reports whether ncclTeamRankToLsa resolved in the loaded library.
func HasTeamRankToWorld ¶
func HasTeamRankToWorld() bool
HasTeamRankToWorld reports whether ncclTeamRankToWorld resolved in the loaded library.
func HasTeamWorld ¶
func HasTeamWorld() bool
HasTeamWorld reports whether ncclTeamWorld resolved in the loaded library.
func HasWaitSignal ¶
func HasWaitSignal() bool
HasWaitSignal reports whether ncclWaitSignal resolved in the loaded library.
func HasWinGetUserPtr ¶
func HasWinGetUserPtr() bool
HasWinGetUserPtr reports whether ncclWinGetUserPtr resolved in the loaded library.
func LLA2ACalcSlots ¶
LLA2ACalcSlots wraps ncclLLA2ACalcSlots. The error reports an unavailable library or symbol.
func LLA2ACreateRequirement ¶
func LLA2ACreateRequirement(nBlocks int32, nSlots int32, outHandle *LLA2AHandle, outReq *DevResourceRequirements) error
LLA2ACreateRequirement wraps ncclLLA2ACreateRequirement.
func Load ¶
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 LsaBarrierCreateRequirement ¶
func LsaBarrierCreateRequirement(team Team, nBarriers int32, outHandle *LsaBarrierHandle, outReq *DevResourceRequirements) error
LsaBarrierCreateRequirement wraps ncclLsaBarrierCreateRequirement.
func MemAlloc ¶
MemAlloc allocates a GPU buffer with size.
Allocated buffer head address will be returned by ptr, and the actual allocated size can be larger than requested because of the buffer granularity requirements from all types of NCCL optimizations.
Wraps ncclMemAlloc.
func ParamDumpAll ¶
func ParamDumpAll() error
ParamDumpAll writes the key and current value of every registered parameter to the NCCL log output.
Useful for diagnostics and configuration auditing. The information of parameters in the output are not sorted. This function returns parameters published in Environment Variables by default. Setting ParamDumpAll to true forces this function to return all parameters. Example of output with ParamDumpAll set to true:
NCCL_NO_CACHE (const char *) [Private, Cached] Comma-separated list of param keys to disable caching (or ALL)
Current value=<unset> set_by=Default default=<unset>
Accepted value: String
NCCL_PARAM_DUMP_ALL (bool) [Private] Print all parameters including private ones
Current value=TRUE set_by=EnvPlugin default=FALSE
Accepted value: Boolean: 1/T/TRUE or 0/F/FALSE
Wraps ncclParamDumpAll. The error reports an unavailable library or symbol.
func ParamGetAllParameterKeys ¶
ParamGetAllParameterKeys returns a pointer to the internal table of all registered parameter keys.
The result is an array of const char* pointers, one per registered parameter, and the length of the result is the number of entries. The table and the strings it contains are owned by the parameter system. Both are valid until the next call to ParamGetAllParameterKeys on the same thread. The keys in the returned table are not sorted. This function returns parameters published in Environment Variables by default. Setting ParamDumpAll to true forces this function to return all parameters.
Wraps ncclParamGetAllParameterKeys.
func ParamGetParameter ¶
ParamGetParameter looks up the parameter identified by key and returns its value as a null-terminated string.
The pointer returned is owned by the parameter system and is valid until the next call to ParamGetParameter on the same thread. valueLen receives the length of the string in bytes, excluding the null terminator. Returns ncclInvalidArgument if key is not found.
Wraps ncclParamGetParameter.
Types ¶
type BindFailure ¶
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 Buffer ¶
type Buffer uintptr
Buffer is an address in memory accessible to NCCL.
It is not a Go pointer and does not keep an allocation alive. The caller must keep the allocation valid until every asynchronous operation using it has completed.
type CPtr ¶
type CPtr uintptr
CPtr is an address owned by NCCL or another C library.
It is not a Go pointer, is not visible to the garbage collector, and does not keep an allocation alive. It is a defined type rather than an alias so that an address the library owns cannot be mixed with an ordinary uintptr by accident; convert explicitly.
type CString ¶
type CString uintptr
CString is the address of a NUL-terminated C string.
It is not a Go pointer and does not keep the string storage alive.
type CallError ¶
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.
type CftBarrierHandle ¶
type CftBarrierHandle struct {
BufHandle DevResourceHandle
NBarriers int32
}
CftBarrierHandle represents ncclCftBarrierHandle_t.
type CftTeamMode ¶
type CftTeamMode int32
CftTeamMode represents selects the CFT team layout returned by Comm.TeamCft.
const ( CftTeamFlat CftTeamMode = 0 // Flat CFT team includes all the ranks that are part of the CFT unicast group. CftTeamHierMultimem CftTeamMode = 1 // Hierarchical CFT team includes ranks that are part of the CFT unicast group and share the same index across different multicast CFT groups. CftTeamHierLsa CftTeamMode = 2 // Hierarchical CFT team includes ranks that are part of the CFT unicast group and share the same index across different LSA groups. CFT data movement routines operate on a logical endpoint ID and an offset within that endpoint. NCCL provides host-side and device-side helpers for translating registered windows and peer ranks into those values. )
func (CftTeamMode) String ¶
func (e CftTeamMode) String() string
String returns the constant name, or a numeric representation for unknown values.
type CollConfig ¶
type CollConfig struct {
Size uint
Magic uint32
Version uint32
Ext uintptr
MinCTAs int32
MaxCTAs int32
NvlsCTAs int32
CgaClusterSize int32
AlgSelection uintptr
ForceAlgSelection int32
CTAPolicy int32
UserProfilerTag uint64
}
CollConfig represents per-collective configuration.
Users assign values to attributes to customize an individual collective call issued through one of the nccl*Config() entry points. Like Config, this is a versioned, append-only struct: in the future, any new members will be added at the end, and existing members will never be removed or reordered. The user owns the storage and must keep the struct (and any linked ConfigExt) valid for the duration of every call that uses it. The same configuration must be set on every rank; NCCL validates it only locally.
type Comm ¶
type Comm uintptr
Comm is an opaque handle for ncclComm_t.
func CommInitRank ¶
CommInitRank creates a new communicator (multi thread/process version).
rank must be between 0 and nranks-1 and unique within a communicator clique. Each rank is associated to a CUDA device, which has to be set before calling CommInitRank. CommInitRank implicitly synchronizes with other ranks, hence it must be called by different threads/processes or used within GroupStart/GroupEnd.
Wraps ncclCommInitRank.
func CommInitRankConfig ¶
CommInitRankConfig works the same way as CommInitRank but accepts a configuration argument of extra attributes for the communicator.
If config is passed as NULL, the communicator will have the default behavior, as if CommInitRank was called. See the Creating a communicator with options section for details on configuration options.
Wraps ncclCommInitRankConfig.
func CommInitRankScalable ¶
func CommInitRankScalable(nranks int32, myrank int32, nId int32, commIds *UniqueId, config *Config) (Comm, error)
CommInitRankScalable works the same way as CommInitRankConfig but accepts a list of ncclUniqueIds instead of a single one.
If only one UniqueId is passed, the communicator will be initialized as if CommInitRankConfig was called. The provided ncclUniqueIds will all be used to initialize the single communicator given in argument. See the Creating a communicator with options section for details on how to create and distribute the list of ncclUniqueIds.
Wraps ncclCommInitRankScalable.
func InitAll ¶
InitAll creates one communicator for each device ordinal. Devices must be nonempty and distinct. The output has one slot per rank. On a native error, the returned slice preserves any partially written handles. The caller must not use those handles for communication.
func (Comm) Abort ¶
Abort frees resources that are allocated to a communicator object comm and aborts any uncompleted operations before destroying the communicator.
All active ranks are required to call this function in order to abort the NCCL communicator successfully. For more use cases, please check Fault Tolerance.
It is not named Close because Comm has other release methods, Deregister and Destroy.
Wraps ncclCommAbort.
func (Comm) AllGather ¶
func (c Comm) AllGather(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, sendcount uint, datatype DataType, stream driver.Stream) error
AllGather gathers sendcount values from all GPUs and leaves identical copies of the result in each recvbuff, receiving data from rank i at offset i*sendcount.
Note: This assumes the receive count is equal to nranks*sendcount, which means that recvbuff should have a size of at least nranks*sendcount elements. In-place operation will happen if sendbuff == recvbuff + rank * sendcount.
Wraps ncclAllGather.
func (Comm) AllGatherConfig ¶
func (c Comm) AllGatherConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, sendcount uint, datatype DataType, stream driver.Stream, config *CollConfig) error
AllGatherConfig is a configurable variant of Comm.AllGather.
Wraps ncclAllGatherConfig.
func (Comm) AllReduce ¶
func (c Comm) AllReduce(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, datatype DataType, op RedOp, stream driver.Stream) error
AllReduce reduces data arrays of length count in sendbuff using the op operation and leaves identical copies of the result in each recvbuff.
In-place operation will happen if sendbuff == recvbuff.
Wraps ncclAllReduce.
func (Comm) AllReduceConfig ¶
func (c Comm) AllReduceConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, datatype DataType, op RedOp, stream driver.Stream, config *CollConfig) error
AllReduceConfig is a configurable variant of Comm.AllReduce.
Wraps ncclAllReduceConfig.
func (Comm) AlltoAll ¶
func (c Comm) AlltoAll(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, datatype DataType, stream driver.Stream) error
AlltoAll sends a separate block of count elements from each rank to every rank.
Each rank sends count values to all other ranks and receives count values from all other ranks.
Data to send to destination rank j is taken from sendbuff+j*count and data received from source rank i is placed at recvbuff+i*count.
Note: This assumes both the total send and receive count is equal to nranks*count, which means that sendbuff and recvbuff should have a size of at least nranks*count elements. In-place operation is currently not supported.
Wraps ncclAlltoAll.
func (Comm) AlltoAllConfig ¶
func (c Comm) AlltoAllConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, datatype DataType, stream driver.Stream, config *CollConfig) error
AlltoAllConfig is a configurable variant of Comm.AlltoAll.
Wraps ncclAlltoAllConfig.
func (Comm) AsyncError ¶
AsyncError queries the progress and potential errors of asynchronous NCCL operations.
Operations which do not require a stream argument (e.g. Comm.Finalize) can be considered complete as soon as the function returns ncclSuccess; operations with a stream argument (e.g. Comm.AllReduce) will return ncclSuccess as soon as the operation is posted on the stream but may also report errors through Comm.AsyncError until they are completed. If the return code of any NCCL function is ncclInProgress, it means the operation is in the process of being enqueued in the background, and users must query the states of the communicators until all the states become ncclSuccess before calling another NCCL function. Before the states change into ncclSuccess, users are not allowed to issue CUDA kernel to the streams being used by NCCL. If there has been an error on the communicator, user should destroy the communicator with Comm.Abort. If an error occurs on the communicator, nothing can be assumed about the completion or correctness of operations enqueued on that communicator.
Wraps ncclCommGetAsyncError.
func (Comm) Broadcast ¶
func (c Comm) Broadcast(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, datatype DataType, root int32, stream driver.Stream) error
Broadcast copies count elements from sendbuff on the root rank to all ranks’ recvbuff.
sendbuff is only used on rank root and ignored for other ranks. In-place operation will happen if sendbuff == recvbuff.
Wraps ncclBroadcast.
func (Comm) BroadcastConfig ¶
func (c Comm) BroadcastConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, datatype DataType, root int32, stream driver.Stream, config *CollConfig) error
BroadcastConfig is a configurable variant of Comm.Broadcast.
Wraps ncclBroadcastConfig.
func (Comm) Count ¶
Count returns the number of ranks in the NCCL communicator comm.
Wraps ncclCommCount.
func (Comm) CuDevice ¶
CuDevice returns the CUDA device associated with the NCCL communicator comm.
Wraps ncclCommCuDevice.
func (Comm) Deregister ¶
func (c Comm) Deregister(handle Registration) error
Deregister deregisters buffer represented by handle under communicator comm.
It is not named Close because Comm has other release methods, Abort and Destroy.
Wraps ncclCommDeregister.
func (Comm) Destroy ¶
Destroy destroys a communicator object comm.
If Comm.Finalize is called by users, users should guarantee that the state of the communicator becomes ncclSuccess before calling Comm.Destroy. In all cases, the communicator should no longer be accessed after Comm.Destroy returns. It is recommended that users call Comm.Finalize and then Comm.Destroy. Comm.Destroy will call Comm.Finalize internally, unless Comm.Finalize was previously called on the communicator. If Comm.Finalize was previously called on the communicator object comm, then Comm.Destroy is a purely local operation. This function is an intra-node collective call, which all ranks on the same node should call to avoid a hang.
It is not named Close because Comm has other release methods, Abort and Deregister.
Wraps ncclCommDestroy.
func (Comm) DevCommCreate ¶
func (c Comm) DevCommCreate(reqs *DevCommRequirements, outDevComm *DevComm) error
DevCommCreate creates a new device communicator (see ncclDevComm) corresponding to the supplied host-side communicator comm.
The result is returned in the outDevComm buffer (which needs to be supplied by the caller). The caller needs to also provide a filled-in list of requirements via the reqs argument (see ncclDevCommRequirements); the function will allocate any necessary resources to meet them. It is recommended to call Comm.QueryProperties before calling the function; the function will fail if the specified requirements are not supported. Since this is a collective call, every rank in the communicator needs to participate. If called within a group, outDevComm may not be filled in until GroupEnd has completed. Note that this is a host-side function.
Wraps ncclDevCommCreate.
func (Comm) DevCommDestroy ¶
DevCommDestroy destroys a device communicator (see ncclDevComm) previously created using Comm.DevCommCreate and releases any allocated resources.
The caller must ensure that no device kernel that uses this device communicator could be running at the time this function is invoked. Note that this is a host-side function.
Wraps ncclDevCommDestroy.
func (Comm) Finalize ¶
Finalize finalizes a communicator object comm.
When the communicator is marked as nonblocking, Comm.Finalize is a nonblocking function. Successful return from it will set communicator state as ncclInProgress and indicates the communicator is under finalization where all uncompleted operations and the network-related resources are being flushed and freed. Once all NCCL operations are complete, the communicator will transition to the ncclSuccess state. Users can query that state with Comm.AsyncError. This function is an intra-node collective call. When a single thread finalizes multiple ranks (multiple GPUs per thread), the calls must be grouped with GroupStart/ GroupEnd to avoid a hang.
Wraps ncclCommFinalize.
func (Comm) Gather ¶
func (c Comm) Gather(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, datatype DataType, root int32, stream driver.Stream) error
Gather gathers count elements from each rank on the root rank.
Each rank sends count elements from sendbuff to the root rank.
On the root rank, data from rank i is placed at recvbuff + i*count. On non-root ranks, recvbuff is not used.
Note: This assumes the receive count is equal to nranks*count, which means that recvbuff should have a size of at least nranks*count elements. In-place operation will happen if sendbuff == recvbuff + root * count.
Wraps ncclGather.
func (Comm) GatherConfig ¶
func (c Comm) GatherConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, datatype DataType, root int32, stream driver.Stream, config *CollConfig) error
GatherConfig is a configurable variant of Comm.Gather.
Wraps ncclGatherConfig.
func (Comm) GinBarrierCreateRequirement ¶
func (c Comm) GinBarrierCreateRequirement(team Team, nBarriers int32, outHandle *GinBarrierHandle, outReq *DevResourceRequirements) error
GinBarrierCreateRequirement wraps ncclGinBarrierCreateRequirement.
func (Comm) Grow ¶
func (c Comm) Grow(nRanks int32, uniqueId *UniqueId, rank int32, newcomm *Comm, config *Config) error
Grow creates a new communicator by adding new ranks to an existing communicator.
It must be called by both existing ranks (from the parent communicator) and new ranks (joining the communicator). For existing ranks:
- comm should be the parent communicator
- rank must be set to -1 (existing ranks retain their original rank in the new communicator)
- uniqueId unused. (existing ranks receive coordination information internally)
- The function creates newcomm with the same rank as in the parent communicator
For new ranks:
- comm should be NULL
- rank must be set to the desired rank in the new communicator (must be >= parent communicator size)
- uniqueId must be the unique identifier obtained from Comm.UniqueId called by the coordinator
The nRanks parameter specifies the total number of ranks in the new communicator and must be greater than the size of the parent communicator. If the new communicator needs a special configuration, it can be passed as config; otherwise, setting config to NULL will make the new communicator inherit the configuration of the parent communicator (for existing ranks) or use default configuration (for new ranks). There should not be any outstanding NCCL operations on the parent communicator when calling this function to avoid potential deadlocks. After the grow operation completes, the parent communicator should be destroyed using Comm.Destroy to free resources. Example workflow:
- Coordinator rank calls Comm.UniqueId to generate the grow identifier
- Coordinator distributes the uniqueId to all new ranks (out-of-band)
- All existing ranks call Comm.Grow with comm =parent, rank =-1, uniqueId =NULL
- All new ranks call Comm.Grow with comm =NULL, rank =new_rank, uniqueId =received_id
The library may write *newcomm after the call returns. Keep the value it points to reachable, and do not read or reuse it, until any enclosing GroupEnd has returned and, for a nonblocking communicator, Comm.AsyncError no longer reports ErrInProgress.
Wraps ncclCommGrow.
func (Comm) LastError ¶
LastError returns a human-readable string corresponding to the last error that occurred in NCCL.
Note: The error is not cleared by calling this function. Please note that the string returned by Comm.LastError could be unrelated to the current call and can be a result of previously launched asynchronous operations, if any.
Wraps ncclGetLastError.
func (Comm) MemStats ¶
func (c Comm) MemStats(stat CommMemStat) (uint64, error)
MemStats queries communicator memory statistics.
The stat parameter selects which statistic to retrieve, and the result is returned. See CommMemStat for the list of available statistics.
Wraps ncclCommMemStats.
func (Comm) QueryProperties ¶
func (c Comm) QueryProperties(props *CommProperties) error
QueryProperties exposes communicator properties by filling in props.
Before calling this function, props must be initialized using NCCL_COMM_PROPERTIES_INITIALIZER. Introduced in NCCL 2.29. Note that this is a host-side function.
Wraps ncclCommQueryProperties.
func (Comm) Recv ¶
func (c Comm) Recv(recvbuff driver.DevicePtr, count uint, datatype DataType, peer int32, stream driver.Stream) error
Recv receives data from rank peer into recvbuff.
Rank peer needs to call Comm.Send with the same datatype and the same count as this rank. This operation is blocking for the GPU. If multiple Comm.Send and Comm.Recv operations need to progress concurrently to complete, they must be fused within a GroupStart/ GroupEnd section. One-sided Remote Memory Access (RMA) operations enable ranks to directly access remote memory without explicit participation from the target process. These operations require the target memory to be pre-registered within a symmetric memory window using Comm.WindowRegister.
Wraps ncclRecv.
func (Comm) RedOpCreatePreMulSum ¶
func (c Comm) RedOpCreatePreMulSum(scalar Buffer, datatype DataType, residence ScalarResidence) (RedOp, error)
RedOpCreatePreMulSum creates a new reduction operator which pre-multiplies input values by a given scalar locally before reducing them with peer values via summation.
Both the input values and the scalar are of type datatype. For use only with collectives launched against comm and datatype. The residence argument indicates whether the memory pointed to by scalar should be dereferenced immediately by the host before this function returns (ncclScalarHostImmediate), or by the device during execution of the reduction collective (ncclScalarDevice). Upon return, the newly created operator’s handle is returned.
Wraps ncclRedOpCreatePreMulSum.
func (Comm) RedOpDestroy ¶
RedOpDestroy destroys the reduction operator op.
The operator must have been created by ncclRedOpCreatePreMul with the matching communicator comm. An operator may be destroyed as soon as the last NCCL function which is given that operator returns.
Wraps ncclRedOpDestroy.
func (Comm) Reduce ¶
func (c Comm) Reduce(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, datatype DataType, op RedOp, root int32, stream driver.Stream) error
Reduce reduces data arrays of length count in sendbuff into recvbuff on the root rank using the op operation.
recvbuff is only used on rank root and ignored for other ranks. In-place operation will happen if sendbuff == recvbuff.
Wraps ncclReduce.
func (Comm) ReduceConfig ¶
func (c Comm) ReduceConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, datatype DataType, op RedOp, root int32, stream driver.Stream, config *CollConfig) error
ReduceConfig is a configurable variant of Comm.Reduce.
Wraps ncclReduceConfig.
func (Comm) ReduceScatter ¶
func (c Comm) ReduceScatter(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, recvcount uint, datatype DataType, op RedOp, stream driver.Stream) error
ReduceScatter reduces data in sendbuff from all GPUs using the op operation and leaves the reduced result scattered over the devices so that the recvbuff on rank i will contain the i-th block of the result.
Note: This assumes the send count is equal to nranks*recvcount, which means that sendbuff should have a size of at least nranks*recvcount elements. In-place operation will happen if recvbuff == sendbuff + rank * recvcount.
Wraps ncclReduceScatter.
func (Comm) ReduceScatterConfig ¶
func (c Comm) ReduceScatterConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, recvcount uint, datatype DataType, op RedOp, stream driver.Stream, config *CollConfig) error
ReduceScatterConfig is a configurable variant of Comm.ReduceScatter.
Wraps ncclReduceScatterConfig.
func (Comm) Register ¶
Register registers the buffer buff with size under communicator comm for zero-copy communication; handle is returned for future deregistration.
See buff and size requirements and more instructions in User Buffer Registration.
Wraps ncclCommRegister.
func (Comm) Resume ¶
Resume resumes all previously suspended resources on communicator comm.
After this call returns successfully, the communicator is fully operational and can be used for NCCL operations again.
Wraps ncclCommResume.
func (Comm) Revoke ¶
Revoke revokes in-flight operations on a communicator without destroying resources.
Successful return may be ncclInProgress (non-blocking) while revocation completes asynchronously; applications can query Comm.AsyncError until it returns ncclSuccess. revokeFlags must be set to NCCL_REVOKE_DEFAULT (0). Other values are reserved for future use. After revoke completes, the communicator is quiesced and safe for destroy, split, and shrink. Launching new collectives on a revoked communicator returns ncclInvalidUsage. Calling Comm.Finalize after revoke is not supported. Resource sharing via splitShare/ shrinkShare is disabled when the parent communicator is revoked.
Wraps ncclCommRevoke.
func (Comm) Scatter ¶
func (c Comm) Scatter(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, datatype DataType, root int32, stream driver.Stream) error
Scatter scatters count elements from the root rank to each rank.
Each rank receives count elements from the root rank.
On the root rank, count elements from sendbuff + i*count are sent to rank i. On non-root ranks, sendbuff is not used.
Note: This assumes the send count is equal to nranks*count, which means that sendbuff should have a size of at least nranks*count elements. In-place operation will happen if recvbuff == sendbuff + root * count. Every collective above also has an *Config variant that takes a trailing CollConfig argument for per-call customization (algorithm selection, CTA counts, and similar overrides described under CollConfig). Initialize the config with NCCL_COLLCONFIG_INITIALIZER and set it identically on every rank. Passing config == NULL is equivalent to calling the plain API.
Wraps ncclScatter.
func (Comm) ScatterConfig ¶
func (c Comm) ScatterConfig(sendbuff driver.DevicePtr, recvbuff driver.DevicePtr, count uint, datatype DataType, root int32, stream driver.Stream, config *CollConfig) error
ScatterConfig is a configurable variant of Comm.Scatter.
Wraps ncclScatterConfig.
func (Comm) Send ¶
func (c Comm) Send(sendbuff driver.DevicePtr, count uint, datatype DataType, peer int32, stream driver.Stream) error
Send sends data from sendbuff to rank peer.
Rank peer needs to call Comm.Recv with the same datatype and the same count as this rank. This operation is blocking for the GPU. If multiple Comm.Send and Comm.Recv operations need to progress concurrently to complete, they must be fused within a GroupStart/ GroupEnd section.
Wraps ncclSend.
func (Comm) Shrink ¶
func (c Comm) Shrink(excludeRanksList *int32, excludeRanksCount int32, newcomm *Comm, config *Config, shrinkFlags int32) error
Shrink creates a new communicator by removing specified ranks from an existing communicator.
It is a collective function that must be called by all participating ranks in the newly created communicator. Ranks that are part of excludeRanksList should not call this function. The original ranks listed in excludeRanksList (of size excludeRanksCount) will be excluded from the new communicator. Within the new communicator, ranks will be updated to maintain a contiguous set of ids. If the new communicator needs a special configuration, it can be passed as config; otherwise, setting config to NULL will make the new communicator inherit the configuration of the parent communicator. The shrinkFlags parameter controls the behavior of the operation. Use NCCL_SHRINK_DEFAULT (or 0) for normal operation, or NCCL_SHRINK_ABORT when shrinking after an error on the parent communicator. Specifically, when using NCCL_SHRINK_DEFAULT, there should not be any outstanding NCCL operations on the comm to avoid potential deadlocks. Further, if the parent communicator has the flag config.shrinkShare set to 1, NCCL will reuse the parent communicator resources. On the other hand, when using NCCL_SHRINK_ABORT, NCCL will automatically abort any outstanding operations on the parent communicator, and no resources will be shared between the parent and the newly created communicator.
The library may write *newcomm after the call returns. Keep the value it points to reachable, and do not read or reuse it, until any enclosing GroupEnd has returned and, for a nonblocking communicator, Comm.AsyncError no longer reports ErrInProgress.
Wraps ncclCommShrink.
func (Comm) Signal ¶
Signal sends a signal to rank peer without transferring data.
The sigIdx is the signal index identifier for the operation. Prior to NCCL 2.31, it must be set to 0. Since NCCL 2.31, it may be set in the range [0, numRmaSig) (see numRmaSig). The ctx selects the communication context. Prior to NCCL 2.31, it must be set to 0. Since NCCL 2.31, it may be set in the range [0, numRmaCtx) (see numRmaCtx). The flags parameter is reserved for future use. It must be set to 0 for now. When a signal is updated on the remote peer, all prior Window.PutSignal and Comm.Signal operations to the same peer and context have also completed their signal updates.
Wraps ncclSignal.
func (Comm) Split ¶
Split is a collective function and creates a set of new communicators from an existing one.
Ranks which pass the same color value will be part of the same group; color must be a non-negative value. If it is passed as NCCL_SPLIT_NOCOLOR, it means that the rank will not be part of any group, therefore returning NULL as newcomm. The value of key will determine the rank order, and the smaller key means the smaller rank in new communicator. If keys are equal between ranks, then the rank in the original communicator will be used to order ranks. If the new communicator needs to have a special configuration, it can be passed as config, otherwise setting config to NULL will make the new communicator inherit the original communicator’s configuration. When split, there should not be any outstanding NCCL operations on the comm. Otherwise, it might cause a deadlock.
The library may write *newcomm after the call returns. Keep the value it points to reachable, and do not read or reuse it, until any enclosing GroupEnd has returned and, for a nonblocking communicator, Comm.AsyncError no longer reports ErrInProgress.
Wraps ncclCommSplit.
func (Comm) Suspend ¶
Suspend suspends communicator operations to free resources.
The communicator cannot be used for any NCCL operations while suspended. There should be no outstanding NCCL operations on comm when this function is called. The flags parameter controls which resources are released:
- NCCL_SUSPEND_MEM ( 0x01) – Release dynamic GPU memory allocations held by the communicator.
A suspended communicator can be restored to an active state by calling Comm.Resume.
Wraps ncclCommSuspend.
func (Comm) TeamCft ¶
func (c Comm) TeamCft(mode CftTeamMode) (Team, error)
TeamCft returns the host-side unicast CFT team containing ranks that are part of the CFT unicast group.
comm is the host-side communicator and mode is a selector used to filter the subset of CFT unicast group ranks that are part of the team (useful to build hierarchical communication patterns).
Wraps ncclTeamCft.
func (Comm) TeamCftMultimem ¶
TeamCftMultimem returns the host-side multicast CFT team containing all the ranks that are part of the CFT multicast group.
Wraps ncclTeamCftMultimem.
func (Comm) TeamRankToLsa ¶
TeamRankToLsa wraps ncclTeamRankToLsa.
func (Comm) TeamRankToWorld ¶
TeamRankToWorld wraps ncclTeamRankToWorld.
func (Comm) UniqueId ¶
UniqueId generates a unique identifier for growing an existing communicator exactly once.
This function must be called by only one rank (the coordinator) before each grow operation on the existing communicator. The coordinator is responsible for distributing the uniqueId to all new ranks before they join the communicator via Comm.Grow. This function should only be called when there are no outstanding NCCL operations on the communicator.
Wraps ncclCommGetUniqueId.
func (Comm) UserRank ¶
UserRank returns the rank of the caller in the NCCL communicator comm.
Wraps ncclCommUserRank.
func (Comm) WaitSignal ¶
WaitSignal waits for signals as described in the signal descriptor array.
The nDesc parameter specifies the number of signal descriptors in the signalDescs array. Each descriptor indicates how many signals ( opCnt) to expect from a specific peer on a particular signal index ( sigIdx) and context ( ctx). The return of Comm.WaitSignal to the CPU thread indicates that the operation has been successfully enqueued to the CUDA stream. At the completion of Comm.WaitSignal on the CUDA stream, all specified signal operations have been received and the corresponding data is visible in local memory.
Wraps ncclWaitSignal.
func (Comm) WinGetUserPtr ¶
WinGetUserPtr wraps ncclWinGetUserPtr.
func (Comm) WindowDeregister ¶
WindowDeregister deregisters NCCL window represented by win under communicator comm.
Deregistration is local to the rank, and caller needs to make sure the corresponding buffer within the window is not being accessed by any NCCL operation.
Wraps ncclCommWindowDeregister.
func (Comm) WindowRegister ¶
func (c Comm) WindowRegister(buff driver.DevicePtr, size uint, win *Window, winFlags WinFlags) error
WindowRegister collectively registers local buffer buff with size under communicator comm into NCCL window.
Since this is a collective call, every rank in the communicator needs to participate in the registration. Size may differ across ranks; callers are responsible for ensuring later operations only access ranges that are valid for the ranks participating in that operation. win is returned for future deregistration (if called within a group, the value may not be filled in until GroupEnd has completed). See buff requirement and more instructions in User Buffer Registration. User can also pass different win flags to control the registration behavior. For more win flags information, please refer to Window Registration Flags. Host APIs do not accept buffers that are symmetrically registered more than once. Passing such buffers to host APIs results in undefined behavior.
The library may write *win after the call returns. Keep the value it points to reachable, and do not read or reuse it, until any enclosing GroupEnd has returned and, for a nonblocking communicator, Comm.AsyncError no longer reports ErrInProgress.
Wraps ncclCommWindowRegister.
type CommMemStat ¶
type CommMemStat int32
CommMemStat represents memory statistic selectors for Comm.MemStats.
const ( StatGpuMemSuspend CommMemStat = 0 // Allocated GPU memory that can be suspended (bytes) StatGpuMemSuspended CommMemStat = 1 // GPU memory suspended? (0=active, 1=suspended) StatGpuMemPersist CommMemStat = 2 // Allocated GPU memory that cannot be suspended (bytes) StatGpuMemTotal CommMemStat = 3 // Total allocated GPU memory tracked by NCCL (bytes) )
func (CommMemStat) String ¶
func (e CommMemStat) String() string
String returns the constant name, or a numeric representation for unknown values.
type CommProperties ¶
type CommProperties struct {
Size uint
Magic uint32
Version uint32
Rank int32
NRanks int32
CudaDev int32
NvmlDev int32
DeviceApiSupport bool
MultimemSupport bool
GinType GinType
NLsaTeams int32
HostRmaSupport bool
RailedGinType GinType
CommHash uint64
GinMinStride int32
GinConnectionType GinConnectionType
GinSupport [64]bool
DevCommRuntimeVersionSize uint
}
CommProperties represents ncclCommProperties_t.
The zero value is not usable. Use NewCommProperties to get a valid initializer.
func NewCommProperties ¶
func NewCommProperties() CommProperties
NewCommProperties returns a CommProperties initialized the way NCCL_COMM_PROPERTIES_INITIALIZER does.
The zero value is not usable. The library validates the size, magic and version this sets and rejects a descriptor without them, and it reads the version to decide which fields it may write. Set workload fields on the result rather than building a CommProperties literal.
type Config ¶
type Config struct {
Size uint
Magic uint32
Version uint32
Blocking int32
CgaClusterSize int32
MinCTAs int32
MaxCTAs int32
NetName CString
TrafficClass int32
CommName CString
CollnetEnable int32
CTAPolicy int32
NvlsCTAs int32
NChannelsPerNetPeer int32
NvlinkCentricSched int32
GraphUsageMode int32
NumRmaCtx int32
MaxP2pPeers int32
GraphStreamOrdering int32
LaunchOrderImplicit int32
NumRmaSig int32
RmaEagerInit int32
HostCftMode int32
}
Config represents communicator configuration.
Users can assign value to attributes to specify the behavior of a communicator.
The zero value is not usable. Use NewConfig to get a valid initializer.
func NewConfig ¶
func NewConfig() Config
NewConfig returns a Config initialized the way NCCL_CONFIG_INITIALIZER does.
The zero value is not usable. The library validates the size, magic and version this sets and rejects a descriptor without them, and it reads the version to decide which fields it may write. Set workload fields on the result rather than building a Config literal.
type ConfigExt ¶
ConfigExt represents a single vendor-specific option expressed as a key-value pair.
Multiple options can be chained into a non-circular linked list through the next pointer and attached to a CollConfig via its ext member. The official NCCL library ignores every extension; a vendor library should assign a unique value to key.vendorId to avoid collision among vendor libraries. It can usually be done by picking a random number. Vendors should choose a non-zero vendorId (less than 2^24) that is unlikely to collide with other vendor libraries. The list is unordered and must not contain duplicate keys.
type DataType ¶
type DataType int32
DataType represents the integral and floating data-types that NCCL defines.
const ( Int8 DataType = 0 // Signed 8-bits integer Char DataType = 0 // Signed 8-bits integer Uint8 DataType = 1 // Unsigned 8-bits integer Int32 DataType = 2 // Signed 32-bits integer Int DataType = 2 // Signed 32-bits integer Uint32 DataType = 3 // Unsigned 32-bits integer Int64 DataType = 4 // Signed 64-bits integer Uint64 DataType = 5 // Unsigned 64-bits integer Float16 DataType = 6 // 16-bits floating point number (half precision) Half DataType = 6 // 16-bits floating point number (half precision) Float32 DataType = 7 // 32-bits floating point number (single precision) Float DataType = 7 // 32-bits floating point number (single precision) Float64 DataType = 8 // 64-bits floating point number (double precision) Double DataType = 8 // 64-bits floating point number (double precision) Bfloat16 DataType = 9 // 16-bits floating point number (truncated precision in bfloat16 format, CUDA 11 or later) Float8e4m3 DataType = 10 // 8-bits floating point number, 4 exponent bits, 3 mantissa bits (CUDA >= 11.8 and SM >= 90) Float8e5m2 DataType = 11 // 8-bits floating point number, 5 exponent bits, 2 mantissa bits (CUDA >= 11.8 and SM >= 90) NumTypes DataType = 12 )
type DevComm ¶
type DevComm struct {
Magic uint32
Version uint32
Rank int32
NRanks int32
NRanksRcp32 uint32
LsaRank int32
LsaSize int32
LsaSizeRcp32 uint32
WindowTable CPtr
ResourceWindow Window
ResourceWindowInlined ResourcewindowVidmem
HybridDenseGinBarrier GinBarrierHandle
LsaMultimem MultimemHandle
LsaBarrier LsaBarrierHandle
RailGinBarrier GinBarrierHandle
GinConnectionCount uint8
BackendIndex uint8
GinNetDeviceTypes [4]uint8
GinHandles [4]CPtr
GinSignalCount int32
GinCounterCount int32
GinSignalShadows CPtr
GinContextCount uint32
GinConnectionStride int32
GinContextStride int32
GinStrongLegacySignals bool
AbortFlag CPtr
HybridLsaBarrier LsaBarrierHandle
HybridRailGinBarrier GinBarrierHandle
WorldGinBarrier GinBarrierHandle
GinConnectionStrideRcp32 uint32
CftRank int32
CftSize int32
CftMultimemRank int32
CftMultimemSize int32
CftMultimemSizeRcp32 uint32
UcLeId CftLeId
McLeId CftLeId
CftBarrier CftBarrierHandle
CftMultimemBarrier CftBarrierHandle
}
DevComm represents ncclDevComm_t.
type DevCommRequirements ¶
type DevCommRequirements struct {
Size uint
Magic uint32
Version uint32
ResourceRequirementsList *DevResourceRequirements
TeamRequirementsList *TeamRequirements
LsaMultimem bool
BarrierCount int32
LsaBarrierCount int32
RailGinBarrierCount int32
LsaLLA2ABlockCount int32
LsaLLA2ASlotCount int32
GinForceEnable bool
GinContextCount int32
GinSignalCount int32
GinCounterCount int32
GinConnectionType GinConnectionType
GinExclusiveContexts bool
GinQueueDepth int32
GinTrafficClass int32
WorldGinBarrierCount int32
GinStrongSignalsRequired bool
GinVaSignalsRequired bool
GinCustomStride int32
GinType GinType
UseRuntimeVersion bool
CftCaps int32
CftBarrierCount int32
}
DevCommRequirements represents ncclDevCommRequirements_t.
The zero value is not usable. Use NewDevCommRequirements to get a valid initializer.
func NewDevCommRequirements ¶
func NewDevCommRequirements() DevCommRequirements
NewDevCommRequirements returns a DevCommRequirements initialized the way NCCL_DEV_COMM_REQUIREMENTS_INITIALIZER does.
The zero value is not usable. The library validates the size, magic and version this sets and rejects a descriptor without them, and it reads the version to decide which fields it may write. Set workload fields on the result rather than building a DevCommRequirements literal.
type DevCommWindowTable ¶
type DevCommWindowTable uintptr
DevCommWindowTable is an opaque handle for ncclDevCommWindowTable_t.
type DevResourceHandle ¶
type DevResourceHandle uint32
DevResourceHandle identifies storage allocated for a device communicator.
type DevResourceRequirements ¶
type DevResourceRequirements struct {
Next *DevResourceRequirements
BufferSize uint
BufferAlign uint
OutBufferHandle *DevResourceHandle
GinSignalCount int32
GinCounterCount int32
OutGinSignalStart *GinSignal
OutGinCounterStart *GinCounter
}
DevResourceRequirements represents ncclDevResourceRequirements_t.
type GinBarrierHandle ¶
type GinBarrierHandle struct {
Signal0 GinSignal
Unused DevResourceHandle
}
GinBarrierHandle represents ncclGinBarrierHandle_t.
type GinConnectionType ¶
type GinConnectionType int32
GinConnectionType specifies the type of GIN connection for device communicators.
This enum controls whether GIN (GPU-Initiated Networking) resources should be allocated and what connection type to use. Used in ncclDevCommRequirements when creating device communicators. Available since NCCL 2.29.7.
const ( GinConnectionNone GinConnectionType = 0 // No GIN connectivity. GinConnectionFull GinConnectionType = 1 // Full GIN connectivity. Each rank is connected to all other ranks. GinConnectionRail GinConnectionType = 2 // Railed GIN connectivity. Each rank is connected to other ranks in the same rail team. GinConnectionCustomStride GinConnectionType = 3 // Strided GIN connectivity. Each rank is connected to other ranks separated by a fixed stride. Available since NCCL 2.31. Host functions. The following are callable from host code only. They provide host-side access to device pointer functionality, enabling host code to obtain pointers to LSA memory regions. All functions return [Result] error codes. On success, ncclSuccess is returned. On failure, appropriate error codes are returned (e.g., ncclInvalidArgument for invalid parameters, ncclInternalError for internal failures), unless otherwise specified. The returned pointers are valid for the lifetime of the window. Pointers should not be used after either the window or communicator is destroyed. Obtained pointers are device pointers. )
func (GinConnectionType) String ¶
func (e GinConnectionType) String() string
String returns the constant name, or a numeric representation for unknown values.
type GinRequest ¶
type GinRequest struct {
Opaque [2]uint64
}
GinRequest represents ncclGinRequest_t.
type GinType ¶
type GinType int32
GinType represents GIN type.
Communication between different GIN types is not supported. Possible values include:
const ( GinTypeNone GinType = 0 // Sentinel: accept any available backend (used in ncclDevCommRequirements) GinTypeProxy GinType = 2 // intentionally not 1. Must match NCCL_NET_DEVICE_GIN_PROXY for backward compatibility GinTypeGdaki GinType = 3 // intentionally not 2. Must match NCCL_NET_DEVICE_GIN_GDAKI for backward compatibility GinTypeGpi GinType = 4 // Must match NCCL_NET_DEVICE_GIN_GPI GinTypeEfaGda GinType = 5 // Must match NCCL_NET_DEVICE_GIN_EFA_GDA for backward compatibility GinMaxTypes GinType = 6 )
type HostCftMode ¶
type HostCftMode int32
HostCftMode represents values for the hostCftMode communicator configuration.
const ( HostCftDefault HostCftMode = -2147483648 // Use the version-specific default. HostCftEnable HostCftMode = 1 // Enable host-side CFT support. HostCftDisable HostCftMode = 2 // Disable host-side CFT support. HostCftFallback HostCftMode = 3 // Try to create CFT logical endpoints. In case of an error, host-side CFT will be disabled. )
func (HostCftMode) String ¶
func (e HostCftMode) String() string
String returns the constant name, or a numeric representation for unknown values.
type LLA2AHandle ¶
type LLA2AHandle struct {
BufHandle DevResourceHandle
NSlots uint32
}
LLA2AHandle represents ncclLLA2AHandle_t.
type LibraryAttempt ¶
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 libnccl could not be opened. Attempts lists every name tried in order. Path is set when an explicit path, from Load or NCCL_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 LsaBarrierHandle ¶
type LsaBarrierHandle struct {
BufHandle DevResourceHandle
NBarriers int32
}
LsaBarrierHandle represents ncclLsaBarrierHandle_t.
type MemLocationType ¶
type MemLocationType int32
MemLocationType identifies the kind of memory a window segment is backed by.
type MultimemHandle ¶
type MultimemHandle struct {
McBasePtr Buffer
}
MultimemHandle represents ncclMultimemHandle_t.
type ParamHandle ¶
type ParamHandle uintptr
ParamHandle is an opaque handle for ncclParamHandle_t.
func ParamBind ¶
func ParamBind(key string) (ParamHandle, error)
ParamBind looks up the parameter identified by key and returns a handle to it.
The returned handle is owned by the parameter system and must not be freed by the caller. If key does not match any registered parameter, the function returns an ncclInvalidArgument error and the result is left unmodified. key is the canonical name of the parameter (typically the corresponding environment variable name).
Wraps ncclParamBind.
Example ¶
ExampleParamBind reads an NCCL parameter by its environment variable name.
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/nccl"
)
func main() {
p, err := nccl.ParamBind("NCCL_IB_ROCE_VERSION_NUM")
if err != nil {
fmt.Println("bind:", err)
return
}
v, err := p.I32()
if err != nil {
fmt.Println("get:", err)
return
}
fmt.Println("NCCL_IB_ROCE_VERSION_NUM =", v)
}
Output:
func (ParamHandle) Get ¶
Get copies the raw binary representation of the parameter bound to h into the caller-allocated buffer out.
maxLen is the size of out in bytes. The number of bytes actually written is returned in *len. If the parameter’s native representation is larger than maxLen, the function returns ncclInvalidArgument and *len is set to the required size.
Wraps ncclParamGet.
func (ParamHandle) I8 ¶
func (p ParamHandle) I8() (int8, error)
I8 reads the value of the parameter bound to h as the type T and returns it.
Returns ncclInvalidArgument if the parameter value cannot be converted to the requested type. These functions will also return ncclInvalidArgument if h or out is NULL. This function family comes in all combinations of signed (I) and unsigned (U) for 8-, 16-, 32-, and 64-bit integers.
Wraps ncclParamGetI8.
func (ParamHandle) I16 ¶
func (p ParamHandle) I16() (int16, error)
I16 reads the value of the parameter bound to h as the type T and returns it.
Returns ncclInvalidArgument if the parameter value cannot be converted to the requested type. These functions will also return ncclInvalidArgument if h or out is NULL. This function family comes in all combinations of signed (I) and unsigned (U) for 8-, 16-, 32-, and 64-bit integers.
Wraps ncclParamGetI16.
func (ParamHandle) I32 ¶
func (p ParamHandle) I32() (int32, error)
I32 reads the value of the parameter bound to h as the type T and returns it.
Returns ncclInvalidArgument if the parameter value cannot be converted to the requested type. These functions will also return ncclInvalidArgument if h or out is NULL. This function family comes in all combinations of signed (I) and unsigned (U) for 8-, 16-, 32-, and 64-bit integers.
Wraps ncclParamGetI32.
func (ParamHandle) I64 ¶
func (p ParamHandle) I64() (int64, error)
I64 reads the value of the parameter bound to h as the type T and returns it.
Returns ncclInvalidArgument if the parameter value cannot be converted to the requested type. These functions will also return ncclInvalidArgument if h or out is NULL. This function family comes in all combinations of signed (I) and unsigned (U) for 8-, 16-, 32-, and 64-bit integers.
Wraps ncclParamGetI64.
func (ParamHandle) Str ¶
func (p ParamHandle) Str() (string, error)
Str returns a C-style string representation of the parameter bound to h.
The pointer returned is owned by the parameter system and is valid until the next call to ParamHandle.Str on the same thread. Callers that need to retain the value across calls must copy it.
Wraps ncclParamGetStr.
func (ParamHandle) U8 ¶
func (p ParamHandle) U8() (uint8, error)
U8 reads the value of the parameter bound to h as the type T and returns it.
Returns ncclInvalidArgument if the parameter value cannot be converted to the requested type. These functions will also return ncclInvalidArgument if h or out is NULL. This function family comes in all combinations of signed (I) and unsigned (U) for 8-, 16-, 32-, and 64-bit integers.
Wraps ncclParamGetU8.
func (ParamHandle) U16 ¶
func (p ParamHandle) U16() (uint16, error)
U16 reads the value of the parameter bound to h as the type T and returns it.
Returns ncclInvalidArgument if the parameter value cannot be converted to the requested type. These functions will also return ncclInvalidArgument if h or out is NULL. This function family comes in all combinations of signed (I) and unsigned (U) for 8-, 16-, 32-, and 64-bit integers.
Wraps ncclParamGetU16.
func (ParamHandle) U32 ¶
func (p ParamHandle) U32() (uint32, error)
U32 reads the value of the parameter bound to h as the type T and returns it.
Returns ncclInvalidArgument if the parameter value cannot be converted to the requested type. These functions will also return ncclInvalidArgument if h or out is NULL. This function family comes in all combinations of signed (I) and unsigned (U) for 8-, 16-, 32-, and 64-bit integers.
Wraps ncclParamGetU32.
func (ParamHandle) U64 ¶
func (p ParamHandle) U64() (uint64, error)
U64 reads the value of the parameter bound to h as the type T and returns it.
Returns ncclInvalidArgument if the parameter value cannot be converted to the requested type. These functions will also return ncclInvalidArgument if h or out is NULL. This function family comes in all combinations of signed (I) and unsigned (U) for 8-, 16-, 32-, and 64-bit integers.
Wraps ncclParamGetU64.
type RedOp ¶
type RedOp int32
RedOp defines the reduction operation.
const ( Sum RedOp = 0 // Perform a sum (+) operation Prod RedOp = 1 // Perform a product (*) operation Max RedOp = 2 // Perform a max operation Min RedOp = 3 // Perform a min operation Avg RedOp = 4 // Perform an average operation, i.e. a sum across all ranks, divided by the number of ranks. NumOps RedOp = 5 MaxRedOp RedOp = 0x7fffffff >> (32 - 8*4) )
type Registration ¶
type Registration uintptr
Registration identifies a buffer registered with a communicator.
type ResourcewindowVidmem ¶
ResourcewindowVidmem represents ncclResourceWindow_vidmem_t.
type Result ¶
type Result int32
Result represents a nccl API error code (ncclResult_t).
When the library is loaded, Result.Error returns rich messages from GetErrorString. When the library is not loaded, it falls back to the numeric error code and Go-defined name.
const ( Success Result = 0 ErrUnhandledCudaError Result = 1 ErrSystemError Result = 2 ErrInternalError Result = 3 ErrInvalidArgument Result = 4 ErrInvalidUsage Result = 5 ErrRemoteError Result = 6 ErrInProgress Result = 7 ErrTimeout Result = 8 ErrNumResults Result = 9 )
nccl error codes from nccl.h.
type ScalarResidence ¶
type ScalarResidence int32
ScalarResidence indicates where (memory space) scalar arguments reside and when they can be dereferenced.
const ( ScalarDevice ScalarResidence = 0 // The scalar resides on device visible memory and should be dereferenced once needed. ScalarHostImmediate ScalarResidence = 1 // The scalar resides in host memory and should be dereferenced in the most immediate way. )
func (ScalarResidence) String ¶
func (e ScalarResidence) String() string
String returns the constant name, or a numeric representation for unknown values.
type SegmentWindow ¶
type SegmentWindow struct {
GinWins [4]uintptr
SegmentSize uint
MemType MemLocationType
}
SegmentWindow represents ncclSegmentWindow.
type SimInfo ¶
SimInfo will be used by GroupSimulateEnd API to query information about simulation.
The zero value is not usable. Use NewSimInfo to get a valid initializer.
func NewSimInfo ¶
func NewSimInfo() SimInfo
NewSimInfo returns a SimInfo initialized the way NCCL_SIM_INFO_INITIALIZER does.
The zero value is not usable. The library validates the size, magic and version this sets and rejects a descriptor without them, and it reads the version to decide which fields it may write. Set workload fields on the result rather than building a SimInfo literal.
type SymbolError ¶
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.
type TeamRequirements ¶
type TeamRequirements struct {
Next *TeamRequirements
Team Team
Multimem bool
OutMultimemHandle *MultimemHandle
}
TeamRequirements represents ncclTeamRequirements_t.
type UniqueId ¶
type UniqueId struct{ Internal [128]byte }
UniqueId is the fixed-size identifier used to initialize NCCL communicators.
func GetUniqueId ¶
GetUniqueId generates an Id to be used in CommInitRank.
GetUniqueId should be called once when creating a communicator and the Id should be distributed to all ranks in the communicator before calling CommInitRank. uniqueId should point to a UniqueId object allocated by the user.
Wraps ncclGetUniqueId.
type WaitSignalDesc ¶
WaitSignalDesc represents wait Comm.Signal Descriptor.
Describes how many signal operations to wait for from a particular rank on a given signal index and context.
type WinFlags ¶
type WinFlags int32
WinFlags represents window registration flags for Comm.WindowRegister.
const ( WinCollSymmetric WinFlags = 0x01 WinDefault WinFlags = 0x00 WinStrictOrdering WinFlags = 0x02 )
Window registration flags for Comm.WindowRegister.
type Window ¶
type Window uintptr
Window is an opaque handle for ncclWindow_t.
func (Window) CftDeviceLeInfo ¶
func (w Window) CftDeviceLeInfo(offset uint, peerCft int32, cftTeam Team) (leId CftLeId, leOffset uint, err error)
CftDeviceLeInfo returns the logical endpoint, and the offset into it, of a byte offset in the window for a peer in cftTeam.
Host-side query for the logical endpoint leId and leOffset corresponding to window, byte offset, and peerCft within cftTeam.
Wraps ncclGetCftDeviceLeInfo.
func (Window) LsaDevicePointer ¶
LsaDevicePointer returns a load/store accessible pointer to the memory buffer of a specific LSA peer within the window.
This function provides host-side access to LSA pointer functionality using LSA rank directly. window is the NCCL window object (must not be NULL). offset is the byte offset within the window (must be >= 0 and < window size). lsaRank is the LSA rank of the target peer (must be >= 0 and < LSA team size). outPtr is the output parameter for the LSA pointer (must not be NULL). On success, ncclSuccess is returned and the LSA pointer is returned. The window must be registered with a communicator that supports LSA. The LSA rank must be within the valid range for the LSA team, and the target peer must be load/store accessible (P2P connectivity required).
Wraps ncclGetLsaDevicePointer.
func (Window) LsaMultimemDevicePointer ¶
LsaMultimemDevicePointer returns a multimem base pointer for the LSA team associated with the given window.
This function provides host-side access to the multimem memory functionality. window is the NCCL window object (must not be NULL). offset is the byte offset within the window. outPtr is the output parameter for the multimem pointer (must not be NULL). This function requires LSA multimem support (multicast capability on the system). The window must be registered with a communicator that supports symmetric memory, and the hardware must support NVLink SHARP multicast functionality.
Note: If the system does not support multimem, the function returns ncclSuccess with the result set to nullptr. This allows applications to gracefully detect and handle the absence of multimem support without breaking the communicator. Users should check if the returned pointer is nullptr to determine availability.
Wraps ncclGetLsaMultimemDevicePointer.
func (Window) MultimemDeviceLeInfo ¶
MultimemDeviceLeInfo returns the multicast logical endpoint, and the offset into it, of a byte offset in the window.
Host-side query for the multicast logical endpoint leId and leOffset corresponding to window and byte offset.
Wraps ncclGetMultimemDeviceLeInfo.
func (Window) MultimemDevicePointer ¶
func (w Window) MultimemDevicePointer(offset uint, multimem MultimemHandle) (driver.DevicePtr, error)
MultimemDevicePointer returns a multimem base pointer using a provided multimem handle instead of the window’s internal multimem.
This function enables using external or custom multimem handles for pointer calculation. window is the NCCL window object (must not be NULL). offset is the byte offset within the window. multimem is the multimem handle containing the multimem base pointer (multimem.mcBasePtr must not be NULL). outPtr is the output parameter for the multimem pointer (must not be NULL). This function requires LSA multimem support (multicast capability on the system).
Note: If the system does not support multimem, the function returns ncclSuccess with the result set to nullptr. The function validates that multimem.mcBasePtr is not nullptr before proceeding.
Wraps ncclGetMultimemDevicePointer.
func (Window) PeerDeviceLeInfo ¶
func (w Window) PeerDeviceLeInfo(offset uint, peerWorld int32) (leId CftLeId, leOffset uint, err error)
PeerDeviceLeInfo returns the logical endpoint, and the offset into it, of a byte offset in the window for a peer in the world team.
Host-side query for the logical endpoint leId and leOffset corresponding to window, byte offset and peerWorld within the world team.
Wraps ncclGetPeerDeviceLeInfo.
func (Window) PeerDevicePointer ¶
PeerDevicePointer returns a load/store accessible pointer to the memory buffer of a specific world rank peer within the window.
This function converts world rank to LSA rank internally and provides host-side access to peer pointer functionality. window is the NCCL window object (must not be NULL). offset is the byte offset within the window. peer is the world rank of the target peer (must be >= 0 and < communicator size). outPtr is the output parameter for the peer pointer (must not be NULL). On success, ncclSuccess is returned and the peer pointer is returned. If the peer is not reachable via LSA (not in LSA team), the result is NULL and ncclSuccess is returned. This matches the behavior of the device-side ncclGetPeerPointer function. The window must be registered with a communicator that supports LSA. The peer rank must be within the valid range for the communicator, and the target peer must be load/store accessible (P2P connectivity required).
Wraps ncclGetPeerDevicePointer.
Example ¶
ExampleWindow_PeerDevicePointer registers a symmetric window and prints, for each rank, a device pointer this rank can load from and store to. A zero pointer means the peer is not reachable by load/store.
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/nccl"
)
func main() {
var comm nccl.Comm // this rank's communicator, e.g. from CommInitRank
const size = 1 << 20
buf, err := nccl.MemAlloc(size)
if err != nil {
fmt.Println("alloc:", err)
return
}
defer nccl.MemFree(buf)
// WindowRegister is collective: every rank registers its own buffer.
// Outside a group on a blocking communicator, win is set on return.
var win nccl.Window
if err := comm.WindowRegister(buf, size, &win, nccl.WinCollSymmetric); err != nil {
fmt.Println("register:", err)
return
}
defer comm.WindowDeregister(win)
n, err := comm.Count()
if err != nil {
fmt.Println("count:", err)
return
}
for peer := range n {
p, err := win.PeerDevicePointer(0, peer)
if err != nil {
fmt.Println("peer pointer:", err)
return
}
if p == 0 {
fmt.Printf("rank %d: not load/store accessible\n", peer)
continue
}
fmt.Printf("rank %d: %#x\n", peer, p)
}
}
Output:
func (Window) PutSignal ¶
func (w Window) PutSignal(localbuff driver.DevicePtr, count uint, datatype DataType, peer int32, peerWinOffset uint, sigIdx int32, ctx int32, flags uint32, comm Comm, stream driver.Stream) error
PutSignal writes data from localbuff to rank peer’s registered memory window peerWin at offset peerWinOffset and subsequently updating a remote signal.
The target memory window peerWin must be registered using Comm.WindowRegister.
Note: localbuff must currently also be registered with Comm.WindowRegister. This requirement may be relaxed in a future release. The sigIdx is the signal index identifier for the operation. Prior to NCCL 2.31, it must be set to 0. Since NCCL 2.31, it may be set in the range [0, numRmaSig) (see numRmaSig). The ctx selects the communication context. Prior to NCCL 2.31, it must be set to 0. Since NCCL 2.31, it may be set in the range [0, numRmaCtx) (see numRmaCtx). The flags parameter is reserved for future use. It must be set to 0 for now. The return of Window.PutSignal to the CPU thread indicates that the operation has been successfully enqueued to the CUDA stream. At the completion of Window.PutSignal on the CUDA stream, the localbuff is safe to reuse or modify. When a signal is updated on the remote peer, it guarantees that the data from the corresponding Window.PutSignal operation has been delivered to the remote memory. All prior Window.PutSignal and Comm.Signal operations to the same peer and context have also completed their signal updates.
Wraps ncclPutSignal.
type WindowVidmem ¶
type WindowVidmem struct {
WinHost Buffer
LsaFlatBase Buffer
LsaRank int32
WorldRank int32
Stride4G uint32
McOffset4K uint32
GinOffset4K uint32
GinWinsDefaultBackend [4]GinWindow
GinMultiSegmentWins uintptr
NumSegments int32
CftFlatRank int32
}
WindowVidmem represents ncclWindow_vidmem_t.