The nvmath.device module is experimental and potentially subject to future changes.

Device API utilities (nvmath.device)#

Overview#

nvmath-python provides the following device-side utilities.

Note

For most use cases, prefer the Complex and Vector types and their instances (complex32, complex64, complex128, half2, and half4). During compilation, they resolve automatically to the matching underlying type: with numba-cuda, the vector types provided by nvmath-python, and with numba-cuda-mlir, the compiler’s native complex and vector types.

They also carry a host-side numpy dtype (the dtype property), so they can be used for host allocation as well.

The remaining Numba vector types (float16x2 to uint32x4 and their *_type variants) are supported only with the numba-cuda compiler. nvmath-python provides them because numba-cuda does not expose all of the required vector types (for example, the float16 vectors). The numba-cuda-mlir compiler exposes all of them in the numba_cuda_mlir.cuda.vector_types module, so the nvmath-python ones are neither needed nor supported there.

See Supported Compilers for an overview of the compiler support.

API Reference#

current_device_lto()

A helper function to get the default code type for link time optimization (LTO) on the current device.

current_device_sm()

A helper function to get the default SM for mathdx types on the current device.

Complex(real_dtype)

Complex type that can be used to represent complex numbers both on host and device side.

Vector(real_dtype, size)

Vector type that can be used to represent vector values both on host and device side.

complex32

Complex type that can be used to represent complex numbers both on host and device side.

complex64

Complex type that can be used to represent complex numbers both on host and device side.

complex128

Complex type that can be used to represent complex numbers both on host and device side.

np_float16x2

NumPy dtype object that encapsulates the np in device.

np_float16x4

NumPy dtype object that encapsulates the np in device.

half2

Vector type that can be used to represent vector values both on host and device side.

half4

Vector type that can be used to represent vector values both on host and device side.

float16x2(x, y)

A Numba-compliant vector object for float16 with vector length 2.

float16x2_type

Numba type of float16x2.

float16x4(x, y, z, w)

A Numba-compliant vector object for float16 with vector length 4.

float16x4_type

Numba type of float16x4.

float32x2(x, y)

A Numba-compliant vector object for float32 with vector length 2.

float32x2_type

Numba type of float32x2.

float32x4(x, y, z, w)

A Numba-compliant vector object for float32 with vector length 4.

float32x4_type

Numba type of float32x4.

float64x2(x, y)

A Numba-compliant vector object for float64 with vector length 2.

float64x2_type

Numba type of float64x2.

float64x4(x, y, z, w)

A Numba-compliant vector object for float64 with vector length 4.

float64x4_type

Numba type of float64x4.

uint32x4(x, y, z, w)

A Numba-compliant vector object for uint32 with vector length 4.

uint32x4_type

Numba type of uint32x4.

ISAVersion(major, minor)

A namedtuple class that encapsulates the code version.

Code(code_type, isa_version, data)

A namedtuple class that encapsulates code type, version, and buffer.

CodeType(kind, cc)

A namedtuple class that encapsulates code kind and compute capability.

ComputeCapability(major, minor[, arch])

A namedtuple class that encapsulates the major and minor compute capability.

Dim3([x, y, z])

A namedtuple class that encapsulates the dimensions for grids and blocks.