Anaconda Enterprise: Documentation

# CUDA Libraries Host API

NumbaPro provides binding to cuRAND, cuFFT host API for operation on NumPy arrays.

## cuRAND

Provides pseudo-random number generator (PRNG) and quasi-random generator (QRNG). See NVIDIA cuRAND.

### class PRNG

class `numbapro.cudalib.curand.``PRNG`(*args, **kws)

  cuRAND pseudo random number generator

  Parameters: | rndtype – Algorithm type. All possible values are listed as class attributes of this class, e.g. TEST, DEFAULT, XORWOW, MRG32K3A, MTGP32. seed – Seed for the RNG. offset – Offset to the random number stream. stream – CUDA stream.

  Example:

      >>> from accelerate.cuda import rand
      >>> from numpy import empty
      >>> prng = rand.PRNG(rndtype=rand.PRNG.XORWOW)
      >>> r = empty(10)
      >>> prng.uniform(r)
      >>> r
      array([ ... ])

  `lognormal`(ary, mean, sigma, size=None)
    Generate floating point random number sampled
      from a log-normal distribution and fill into ary.

    Parameters: | ary – Numpy array or cuda device array. mean – Center of the distribution. sigma – Standard deviation of the distribution. size – Number of samples. Default to array size.

  `normal`(ary, mean, sigma, size=None)

    Generate floating point random number sampled from a normal distribution and fill into ary.

    Parameters: | ary – Numpy array or cuda device array. mean – Center of the distribution. sigma – Standard deviation of the distribution. size – Number of samples. Default to array size.

  `poisson`(ary, lmbd, size=None)

    Generate floating point random number sampled from a poisson distribution and fill into ary.

    Parameters: | ary – Numpy array or cuda device array. lmbda – Lambda for the distribution. size – Number of samples. Default to array size.

  `seed`

    Mutatable attribute for the seed for the RNG

  `stream`

    Associate a CUDA stream to the generator object. All subsequent calls will use this stream.

  `uniform`(ary, size=None)
    Generate floating point random number sampled
      from a uniform distribution and fill into ary.

    Parameters: | ary – Numpy array or cuda device array. size – Number of samples. Default to array size.

### class QRNG

class `numbapro.cudalib.curand.``QRNG`(*args, **kws)

  cuRAND quasi random number generator

  Parameters: | rndtype – Algorithm type. Also control output data type. All possible values are listed as class attributes of this class, e.g. TEST, DEFAULT, SOBOL32, SCRAMBLED_SOBOL32, SOBOL64, SCRAMABLED_SOBOL64. ndim – Number of dimension for the QRNG. offset – Offset to the random number stream. stream – CUDA stream.

  `generate`(ary, size=None)

    Generate quasi random number in ary.

    Parameters: | ary – Numpy array or cuda device array. size – Number of samples; Default to array size. Must be multiple of ndim.

  `ndim`

    Mutatable attribute for number of dimension for the QRNG.

  `stream`

    Associate a CUDA stream to the generator object. All subsequent calls will use this stream.

### Top Level PRNG Functions

Simple interface to the PRNG methods.

Note

This methods automatically create a PRNG object.

`numbapro.cudalib.curand.``uniform`(size, dtype=<type 'float'>, device=False)

  Generate floating point random number sampled from a uniform distribution

  Parameters: | size – Number of samples. dtype – np.float32 or np.float64. device – Set to True to return a device array instead or numpy array.
  Returns: | A numpy array or a device array.

      >>> from accelerate.cuda import rand
      >>> rand.uniform(size=10)
      array([...])

  See also

  `accelerate.cuda.rand.PRNG.uniform()`

`numbapro.cudalib.curand.``normal`(mean, sigma, size, dtype=<type 'float'>, device=False)

  Generate floating point random number sampled from a normal distribution

  Parameters: | mean – Center point of the distribution. sigma – Standard deviation of the distribution. size – — Number of samples. dtype – np.float32 or np.float64. device – Set to True to return a device array instead or ndarray.
  Returns: | A numpy array or a device array.

      >>> from accelerate.cuda import rand
      >>> rand.normal(mean=0, sigma=1, size=10)
      array([...])

  See also

  `accelerate.cuda.rand.PRNG.normal()`

`numbapro.cudalib.curand.``lognormal`(mean, sigma, size, dtype=<type 'float'>, device=False)

  Generate floating point random number sampled from a log-normal distribution.

  Parameters: | mean – Center point of the distribution. sigma – Standard deviation of the distribution. size – Number of samples. dtype – np.float32 or np.float64. device – set to True to return a device array instead or ndarray.
  Returns: | A numpy array or a device array.

      >>> from accelerate.cuda import rand
      >>> rand.lognormal(mean=0, sigma=1, size=10)
      array([...])

  See also

  `accelerate.cuda.rand.PRNG.lognormal()`

`numbapro.cudalib.curand.``poisson`(lmbd, size, device=False)

  Generate int32 random number sampled from a poisson distribution.

  Parameters: | lmbda – Lambda of the distribution. size – Number of samples device – Set to True to return a device array instead or ndarray.
  Returns: | A numpy array or a device array.

      >>> from accelerate.cuda import rand
      >>> rand.poisson(lmbd=1, size=10)
      array([...], dtype=uint32)

  See also

  `accelerate.cuda.rand.PRNG.poisson()`

### Top Level QRNG Functions

Simple interface to the QRNG methods.

Note

This methods automatically create a QRNG object.

`numbapro.cudalib.curand.``quasi`(size, bits=32, nd=1, device=False)

  Generate quasi random number using SOBOL{bits} RNG type.

  Parameters: | size – Number of samples. bits – Bit length of output element; e.g. 32 or 64. nd – Number of dimension . device – Set to True to return a device array instead or ndarray.
  Returns: | A numpy array or a device array.

      >>> from accelerate.cuda import rand
      >>> rand.quasi(10)
      array([...], dtype=uint32)

  See also

  `accelerate.cuda.rand.QRNG.generate()`

## cuFFT

Provides FFT and inverse FFT for 1D, 2D and 3D arrays. See NVIDIA cuFFT.

Note

cuFFT only supports FFT operations on numpy.float32, numpy float64, numpy.complex64, numpy.complex128 with C-contiguous datalayout.

### Forward FFT

`numbapro.cudalib.cufft.``fft`(ary, out[, stream])

`numbapro.cudalib.cufft.``fft_inplace`(ary[, stream])

  Parameters: | ary – The input array. The inplace version stores the result in here. out – The output array for non-inplace versions. stream – The CUDA stream in which all operations will take place.

### Inverse FFT

`numbapro.cudalib.cufft.``ifft`(ary, out[, stream])

`numbapro.cudalib.cufft.``ifft_inplace`(ary[, stream])

  Parameters: | ary – The input array. The inplace version stores the result in here. out – The output array for non-inplace versions. stream – The CUDA stream in which all operations will take place.

### FFTPlan

class `numbapro.cudalib.cufft.``FFTPlan`(*args, **kws)

  Parameters: | shape – Input array shape. itype – Input data type. otype – Output data type. batch – Maximum number of operation to perform. stream – A CUDA stream for all the operations to put on. mode – Operation mode; e.g. MODE_NATIVE, MODE_FFTW_PADDING, MODE_FFTW_ASYMMETRIC, MODE_FFTW_ALL, MODE_DEFAULT.

  `forward`(ary, out=None)

    Perform forward FFT

    Parameters: | ary – Input array out – Optional output array
    Returns: | The output array or a new numpy array is out is None.

    Note

    If ary is out, an inplace operation is performed.

  `inverse`(ary, out=None)

    Perform inverse FFT

    Parameters: | ary – Input array out – Optional output array
    Returns: | The output array or a new numpy array is out is None.

## cuBLAS

Provides basic linear algebra building blocks that operates on the CUDA device. See NVIDIA cuBLAS.

The cuBlas binding provides a simpler interface to use NumPy arrays and device arrays. We don’t need special naming convention to identify the array types. Type information are inferred from the given arguments. Arguments for array storage information in cuBLAS C-API are not necessary since NumPy arrays and device arrays already contain the information. Whenever an array is required in an argument, user can pass in NumPy arrays or device arrays. The binding will automatically transfer any NumPy arrays to the device as needed.

class `numbapro.cudalib.cublas.``Blas`(*args, **kws)
  `amax`(x)

    Same as np.argmax(x)

  `amin`(x)

    Same as np.argmin(x)

  `asum`(x)

    Same as np.sum(x)

  `axpy`(alpha, x, y)

    Same as y = alpha * x + y

  `dgmm`(side, m, n, A:r, x:r, C:w)
  `dot`(x, y)

    Compute and return the vector dot product of x and y.

  `dotc`(x, y)

    Same as np.vdot

  `gbmv`(trans, m, n, kl, ku, alpha, A:r, x:r, beta, y:w)
  `geam`(transa, transb, m, n, alpha, A:r, beta, B:r, C:w)
  `gemm`(transa, transb, m, n, k, alpha, A:r, B:r, beta, C:w)
  `gemv`(trans, m, n, alpha, A:r, x:r, beta, y:w)
  `ger`(m, n, alpha, x:r, y:r, A:w)
  `gerc`(m, n, alpha, x:r, y:r, A:w)
  `geru`(m, n, alpha, x:r, y:r, A:w)
  `hbmv`(uplo, n, k, alpha, A:r, x:r, beta, y:w)
  `hemm`(side, uplo, m, n, alpha, A:r, B:r, beta, C:w)
  `hemv`(uplo, n, alpha, A:r, x:r, beta, y:w)
  `her`(uplo, n, alpha, x:r, A:w)
  `her2`(uplo, n, alpha, x:r, y:r, A:w)
  `herk`(uplo, trans, n, k, alpha, A:r, beta, C:w)
  `hpmv`(uplo, n, alpha, AP:r, x:r, beta, y:w)
  `hpr`(uplo, n, alpha, x:r, AP:w)
  `hpr2`(uplo, n, alpha, x:r, y:r, A:w)
  `nrm2`(x)

    Same as np.linalg.norm

  `rot`(x, y, c, s)

    Same as x, y = c * x + s * y, -s * x + c * y

  `rotg`(a, b)

    Compute the given rotation matrix given a column vector (a, b). Returns r, z, c, s.

    r: r = a ** 2 + b ** 2.

    z: Use to recover c and s.

    if abs(z) < 1:
      c, s = 1 - z ** 2, z
    elif abs(z) == 1:
      c, s = 0, 1
    else:
      c, s = 1 / z, 1 - z ** 2

    c: Cosine element of the rotation matrix.

    s: Sine element of the rotation matrix.

  `rotm`(x, y, param)

    Applies the modified Givens transformation.

    x, y = h11 * x + h12 * y, h21 * x + h22 * y

    param — [flag, h11, h21, h12, h22]

    Refer to cuBLAS documentation for detail.

  `rotmg`(d1, d2, x1, y1)

    Constructs the modified Givens transformation.

    Returns param that is usable in rotm.

    Refer to cuBLAS documentation for detail.

  `sbmv`(uplo, n, k, alpha, A:r, x:r, beta, y:w)
  `scal`(alpha, x)

    Same as x = alpha * x

  `spmv`(uplo, n, alpha, AP:r, x:r, beta, y:w)
  `spr`(uplo, n, alpha, x:r, AP:w)
  `spr2`(uplo, n, alpha, x:r, y:r, A:w)
  `symm`(side, uplo, m, n, alpha, A:r, B:r, beta, C:w)
  `symv`(uplo, n, alpha, A:r, x:r, beta, y:w)
  `syr`(uplo, n, alpha, x:r, A:w)
  `syr2`(uplo, n, alpha, x:r, y:r, A:w)
  `syrk`(uplo, trans, n, k, alpha, A:r, beta, C:w)
  `tbmv`(uplo, trans, diag, n, k, A:r, x:w)
  `tbsv`(uplo, trans, diag, n, k, A:r, x:w)
  `tpmv`(uplo, trans, diag, n, AP:r, x:w)
  `tpsv`(uplo, trans, diag, n, AP:r, x:w)
  `trmm`(side, uplo, trans, diag, m, n, alpha, A:r, B:r, C:w)
  `trmv`(uplo, trans, diag, n, A:r, x:w)
  `trsm`(side, uplo, trans, diag, m, n, alpha, A:r, B:w)
  `trsv`(uplo, trans, diag, n, A:r, x:w)

### BLAS Level 1

`numbapro.cudalib.cublas.Blas.``nrm2`(x)

  Computes the L2 norm for array x. Same as numpy.linalg.norm(x).

  Parameters: | x (array) – input vector
  Returns: | resulting norm.

`numbapro.cudalib.cublas.Blas.``dot`(x, y)

  Compute the dot product of array x and array y. Same as np.dot(x, y).

  Parameters: | x (array) – vector y (array) – vector
  Returns: | dot product of x and y

`numbapro.cudalib.cublas.Blas.``dotu`(x, y)

  Deprecated since version 0.21.0: Use `dot()` instead.

  Compute the dot product of array x and array y for complex dtype only. Same as np.dot(x, y).

  Parameters: | x (array) – vector y (array) – vector
  Returns: | dot product of x and y

`numbapro.cudalib.cublas.Blas.``dotc`(x, y)

  Uses the conjugate of the element of the vectors to compute the dot product of array x and array y for complex dtype only. Same as np.vdot(x, y).

  Parameters: | x (array) – vector y (array) – vector
  Returns: | dot product of x and y

`numbapro.cudalib.cublas.Blas.``scal`(alpha, x)

  Scale x inplace by alpha. Same as x = alpha * x

  Parameters: | alpha – scalar x (array) – vector

`numbapro.cudalib.cublas.Blas.``axpy`(alpha, x)

  Compute y = alpha * x + y inplace.

  Parameters: | alpha – scalar x (array) – vector

`numbapro.cudalib.cublas.Blas.``amax`(x)

  Find the index of the first largest element in array x. Same as np.argmax(x)

  Parameters: | x (array) – vector
  Returns: | index (start from 0).

`numbapro.cudalib.cublas.Blas.``amin`(x)

  Find the index of the first largest element in array x. Same as np.argmin(x)

  Parameters: | x (array) – vector
  Returns: | index (start from 0).

`numbapro.cudalib.cublas.Blas.``asum`(x)

  Compute the sum of all element in array x.

  Parameters: | x (array) – vector
  Returns: | x.sum()

`numbapro.cudalib.cublas.Blas.``rot`(x, y, c, s)

  Apply the Givens rotation matrix specified by the cosine element c and the sine element s inplace on vector element x and y.

  Same as x, y = c * x + s * y, -s * x + c * y

  Parameters: | x (array) – vector y (array) – vector

`numbapro.cudalib.cublas.Blas.``rotg`(a, b)

  Constructs the Givens rotation matrix with the column vector (a, b).

  Parameters: | a (scalar) – first element of the column vector b (scalar) – second element of the column vector
  Returns: | a tuple (r, z, c, s) r – r = a**2 + b**2 z – Use to reconstruct c and s. Refer to cuBLAS documentation for detail. c – The consine element. s – The sine element.

`numbapro.cudalib.cublas.Blas.``rotm`(x, y, param)

  Applies the modified Givens transformation inplace.

  Same as:

      param = flag, h11, h21, h12, h22
      x[i] = h11 * x[i] + h12 * y[i]
      y[i] = h21 * x[i] + h22 * y[i]

  Refer to the cuBLAS documentation for the use of flag.

  Parameters: | x (array) – vector y (array) – vector

`numbapro.cudalib.cublas.Blas.``rotmg`(d1, d2, x1, y1)

  Constructs the modified Givens transformation H that zeros out the second entry of a column vector (d1 * x1, d2 * y1).

  Parameters: | d1 (scalar) – d2 (scalar) – x1 (scalar) – y1 (scalar) –
  Returns: | A 1D array that is usable in rotm. The first element is the flag for rotm. The rest of the elements corresponds to the h11, h21, h12, h22 elements of H.

### BLAS Level 2

All level 2 routines follow the following naming convention for all arguments:

- A, B, C, AP – (2D array) Matrix argument.

    AP implies packed storage for banded matrix.

- x, y, z – (1D arrays) Vector argument.

- alpha, beta – (scalar) Can be floats or complex numbers depending.

- m – (scalar) Number of rows of matrix A.

- n – (scalar) Number of columns of matrix A. If m is not needed,

    n also means the number of rows of the matrix A; thus, implying a square matrix.

- trans, transa, transb – (string)

    ‘N’ means the non-transpose operation is selected; ‘T’ means the transpose operation is selected; ‘C’ means the conjugate transpose operation is selected. trans only applies to the only matrix argument. transa and transb apply to matrix A and matrix B, respectively.

- uplo – (string) Can be ‘U’ for filling the upper trianglar matrix; or ‘L’ for

    filling the lower trianglar matrix.

- diag – (boolean) Whether the matrix diagonal has unit elements.

- trans – CUBLAS_OP_MAP

- mode – (string) ‘L’ means the matrix is on the left side in the equation.

    ‘R’ means the matrix is on the right side in the equation.

Note

The last array argument is always overwritten with the result.

`numbapro.cudalib.cublas.Blas.``gbmv`(trans, m, n, kl, ku, alpha, A, x, beta, y')

  banded matrix-vector multiplication y = alpha * op(A) * x + beta * y

`numbapro.cudalib.cublas.Blas.``gemv`(trans, m, n, alpha, A, x, beta, y)

  matrix-vector multiplication y = alpha * op(A) * x + beta * y

`numbapro.cudalib.cublas.Blas.``trmv`(uplo, trans, diag, n, A, x)

  triangular matrix-vector multiplication x = op(A) * x

`numbapro.cudalib.cublas.Blas.``tbmv`(uplo, trans, diag, n, k, A, x)

  triangular banded matrix-vector x = op(A) * x

`numbapro.cudalib.cublas.Blas.``tpmv`(uplo, trans, diag, n, AP, x)

  triangular packed matrix-vector multiplication x = op(A) * x

`numbapro.cudalib.cublas.Blas.``trsv`(uplo, trans, diag, n, A, x)

  Solves the triangular linear system with a single right-hand-side. op(A) * x = b

`numbapro.cudalib.cublas.Blas.``tpsv`(uplo, trans, diag, n, AP, x)

  Solves the packed triangular linear system with a single right-hand-side. op(A) * x = b

`numbapro.cudalib.cublas.Blas.``tbsv`(uplo, trans, diag, n, k, A, x)

  Solves the triangular banded linear system with a single right-hand-side. op(A) * x = b

`numbapro.cudalib.cublas.Blas.``symv`(uplo, n, alpha, A, x, beta, y)

  symmetric matrix-vector multiplication y = alpha * A * x + beta * y

`numbapro.cudalib.cublas.Blas.``hemv`(uplo, n, alpha, A, x, beta, y)

  Hermitian matrix-vector multiplication y = alpha * A * x + beta * y

`numbapro.cudalib.cublas.Blas.``sbmv`(uplo, n, k, alpha, A, x, beta, y)

  symmetric banded matrix-vector multiplication y = alpha * A * x + beta * y

`numbapro.cudalib.cublas.Blas.``hbmv`(uplo, n, k, alpha, A, x, beta, y)

  Hermitian banded matrix-vector multiplication y = alpha * A * x + beta * y

`numbapro.cudalib.cublas.Blas.``spmv`(uplo, n, alpha, AP, x, beta, y)

  symmetric packed matrix-vector multiplication y = alpha * A * x + beta * y

`numbapro.cudalib.cublas.Blas.``hpmv`(uplo, n, alpha, AP, x, beta, y)

  Hermitian packed matrix-vector multiplication y = alpha * A * x + beta * y

`numbapro.cudalib.cublas.Blas.``ger`(m, n, alpha, x, y, A)

  the rank-1 update A := alpha * x * y ** T + A

`numbapro.cudalib.cublas.Blas.``geru`(m, n, alpha, x, y, A)

  the rank-1 update A := alpha * x * y ** T + A

`numbapro.cudalib.cublas.Blas.``gerc`(m, n, alpha, x, y, A)

  the rank-1 update A := alpha * x * y ** H + A

`numbapro.cudalib.cublas.Blas.``syr`(uplo, n, alpha, x, A)

  symmetric rank 1 operation A := alpha * x * x ** T + A

`numbapro.cudalib.cublas.Blas.``her`(uplo, n, alpha, x, A)

  hermitian rank 1 operation A := alpha * x * x ** H + A

`numbapro.cudalib.cublas.Blas.``spr`(uplo, n, alpha, x, AP)

  the symmetric rank 1 operation A := alpha * x * x ** T + A

`numbapro.cudalib.cublas.Blas.``hpr`(uplo, n, alpha, x, AP)

  hermitian rank 1 operation A := alpha * x * x ** H + A

`numbapro.cudalib.cublas.Blas.``syr2`(uplo, n, alpha, x, y, A)

  symmetric rank-2 update A = alpha * x * y ** T + y * x ** T + A

`numbapro.cudalib.cublas.Blas.``her2`(uplo, n, alpha, x, y, A)

  Hermitian rank-2 update A = alpha * x * y ** H + alpha * y * x ** H + A

`numbapro.cudalib.cublas.Blas.``spr2`(uplo, n, alpha, x, y, A)

  packed symmetric rank-2 update A = alpha * x * y ** T + y * x ** T + A

`numbapro.cudalib.cublas.Blas.``hpr2`(uplo, n, alpha, x, y, A)

  packed Hermitian rank-2 update A = alpha * x * y ** H + alpha * y * x ** H + A

### BLAS Level 3

All level 3 routines follow the same naming convention for arguments as in level 2 routines.

`numbapro.cudalib.cublas.Blas.``gemm`(transa, transb, m, n, k, alpha, A, B, beta, C)

  matrix-matrix multiplication C = alpha * op(A) * op(B) + beta * C

`numbapro.cudalib.cublas.Blas.``syrk`(uplo, trans, n, k, alpha, A, beta, C)

  symmetric rank- k update C = alpha * op(A) * op(A) ** T + beta * C

`numbapro.cudalib.cublas.Blas.``herk`(uplo, trans, n, k, alpha, A, beta, C)

  Hermitian rank- k update C = alpha * op(A) * op(A) ** H + beta * C

`numbapro.cudalib.cublas.Blas.``symm`(side, uplo, m, n, alpha, A, B, beta, C)

  symmetric matrix-matrix multiplication:

      if  side == 'L':
          C = alpha * A * B + beta * C
      else:  # side == 'R'
          C = alpha * B * A + beta * C

`numbapro.cudalib.cublas.Blas.``hemm`(side, uplo, m, n, alpha, A, B, beta, C)

  Hermitian matrix-matrix multiplication:

      if  side == 'L':
          C = alpha * A * B + beta * C
      else:   #  side == 'R':
          C = alpha * B * A + beta * C

`numbapro.cudalib.cublas.Blas.``trsm`(side, uplo, trans, diag, m, n, alpha, A, B)

  Solves the triangular linear system with multiple right-hand-sides:

      if  side == 'L':
          op(A) * X = alpha * B
      else:       # side == 'R'
          X * op(A) = alpha * B

`numbapro.cudalib.cublas.Blas.``trmm`(side, uplo, trans, diag, m, n, alpha, A, B, C)

  triangular matrix-matrix multiplication:

      if  side == ':'
          C = alpha * op(A) * B
      else:   # side == 'R'
          C = alpha * B * op(A)

`numbapro.cudalib.cublas.Blas.``dgmm`(side, m, n, A, x, C)

  matrix-matrix multiplication:

      if  mode == 'R':
          C = A * x * diag(X)
      else:       # mode == 'L'
          C = diag(X) * x * A

`numbapro.cudalib.cublas.Blas.``geam`(transa, transb, m, n, alpha, A, beta, B, C)

  matrix-matrix addition/transposition C = alpha * op(A) + beta * op(B)

## cuSPARSE

class `numbapro.cudalib.cusparse.``Sparse`(*args, **kws)

  All cuSPARSE functions are available under the Sparse object.

  Parameters: | idxbase – The base for indexing, either 0 or 1. Optional, defaults to 0.

  `Xcoo2csr`(cooRowInd, nnz, m, csrRowPtr)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-bsr2csr

  `Xcsr2bsrNnz`(dirA, m, n, descrA, csrRowPtrA, csrColIndA, blockDim, descrC, bsrRowPtrC)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csr2bsr

  `Xcsr2coo`(csrRowPtr, nnz, m, cooRowInd)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csr2coo

  `XcsrgeamNnz`(m, n, descrA, nnzA, csrRowPtrA, csrColIndA, descrB, nnzB, csrRowPtrB, csrColIndB, descrC, csrRowPtrC)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrgeam

    Returns: | nnzC
    Return type: | int

  `XcsrgemmNnz`(transA, transB, m, n, k, descrA, nnzA, csrRowPtrA, csrColIndA, descrB, nnzB, csrRowPtrB, csrColIndB, descrC, csrRowPtrC)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrgemm

    Returns: | nnzC
    Return type: | int

  `axpyi`(alpha, xVal, xInd, y)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-axpyi

  `bsrmv`(dir, trans, mb, nb, nnzb, alpha, descr, bsrVal, bsrRowPtr, bsrColInd, blockDim, x, beta, y)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-bsrmv

  `bsrxmv`(dir, trans, sizeOfMask, mb, nb, nnzb, alpha, descr, bsrVal, bsrMaskPtr, bsrRowPtr, bsrEndPtr, bsrColInd, blockDim, x, beta, y)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-bsrxmv

  `csc2dense`(m, n, descrA, cscValA, cscRowIndA, cscColPtrA, A, lda)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csc2dense

  `csr2bsr`(dirA, m, n, descrA, csrValA, csrRowPtrA, csrColIndA, blockDim, descrC, bsrValC, bsrRowPtrC, bsrColIndC)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csr2bsr

  `csr2csc`(m, n, nnz, csrVal, csrRowPtr, csrColInd, cscVal, cscRowInd, cscColPtr, copyValues)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csr2csc

  `csr2dense`(m, n, descrA, csrValA, csrRowPtrA, csrColIndA, A, lda)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csr2dense

  `csrgeam`(m, n, alpha, descrA, nnzA, csrValA, csrRowPtrA, csrColIndA, beta, descrB, nnzB, csrValB, csrRowPtrB, csrColIndB, descrC, csrValC, csrRowPtrC, csrColIndC)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrgeam

  `csrgemm`(transA, transB, m, n, k, descrA, nnzA, csrValA, csrRowPtrA, csrColIndA, descrB, nnzB, csrValB, csrRowPtrB, csrColIndB, descrC, csrValC, csrRowPtrC, csrColIndC)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrgemm

  `csrgemm_ez`(matA, matB, transA='N', transB='N', descrA=None, descrB=None, descrC=None)

    Raises ValueError if the result is entirely zero.

    Returns: | a csr matrix of the matrix product (matA * matB).
    Return type: | CudaSparseMatrix

    Notes

    Calls XcsrgemmNnz and csrgemm

  `csric0`(trans, m, descr, csrValM, csrRowPtrA, csrColIndA, info)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csric0

  `csrilu0`(trans, m, descr, csrValM, csrRowPtrA, csrColIndA, info)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrilu0

  `csrmm`(transA, m, n, k, nnz, alpha, descrA, csrValA, csrRowPtrA, csrColIndA, B, ldb, beta, C, ldc)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrmm

  `csrmm2`(transA, transB, m, n, k, nnz, alpha, descrA, csrValA, csrRowPtrA, csrColIndA, B, ldb, beta, C, ldc)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrmm2

  `csrmv`(trans, m, n, nnz, alpha, descr, csrVal, csrRowPtr, csrColInd, x, beta, y)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrmv

  `csrsm_analysis`(transA, m, nnz, descrA, csrValA, csrRowPtrA, csrColIndA)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrsmanalysis

  `csrsm_solve`(transA, m, n, alpha, descrA, csrValA, csrRowPtrA, csrColIndA, info, X, ldx, Y, ldy)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrsmsolve

  `csrsv_analysis`(trans, m, nnz, descr, csrVal, csrRowPtr, csrColInd)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrsvanalysis

    Returns: |
    Return type: | SolveAnalysisInfo

  `csrsv_solve`(trans, m, alpha, descr, csrVal, csrRowPtr, csrColInd, info, x, y)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrsvsolve

  `dense2csc`(m, n, descrA, A, lda, nnzPerCol, cscValA, cscRowIndA, cscColPtrA)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-dense2csc

  `dense2csr`(m, n, descrA, A, lda, nnzPerRow, csrValA, csrRowPtrA, csrColIndA)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-dense2csr

    Returns: | nnzTotalDevHostPtr
    Return type: | int

  `dotci`(xVal, xInd, y)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-dotci

  `doti`(xVal, xInd, y)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-doti

  `gthr`(y, xVal, xInd)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-gthr

  `gthrz`(y, xVal, xInd)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-gthrz

  `gtsv`(m, n, dl, d, du, B, ldb)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-gtsv

  `gtsvStridedBatch`(m, dl, d, du, x, batchCount, batchStride)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-gtsvstridedbatch

  `gtsv_nopivot`(m, n, dl, d, du, B, ldb)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-gtsv_nopivot

  `nnz`(dirA, m, n, descrA, A, lda, nnzPerRowCol)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-nnz

  `roti`(xVal, xInd, y, c, s)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-roti

  `sctr`(xVal, xInd, y)

    http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-sctr

## Sorting

NumbaPro provides host-side sorting routines.

### Sorting Large Arrays

The `RadixSort` class is recommended for sorting large (approx. more than 1 million items) arrays of numeric types.

class `numbapro.cudalib.sorting.``RadixSort`(maxcount, dtype, descending=False, stream=0)

  Provides radix sort and radix select.

  The algorithm implemented here is best for large arrays (`N > 1e6`) due to the latency introduced by its use of multiple kernel launches. It is recommended to use `segmented_sort` instead for batches of smaller arrays.

  Parameters: | maxcount (int) – Maximum number of items to sort dtype (numpy.dtype) – The element type to sort descending (bool) – Sort in descending order? stream – The CUDA stream to run the kernels in

  `argselect`(k, keys, begin_bit=0, end_bit=None)

    Similar to `RadixSort.select` but returns the new sorted indices.

    Parameters: | keys (numpy.ndarray) – Keys to sort inplace begin_bit (int) – The first bit to sort end_bit (int) – Optional. The last bit to sort
    Returns: | The indices indicating the new ordering as an array on the CUDA device or on the host.

  `argsort`(keys, begin_bit=0, end_bit=None)

    Similar to `RadixSort.sort` but returns the new sorted indices.

    Parameters: | keys (numpy.ndarray) – Keys to sort inplace begin_bit (int) – The first bit to sort end_bit (int) – Optional. The last bit to sort
    Returns: | The indices indicating the new ordering as an array on the CUDA device or on the host.

  `close`()

    Explicitly release internal resources

    Called automatically when the object is deleted.

  `init_arg`(size)

    Initialize an empty CUDA ndarray of uint32 with ascending integers starting from zero

    Parameters: | size (int) – Number of elements for the output array
    Returns: | An array with values `[0, 1, 2, ...m size - 1 ]`

  `select`(k, keys, vals=None, begin_bit=0, end_bit=None)

    Perform a inplace k-select on `keys`.

    Memory transfer is performed automatically.

    Parameters: | keys (numpy.ndarray) – Keys to sort inplace vals (numpy.ndarray) – Optional. Additional values to be reordered along the sort. It is modified in place. Only the `uint32` dtype is supported in this version. begin_bit (int) – The first bit to sort end_bit (int) – Optional. The last bit to sort

  `sort`(keys, vals=None, begin_bit=0, end_bit=None)

    Perform a inplace sort on `keys`. Memory transfer is performed automatically.

    Parameters: | keys (numpy.ndarray) – Keys to sort inplace vals (numpy.ndarray) – Optional. Additional values to be reordered along the sort. It is modified in place. Only the `uint32` dtype is supported in this version. begin_bit (int) – The first bit to sort end_bit (int) – Optional. The last bit to sort

### Sorting Many Small Arrays

Using `RadixSort` on small (approx. less than 1 million items) arrays has significant overhead due to multiple kernel launch. A better alternative is to use the `segmented_sort()` which uses a single kernel to sort many of small arrays in one batch.

`numbapro.cudalib.sorting.``segmented_sort`(keys, vals, segments, stream=0)

  Performs an inplace sort on small segments (N < 1e6).

  Parameters: | keys (numpy.ndarray) – Keys to sort inplace. vals (numpy.ndarray) – Values to be reordered inplace along the sort. Only the `uint32` dtype is supported in this implementation. segments (numpy.ndarray) – Segment separation location. e.g. `array([3, 6, 8])` for segments of `keys[:3]`, `keys[3:6]`, `keys[6:8]`, `keys[8:]`. stream – Optional. A cuda stream in which the kernels are executed.