Skip to main content

cutensorBlockSparseContract

Function cutensorBlockSparseContract 

Source
pub unsafe extern "C" fn cutensorBlockSparseContract(
    handle: cutensorHandle_t,
    plan: cutensorPlan_t,
    alpha: *const c_void,
    A: *const *const c_void,
    B: *const *const c_void,
    beta: *const c_void,
    C: *const *const c_void,
    D: *const *mut c_void,
    workspace: *mut c_void,
    workspaceSize: u64,
    stream: cudaStream_t,
) -> cutensorStatus_t
Expand description

This routine computes the block-sparse tensor contraction $D = alpha \* A \* B + beta \* C$.

$$ \mathcal{D}{{modes}\mathcal{D}} \gets \alpha \* \mathcal{A}{{modes}\mathcal{A}} B_{{modes}\mathcal{B}} + \beta \mathcal{C}{{modes}_\mathcal{C}} $$ The active CUDA device must match the CUDA device that was active at the time at which the plan was created.

The array-parameters A, B, C, and D are host-arrays containing pointers to GPU-accessible memory. For example, A is a host-array whose size equals the number of non-zero blocks in tensor $\mathcal{A}$. A[i] is a pointer to the GPU-accessible memory location of block number i of $\mathcal{A}$. The blocks are numbered in the same way as in the construction of $\mathcal{A}$’s block-sparse tensor descriptor. The same analogously holds for the other array-parameters B, C, and D.

§Parameters

  • handle: Opaque handle holding cuTENSOR’s library context.
  • plan: Opaque handle holding the contraction execution plan (created by cutensorCreateBlockSparseContraction followed by cutensorCreatePlan).
  • alpha: Scaling for A*B. Its data type is determined by ‘descCompute’ (see cutensorCreateBlockSparseContraction). Pointer to host memory.
  • A: Host-array of size numNonZeroBlocks(A), containing pointers to GPU-accessible memory, corresponding the blocks of A. The data accessed via these pointers must not overlap with the elements written to D.
  • B: Host-array of size numNonZeroBlocks(B), containing pointers to GPU-accessible memory, corresponding the blocks of B. The data accessed via these pointers must not overlap with the elements written to D.
  • beta: Scaling for C. Its data type is determined by ‘descCompute’ (see cutensorCreateBlockSparseContraction). Pointer to host memory.
  • C: Host-array of size numNonZeroBlocks(C), containing pointers to GPU-accessible memory, corresponding the blocks of C.
  • D: Host-array of size numNonZeroBlocks(D), containing pointers to GPU-accessible memory, corresponding the blocks of D.
  • workspace: This pointer provides the required workspace in device memory. The workspace must be aligned to 256 bytes (i.e., the default alignment of cudaMalloc).
  • workspaceSize: Size of the workspace array in bytes; please refer to cutensorEstimateWorkspaceSize to query the required workspace. For block-sparse contractions, this estimate is exact.
  • stream: The CUDA stream to which all of the computation is synchronised.

§Return value