» 1. Introduction v13.0 | PDF | Archive cuBLAS The API Reference guide for cuBLAS, the CUDA Basic Linear Algebra Subroutine library. 1. Introduction The cuBLAS library is an implementation of BLAS (Basic Linear Algebra Subprograms) on top of the NVIDIA®CUDA™ runtime. It allows the user to access the computational resources of NVIDIA Graphics Processing Unit (GPU). The cuBLAS Library exposes four sets of APIs: The cuBLAS API, which is simply called cuBLAS API in this document (starting with CUDA 6.0), The cuBLASXt API (starting with CUDA 6.0), and The cuBLASLt API (starting with CUDA 10.1) The cuBLASDx API (not shipped with the CUDA Toolkit) To use the cuBLAS API, the application must allocate the required matrices and vectors in the GPU memory space, fill them with data, call the sequence of desired cuBLAS functions, and then upload the results from the GPU memory space back to the host. The cuBLAS API also provides helper functions for writing and retrieving data from the GPU. To use the cuBLASXt API, the application may have the data on the Host or any of the devices involved in the computation, and the Library will take care of dispatching the operation to, and transferring the data to, one or multiple GPUs present in the system, depending on the user request. The cuBLASLt is a lightweight library dedicated to GEneral Matrix-to-matrix Multiply (GEMM) operations with a new flexible API. This library adds flexibility in matrix data layouts, input types, compute types, and also in choosing the algorithmic implementations and heuristics through parameter programmability. After a set of options for the intended GEMM operation are identified by the user, these options can be used repeatedly for different inputs. This is analogous to how cuFFT and FFTW first create a plan and reuse for same size and type FFTs with different input data. 1.1. Data Layout For maximum compatibility with existing Fortran environments, the cuBLAS library uses column-major storage, and 1-based indexing. Since C and C++ use row-major storage, applications written in these languages can not use the native array semantics for two-dimensional arrays. Instead, macros or inline functions should be defined to implement matrices on top of one-dimensional arrays. For Fortran code ported to C in mechanical fashion, one may chose to retain 1-based indexing to avoid the need to transform loops. In this case, the array index of a matrix element in row “i” and column “j” can be computed via the following macro #define IDX2F(i,j,ld) ((((j)-1)\*(ld))+((i)-1)) Here, ld refers to the leading dimension of the matrix, which in the case of column-major storage is the number of rows of the allocated matrix (even if only a submatrix of it is being used). For natively written C and C++ code, one would most likely choose 0-based indexing, in which case the array index of a matrix element in row “i” and column “j” can be computed via the following macro #define IDX2C(i,j,ld) (((j)\*(ld))+(i)) 1.2. New and Legacy cuBLAS API Starting with version 4.0, the cuBLAS Library provides a new API, in addition to the existing legacy API. This section discusses why a new API is provided, the advantages of using it, and the differences with the existing legacy API. Warning The legacy cuBLAS API is deprecated and will be removed in future release. The new cuBLAS library API can be used by including the header file cublas\_v2.h. It has the following features that the legacy cuBLAS API does not have: The handle to the cuBLAS library context is initialized using the function and is explicitly passed to every subsequent library function call. This allows the user to have more control over the library setup when using multiple host threads and multiple GPUs. This also allows the cuBLAS APIs to be reentrant. The scalars \\(\\alpha\\) and \\(\\beta\\) can be passed by reference on the host or the device, instead of only being allowed to be passed by value on the host. This change allows library functions to execute asynchronously using streams even when \\(\\alpha\\) and \\(\\beta\\) are generated by a previous kernel. When a library routine returns a scalar result, it can be returned by reference on the host or the device, instead of only being allowed to be returned by value only on the host. This change allows library routines to be called asynchronously when the scalar result is generated and returned by reference on the device resulting in maximum parallelism. The error status cublasStatus\_t is returned by all cuBLAS library function calls. This change facilitates debugging and simplifies software development. Note that cublasStatus was renamed cublasStatus\_t to be more consistent with other types in the cuBLAS library. The cublasAlloc() and cublasFree() functions have been deprecated. This change removes these unnecessary wrappers around cudaMalloc() and cudaFree(), respectively. The function cublasSetKernelStream() was renamed cublasSetStream() to be more consistent with the other CUDA libraries. The legacy cuBLAS API, explained in more detail in Using the cuBLAS Legacy API, can be used by including the header file cublas.h. Since the legacy API is identical to the previously released cuBLAS library API, existing applications will work out of the box and automatically use this legacy API without any source code changes. The current and the legacy cuBLAS APIs cannot be used simultaneously in a single translation unit: including both cublas.h and cublas\_v2.h header files will lead to compilation errors due to incompatible symbol redeclarations. In general, new applications should not use the legacy cuBLAS API, and existing applications should convert to using the new API if it requires sophisticated and optimal stream parallelism, or if it calls cuBLAS routines concurrently from multiple threads. For the rest of the document, the new cuBLAS Library API will simply be referred to as the cuBLAS Library API. As mentioned earlier the interfaces to the legacy and the cuBLAS library APIs are the header file cublas.h and cublas\_v2.h, respectively. In addition, applications using the cuBLAS library need to link against: The DSO cublas.so for Linux, The DLL cublas.dll for Windows, or The dynamic library cublas.dylib for Mac OS X. Note The same dynamic library implements both the new and legacy cuBLAS APIs. 1.3. Example Code For sample code references please see the two examples below. They show an application written in C using the cuBLAS library API with two indexing styles (Example 1. “Application Using C and cuBLAS: 1-based indexing” and Example 2. “Application Using C and cuBLAS: 0-based Indexing”). //Example 1. Application Using C and cuBLAS: 1-based indexing //----------------------------------------------------------- #include #include #include #include #include "cublas\_v2.h" #define M 6 #define N 5 #define IDX2F(i,j,ld) ((((j)-1)\*(ld))+((i)-1)) static \_\_inline\_\_ void modify (cublasHandle\_t handle, float \*m, int ldm, int n, int p, int q, float alpha, float beta){ cublasSscal (handle, n-q+1, &alpha, &m\[IDX2F(p,q,ldm)\], ldm); cublasSscal (handle, ldm-p+1, &beta, &m\[IDX2F(p,q,ldm)\], 1); } int main (void){ cudaError\_t cudaStat; cublasStatus\_t stat; cublasHandle\_t handle; int i, j; float\* devPtrA; float\* a = 0; a = (float \*)malloc (M \* N \* sizeof (\*a)); if (!a) { printf ("host memory allocation failed"); return EXIT\_FAILURE; } for (j = 1; j <= N; j++) { for (i = 1; i <= M; i++) { a\[IDX2F(i,j,M)\] = (float)((i-1) \* N + j); } } cudaStat = cudaMalloc ((void\*\*)&devPtrA, M\*N\*sizeof(\*a)); if (cudaStat!= cudaSuccess) { printf ("device memory allocation failed"); free (a); return EXIT\_FAILURE; } stat = cublasCreate(&handle); if (stat!= CUBLAS\_STATUS\_SUCCESS) { printf ("CUBLAS initialization failed\\n"); free (a); cudaFree (devPtrA); return EXIT\_FAILURE; } stat = cublasSetMatrix (M, N, sizeof(\*a), a, M, devPtrA, M); if (stat!= CUBLAS\_STATUS\_SUCCESS) { printf ("data download failed"); free (a); cudaFree (devPtrA); cublasDestroy(handle); return EXIT\_FAILURE; } modify (handle, devPtrA, M, N, 2, 3, 16.0f, 12.0f); stat = cublasGetMatrix (M, N, sizeof(\*a), devPtrA, M, a, M); if (stat!= CUBLAS\_STATUS\_SUCCESS) { printf ("data upload failed"); free (a); cudaFree (devPtrA); cublasDestroy(handle); return EXIT\_FAILURE; } cudaFree (devPtrA); cublasDestroy(handle); for (j = 1; j <= N; j++) { for (i = 1; i <= M; i++) { printf ("%7.0f", a\[IDX2F(i,j,M)\]); } printf ("\\n"); } free(a); return EXIT\_SUCCESS; } //Example 2. Application Using C and cuBLAS: 0-based indexing //----------------------------------------------------------- #include #include #include #include #include "cublas\_v2.h" #define M 6 #define N 5 #define IDX2C(i,j,ld) (((j)\*(ld))+(i)) static \_\_inline\_\_ void modify (cublasHandle\_t handle, float \*m, int ldm, int n, int p, int q, float alpha, float beta){ cublasSscal (handle, n-q, &alpha, &m\[IDX2C(p,q,ldm)\], ldm); cublasSscal (handle, ldm-p, &beta, &m\[IDX2C(p,q,ldm)\], 1); } int main (void){ cudaError\_t cudaStat; cublasStatus\_t stat; cublasHandle\_t handle; int i, j; float\* devPtrA; float\* a = 0; a = (float \*)malloc (M \* N \* sizeof (\*a)); if (!a) { printf ("host memory allocation failed"); return EXIT\_FAILURE; } for (j = 0; j < N; j++) { for (i = 0; i < M; i++) { a\[IDX2C(i,j,M)\] = (float)(i \* N + j + 1); } } cudaStat = cudaMalloc ((void\*\*)&devPtrA, M\*N\*sizeof(\*a)); if (cudaStat!= cudaSuccess) { printf ("device memory allocation failed"); free (a); return EXIT\_FAILURE; } stat = cublasCreate(&handle); if (stat!= CUBLAS\_STATUS\_SUCCESS) { printf ("CUBLAS initialization failed\\n"); free (a); cudaFree (devPtrA); return EXIT\_FAILURE; } stat = cublasSetMatrix (M, N, sizeof(\*a), a, M, devPtrA, M); if (stat!= CUBLAS\_STATUS\_SUCCESS) { printf ("data download failed"); free (a); cudaFree (devPtrA); cublasDestroy(handle); return EXIT\_FAILURE; } modify (handle, devPtrA, M, N, 1, 2, 16.0f, 12.0f); stat = cublasGetMatrix (M, N, sizeof(\*a), devPtrA, M, a, M); if (stat!= CUBLAS\_STATUS\_SUCCESS) { printf ("data upload failed"); free (a); cudaFree (devPtrA); cublasDestroy(handle); return EXIT\_FAILURE; } cudaFree (devPtrA); cublasDestroy(handle); for (j = 0; j < N; j++) { for (i = 0; i < M; i++) { printf ("%7.0f", a\[IDX2C(i,j,M)\]); } printf ("\\n"); } free(a); return EXIT\_SUCCESS; } 1.4. Forward Compatibility cuBLAS library can work on future GPUs in most cases thanks to PTX JIT. However, there are certain limitations: There are no performance guarantees: running on new hardware may be slower despite better theoretical peaks. There is limited forward compatibility for narrow precisions (FP4 and FP8) and tiled 8-bit integer layouts. 1.5. Floating Point Emulation Floating point emulation was first introduced in CUDA 12.9 and is used to further accelerate matrix multiplication for higher precision data types. Floating point emulation works by first transforming the inputs into multiple lower precision values, then leverages lower precision hardware units to compute partial results, and finally recombines the results back into full precision. These algorithms can provide a significant performance advantage over native precision arithmetic while maintaining the same or better accuracy; however, the results are not IEEE-754 compliant. Floating Point Emulation Support Overview Floating Point Emulation Algorithm Precision Emulated Supported compute capabilities CUDA Version BF16x9 FP32 10.0, 10.3 12.9+ Fixed-Point FP64 8.x, 9.0, 10.0, 11.0, 12.x 13.0u2+ To enable floating point emulation without any code changes, the following environment variables can be used. Floating Point Emulation Environment Variables Environment Variable Description CUBLAS\_EMULATION\_STRATEGY An environment variable for overriding the default emulation strategy. The valid values are performant and eager; see cublasEmulationStrategy\_t for more details. CUBLAS\_EMULATE\_SINGLE\_PRECISION An environment variable for enabling and disabling single precision floating point emulation using the values 1 and 0, respectively. CUBLAS\_EMULATE\_DOUBLE\_PRECISION An environment variable for enabling and disabling double precision floating point emulation using the values 1 and 0, respectively. CUBLAS\_FIXEDPOINT\_EMULATION\_MANTISSA\_BIT\_COUNT The number of mantissa bits to be used for fixed-point emulation. When set, emulated algorithms will use the specified number of mantissa bits. This is equivalent to calling cublasSetFixedPointEmulationMantissaControl() with CUDA\_EMULATION\_MANTISSA\_CONTROL\_FIXED (see cudaEmulationMantissaControl\_t) and cublasSetFixedPointEmulationMaxMantissaBitCount() to the user-provided value. 1.5.1. BF16x9 The BF16x9 algorithm is used for emulating FP32 arithmetic. An FP32 value can be exactly represented as three BF16 values as follows: \\\[\\begin{split}a & = a\_0 + 2^{-8} a\_1 + 2^{-16} a\_2 \\\\\\end{split}\\\] We can fully reconstruct the FP32 value from the BF16 values without any loss of accuracy. Using this, we define an FMA operation (d = ab + c) as follows: \\\[\\begin{split}d & = ab + c \\\\ & = (a\_0 + 2^{-8} a\_1 + 2^{-16} a\_2) \\cdot (b\_0 + 2^{-8} b\_1 + 2^{-16} b\_2) + c \\\\ & = a\_0b\_0 + 2^{-8}a\_0b\_1 + 2^{-16}a\_0b\_2 \\\\ & \\quad + 2^{-8}a\_1b\_0 + 2^{-16}a\_1b\_1 + 2^{-24}a\_1b\_2 \\\\ & \\quad + 2^{-16}a\_2b\_0 + 2^{-24}a\_2b\_1 + 2^{-32}a\_2b\_2 + c \\\\\\end{split}\\\] In practice, the BF16 tensor cores are utilized rather than FMA units and this idea naturally extends into complex arithmetic as well. While BF16x9 can be supported on all hardware, it only provides a performance advantage when peak BF16 throughput is more than nine times greater than peak FP32 throughput. It also requires special hardware features to apply the additional scaling factors in a performant manner. As a result, BF16x9 is only supported on select architectures. See the Floating Point Emulation Support Overview table for more details. 1.5.2. Fixed-Point Fixed-point emulation is used for emulating FP64 arithmetic and follows the Ozaki Scheme. Fixed-point representations emulate floating point through the addition of a shared power of two scaling factor and by encoding the remaining dynamic range of floating point within mantissa bits. The scaling factor is shared for elements in the same row of the A matrix or column of the B matrix and is used to logically scale all elements to be between -1 and 1 inclusively. Due to the large dynamic range of FP64, there is no single configuration of fixed-point which is both performant and accurate for all floating point inputs. Therefore, we enable two flavors of fixed-point emulation: Dynamic Mantissa Control and Fixed Mantissa Control. These configurations can be set with cublasSetFixedPointEmulationMantissaControl(). 1.5.2.1. Dynamic Mantissa Control Dynamic mantissa control represents the cuBLAS library default mantissa control. Our automatic dynamic precision framework computes the proper number of fixed-point mantissa bits required to maintain equal or better accuracy than FP64. If the number of required mantissa bits exceeds a library defined default (see Default Library Configurations) or a user provided maximum number of bits (see cublasSetFixedPointEmulationMaxMantissaBitCount()), the framework dynamically dispatches to native FP64. 1.5.2.2. Fixed Mantissa Control Fixed mantissa control can be leveraged to further accelerate fixed-point emulation. The user can provide the number of mantissa bits for the fixed-point representation via cublasSetFixedPointEmulationMaxMantissaBitCount(); however, without the automatic dynamic precision framework, it is not possible to guarantee equal or better accuracy than FP64 arithmetic. 1.5.2.3. Representation and Mappings The fixed-point representation consists of a shared scaling factor for elements in the same row or column of a matrix, a sign bit, and mantissa bits. We store the sign bit and mantissa bits within 8-bit integers. Each matrix of 8-bit integers are referred to as a slice and the computational cost grows quadratically with the number of slices. The formula to convert mantissa bit count to slice count is as follows: \\\[\\text{sliceCount} = \\text{ceildiv}(\\text{mantissaBitCount} + 1, 8)\\\] Note The number of mantissa bits will always be rounded up to fully occupy the least significant slice 1.5.2.4. Fixed-Point Workspace Requirements To compute with fixed-point emulation, the A and B matrices are translated into a fixed-point representation in workspace memory. This leads to workspace requirements that are problem size and emulation parameter dependent. The following function will provide a safe bound (possibly overestimating) on the workspace required for fixed-point emulation: size\_t getFixedPointWorkspaceSizeInBytes(int m, int n, int k, int batchCount, bool isComplex, cudaEmulationMantissaControl mantissaControl, int maxMantissaBitCount) { constexpr double MULTIPLIER = 1.25; int mult = isComplex? 2: 1; int numSlices = ceildiv(maxMantissaBitCount + 1, 8); int padded\_m = ceildiv(m, 1024) \* 1024; int padded\_n = ceildiv(n, 1024) \* 1024; int padded\_k = ceildiv(k, 128) \* 128; int num\_blocks\_k = ceildiv(k, 64); size\_t gemm\_workspace = sizeof(int8\_t) \* ((size\_t)padded\_m \* padded\_k + (size\_t)padded\_n \* padded\_k) \* mult \* numSlices; gemm\_workspace += sizeof(int32\_t) \* ((size\_t)padded\_m + padded\_n) \* mult; if (isComplex) { gemm\_workspace += sizeof(double) \* (size\_t)m \* n \* mult \* mult; } size\_t adp\_workspace = 0; if (mantissaControl == CUDA\_EMULATION\_MANTISSA\_CONTROL\_DYNAMIC) { adp\_workspace = sizeof(int32\_t) \* ((size\_t)m \* num\_blocks\_k + (size\_t)n \* num\_blocks\_k + (size\_t)m \* n) \* mult; } constexpr size\_t CONSTANT\_SIZE = 128 \* 1024 \* 1024; return (size\_t)(std::max(gemm\_workspace, adp\_workspace) \* batchCount \* MULTIPLIER) + CONSTANT\_SIZE; } This function can be used to manage your own workspace memory with cublasSetWorkspace(), which can be used to guarantee reproducible results and improve performance. 1.5.2.5. Fixed-Point Performance Guide Fixed-point emulation allows users to make performance and precision trade-offs for further acceleration. For dynamic mantissa control, users are able to configure the automatic dynamic precision framework to use fewer or more bits than the accuracy of native FP64 requires with cublasSetFixedPointEmulationMantissaBitOffset(). Fixed mantissa control can be similarly tuned by increasing or decreasing the number of mantissa bits with cublasSetFixedPointEmulationMaxMantissaBitCount(). Due to the large fixed-point workspace requirements, asynchronous allocation is done with cudaMallocAsync(). In cases where not enough GEMMs are called to amortize the cost of memory allocation, or very frequent CUDA stream synchronization occurs, you can improve performance by: Reducing the number of CUDA stream synchronizations Managing your own memory and providing workspace with cublasSetWorkspace() Allowing the default memory pool to retain memory between synchronizations 1.5.3. Default Library Configurations Library default values for emulation are subject to change. Emulation Configuration Default Values API Mantissa Control Default Behavior cublasGetEmulationStrategy() Not applicable CUBLAS\_EMULATION\_STRATEGY\_DEFAULT cublasGetEmulationSpecialValuesSupport() Not applicable CUBLAS\_EMULATION\_SPECIAL\_VALUES\_SUPPORT\_DEFAULT cublasGetFixedPointEmulationMantissaControl() Not applicable CUDA\_EMULATION\_MANTISSA\_CONTROL\_DYNAMIC cublasGetFixedPointEmulationMaxMantissaBitCount() CUDA\_EMULATION\_MANTISSA\_CONTROL\_DYNAMIC 79 cublasGetFixedPointEmulationMaxMantissaBitCount() CUDA\_EMULATION\_MANTISSA\_CONTROL\_FIXED 55 cublasGetFixedPointEmulationMantissaBitOffset() Not applicable 0 cublasGetFixedPointEmulationMantissaBitCountPointer() Not applicable NULL 1.5.4. Support For Floating Point Special Values The implementations of floating point emulation algorithms maintain the accuracy of the emulated precision for both normal and denormalized values but may not adhere to the IEEE-754 standard with respect to \\(\\text{Inf}\\), \\(\\text{NaN}\\), or signed zeros. If the underlying emulated algorithm cannot implicitly support a given special value, and the library is configured to support it (see cublasSetEmulationSpecialValuesSupport()), then extra steps are taken to support it. The following table shows which special values are implicitly supported for each emulation algorithm. Emulation Algorithms Implicit Special Values Support Floating Point Emulation Algorithm Implicitly Supported Special Values BF16x9 \\(\\text{NaN}\\) Fixed-Point None 2. Using the cuBLAS API 2.1. General Description This section describes how to use the cuBLAS library API. 2.1.1. Error Status All cuBLAS library function calls return the error status cublasStatus\_t. 2.1.2. cuBLAS Context The application must initialize a handle to the cuBLAS library context by calling the cublasCreate() function. Then, the handle is explicitly passed to every subsequent library function call. Once the application finishes using the library, it must call the function cublasDestroy() to release the resources associated with the cuBLAS library context. This approach allows the user to explicitly control the library setup when using multiple host threads and multiple GPUs. For example, the application can use cudaSetDevice() to associate different devices with different host threads and in each of those host threads it can initialize a unique handle to the cuBLAS library context, which will use the particular device associated with that host thread. Then, the cuBLAS library function calls made with different handles will automatically dispatch the computation to different devices. The device associated with a particular cuBLAS context is assumed to remain unchanged between the corresponding cublasCreate() and cublasDestroy() calls. In order for the cuBLAS library to use a different device in the same host thread, the application must set the new device to be used by calling cudaSetDevice() and then create another cuBLAS context, which will be associated with the new device, by calling cublasCreate(). When multiple devices are available, applications must ensure that the device associated with a given cuBLAS context is current (e.g. by calling cudaSetDevice()) before invoking cuBLAS functions with this context. A cuBLAS library context is tightly coupled with the CUDA context that is current at the time of the cublasCreate() call. An application that uses multiple CUDA contexts is required to create a cuBLAS context per CUDA context and make sure the former never outlives the latter. Starting from version 12.8, cuBLAS detects if the underlying CUDA context is tied to a graphics context and follows the shared memory size limits that are set in such case. 2.1.3. Thread Safety The library is thread safe and its functions can be called from multiple host threads, even with the same handle. When multiple threads share the same handle, extreme care needs to be taken when the handle configuration is changed because that change will affect potentially subsequent cuBLAS calls in all threads. It is even more true for the destruction of the handle. So it is not recommended that multiple thread share the same cuBLAS handle. Additional considerations apply when the same handle is used from multiple threads with a user provided workspace. See cublasSetWorkspace() for details. 2.1.4. Results Reproducibility By design, all cuBLAS API routines from a given toolkit version, generate the same bit-wise results at every run when executed on GPUs with the same architecture and the same number of SMs. However, bit-wise reproducibility is not guaranteed across toolkit versions because the implementation might differ due to some implementation changes. This guarantee no longer holds when multiple CUDA streams are active or fixed-point emulation is used. If multiple concurrent streams are active, the library may optimize total performance by picking different internal implementations. Note The non-deterministic behavior of multi-stream execution is due to library optimizations in selecting internal workspace for the routines running in parallel streams. To avoid this effect user can either: provide a separate workspace for each used stream using the cublasSetWorkspace() function, or have one cuBLAS handle per stream, or use cublasLtMatmul() instead of GEMM-family of functions and provide user owned workspace, or set a debug environment variable CUBLAS\_WORKSPACE\_CONFIG to:16:8 (may limit overall performance) or:4096:8 (will increase library footprint in GPU memory by approximately 24MiB). The non-deterministic behavior of fixed-point emulation is due to the large workspace memory requirements (see Fixed-Point Workspace Requirements for details). This requires dynamically allocating memory with cudaMallocAsync() and allocation failures result in fallbacks to non-emulated routines. To avoid this effect, users can provide workspace via cublasSetWorkspace() to meet fixed-point emulation workspace requirements. Any of those settings will allow for deterministic behavior even with multiple concurrent streams sharing a single cuBLAS handle. This behavior is expected to change in a future release. For some routines such as cublas symv() and cublas hemv(), an alternate significantly faster routine can be chosen using the routine cublasSetAtomicsMode(). In that case, the results are not guaranteed to be bit-wise reproducible because atomics are used for the computation. 2.1.5. Scalar Parameters There are two categories of the functions that use scalar parameters: Functions that take alpha and/or beta parameters by reference on the host or the device as scaling factors, such as gemm. Functions that return a scalar result on the host or the device such as amax(), amin, asum(), rotg(), rotmg(), dot() and nrm2(). For the functions of the first category, when the pointer mode is set to CUBLAS\_POINTER\_MODE\_HOST, the scalar parameters alpha and/or beta can be on the stack or allocated on the heap, shouldn’t be placed in managed memory. Underneath, the CUDA kernels related to those functions will be launched with the value of alpha and/or beta. Therefore if they were allocated on the heap, they can be freed just after the return of the call even though the kernel launch is asynchronous. When the pointer mode is set to CUBLAS\_POINTER\_MODE\_DEVICE, alpha and/or beta must be accessible on the device and their values should not be modified until the kernel is done. Note that since cudaFree() does an implicit cudaDeviceSynchronize(), cudaFree() can still be called on alpha and/or beta just after the call but it would defeat the purpose of using this pointer mode in that case. For the functions of the second category, when the pointer mode is set to CUBLAS\_POINTER\_MODE\_HOST, these functions block the CPU, until the GPU has completed its computation and the results have been copied back to the Host. When the pointer mode is set to CUBLAS\_POINTER\_MODE\_DEVICE, these functions return immediately. In this case, similar to matrix and vector results, the scalar result is ready only when execution of the routine on the GPU has completed. This requires proper synchronization in order to read the result from the host. In either case, the pointer mode CUBLAS\_POINTER\_MODE\_DEVICE allows the library functions to execute completely asynchronously from the Host even when alpha and/or beta are generated by a previous kernel. For example, this situation can arise when iterative methods for solution of linear systems and eigenvalue problems are implemented using the cuBLAS library. 2.1.6. Parallelism with Streams If the application uses the results computed by multiple independent tasks, CUDA™ streams can be used to overlap the computation performed in these tasks. The application can conceptually associate each stream with each task. In order to achieve the overlap of computation between the tasks, the user should create CUDA™ streams using the function cudaStreamCreate() and set the stream to be used by each individual cuBLAS library routine by calling cublasSetStream() just before calling the actual cuBLAS routine. Note that cublasSetStream() resets the user-provided workspace to the default workspace pool; see cublasSetWorkspace(). Then, the computation performed in separate streams would be overlapped automatically when possible on the GPU. This approach is especially useful when the computation performed by a single task is relatively small and is not enough to fill the GPU with work. We recommend using the new cuBLAS API with scalar parameters and results passed by reference in the device memory to achieve maximum overlap of the computation when using streams. A particular application of streams, batching of multiple small kernels, is described in the following section. 2.1.7. Batching Kernels In this section, we explain how to use streams to batch the execution of small kernels. For instance, suppose that we have an application where we need to make many small independent matrix-matrix multiplications with dense matrices. It is clear that even with millions of small independent matrices we will not be able to achieve the same GFLOPS rate as with a one large matrix. For example, a single \\(n \\times n\\) large matrix-matrix multiplication performs \\(n^{3}\\) operations for \\(n^{2}\\) input size, while 1024 \\(\\frac{n}{32} \\times \\frac{n}{32}\\) small matrix-matrix multiplications perform \\(1024\\left( \\frac{n}{32} \\right)^{3} = \\frac{n^{3}}{32}\\) operations for the same input size. However, it is also clear that we can achieve a significantly better performance with many small independent matrices compared with a single small matrix. The architecture family of GPUs allows us to execute multiple kernels simultaneously. Hence, in order to batch the execution of independent kernels, we can run each of them in a separate stream. In particular, in the above example we could create 1024 CUDA™ streams using the function cudaStreamCreate(), then preface each call to cublas gemm() with a call to cublasSetStream() with a different stream for each of the matrix-matrix multiplications (note that cublasSetStream() resets user-provided workspace to the default workspace pool, see cublasSetWorkspace()). This will ensure that when possible the different computations will be executed concurrently. Although the user can create many streams, in practice it is not possible to have more than 32 concurrent kernels executing at the same time. 2.1.8. Cache Configuration On some devices, L1 cache and shared memory use the same hardware resources. The cache configuration can be set directly with the CUDA Runtime function cudaDeviceSetCacheConfig. The cache configuration can also be set specifically for some functions using the routine cudaFuncSetCacheConfig. Please refer to the CUDA Runtime API documentation for details about the cache configuration settings. Because switching from one configuration to another can affect kernels concurrency, the cuBLAS Library does not set any cache configuration preference and relies on the current setting. However, some cuBLAS routines, especially Level-3 routines, rely heavily on shared memory. Thus the cache preference setting might affect adversely their performance. 2.1.9. Static Library Support The cuBLAS Library is also delivered in a static form as libcublas\_static.a on Linux. The static cuBLAS library and all other static math libraries depend on a common thread abstraction layer library called libculibos.a. For example, on Linux, to compile a small application using cuBLAS, against the dynamic library, the following command can be used: nvcc myCublasApp.c -lcublas -o myCublasApp Whereas to compile against the static cuBLAS library, the following command must be used: nvcc myCublasApp.c -lcublas\_static -lculibos -o myCublasApp It is also possible to use the native Host C++ compiler. Depending on the Host operating system, some additional libraries like pthread or dl might be needed on the linking line. The following command on Linux is suggested: g++ myCublasApp.c -lcublas\_static -lculibos -lcudart\_static -lpthread -ldl -I /include -L /lib64 -o myCublasApp Note that in the latter case, the library cuda is not needed. The CUDA Runtime will try to open explicitly the cuda library if needed. In the case of a system which does not have the CUDA driver installed, this allows the application to gracefully manage this issue and potentially run if a CPU-only path is available. Starting with release 11.2, using the typed functions instead of the extension functions (cublas\*\*Ex()) helps in reducing the binary size when linking to static cuBLAS Library. 2.1.10. GEMM Algorithms Numerical Behavior Some GEMM algorithms split the computation along the dimension K to increase the GPU occupancy, especially when the dimension K is large compared to dimensions M and N. When this type of algorithm is chosen by the cuBLAS heuristics or explicitly by the user, the results of each split is summed deterministically into the resulting matrix to get the final result. For the routines cublas gemmEx() and cublasGemmEx(), when the compute type is greater than the output type, the sum of the split chunks can potentially lead to some intermediate overflows thus producing a final resulting matrix with some overflows. Those overflows might not have occurred if all the dot products had been accumulated in the compute type before being converted at the end in the output type. This computation side-effect can be easily exposed when the computeType is CUDA\_R\_32F and Atype, Btype and Ctype are CUDA\_R\_16F. This behavior can be controlled using the compute precision mode CUBLAS\_MATH\_DISALLOW\_REDUCED\_PRECISION\_REDUCTION with cublasSetMathMode() 2.1.11. Tensor Core Usage Tensor cores were first introduced with Volta GPUs (compute capability 7.0 and above) and significantly accelerate matrix multiplications. Starting with cuBLAS version 11.0.0, the library may automatically make use of Tensor Core capabilities wherever possible, unless they are explicitly disabled by selecting pedantic compute modes in cuBLAS (see cublasSetMathMode(), cublasMath\_t). It should be noted that the library will pick a Tensor Core enabled implementation wherever it determines that it would provide the best performance. The best performance when using Tensor Cores can be achieved when the matrix dimensions and pointers meet certain memory alignment requirements. Specifically, all of the following conditions must be satisfied to get the most performance out of Tensor Cores: ((op\_A == CUBLAS\_OP\_N? m: k) \* AtypeSize) % 16 == 0 ((op\_B == CUBLAS\_OP\_N? k: n) \* BtypeSize) % 16 == 0 (m \* CtypeSize) % 16 == 0 (lda \* AtypeSize) % 16 == 0 (ldb \* BtypeSize) % 16 == 0 (ldc \* CtypeSize) % 16 == 0 intptr\_t(A) % 16 == 0 intptr\_t(B) % 16 == 0 intptr\_t(C) % 16 == 0 To conduct matrix multiplication with FP8 types (see 8-bit Floating Point Data Types (FP8) Usage), you must ensure that your matrix dimensions and pointers meet the optimal requirements listed above. Aside from FP8, there are no longer any restrictions on matrix dimensions and memory alignments to use Tensor Cores (starting with cuBLAS version 11.0.0). 2.1.12. CUDA Graphs Support cuBLAS routines can be captured in CUDA Graph stream capture without restrictions in most situations. The exception are routines that output results into host buffers (e.g. cublas dot() while pointer mode CUBLAS\_POINTER\_MODE\_HOST is configured), as it enforces synchronization. For input coefficients (such as alpha, beta) behavior depends on the pointer mode setting: In the case of CUBLAS(LT)\_POINTER\_MODE\_HOST, coefficient values are captured in the graph. In the case of pointer modes with device pointers, coefficient value is accessed using the device pointer at the time of graph execution. Note When captured in CUDA Graph stream capture, cuBLAS routines can create memory nodes through the use of stream-ordered allocation APIs, cudaMallocAsync and cudaFreeAsync. However, as there is currently no support for memory nodes in child graphs or graphs launched from the device, attempts to capture cuBLAS routines in such scenarios may fail. To avoid this issue, use the cublasSetWorkspace() function to provide user-owned workspace memory. 2.1.13. 64-bit Integer Interface cuBLAS version 12 introduced 64-bit integer capable functions. Each 64-bit integer function is equivalent to a 32-bit integer function with the following changes: The function name has \_64 suffix. The dimension (problem size) data type changed from int to int64\_t. Examples of dimension: m, n, and k. The leading dimension data type changed from int to int64\_t. Examples of leading dimension: lda, ldb, and ldc. The vector increment data type changed from int to int64\_t. Examples of vector increment: incx and incy. For example, consider the following 32-bit integer functions: cublasStatus\_t cublasSetMatrix(int rows, int cols, int elemSize, const void \*A, int lda, void \*B, int ldb); cublasStatus\_t cublasIsamax(cublasHandle\_t handle, int n, const float \*x, int incx, int \*result); cublasStatus\_t cublasSsyr(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const float \*alpha, const float \*x, int incx, float \*A, int lda); The equivalent 64-bit integer functions are: cublasStatus\_t cublasSetMatrix\_64(int64\_t rows, int64\_t cols, int64\_t elemSize, const void \*A, int64\_t lda, void \*B, int64\_t ldb); cublasStatus\_t cublasIsamax\_64(cublasHandle\_t handle, int64\_t n, const float \*x, int64\_t incx, int64\_t \*result); cublasStatus\_t cublasSsyr\_64(cublasHandle\_t handle, cublasFillMode\_t uplo, int64\_t n, const float \*alpha, const float \*x, int64\_t incx, float \*A, int64\_t lda); Not every function has a 64-bit integer equivalent. For instance, cublasSetMathMode() doesn’t have any arguments that could meaningfully be int64\_t. For documentation brevity, the 64-bit integer APIs are not explicitly listed, but only mentioned that they exist for the relevant functions. 2.2. cuBLAS Datatypes Reference 2.2.1. cublasHandle\_t The cublasHandle\_t type is a pointer type to an opaque structure holding the cuBLAS library context. The cuBLAS library context must be initialized using cublasCreate() and the returned handle must be passed to all subsequent library function calls. The context should be destroyed at the end using cublasDestroy(). 2.2.2. cublasStatus\_t The type is used for function status returns. All cuBLAS library functions return their status, which can have the following values. Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully. CUBLAS\_STATUS\_NOT\_INITIALIZED The cuBLAS library was not initialized. This is usually caused by the lack of a prior cublasCreate() call, an error in the CUDA Runtime API called by the cuBLAS routine, or an error in the hardware setup. To correct: call cublasCreate() before the function call; and check that the hardware, an appropriate version of the driver, and the cuBLAS library are correctly installed. CUBLAS\_STATUS\_ALLOC\_FAILED Resource allocation failed inside the cuBLAS library. This is usually caused by a cudaMalloc() failure. To correct: prior to the function call, deallocate previously allocated memory as much as possible. CUBLAS\_STATUS\_INVALID\_VALUE An unsupported value or parameter was passed to the function (a negative vector size, for example). To correct: ensure that all the parameters being passed have valid values. CUBLAS\_STATUS\_ARCH\_MISMATCH The function requires a feature absent from the device architecture; usually caused by compute capability lower than 5.0. To correct: compile and run the application on a device with appropriate compute capability. CUBLAS\_STATUS\_MAPPING\_ERROR An access to GPU memory space failed, which is usually caused by a failure to bind a texture. To correct: before the function call, unbind any previously bound textures. CUBLAS\_STATUS\_EXECUTION\_FAILED The GPU program failed to execute. This is often caused by a launch failure of the kernel on the GPU, which can be caused by multiple reasons. To correct: check that the hardware, an appropriate version of the driver, and the cuBLAS library are correctly installed. CUBLAS\_STATUS\_INTERNAL\_ERROR An internal cuBLAS operation failed. This error is usually caused by a cudaMemcpyAsync() failure. To correct: check that the hardware, an appropriate version of the driver, and the cuBLAS library are correctly installed. Also, check that the memory passed as a parameter to the routine is not being deallocated prior to the routine’s completion. CUBLAS\_STATUS\_NOT\_SUPPORTED The functionality requested is not supported. CUBLAS\_STATUS\_LICENSE\_ERROR The functionality requested requires some license and an error was detected when trying to check the current licensing. This error can happen if the license is not present or is expired or if the environment variable NVIDIA\_LICENSE\_FILE is not set properly. 2.2.3. cublasOperation\_t The cublasOperation\_t type indicates which operation needs to be performed with the dense matrix. Its values correspond to Fortran characters ‘N’ or ‘n’ (non-transpose), ‘T’ or ‘t’ (transpose) and ‘C’ or ‘c’ (conjugate transpose) that are often used as parameters to legacy BLAS implementations. Value Meaning CUBLAS\_OP\_N The non-transpose operation is selected. CUBLAS\_OP\_T The transpose operation is selected. CUBLAS\_OP\_C The conjugate transpose operation is selected. 2.2.4. cublasFillMode\_t The type indicates which part (lower or upper) of the dense matrix was filled and consequently should be used by the function. Its values correspond to Fortran characters L or l (lower) and U or u (upper) that are often used as parameters to legacy BLAS implementations. Value Meaning CUBLAS\_FILL\_MODE\_LOWER The lower part of the matrix is filled. CUBLAS\_FILL\_MODE\_UPPER The upper part of the matrix is filled. CUBLAS\_FILL\_MODE\_FULL The full matrix is filled. 2.2.5. cublasDiagType\_t The type indicates whether the main diagonal of the dense matrix is unity and consequently should not be touched or modified by the function. Its values correspond to Fortran characters ‘N’ or ‘n’ (non-unit) and ‘U’ or ‘u’ (unit) that are often used as parameters to legacy BLAS implementations. Value Meaning CUBLAS\_DIAG\_NON\_UNIT The matrix diagonal has non-unit elements. CUBLAS\_DIAG\_UNIT The matrix diagonal has unit elements. 2.2.6. cublasSideMode\_t The type indicates whether the dense matrix is on the left or right side in the matrix equation solved by a particular function. Its values correspond to Fortran characters ‘L’ or ‘l’ (left) and ‘R’ or ‘r’ (right) that are often used as parameters to legacy BLAS implementations. Value Meaning CUBLAS\_SIDE\_LEFT The matrix is on the left side in the equation. CUBLAS\_SIDE\_RIGHT The matrix is on the right side in the equation. 2.2.7. cublasPointerMode\_t The cublasPointerMode\_t type indicates whether the scalar values are passed by reference on the host or device. It is important to point out that if several scalar values are present in the function call, all of them must conform to the same single pointer mode. The pointer mode can be set and retrieved using cublasSetPointerMode() and cublasGetPointerMode() routines, respectively. Value Meaning CUBLAS\_POINTER\_MODE\_HOST The scalars are passed by reference on the host. CUBLAS\_POINTER\_MODE\_DEVICE The scalars are passed by reference on the device. 2.2.8. cublasAtomicsMode\_t The type indicates whether cuBLAS routines which has an alternate implementation using atomics can be used. The atomics mode can be set and queried using cublasSetAtomicsMode() and cublasGetAtomicsMode() and routines, respectively. Value Meaning CUBLAS\_ATOMICS\_NOT\_ALLOWED The usage of atomics is not allowed. CUBLAS\_ATOMICS\_ALLOWED The usage of atomics is allowed. 2.2.9. cublasGemmAlgo\_t cublasGemmAlgo\_t type is an enumerant to specify the algorithm for matrix-matrix multiplication on GPU architectures up to sm\_75. On sm\_80 and newer GPU architectures, this enumarant has no effect. cuBLAS has the following algorithm options: Value Meaning CUBLAS\_GEMM\_DEFAULT Apply Heuristics to select the GEMM algorithm CUBLAS\_GEMM\_ALGO0 to CUBLAS\_GEMM\_ALGO23 Explicitly choose an Algorithm 0..23. Note: Doesn’t have effect on NVIDIA Ampere architecture GPUs and newer. CUBLAS\_GEMM\_DEFAULT\_TENSOR\_OP\[DEPRECATED\] This mode is deprecated and will be removed in a future release. Apply Heuristics to select the GEMM algorithm, while allowing use of reduced precision CUBLAS\_COMPUTE\_32F\_FAST\_16F kernels (for backward compatibility). CUBLAS\_GEMM\_ALGO0\_TENSOR\_OP to CUBLAS\_GEMM\_ALGO15\_TENSOR\_OP\[DEPRECATED\] Those values are deprecated and will be removed in a future release. Explicitly choose a Tensor core GEMM Algorithm 0..15. Allows use of reduced precision CUBLAS\_COMPUTE\_32F\_FAST\_16F kernels (for backward compatibility). Note: Doesn’t have effect on NVIDIA Ampere architecture GPUs and newer. CUBLAS\_GEMM\_AUTOTUNE \[EXPERIMENTAL\] The library will benchmark a number of available algorithms and choose the optimal one for the given problem configuration. Solution is cached in cublas handle so that next calls with the problem size will use the cached configuration. Note: To avoid overwriting the user’s data, the library will allocate the amount of memory corresponding to the size of the output. Note: The benchmarking is not supported during stream capture; CUBLAS\_STATUS\_NOT\_SUPPORTED will be returned under stream capture if no configuration was found in the cache for the given problem size. 2.2.10. cublasMath\_t cublasMath\_t enumerate type is used in cublasSetMathMode() to choose compute precision modes as defined in the following table. Since this setting does not directly control the use of Tensor Cores, the mode CUBLAS\_TENSOR\_OP\_MATH is being deprecated, and will be removed in a future release. Value Meaning CUBLAS\_DEFAULT\_MATH This is the default and highest-performance mode that uses compute and intermediate storage precisions with at least the same number of mantissa and exponent bits as requested. Tensor Cores will be used whenever possible. CUBLAS\_PEDANTIC\_MATH This mode uses the prescribed precision and standardized arithmetic for all phases of calculations and is primarily intended for numerical robustness studies, testing, and debugging. This mode might not be as performant as the other modes. CUBLAS\_TF32\_TENSOR\_OP\_MATH Enable acceleration of single-precision routines using TF32 tensor cores. Note that input conversions round to nearest even. CUBLAS\_FP32\_EMULATED\_BF16X9\_MATH Enable acceleration of single-precision routines using the BF16x9 algorithm. See Floating Point Emulation for more details. For single precision GEMM routines cuBLAS will use the CUBLAS\_COMPUTE\_32F\_EMULATED\_16BFX9 compute type. CUBLAS\_FP64\_EMULATED\_FIXEDPOINT\_MATH Enable acceleration of double-precision routines using fixed-point emulation algorithms. See Floating Point Emulation for more details. CUBLAS\_MATH\_DISALLOW\_REDUCED\_PRECISION\_REDUCTION Forces any reductions during matrix multiplications to use the accumulator type (that is, compute type) and not the output type in case of mixed precision routines where output type precision is less than the compute type precision. This is a flag that can be set (using a bitwise or operation) alongside any of the other values. CUBLAS\_TENSOR\_OP\_MATH \[DEPRECATED\] This mode is deprecated and will be removed in a future release. Allows the library to use Tensor Core operations whenever possible. For single precision GEMM routines cuBLAS will use the CUBLAS\_COMPUTE\_32F\_FAST\_16F compute type. 2.2.11. cublasComputeType\_t cublasComputeType\_t enumerate type is used in cublasGemmEx() and cublasLtMatmul() (including all batched and strided batched variants) to choose compute precision modes as defined below. Value | Meaning CUBLAS\_COMPUTE\_16F This is the default and highest-performance mode for 16-bit half precision floating point and all compute and intermediate storage precisions with at least 16-bit half precision. Tensor Cores will be used whenever possible. CUBLAS\_COMPUTE\_16F\_PEDANTIC This mode uses 16-bit half precision floating point standardized arithmetic for all phases of calculations and is primarily intended for numerical robustness studies, testing, and debugging. This mode might not be as performant as the other modes since it disables use of tensor cores. CUBLAS\_COMPUTE\_32F This is the default 32-bit single precision floating point and uses compute and intermediate storage precisions of at least 32-bits. CUBLAS\_COMPUTE\_32F\_PEDANTIC Uses 32-bit single precision floating point arithmetic for all phases of calculations and also disables algorithmic optimizations such as Gaussian complexity reduction (3M). CUBLAS\_COMPUTE\_32F\_FAST\_16F Allows the library to use Tensor Cores with automatic down-conversion and 16-bit half-precision compute for 32-bit input and output matrices. CUBLAS\_COMPUTE\_32F\_FAST\_16BF Allows the library to use Tensor Cores with automatic down-convesion and bfloat16 compute for 32-bit input and output matrices. See Alternate Floating Point section for more details on bfloat16. CUBLAS\_COMPUTE\_32F\_FAST\_TF32 Allows the library to use Tensor Cores with TF32 compute for 32-bit floating point input and output matrices. Note that input conversions round to nearest even. See Alternate Floating Point section for more details on TF32 compute. CUBLAS\_COMPUTE\_32F\_EMULATED\_16BFX9 Allows the library to use the BF16x9 floating point emulation algorithm for 32-bit floating point arithmetic. See Floating Point Emulation for more details. CUBLAS\_COMPUTE\_64F This is the default 64-bit double precision floating point and uses compute and intermediate storage precisions of at least 64-bits. CUBLAS\_COMPUTE\_64F\_EMULATED\_FIXEDPOINT Allows the library to use fixed-point emulation algorithms for 64-bit double precision floating point arithmetic. See Floating Point Emulation for more details. CUBLAS\_COMPUTE\_64F\_PEDANTIC Uses 64-bit double precision floating point arithmetic for all phases of calculations and also disables algorithmic optimizations such as Gaussian complexity reduction (3M). CUBLAS\_COMPUTE\_32I This is the default 32-bit integer mode and uses compute and intermediate storage precisions of at least 32-bits. CUBLAS\_COMPUTE\_32I\_PEDANTIC Uses 32-bit integer arithmetic for all phases of calculations. Note Setting the environment variable NVIDIA\_TF32\_OVERRIDE = 0 will override any defaults or programmatic configuration of NVIDIA libraries, and consequently, cuBLAS will not accelerate single-precision computations with TF32 tensor cores. 2.2.12. cublasEmulationStrategy\_t cublasEmulationStrategy\_t enumerate type is used in cublasSetEmulationStrategy() to choose how to leverage floating point emulation algorithms. Value Meaning CUBLAS\_EMULATION\_STRATEGY\_DEFAULT This is the default emulation strategy and is equivalent to CUBLAS\_EMULATION\_STRATEGY\_PERFORMANT unless the CUBLAS\_EMULATION\_STRATEGY environment variable is set. CUBLAS\_EMULATION\_STRATEGY\_PERFORMANT A strategy which utilizes emulation whenever it provides a performance benefit. CUBLAS\_EMULATION\_STRATEGY\_EAGER A strategy which utilizes emulation whenever possible. Note In general, the cublasSetEmulationStrategy() function takes precedence over the environment variable setting. However, setting the environment variable CUBLAS\_EMULATION\_STRATEGY to performant or eager will override the default emulation strategy with the corresponding emulation strategy, even if the default strategy was set by the function call. 2.3. CUDA Datatypes Reference The chapter describes types shared by multiple CUDA Libraries and defined in the header file library\_types.h. 2.3.1. cudaDataType\_t The cudaDataType\_t type is an enumerant to specify the data precision. It is used when the data reference does not carry the type itself (e.g void \*) For example, it is used in the routine cublasSgemmEx(). Value Meaning CUDA\_R\_16F The data type is a 16-bit real half precision floating-point CUDA\_C\_16F The data type is a 32-bit structure comprised of two half precision floating-points representing a complex number. CUDA\_R\_16BF The data type is a 16-bit real bfloat16 floating-point CUDA\_C\_16BF The data type is a 32-bit structure comprised of two bfloat16 floating-points representing a complex number. CUDA\_R\_32F The data type is a 32-bit real single precision floating-point CUDA\_C\_32F The data type is a 64-bit structure comprised of two single precision floating-points representing a complex number. CUDA\_R\_64F The data type is a 64-bit real double precision floating-point CUDA\_C\_64F The data type is a 128-bit structure comprised of two double precision floating-points representing a complex number. CUDA\_R\_8I The data type is a 8-bit real signed integer CUDA\_C\_8I The data type is a 16-bit structure comprised of two 8-bit signed integers representing a complex number. CUDA\_R\_8U The data type is a 8-bit real unsigned integer CUDA\_C\_8U The data type is a 16-bit structure comprised of two 8-bit unsigned integers representing a complex number. CUDA\_R\_32I The data type is a 32-bit real signed integer CUDA\_C\_32I The data type is a 64-bit structure comprised of two 32-bit signed integers representing a complex number. CUDA\_R\_8F\_E4M3 The data type is an 8-bit real floating point in E4M3 format CUDA\_R\_8F\_E5M2 The data type is an 8-bit real floating point in E5M2 format CUDA\_R\_4F\_E2M1 The data type is a 4-bit real floating point in E2M1 format 2.3.2. cudaEmulationStrategy\_t The cudaEmulationStrategy\_t is a parameter to specify how to leverage floating point emulation algorithms. This is equivalent to cublasEmulationStrategy\_t. 2.3.3. cudaEmulationMantissaControl\_t The cudaEmulationMantissaControl\_t is an enumerated type to specify how to configure how the number of mantissa bits are calculated in floating point emulation algorithms. See See cublasSetFixedPointEmulationMantissaControl() and cublasGetFixedPointEmulationMaxMantissaBitCount(). Value Meaning CUDA\_EMULATION\_MANTISSA\_CONTROL\_DYNAMIC The number of retained mantissa bits is computed at runtime to ensure the same or better accuracy than the native floating point representation. CUDA\_EMULATION\_MANTISSA\_CONTROL\_FIXED The number of retained mantissa bits is fixed at runtime. 2.3.4. cudaEmulationSpecialValuesSupport\_t The cudaEmulationSpecialValuesSupport\_t is an enumerated type to specify how to configure which floating point special values are required to be supported by floating point emulation algorithms. See cublasSetEmulationSpecialValuesSupport() and cublasGetEmulationSpecialValuesSupport(). Value Meaning CUDA\_EMULATION\_SPECIAL\_VALUES\_SUPPORT\_DEFAULT The default special value support mask which contains support for signed infinities and NaN values. CUDA\_EMULATION\_SPECIAL\_VALUES\_SUPPORT\_NONE There are no requirements for emulation algorithms to support special values. CUDA\_EMULATION\_SPECIAL\_VALUES\_SUPPORT\_INFINITY Require emulation algorithms to handle signed infinity inputs and outputs. CUDA\_EMULATION\_SPECIAL\_VALUES\_SUPPORT\_NAN Require emulation algorithms to handle NaN inputs and outputs. 2.3.5. libraryPropertyType\_t The libraryPropertyType\_t is used as a parameter to specify which property is requested when using the routine cublasGetProperty() Value Meaning MAJOR\_VERSION enumerant to query the major version MINOR\_VERSION enumerant to query the minor version PATCH\_LEVEL number to identify the patch level 2.4. cuBLAS Helper Function Reference 2.4.1. cublasCreate() cublasStatus\_t cublasCreate(cublasHandle\_t \*handle) This function initializes the cuBLAS library and creates a handle to an opaque structure holding the cuBLAS library context. It allocates hardware resources on the host and device and must be called prior to making any other cuBLAS library calls. The cuBLAS library context is tied to the current CUDA device. To use the library on multiple devices, one cuBLAS handle needs to be created for each device. See also cuBLAS Context. For a given device, multiple cuBLAS handles with different configurations can be created. For multi-threaded applications that use the same device from different threads, the recommended programming model is to create one cuBLAS handle per thread and use that cuBLAS handle for the entire life of the thread. Because cublasCreate() allocates some internal resources and the release of those resources by calling cublasDestroy() will implicitly call cudaDeviceSynchronize(), it is recommended to minimize the number of times these functions are called. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The initialization succeeded CUBLAS\_STATUS\_NOT\_INITIALIZED The CUDA™ Runtime initialization failed CUBLAS\_STATUS\_ALLOC\_FAILED The resources could not be allocated CUBLAS\_STATUS\_INVALID\_VALUE handle is NULL 2.4.2. cublasDestroy() cublasStatus\_t cublasDestroy(cublasHandle\_t handle) This function releases hardware resources used by the cuBLAS library. This function is usually the last call with a particular handle to the cuBLAS library. Because cublasCreate() allocates some internal resources and the release of those resources by calling cublasDestroy() will implicitly call cudaDeviceSynchronize(), it is recommended to minimize the number of times these functions are called. Return Value Meaning CUBLAS\_STATUS\_SUCCESS the shut down succeeded CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized 2.4.3. cublasGetVersion() cublasStatus\_t cublasGetVersion(cublasHandle\_t handle, int \*version) This function returns the version number of the cuBLAS library. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_INVALID\_VALUE version is NULL Note This function can be safely called with handle set to NULL. This allows users to get the version of the library without a handle. Another way to do this is with cublasGetProperty(). 2.4.4. cublasGetProperty() cublasStatus\_t cublasGetProperty(libraryPropertyType type, int \*value) This function returns the value of the requested property in memory pointed to by value. Refer to libraryPropertyType for supported types. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_INVALID\_VALUE Invalid type or value If type has an invalid value, or if value is NULL 2.4.5. cublasGetStatusName() const char\* cublasGetStatusName(cublasStatus\_t status) This function returns the string representation of a given status. Return Value Meaning NULL-terminated string The string representation of the status 2.4.6. cublasGetStatusString() const char\* cublasGetStatusString(cublasStatus\_t status) This function returns the description string for a given status. Return Value Meaning NULL-terminated string The description of the status 2.4.7. cublasSetStream() cublasStatus\_t cublasSetStream(cublasHandle\_t handle, cudaStream\_t streamId) This function sets the cuBLAS library stream, which will be used to execute all subsequent calls to the cuBLAS library functions. If the cuBLAS library stream is not set, all kernels use the default NULL stream. In particular, this routine can be used to change the stream between kernel launches and then to reset the cuBLAS library stream back to NULL. Additionally this function unconditionally resets the cuBLAS library workspace back to the default workspace pool (see cublasSetWorkspace()). Return Value Meaning CUBLAS\_STATUS\_SUCCESS the stream was set successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized 2.4.8. cublasSetWorkspace() cublasStatus\_t cublasSetWorkspace(cublasHandle\_t handle, void \*workspace, size\_t workspaceSizeInBytes) This function sets the cuBLAS library workspace to a user-owned device buffer, which will be used to execute all subsequent calls to the cuBLAS library functions (on the currently set stream). If the cuBLAS library workspace is not set, all kernels will use the default workspace pool allocated during the cuBLAS context creation. In particular, this routine can be used to change the workspace between kernel launches. The workspace pointer has to be aligned to at least 256 bytes, otherwise CUBLAS\_STATUS\_INVALID\_VALUE error is returned. The cublasSetStream() function unconditionally resets the cuBLAS library workspace back to the default workspace pool. Calling this function, including with workspaceSizeInBytes equal to 0, will prevent the cuBLAS library from utilizing the default workspace. Too small value of workspaceSizeInBytes may cause some routines to fail with CUBLAS\_STATUS\_ALLOC\_FAILED error returned or cause large regressions in performance. Workspace size equal to or larger than 16KiB is enough to prevent CUBLAS\_STATUS\_ALLOC\_FAILED error, while a larger workspace can provide performance benefits for some routines. Note If the stream set by cublasSetStream() is cudaStreamPerThread and there are multiple threads using the same cuBLAS library handle, then users must manually manage synchronization to avoid possible race conditions in the user provided workspace. Alternatively, users may rely on the default workspace pool which safely guards against race conditions. Warning cuBLAS functions may invoke more than one CUDA kernel, and rely on workspace being intact between the invocations. Hence, if cuBLAS handle is configured with user-provided workspace and is being used from multiple threads, it is user’s responsibility to serialize cuBLAS calls between threads, as otherwise the kernels from different cuBLAS invocations might interleave and invalidate the assumptions each of them makes regarding workspace intactness. The default workspace pool managed by cuBLAS is thread safe. The table below shows the recommended size of user-provided workspace. This is based on the cuBLAS default workspace pool size which is GPU architecture dependent. GPU Architecture Recommended workspace size NVIDIA Hopper Architecture (sm90) 32 MiB NVIDIA Blackwell Architecture (sm10x) 32 MiB NVIDIA Blackwell Architecture (sm12x) 32 MiB Other 4 MiB Note If the cuBLAS library is configured to utilize fixed-point emulation, which can be done by setting the corresponding math mode in cublasSetMathMode() or calling APIs with CUBLAS\_COMPUTE\_64F\_EMULATED\_FIXEDPOINT, it can be beneficial to provide more workspace than recommended for the GPU architecture. See Fixed-Point Workspace Requirements for more details. The possible error values returned by this function and their meanings are listed below. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The stream was set successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE The workspace pointer wasn’t aligned to at least 256 bytes 2.4.9. cublasGetStream() cublasStatus\_t cublasGetStream(cublasHandle\_t handle, cudaStream\_t \*streamId) This function gets the cuBLAS library stream, which is being used to execute all calls to the cuBLAS library functions. If the cuBLAS library stream is not set, all kernels use the default NULL stream. Return Value Meaning CUBLAS\_STATUS\_SUCCESS the stream was returned successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE streamId is NULL 2.4.10. cublasGetPointerMode() cublasStatus\_t cublasGetPointerMode(cublasHandle\_t handle, cublasPointerMode\_t \*mode) This function obtains the pointer mode used by the cuBLAS library. Please see the section on the cublasPointerMode\_t type for more details. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The pointer mode was obtained successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE mode is NULL 2.4.11. cublasSetPointerMode() cublasStatus\_t cublasSetPointerMode(cublasHandle\_t handle, cublasPointerMode\_t mode) This function sets the pointer mode used by the cuBLAS library. The default is for the values to be passed by reference on the host. Please see the section on the cublasPointerMode\_t type for more details. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The pointer mode was set successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE mode is not CUBLAS\_POINTER\_MODE\_HOST or CUBLAS\_POINTER\_MODE\_DEVICE 2.4.12. cublasSetVector() cublasStatus\_t cublasSetVector(int n, int elemSize, const void \*x, int incx, void \*y, int incy) This function supports the 64-bit Integer Interface. This function copies n elements from a vector x in host memory space to a vector y in GPU memory space. Elements in both vectors are assumed to have a size of elemSize bytes. The storage spacing between consecutive elements is given by incx for the source vector x and by incy for the destination vector y. Since column-major format for two-dimensional matrices is assumed, if a vector is part of a matrix, a vector increment equal to 1 accesses a (partial) column of that matrix. Similarly, using an increment equal to the leading dimension of the matrix results in accesses to a (partial) row of that matrix. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_INVALID\_VALUE The parameters incx, incy, or elemSize are not positive CUBLAS\_STATUS\_MAPPING\_ERROR There was an error accessing GPU memory 2.4.13. cublasGetVector() cublasStatus\_t cublasGetVector(int n, int elemSize, const void \*x, int incx, void \*y, int incy) This function supports the 64-bit Integer Interface. This function copies n elements from a vector x in GPU memory space to a vector y in host memory space. Elements in both vectors are assumed to have a size of elemSize bytes. The storage spacing between consecutive elements is given by incx for the source vector and incy for the destination vector y. Since column-major format for two-dimensional matrices is assumed, if a vector is part of a matrix, a vector increment equal to 1 accesses a (partial) column of that matrix. Similarly, using an increment equal to the leading dimension of the matrix results in accesses to a (partial) row of that matrix. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_INVALID\_VALUE The parameters incx, incy, or elemSize are not positive CUBLAS\_STATUS\_MAPPING\_ERROR There was an error accessing GPU memory 2.4.14. cublasSetMatrix() cublasStatus\_t cublasSetMatrix(int rows, int cols, int elemSize, const void \*A, int lda, void \*B, int ldb) This function supports the 64-bit Integer Interface. This function copies a tile of rows x cols elements from a matrix A in host memory space to a matrix B in GPU memory space. It is assumed that each element requires storage of elemSize bytes and that both matrices are stored in column-major format, with the leading dimension of the source matrix A and destination matrix B given in lda and ldb, respectively. The leading dimension indicates the number of rows of the allocated matrix, even if only a submatrix of it is being used. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_INVALID\_VALUE The parameters rows or cols are negative, or elemSize, lda ldb are not positive. CUBLAS\_STATUS\_MAPPING\_ERROR There was an error accessing GPU memory 2.4.15. cublasGetMatrix() cublasStatus\_t cublasGetMatrix(int rows, int cols, int elemSize, const void \*A, int lda, void \*B, int ldb) This function supports the 64-bit Integer Interface. This function copies a tile of rows x cols elements from a matrix A in GPU memory space to a matrix B in host memory space. It is assumed that each element requires storage of elemSize bytes and that both matrices are stored in column-major format, with the leading dimension of the source matrix A and destination matrix B given in lda and ldb, respectively. The leading dimension indicates the number of rows of the allocated matrix, even if only a submatrix of it is being used. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_INVALID\_VALUE The parameters rows or cols are negative, or elemSize, lda ldb are not positive. CUBLAS\_STATUS\_MAPPING\_ERROR There was an error accessing GPU memory 2.4.16. cublasSetVectorAsync() cublasStatus\_t cublasSetVectorAsync(int n, int elemSize, const void \*hostPtr, int incx, void \*devicePtr, int incy, cudaStream\_t stream) This function supports the 64-bit Integer Interface. This function has the same functionality as cublasSetVector(), with the exception that the data transfer is done asynchronously (with respect to the host) using the given CUDA™ stream parameter. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_INVALID\_VALUE The parameters incx, incy, or elemSize are not positive CUBLAS\_STATUS\_MAPPING\_ERROR There was an error accessing GPU memory 2.4.17. cublasGetVectorAsync() cublasStatus\_t cublasGetVectorAsync(int n, int elemSize, const void \*devicePtr, int incx, void \*hostPtr, int incy, cudaStream\_t stream) This function supports the 64-bit Integer Interface. This function has the same functionality as cublasGetVector(), with the exception that the data transfer is done asynchronously (with respect to the host) using the given CUDA™ stream parameter. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_INVALID\_VALUE The parameters incx, incy, or elemSize are not positive CUBLAS\_STATUS\_MAPPING\_ERROR There was an error accessing GPU memory 2.4.18. cublasSetMatrixAsync() cublasStatus\_t cublasSetMatrixAsync(int rows, int cols, int elemSize, const void \*A, int lda, void \*B, int ldb, cudaStream\_t stream) This function supports the 64-bit Integer Interface. This function has the same functionality as cublasSetMatrix(), with the exception that the data transfer is done asynchronously (with respect to the host) using the given CUDA™ stream parameter. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_INVALID\_VALUE The parameters rows or cols are negative, or elemSize, lda ldb are not positive. CUBLAS\_STATUS\_MAPPING\_ERROR There was an error accessing GPU memory 2.4.19. cublasGetMatrixAsync() cublasStatus\_t cublasGetMatrixAsync(int rows, int cols, int elemSize, const void \*A, int lda, void \*B, int ldb, cudaStream\_t stream) This function supports the 64-bit Integer Interface. This function has the same functionality as cublasGetMatrix(), with the exception that the data transfer is done asynchronously (with respect to the host) using the given CUDA™ stream parameter. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_INVALID\_VALUE The parameters rows or cols are negative, or elemSize, lda ldb are not positive. CUBLAS\_STATUS\_MAPPING\_ERROR There was an error accessing GPU memory 2.4.20. cublasSetAtomicsMode() cublasStatus\_t cublasSetAtomicsMode(cublasHandlet handle, cublasAtomicsMode\_t mode) Some routines like cublas symv() and cublas hemv() have an alternate implementation that use atomics to cumulate results. This implementation is generally significantly faster but can generate results that are not strictly identical from one run to the others. Mathematically, those different results are not significant but when debugging those differences can be prejudicial. This function allows or disallows the usage of atomics in the cuBLAS library for all routines which have an alternate implementation. When not explicitly specified in the documentation of any cuBLAS routine, it means that this routine does not have an alternate implementation that use atomics. When atomics mode is disabled, each cuBLAS routine should produce the same results from one run to the other when called with identical parameters on the same Hardware. The default atomics mode of default initialized cublasHandle\_t object is CUBLAS\_ATOMICS\_NOT\_ALLOWED. Please see the section on the type for more details. Return Value Meaning CUBLAS\_STATUS\_SUCCESS the atomics mode was set successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized 2.4.21. cublasGetAtomicsMode() cublasStatus\_t cublasGetAtomicsMode(cublasHandle\_t handle, cublasAtomicsMode\_t \*mode) This function queries the atomic mode of a specific cuBLAS context. The default atomics mode of default initialized cublasHandle\_t object is CUBLAS\_ATOMICS\_NOT\_ALLOWED. Please see the section on the type for more details. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The atomics mode was queried successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE The argument mode is a NULL pointer 2.4.22. cublasSetMathMode() cublasStatus\_t cublasSetMathMode(cublasHandle\_t handle, cublasMath\_t mode) The cublasSetMathMode() function enables you to choose the compute precision modes as defined by cublasMath\_t. Users are allowed to set the compute precision mode as a logical combination of them (except the deprecated CUBLAS\_TENSOR\_OP\_MATH). For example, cublasSetMathMode(handle, CUBLAS\_DEFAULT\_MATH | CUBLAS\_MATH\_DISALLOW\_REDUCED\_PRECISION\_REDUCTION). Please note that the default math mode is CUBLAS\_DEFAULT\_MATH. For matrix and compute precisions allowed for cublasGemmEx() and cublasLtMatmul() APIs and their strided variants please refer to: cublasGemmEx(), cublasGemmBatchedEx(), cublasGemmStridedBatchedEx(), and cublasLtMatmul(). Return Value Meaning CUBLAS\_STATUS\_SUCCESS The math mode was set successfully. CUBLAS\_STATUS\_INVALID\_VALUE An invalid value for mode was specified. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. 2.4.23. cublasGetMathMode() cublasStatus\_t cublasGetMathMode(cublasHandle\_t handle, cublasMath\_t \*mode) This function returns the math mode used by the library routines. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The math type was returned successfully. CUBLAS\_STATUS\_INVALID\_VALUE If mode is NULL. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. 2.4.24. cublasSetSmCountTarget() cublasStatus\_t cublasSetSmCountTarget(cublasHandle\_t handle, int smCountTarget) The cublasSetSmCountTarget() function allows overriding the number of multiprocessors available to the library during kernels execution. This option can be used to improve the library performance when cuBLAS routines are known to run concurrently with other work on different CUDA streams. For example, on an NVIDIA A100 GPU, which has 108 multiprocessors, when there is a concurrent kenrel running with grid size of 8, one can use cublasSetSmCountTarget() with smCountTarget set to 100 to override the library heuristics to optimize for running on the remaining 100 multiprocessors. When set to 0, the library returns to its default behavior. The input value should not exceed the device’s multiprocessor count, which can be obtained using cudaDeviceGetAttribute. Negative values are not accepted. The user must ensure thread safety when modifying the library handle with this routine similar to when using cublasSetStream(), etc. Return Value Meaning CUBLAS\_STATUS\_SUCCESS SM count target was set successfully. CUBLAS\_STATUS\_INVALID\_VALUE The value of smCountTarget outside of the allowed range. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. 2.4.25. cublasGetSmCountTarget() cublasStatus\_t cublasGetSmCountTarget(cublasHandle\_t handle, int \*smCountTarget) This function obtains the value previously programmed to the library handle. Return Value Meaning CUBLAS\_STATUS\_SUCCESS SM count target was returned successfully. CUBLAS\_STATUS\_INVALID\_VALUE smCountTarget is NULL. CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized. 2.4.26. cublasSetEmulationStrategy() cublasStatus\_t cublasSetEmulationStrategy(cublasHandle\_t handle, cublasEmulationStrategy\_t emulationStrategy) The cublasSetEmulationStrategy() function enables you to select how the library should make use of floating point emulation. For more details, please see cublasEmulationStrategy\_t. Return Value Meaning CUBLAS\_STATUS\_SUCCESS The emulation strategy was set successfully. CUBLAS\_STATUS\_INVALID\_VALUE An invalid value for emulation strategy was specified. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. 2.4.27. cublasGetEmulationStrategy() cublasStatus\_t cublasGetEmulationStrategy(cublasHandle\_t handle, cublasEmulationStrategy\_t \*emulationStrategy) This function obtains the value previously programmed to the library handle. Return Value Meaning CUBLAS\_STATUS\_SUCCESS emulation strategy was returned successfully. CUBLAS\_STATUS\_INVALID\_VALUE emulationStrategy is NULL. CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized. 2.4.28. cublasGetEmulationSpecialValuesSupport() cublasStatus\_t cublasGetEmulationSpecialValuesSupport(cublasHandle\_t handle, cudaEmulationSpecialValuesSupport \*mask) This function obtains the value previously programmed to the library handle. Return Value Meaning CUBLAS\_STATUS\_SUCCESS emulation special values support was returned successfully. CUBLAS\_STATUS\_INVALID\_VALUE mask is NULL. CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized. 2.4.29. cublasSetEmulationSpecialValuesSupport() cublasStatus\_t cublasSetEmulationSpecialValuesSupport(cublasHandle\_t handle, cudaEmulationSpecialValuesSupport mask) This function sets the value previously programmed to the library handle. Return Value Meaning CUBLAS\_STATUS\_SUCCESS emulation special values support was set successfully. CUBLAS\_STATUS\_INVALID\_VALUE mask is outside of the allowed range. CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized. 2.4.30. cublasGetFixedPointEmulationMantissaControl() cublasStatus\_t cublasGetFixedPointEmulationMantissaControl(cublasHandle\_t handle, cudaEmulationMantissaControl \*mantissaControl) This function obtains the value previously programmed to the library handle. Return Value Meaning CUBLAS\_STATUS\_SUCCESS fixed-point emulation mantissa control was returned successfully. CUBLAS\_STATUS\_INVALID\_VALUE mantissaControl is NULL. CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized. 2.4.31. cublasSetFixedPointEmulationMantissaControl() cublasStatus\_t cublasSetFixedPointEmulationMantissaControl(cublasHandle\_t handle, cudaEmulationMantissaControl mantissaControl) This function sets the value previously programmed to the library handle. Return Value Meaning CUBLAS\_STATUS\_SUCCESS fixed-point emulation mantissa control was set successfully. CUBLAS\_STATUS\_INVALID\_VALUE mantissaControl is outside of the allowed range. CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized. 2.4.32. cublasGetFixedPointEmulationMaxMantissaBitCount() cublasStatus\_t cublasGetFixedPointEmulationMaxMantissaBitCount(cublasHandle\_t handle, int \*maxMantissaBitCount) This function obtains the value previously programmed to the library handle. Return Value Meaning CUBLAS\_STATUS\_SUCCESS maxMantissaBitCount was returned successfully. CUBLAS\_STATUS\_INVALID\_VALUE maxMantissaBitCount is NULL. CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized. 2.4.33. cublasSetFixedPointEmulationMaxMantissaBitCount() cublasStatus\_t cublasSetFixedPointEmulationMaxMantissaBitCount(cublasHandle\_t handle, int maxMantissaBitCount) This function sets the value previously programmed to the library handle. Return Value Meaning CUBLAS\_STATUS\_SUCCESS maxMantissaBitCount was set successfully. CUBLAS\_STATUS\_INVALID\_VALUE maxMantissaBitCount is outside of the allowed range. CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized. 2.4.34. cublasGetFixedPointEmulationMantissaBitOffset() cublasStatus\_t cublasGetFixedPointEmulationMantissaBitOffset(cublasHandle\_t handle, int \*mantissaBitOffset) This function obtains the value previously programmed to the library handle. Return Value Meaning CUBLAS\_STATUS\_SUCCESS mantissaBitOffset was returned successfully. CUBLAS\_STATUS\_INVALID\_VALUE mantissaBitOffset is NULL. CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized. 2.4.35. cublasSetFixedPointEmulationMantissaBitOffset() cublasStatus\_t cublasSetFixedPointEmulationMantissaBitOffset(cublasHandle\_t handle, int mantissaBitOffset) This function sets the value previously programmed to the library handle. Return Value Meaning CUBLAS\_STATUS\_SUCCESS mantissaBitOffset was set successfully. CUBLAS\_STATUS\_INVALID\_VALUE mantissaBitOffset is outside of the allowed range. CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized. 2.4.36. cublasGetFixedPointEmulationMantissaBitCountPointer() cublasStatus\_t cublasGetFixedPointEmulationMantissaBitCountPointer(cublasHandle\_t handle, int \*\*mantissaBitCount) This function obtains the value previously programmed to the library handle. Return Value Meaning CUBLAS\_STATUS\_SUCCESS mantissaBitCount was returned successfully. CUBLAS\_STATUS\_INVALID\_VALUE mantissaBitCount is NULL. CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized. 2.4.37. cublasSetFixedPointEmulationMantissaBitCountPointer() cublasStatus\_t cublasSetFixedPointEmulationMantissaBitCountPointer(cublasHandle\_t handle, int \*mantissaBitCount) This function sets the value previously programmed to the library handle. Return Value Meaning CUBLAS\_STATUS\_SUCCESS mantissaBitCount was set successfully. CUBLAS\_STATUS\_INVALID\_VALUE mantissaBitCount is outside of the allowed range. CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized. 2.4.38. cublasLoggerConfigure() cublasStatus\_t cublasLoggerConfigure( int logIsOn, int logToStdOut, int logToStdErr, const char\* logFileName) This function configures logging during runtime. Besides this type of configuration, it is possible to configure logging with special environment variables which will be checked by libcublas: CUBLAS\_LOGINFO\_DBG - setting this environment variable to 1 means turning logging on (by default logging is off). CUBLAS\_LOGDEST\_DBG - this environment variable encodes where to write the log to: stdout, stderr mean to write log messages to standard output or error streams, respectively. Other values are interpreted as file names. Parameters Param. Memory In/out Meaning logIsOn host input Turn on/off logging completely. By default is off, but is turned on by calling cublasSetLoggerCallback() to user defined callback function. logToStdOut host input Turn on/off logging to standard output I/O stream. By default is off. logToStdErr host input Turn on/off logging to standard error I/O stream. By default is off. logFileName host input Turn on/off logging to file in filesystem specified by it’s name. cublasLoggerConfigure() copies the content of logFileName. You should provide null pointer if you are not interested in this type of logging. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully 2.4.39. cublasGetLoggerCallback() cublasStatus\_t cublasGetLoggerCallback( cublasLogCallback\* userCallback) This function retrieves function pointer to previously installed custom user defined callback function via cublasSetLoggerCallback() or zero otherwise. Param. Memory In/out Meaning userCallback host output Pointer to user defined callback function. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_INVALID\_VALUE userCallback is NULL 2.4.40. cublasSetLoggerCallback() cublasStatus\_t cublasSetLoggerCallback( cublasLogCallback userCallback) This function installs a custom user defined callback function via cublas C public API. Param. Memory In/out Meaning userCallback host input Pointer to user defined callback function. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully 2.5. cuBLAS Level-1 Function Reference In this chapter we describe the Level-1 Basic Linear Algebra Subprograms (BLAS1) functions that perform scalar and vector based operations. We will use abbreviations for type and for the corresponding short type to make a more concise and clear presentation of the implemented functions. Unless otherwise specified and have the following meanings:Meaning float s or S real single-precision double d or D real double-precision cuComplex c or C complex single-precision cuDoubleComplex z or Z complex double-precision When the parameters and returned values of the function differ, which sometimes happens for complex input, the can also be Sc, Cs, Dz and Zd. The abbreviation \\(\\mathbf{Re}(\\cdot)\\) and \\(\\mathbf{Im}(\\cdot)\\) will stand for the real and imaginary part of a number, respectively. Since imaginary part of a real number does not exist, we will consider it to be zero and can usually simply discard it from the equation where it is being used. Also, the \\(\\bar{\\alpha}\\) will denote the complex conjugate of \\(\\alpha\\). In general throughout the documentation, the lower case Greek symbols \\(\\alpha\\) and \\(\\beta\\) will denote scalars, lower case English letters in bold type \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) will denote vectors and capital English letters \\(A\\), \\(B\\) and \\(C\\) will denote matrices. 2.5.1. cublasI amax() cublasStatus\_t cublasIsamax(cublasHandle\_t handle, int n, const float \*x, int incx, int \*result) cublasStatus\_t cublasIdamax(cublasHandle\_t handle, int n, const double \*x, int incx, int \*result) cublasStatus\_t cublasIcamax(cublasHandle\_t handle, int n, const cuComplex \*x, int incx, int \*result) cublasStatus\_t cublasIzamax(cublasHandle\_t handle, int n, const cuDoubleComplex \*x, int incx, int \*result) This function supports the 64-bit Integer Interface. This function finds the (smallest) index of the element of the maximum magnitude. Hence, the result is the first \\(i\\) such that \\(\\left| \\mathbf{Im}\\left( {x\\lbrack j\\rbrack} \\right) \\middle| + \\middle| \\mathbf{Re}\\left( {x\\lbrack j\\rbrack} \\right) \\right|\\) is maximum for \\(i = 1,\\ldots,n\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{ incx}\\). Notice that the last equation reflects 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vector x. x device input vector with elements. incx input Stride between consecutive elements of x. result host or device output The resulting index, which is set to 0 if n <= 0 or incx <= 0. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_ALLOC\_FAILED The reduction buffer could not be allocated CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU CUBLAS\_STATUS\_INVALID\_VALUE result is NULL For references please refer to NETLIB documentation: isamax(), idamax(), icamax(), izamax() 2.5.2. cublasI amin() cublasStatus\_t cublasIsamin(cublasHandle\_t handle, int n, const float \*x, int incx, int \*result) cublasStatus\_t cublasIdamin(cublasHandle\_t handle, int n, const double \*x, int incx, int \*result) cublasStatus\_t cublasIcamin(cublasHandle\_t handle, int n, const cuComplex \*x, int incx, int \*result) cublasStatus\_t cublasIzamin(cublasHandle\_t handle, int n, const cuDoubleComplex \*x, int incx, int \*result) This function supports the 64-bit Integer Interface. This function finds the (smallest) index of the element of the minimum magnitude. Hence, the result is the first \\(i\\) such that \\(\\left| \\mathbf{Im}\\left( {x\\lbrack j\\rbrack} \\right) \\middle| + \\middle| \\mathbf{Re}\\left( {x\\lbrack j\\rbrack} \\right) \\right|\\) is minimum for \\(i = 1,\\ldots,n\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\) Notice that the last equation reflects 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vector x. x device input vector with elements. incx input Stride between consecutive elements of x. result host or device output The resulting index, which is set to 0 if n <= 0 or incx <= 0. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_ALLOC\_FAILED The reduction buffer could not be allocated CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU CUBLAS\_STATUS\_INVALID\_VALUE result is NULL For references please refer to NETLIB documentation: isamin() 2.5.3. cublas asum() cublasStatus\_t cublasSasum(cublasHandle\_t handle, int n, const float \*x, int incx, float \*result) cublasStatus\_t cublasDasum(cublasHandle\_t handle, int n, const double \*x, int incx, double \*result) cublasStatus\_t cublasScasum(cublasHandle\_t handle, int n, const cuComplex \*x, int incx, float \*result) cublasStatus\_t cublasDzasum(cublasHandle\_t handle, int n, const cuDoubleComplex \*x, int incx, double \*result) This function supports the 64-bit Integer Interface. This function computes the sum of the absolute values of the elements of vector x. Hence, the result is \\(\\left. \\sum\_{i = 1}^{n} \\middle| \\mathbf{Im}\\left( {x\\lbrack j\\rbrack} \\right) \\middle| + \\middle| \\mathbf{Re}\\left( {x\\lbrack j\\rbrack} \\right) \\right|\\) where \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\). Notice that the last equation reflects 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vector x. x device input vector with elements. incx input Stride between consecutive elements of x. result host or device output The resulting sum, which is set to 0 if n <= 0 or incx <= 0. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_ALLOC\_FAILED The reduction buffer could not be allocated CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU CUBLAS\_STATUS\_INVALID\_VALUE result is NULL For references please refer to NETLIB documentation: sasum(), dasum(), scasum(), dzasum() 2.5.4. cublas axpy() cublasStatus\_t cublasSaxpy(cublasHandle\_t handle, int n, const float \*alpha, const float \*x, int incx, float \*y, int incy) cublasStatus\_t cublasDaxpy(cublasHandle\_t handle, int n, const double \*alpha, const double \*x, int incx, double \*y, int incy) cublasStatus\_t cublasCaxpy(cublasHandle\_t handle, int n, const cuComplex \*alpha, const cuComplex \*x, int incx, cuComplex \*y, int incy) cublasStatus\_t cublasZaxpy(cublasHandle\_t handle, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*x, int incx, cuDoubleComplex \*y, int incy) This function supports the 64-bit Integer Interface. This function multiplies the vector x by the scalar \\(\\alpha\\) and adds it to the vector y overwriting the latest vector with the result. Hence, the performed operation is \\(\\mathbf{y}\\lbrack j\\rbrack = \\alpha \\times \\mathbf{x}\\lbrack k\\rbrack + \\mathbf{y}\\lbrack j\\rbrack\\) for \\(i = 1,\\ldots,n\\), \\(k = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incy}\\). Notice that the last two equations reflect 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. alpha host or device input scalar used for multiplication. n input Number of elements in the vector x and y. x device input vector with n elements. incx input Stride between consecutive elements of x. y device in/out vector with n elements. incy input Stride between consecutive elements of y. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: saxpy(), daxpy(), caxpy(), zaxpy() 2.5.5. cublas copy() cublasStatus\_t cublasScopy(cublasHandle\_t handle, int n, const float \*x, int incx, float \*y, int incy) cublasStatus\_t cublasDcopy(cublasHandle\_t handle, int n, const double \*x, int incx, double \*y, int incy) cublasStatus\_t cublasCcopy(cublasHandle\_t handle, int n, const cuComplex \*x, int incx, cuComplex \*y, int incy) cublasStatus\_t cublasZcopy(cublasHandle\_t handle, int n, const cuDoubleComplex \*x, int incx, cuDoubleComplex \*y, int incy) This function supports the 64-bit Integer Interface. This function copies the vector x into the vector y. Hence, the performed operation is \\(\\mathbf{y}\\lbrack j\\rbrack = \\mathbf{x}\\lbrack k\\rbrack\\) for \\(i = 1,\\ldots,n\\), \\(k = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incy}\\). Notice that the last two equations reflect 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vector x and y. x device input vector with n elements. incx input Stride between consecutive elements of x. y device in/out vector with n elements. incy input Stride between consecutive elements of y. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: scopy(), dcopy(), ccopy(), zcopy() 2.5.6. cublas dot() cublasStatus\_t cublasSdot (cublasHandle\_t handle, int n, const float \*x, int incx, const float \*y, int incy, float \*result) cublasStatus\_t cublasDdot (cublasHandle\_t handle, int n, const double \*x, int incx, const double \*y, int incy, double \*result) cublasStatus\_t cublasCdotu(cublasHandle\_t handle, int n, const cuComplex \*x, int incx, const cuComplex \*y, int incy, cuComplex \*result) cublasStatus\_t cublasCdotc(cublasHandle\_t handle, int n, const cuComplex \*x, int incx, const cuComplex \*y, int incy, cuComplex \*result) cublasStatus\_t cublasZdotu(cublasHandle\_t handle, int n, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*y, int incy, cuDoubleComplex \*result) cublasStatus\_t cublasZdotc(cublasHandle\_t handle, int n, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*y, int incy, cuDoubleComplex \*result) This function supports the 64-bit Integer Interface. This function computes the dot product of vectors x and y. Hence, the result is \\(\\sum\_{i = 1}^{n}\\left( {\\mathbf{x}\\lbrack k\\rbrack \\times \\mathbf{y}\\lbrack j\\rbrack} \\right)\\) where \\(k = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incy}\\). Notice that in the first equation the conjugate of the element of vector x should be used if the function name ends in character ‘c’ and that the last two equations reflect 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vectors x and y. x device input vector with n elements. incx input Stride between consecutive elements of x. y device input vector with n elements. incy input Stride between consecutive elements of y. result host or device output The resulting dot product, which is set to 0 if n <= 0 The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_ALLOC\_FAILED The reduction buffer could not be allocated CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sdot(), ddot(), cdotu(), cdotc(), zdotu(), zdotc() 2.5.7. cublas nrm2() cublasStatus\_t cublasSnrm2(cublasHandle\_t handle, int n, const float \*x, int incx, float \*result) cublasStatus\_t cublasDnrm2(cublasHandle\_t handle, int n, const double \*x, int incx, double \*result) cublasStatus\_t cublasScnrm2(cublasHandle\_t handle, int n, const cuComplex \*x, int incx, float \*result) cublasStatus\_t cublasDznrm2(cublasHandle\_t handle, int n, const cuDoubleComplex \*x, int incx, double \*result) This function supports the 64-bit Integer Interface. This function computes the Euclidean norm of the vector x. The code uses a multiphase model of accumulation to avoid intermediate underflow and overflow, with the result being equivalent to \\(\\sqrt{\\sum\_{i = 1}^{n}\\left( {\\mathbf{x}\\lbrack j\\rbrack \\times \\mathbf{x}\\lbrack j\\rbrack} \\right)}\\) where \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\) in exact arithmetic. Notice that the last equation reflects 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vector x. x device input vector with n elements. incx input Stride between consecutive elements of x. result host or device output The resulting norm, which is set to 0 if n <= 0 or incx <= 0. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_ALLOC\_FAILED The reduction buffer could not be allocated CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU CUBLAS\_STATUS\_INVALID\_VALUE result is NULL For references please refer to NETLIB documentation: snrm2(), dnrm2(), scnrm2(), dznrm2() 2.5.8. cublas rot() cublasStatus\_t cublasSrot(cublasHandle\_t handle, int n, float \*x, int incx, float \*y, int incy, const float \*c, const float \*s) cublasStatus\_t cublasDrot(cublasHandle\_t handle, int n, double \*x, int incx, double \*y, int incy, const double \*c, const double \*s) cublasStatus\_t cublasCrot(cublasHandle\_t handle, int n, cuComplex \*x, int incx, cuComplex \*y, int incy, const float \*c, const cuComplex \*s) cublasStatus\_t cublasCsrot(cublasHandle\_t handle, int n, cuComplex \*x, int incx, cuComplex \*y, int incy, const float \*c, const float \*s) cublasStatus\_t cublasZrot(cublasHandle\_t handle, int n, cuDoubleComplex \*x, int incx, cuDoubleComplex \*y, int incy, const double \*c, const cuDoubleComplex \*s) cublasStatus\_t cublasZdrot(cublasHandle\_t handle, int n, cuDoubleComplex \*x, int incx, cuDoubleComplex \*y, int incy, const double \*c, const double \*s) This function supports the 64-bit Integer Interface. This function applies Givens rotation matrix (i.e., rotation in the x,y plane counter-clockwise by angle defined by \\(cos(alpha) = c\\), \\(sin(alpha) = s\\)): \\(G = \\begin{pmatrix} c & s \\\\ {- s} & c \\\\ \\end{pmatrix}\\) to vectors x and y. Hence, the result is \\(\\mathbf{x}\\lbrack k\\rbrack = c \\times \\mathbf{x}\\lbrack k\\rbrack + s \\times \\mathbf{y}\\lbrack j\\rbrack\\) and \\(\\mathbf{y}\\lbrack j\\rbrack = - s \\times \\mathbf{x}\\lbrack k\\rbrack + c \\times \\mathbf{y}\\lbrack j\\rbrack\\) where \\(k = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incy}\\). Notice that the last two equations reflect 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vectors x and y. x device in/out vector with n elements. incx input Stride between consecutive elements of x. y device in/out vector with n elements. incy input Stride between consecutive elements of y. c host or device input Cosine element of the rotation matrix. s host or device input Sine element of the rotation matrix. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: srot(), drot(), crot(), csrot(), zrot(), zdrot() 2.5.9. cublas rotg() cublasStatus\_t cublasSrotg(cublasHandle\_t handle, float \*a, float \*b, float \*c, float \*s) cublasStatus\_t cublasDrotg(cublasHandle\_t handle, double \*a, double \*b, double \*c, double \*s) cublasStatus\_t cublasCrotg(cublasHandle\_t handle, cuComplex \*a, cuComplex \*b, float \*c, cuComplex \*s) cublasStatus\_t cublasZrotg(cublasHandle\_t handle, cuDoubleComplex \*a, cuDoubleComplex \*b, double \*c, cuDoubleComplex \*s) This function supports the 64-bit Integer Interface. This function constructs the Givens rotation matrix \\(G = \\begin{pmatrix} c & s \\\\ {- s} & c \\\\ \\end{pmatrix}\\) that zeros out the second entry of a \\(2 \\times 1\\) vector \\(\\left( {a,b} \\right)^{T}\\). Then, for real numbers we can write \\(\\begin{pmatrix} c & s \\\\ {- s} & c \\\\ \\end{pmatrix}\\begin{pmatrix} a \\\\ b \\\\ \\end{pmatrix} = \\begin{pmatrix} r \\\\ 0 \\\\ \\end{pmatrix}\\) where \\(c^{2} + s^{2} = 1\\) and \\(r = \\pm \\sqrt{a^{2} + b^{2}}\\). The parameters \\(a\\) and \\(b\\) are overwritten with \\(r\\) and \\(z\\), respectively. The value of \\(z\\) is such that \\(c\\) and \\(s\\) may be recovered using the following rules: \\(\\left( {c,s} \\right) = \\begin{cases} \\left( {\\sqrt{1 - z^{2}},z} \\right) & {\\text{ if }\\left| z \\middle| < 1 \\right.} \\\\ \\left( {0.0,1.0} \\right) & {\\text{ if }\\left| z \\middle| = 1 \\right.} \\\\ \\left( 1/z,\\sqrt{1 - z^{2}} \\right) & {\\text{ if }\\left| z \\middle| > 1 \\right.} \\\\ \\end{cases}\\) For complex numbers we can write \\(\\begin{pmatrix} c & s \\\\ {- \\bar{s}} & c \\\\ \\end{pmatrix}\\begin{pmatrix} a \\\\ b \\\\ \\end{pmatrix} = \\begin{pmatrix} r \\\\ 0 \\\\ \\end{pmatrix}\\) where \\(c^{2} + \\left( {\\bar{s} \\times s} \\right) = 1\\) and \\(r = \\frac{a}{|a|} \\times \\parallel \\left( {a,b} \\right)^{T} \\parallel\_{2}\\) with \\(\\parallel \\left( {a,b} \\right)^{T} \\parallel\_{2} = \\sqrt{\\left| a|^{2} + \\middle| B|^{2} \\right.}\\) for \\(a \\neq 0\\) and \\(r = b\\) for \\(a = 0\\). Finally, the parameter \\(a\\) is overwritten with \\(r\\) on exit. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. a host or device in/out scalar that is overwritten with \\(r\\). b host or device in/out scalar that is overwritten with \\(z\\). c host or device output Cosine element of the rotation matrix. s host or device output Sine element of the rotation matrix. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: srotg(), drotg(), crotg(), zrotg() 2.5.10. cublas rotm() cublasStatus\_t cublasSrotm(cublasHandle\_t handle, int n, float \*x, int incx, float \*y, int incy, const float\* param) cublasStatus\_t cublasDrotm(cublasHandle\_t handle, int n, double \*x, int incx, double \*y, int incy, const double\* param) This function supports the 64-bit Integer Interface. This function applies the modified Givens transformation \\(H = \\begin{pmatrix} h\_{11} & h\_{12} \\\\ h\_{21} & h\_{22} \\\\ \\end{pmatrix}\\) to vectors x and y. Hence, the result is \\(\\mathbf{x}\\lbrack k\\rbrack = h\_{11} \\times \\mathbf{x}\\lbrack k\\rbrack + h\_{12} \\times \\mathbf{y}\\lbrack j\\rbrack\\) and \\(\\mathbf{y}\\lbrack j\\rbrack = h\_{21} \\times \\mathbf{x}\\lbrack k\\rbrack + h\_{22} \\times \\mathbf{y}\\lbrack j\\rbrack\\) where \\(k = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incy}\\). Notice that the last two equations reflect 1-based indexing used for compatibility with Fortran. The elements,, and of matrix \\(H\\) are stored in param\[1\], param\[2\], param\[3\] and param\[4\], respectively. The flag = param\[0\] defines the following predefined values for the matrix \\(H\\) entries flag == -1.0 flag == 0.0 flag == 1.0 flag == -2.0 \\(\\begin{pmatrix} h\_{11} & h\_{12} \\\\ h\_{21} & h\_{22} \\\\ \\end{pmatrix}\\) \\(\\begin{pmatrix} {1.0} & h\_{12} \\\\ h\_{21} & {1.0} \\\\ \\end{pmatrix}\\) \\(\\begin{pmatrix} h\_{11} & {1.0} \\\\ {- 1.0} & h\_{22} \\\\ \\end{pmatrix}\\) \\(\\begin{pmatrix} {1.0} & {0.0} \\\\ {0.0} & {1.0} \\\\ \\end{pmatrix}\\) Notice that the values -1.0, 0.0 and 1.0 implied by the flag are not stored in param. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vectors x and y. x device in/out vector with n elements. incx input Stride between consecutive elements of x. y device in/out vector with n elements. incy input Stride between consecutive elements of y. param host or device input vector of 5 elements, where param\[0\] and param\[1..4\] contain the flag and matrix \\(H\\). The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: srotm(), drotm() 2.5.11. cublas rotmg() cublasStatus\_t cublasSrotmg(cublasHandle\_t handle, float \*d1, float \*d2, float \*x1, const float \*y1, float \*param) cublasStatus\_t cublasDrotmg(cublasHandle\_t handle, double \*d1, double \*d2, double \*x1, const double \*y1, double \*param) This function supports the 64-bit Integer Interface. This function constructs the modified Givens transformation \\(H = \\begin{pmatrix} h\_{11} & h\_{12} \\\\ h\_{21} & h\_{22} \\\\ \\end{pmatrix}\\) that zeros out the second entry of a \\(2 \\times 1\\) vector \\(\\left( {\\sqrt{d1}\*x1,\\sqrt{d2}\*y1} \\right)^{T}\\). The flag = param\[0\] defines the following predefined values for the matrix \\(H\\) entries flag == -1.0 flag == 0.0 flag == 1.0 flag == -2.0 \\(\\begin{pmatrix} h\_{11} & h\_{12} \\\\ h\_{21} & h\_{22} \\\\ \\end{pmatrix}\\) \\(\\begin{pmatrix} {1.0} & h\_{12} \\\\ h\_{21} & {1.0} \\\\ \\end{pmatrix}\\) \\(\\begin{pmatrix} h\_{11} & {1.0} \\\\ {- 1.0} & h\_{22} \\\\ \\end{pmatrix}\\) \\(\\begin{pmatrix} {1.0} & {0.0} \\\\ {0.0} & {1.0} \\\\ \\end{pmatrix}\\) Notice that the values -1.0, 0.0 and 1.0 implied by the flag are not stored in param. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. d1 host or device in/out scalar that is overwritten on exit. d2 host or device in/out scalar that is overwritten on exit. x1 host or device in/out scalar that is overwritten on exit. y1 host or device input scalar. param host or device output vector of 5 elements, where param\[0\] and param\[1-4\] contain the flag and matrix \\(H\\). The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: srotmg(), drotmg() 2.5.12. cublas scal() cublasStatus\_t cublasSscal(cublasHandle\_t handle, int n, const float \*alpha, float \*x, int incx) cublasStatus\_t cublasDscal(cublasHandle\_t handle, int n, const double \*alpha, double \*x, int incx) cublasStatus\_t cublasCscal(cublasHandle\_t handle, int n, const cuComplex \*alpha, cuComplex \*x, int incx) cublasStatus\_t cublasCsscal(cublasHandle\_t handle, int n, const float \*alpha, cuComplex \*x, int incx) cublasStatus\_t cublasZscal(cublasHandle\_t handle, int n, const cuDoubleComplex \*alpha, cuDoubleComplex \*x, int incx) cublasStatus\_t cublasZdscal(cublasHandle\_t handle, int n, const double \*alpha, cuDoubleComplex \*x, int incx) This function supports the 64-bit Integer Interface. This function scales the vector x by the scalar \\(\\alpha\\) and overwrites it with the result. Hence, the performed operation is \\(\\mathbf{x}\\lbrack j\\rbrack = \\alpha \\times \\mathbf{x}\\lbrack j\\rbrack\\) for \\(i = 1,\\ldots,n\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\). Notice that the last two equations reflect 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. alpha host or device input scalar used for multiplication. n input Number of elements in the vector x. x device in/out vector with n elements. incx input Stride between consecutive elements of x. The possible error values returned by this function and their meanings are listed below.:class: table-no-stripes Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sscal(), dscal(), csscal(), cscal(), zdscal(), zscal() 2.5.13. cublas swap() cublasStatus\_t cublasSswap(cublasHandle\_t handle, int n, float \*x, int incx, float \*y, int incy) cublasStatus\_t cublasDswap(cublasHandle\_t handle, int n, double \*x, int incx, double \*y, int incy) cublasStatus\_t cublasCswap(cublasHandle\_t handle, int n, cuComplex \*x, int incx, cuComplex \*y, int incy) cublasStatus\_t cublasZswap(cublasHandle\_t handle, int n, cuDoubleComplex \*x, int incx, cuDoubleComplex \*y, int incy) This function supports the 64-bit Integer Interface. This function interchanges the elements of vector x and y. Hence, the performed operation is \\(\\left. \\mathbf{y}\\lbrack j\\rbrack\\Leftrightarrow\\mathbf{x}\\lbrack k\\rbrack \\right.\\) for \\(i = 1,\\ldots,n\\), \\(k = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incy}\\). Notice that the last two equations reflect 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vectors x and y. x device in/out vector with n elements. incx input Stride between consecutive elements of x. y device in/out vector with n elements. incy input Stride between consecutive elements of y. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sswap(), dswap(), cswap(), zswap() 2.6. cuBLAS Level-2 Function Reference In this chapter we describe the Level-2 Basic Linear Algebra Subprograms (BLAS2) functions that perform matrix-vector operations. 2.6.1. cublas gbmv() cublasStatus\_t cublasSgbmv(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, int kl, int ku, const float \*alpha, const float \*A, int lda, const float \*x, int incx, const float \*beta, float \*y, int incy) cublasStatus\_t cublasDgbmv(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, int kl, int ku, const double \*alpha, const double \*A, int lda, const double \*x, int incx, const double \*beta, double \*y, int incy) cublasStatus\_t cublasCgbmv(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, int kl, int ku, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*x, int incx, const cuComplex \*beta, cuComplex \*y, int incy) cublasStatus\_t cublasZgbmv(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, int kl, int ku, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*beta, cuDoubleComplex \*y, int incy) This function supports the 64-bit Integer Interface. This function performs the banded matrix-vector multiplication \\(\\mathbf{y} = \\alpha\\text{ op}(A)\\mathbf{x} + \\beta\\mathbf{y}\\) where \\(A\\) is a banded matrix with \\(kl\\) subdiagonals and \\(ku\\) superdiagonals, \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) are vectors, and \\(\\alpha\\) and \\(\\beta\\) are scalars. Also, for matrix \\(A\\) \\(\\text{ op}(A) = \\begin{cases} A & \\text{ if trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$} \\\\ A^{T} & \\text{ if trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$} \\\\ A^{H} & \\text{ if trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$} \\\\ \\end{cases}\\) The banded matrix \\(A\\) is stored column by column, with the main diagonal stored in row \\(ku + 1\\) (starting in first position), the first superdiagonal stored in row \\(ku\\) (starting in second position), the first subdiagonal stored in row \\(ku + 2\\) (starting in first position), etc. So that in general, the element \\(A\\left( {i,j} \\right)\\) is stored in the memory location A(ku+1+i-j,j) for \\(j = 1,\\ldots,n\\) and \\(i \\in \\left\\lbrack {\\max\\left( {1,j - ku} \\right),\\min\\left( {m,j + kl} \\right)} \\right\\rbrack\\). Also, the elements in the array \\(A\\) that do not conceptually correspond to the elements in the banded matrix (the top left \\(ku \\times ku\\) and bottom right \\(kl \\times kl\\) triangles) are not referenced. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. trans input Operation op(A) that is non- or (conj.) transpose. m input Number of rows of matrix A. n input Number of columns of matrix A. kl input Number of subdiagonals of matrix A. ku input Number of superdiagonals of matrix A. alpha host or device input scalar used for multiplication. A device input array of dimension lda x n with lda >= kl + ku + 1. lda input Leading dimension of two-dimensional array used to store matrix A. x device input vector with n elements if trans == CUBLAS\_OP\_N and m elements otherwise. incx input Stride between consecutive elements of x. beta host or device input scalar used for multiplication. If beta == 0 then y does not have to be a valid input. y device in/out vector with m elements if trans == CUBLAS\_OP\_N and n elements otherwise. incy input Stride between consecutive elements of y. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0, n < 0, kl < 0 or ku < 0, or if lda < (kl + ku + 1), or if incx == 0 or incy == 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T, CUBLAS\_OP\_C, or if alpha or beta are NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sgbmv(), dgbmv(), cgbmv(), zgbmv() 2.6.2. cublas gemv() cublasStatus\_t cublasSgemv(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const float \*alpha, const float \*A, int lda, const float \*x, int incx, const float \*beta, float \*y, int incy) cublasStatus\_t cublasDgemv(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const double \*alpha, const double \*A, int lda, const double \*x, int incx, const double \*beta, double \*y, int incy) cublasStatus\_t cublasCgemv(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*x, int incx, const cuComplex \*beta, cuComplex \*y, int incy) cublasStatus\_t cublasZgemv(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*beta, cuDoubleComplex \*y, int incy) This function supports the 64-bit Integer Interface. This function performs the matrix-vector multiplication \\(\\textbf{y} = \\alpha\\text{ op}(A)\\textbf{x} + \\beta\\textbf{y}\\) where \\(A\\) is a \\(m \\times n\\) matrix stored in column-major format, \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) are vectors, and \\(\\alpha\\) and \\(\\beta\\) are scalars. Also, for matrix \\(A\\) \\(\\text{ op}(A) = \\begin{cases} A & \\text{ if trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$} \\\\ A^{T} & \\text{ if trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$} \\\\ A^{H} & \\text{ if trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$} \\\\ \\end{cases}\\) Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. trans input Operation op(A) that is non- or (conj.) transpose. m input Number of rows of matrix A. n input Number of columns of matrix A. alpha host or device input scalar used for multiplication. A device input array of dimension lda x n with lda >= max(1, m). Before entry, the leading m by n part of the array A must contain the matrix of coefficients. Unchanged on exit. lda input Leading dimension of two-dimensional array used to store matrix A. lda must be at least max(1, m). x device input vector at least (1 + (n - 1) \* abs(incx)) elements if trans == CUBLAS\_OP\_N and at least (1 + (m - 1) \* abs(incx)) elements otherwise. incx input Stride between consecutive elements of x. beta host or device input scalar used for multiplication. If beta == 0 then y does not have to be a valid input. y device in/out vector at least (1 + (m - 1) \* abs(incy)) elements if trans == CUBLAS\_OP\_N and at least (1 + (n - 1) \* abs(incy)) elements otherwise. incy input Stride between consecutive elements of y The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE The parameters m < 0 or n < 0, or incx == 0 or incy == 0 CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sgemv(), dgemv(), cgemv(), zgemv() 2.6.3. cublas ger() cublasStatus\_t cublasSger(cublasHandle\_t handle, int m, int n, const float \*alpha, const float \*x, int incx, const float \*y, int incy, float \*A, int lda) cublasStatus\_t cublasDger(cublasHandle\_t handle, int m, int n, const double \*alpha, const double \*x, int incx, const double \*y, int incy, double \*A, int lda) cublasStatus\_t cublasCgeru(cublasHandle\_t handle, int m, int n, const cuComplex \*alpha, const cuComplex \*x, int incx, const cuComplex \*y, int incy, cuComplex \*A, int lda) cublasStatus\_t cublasCgerc(cublasHandle\_t handle, int m, int n, const cuComplex \*alpha, const cuComplex \*x, int incx, const cuComplex \*y, int incy, cuComplex \*A, int lda) cublasStatus\_t cublasZgeru(cublasHandle\_t handle, int m, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*y, int incy, cuDoubleComplex \*A, int lda) cublasStatus\_t cublasZgerc(cublasHandle\_t handle, int m, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*y, int incy, cuDoubleComplex \*A, int lda) This function supports the 64-bit Integer Interface. This function performs the rank-1 update \\(A = \\begin{cases} {\\alpha\\mathbf{xy}^{T} + A} & \\text{if ger(),geru() is called} \\\\ {\\alpha\\mathbf{xy}^{H} + A} & \\text{if gerc() is called} \\\\ \\end{cases}\\) where \\(A\\) is a \\(m \\times n\\) matrix stored in column-major format, \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) are vectors, and \\(\\alpha\\) is a scalar. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. m input Number of rows of matrix A. n input Number of columns of matrix A. alpha host or device input scalar used for multiplication. x device input vector with m elements. incx input Stride between consecutive elements of x. y device input vector with n elements. incy input Stride between consecutive elements of y. A device in/out array of dimension lda x n with lda >= max(1, m). lda input Leading dimension of two-dimensional array used to store matrix A. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0, or if incx == 0 or incy == 0, or if alpha is NULL, or if lda < max(1, m) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sger(), dger(), cgeru(), cgerc(), zgeru(), zgerc() 2.6.4. cublas sbmv() cublasStatus\_t cublasSsbmv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, int k, const float \*alpha, const float \*A, int lda, const float \*x, int incx, const float \*beta, float \*y, int incy) cublasStatus\_t cublasDsbmv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, int k, const double \*alpha, const double \*A, int lda, const double \*x, int incx, const double \*beta, double \*y, int incy) This function supports the 64-bit Integer Interface. This function performs the symmetric banded matrix-vector multiplication \\(\\textbf{y} = \\alpha A\\textbf{x} + \\beta\\textbf{y}\\) where \\(A\\) is a \\(n \\times n\\) symmetric banded matrix with \\(k\\) subdiagonals and superdiagonals, \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) are vectors, and \\(\\alpha\\) and \\(\\beta\\) are scalars. If uplo == CUBLAS\_FILL\_MODE\_LOWER then the symmetric banded matrix \\(A\\) is stored column by column, with the main diagonal of the matrix stored in row 1, the first subdiagonal in row 2 (starting at first position), the second subdiagonal in row 3 (starting at first position), etc. So that in general, the element \\(A(i,j)\\) is stored in the memory location A(1+i-j,j) for \\(j = 1,\\ldots,n\\) and \\(i \\in \\lbrack j,\\min(m,j + k)\\rbrack\\). Also, the elements in the array A that do not conceptually correspond to the elements in the banded matrix (the bottom right \\(k \\times k\\) triangle) are not referenced. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the symmetric banded matrix \\(A\\) is stored column by column, with the main diagonal of the matrix stored in row k + 1, the first superdiagonal in row k (starting at second position), the second superdiagonal in row k-1 (starting at third position), etc. So that in general, the element \\(A(i,j)\\) is stored in the memory location A(1+k+i-j,j) for \\(j = 1,\\ldots,n\\) and \\(i \\in \\lbrack\\max(1,j - k),j\\rbrack\\). Also, the elements in the array A that do not conceptually correspond to the elements in the banded matrix (the top left \\(k \\times k\\) triangle) are not referenced. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix A. k input Number of sub- and super-diagonals of matrix A. alpha host or device input scalar used for multiplication. A device input array of dimension lda x n with lda >= k + 1. lda input Leading dimension of two-dimensional array used to store matrix A. x device input vector with n elements. incx input Stride between consecutive elements of x. beta host or device input scalar used for multiplication. If beta == 0 then y does not have to be a valid input. y device in/out vector with n elements. incy input Stride between consecutive elements of y. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if incx == 0 or incy == 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if alpha or beta are NULL, or if lda < (1 + k) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: ssbmv(), dsbmv() 2.6.5. cublas spmv() cublasStatus\_t cublasSspmv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const float \*alpha, const float \*AP, const float \*x, int incx, const float \*beta, float \*y, int incy) cublasStatus\_t cublasDspmv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const double \*alpha, const double \*AP, const double \*x, int incx, const double \*beta, double \*y, int incy) This function supports the 64-bit Integer Interface. This function performs the symmetric packed matrix-vector multiplication \\(\\textbf{y} = \\alpha A\\textbf{x} + \\beta\\textbf{y}\\) where \\(A\\) is a \\(n \\times n\\) symmetric matrix stored in packed format, \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) are vectors, and \\(\\alpha\\) and \\(\\beta\\) are scalars. If uplo == CUBLAS\_FILL\_MODE\_LOWER then the elements in the lower triangular part of the symmetric matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+((2\*n-j+1)\*j)/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\geq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the elements in the upper triangular part of the symmetric matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+(j\*(j+1))/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\leq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix \\(A\\) lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix \\(A\\). alpha host or device input scalar used for multiplication. AP device input array with \\(A\\) stored in packed format. x device input vector with n elements. incx input Stride between consecutive elements of x. beta host or device input scalar used for multiplication. If beta == 0 then y does not have to be a valid input. y device input vector with n elements. incy input Stride between consecutive elements of y. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0 or incy == 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if alpha or beta are NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sspmv(), dspmv() 2.6.6. cublas spr() cublasStatus\_t cublasSspr(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const float \*alpha, const float \*x, int incx, float \*AP) cublasStatus\_t cublasDspr(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const double \*alpha, const double \*x, int incx, double \*AP) This function supports the 64-bit Integer Interface. This function performs the packed symmetric rank-1 update \\(A = \\alpha\\textbf{x}\\textbf{x}^{T} + A\\) where \\(A\\) is a \\(n \\times n\\) symmetric matrix stored in packed format, \\(\\mathbf{x}\\) is a vector, and \\(\\alpha\\) is a scalar. If uplo == CUBLAS\_FILL\_MODE\_LOWER then the elements in the lower triangular part of the symmetric matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+((2\*n-j+1)\*j)/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\geq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the elements in the upper triangular part of the symmetric matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+(j\*(j+1))/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\leq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix \\(A\\) lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix \\(A\\). alpha host or device input scalar used for multiplication. x device input vector with n elements. incx input Stride between consecutive elements of x. AP device in/out array with \\(A\\) stored in packed format. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if alpha is NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sspr(), dspr() 2.6.7. cublas spr2() cublasStatus\_t cublasSspr2(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const float \*alpha, const float \*x, int incx, const float \*y, int incy, float \*AP) cublasStatus\_t cublasDspr2(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const double \*alpha, const double \*x, int incx, const double \*y, int incy, double \*AP) This function supports the 64-bit Integer Interface. This function performs the packed symmetric rank-2 update \\(A = \\alpha\\left( {\\textbf{x}\\textbf{y}^{T} + \\textbf{y}\\textbf{x}^{T}} \\right) + A\\) where \\(A\\) is a \\(n \\times n\\) symmetric matrix stored in packed format, \\(\\mathbf{x}\\) is a vector, and \\(\\alpha\\) is a scalar. If uplo == CUBLAS\_FILL\_MODE\_LOWER then the elements in the lower triangular part of the symmetric matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+((2\*n-j+1)\*j)/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\geq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the elements in the upper triangular part of the symmetric matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+(j\*(j+1))/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\leq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix \\(A\\) lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix \\(A\\). alpha host or device input scalar used for multiplication. x device input vector with n elements. incx input Stride between consecutive elements of x. y device input vector with n elements. incy input Stride between consecutive elements of y. AP device in/out array with \\(A\\) stored in packed format. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0 or incy == 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if alpha is NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sspr2(), dspr2() 2.6.8. cublas symv() cublasStatus\_t cublasSsymv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const float \*alpha, const float \*A, int lda, const float \*x, int incx, const float \*beta, float \*y, int incy) cublasStatus\_t cublasDsymv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const double \*alpha, const double \*A, int lda, const double \*x, int incx, const double \*beta, double \*y, int incy) cublasStatus\_t cublasCsymv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuComplex \*alpha, /\* host or device pointer \*/ const cuComplex \*A, int lda, const cuComplex \*x, int incx, const cuComplex \*beta, cuComplex \*y, int incy) cublasStatus\_t cublasZsymv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*beta, cuDoubleComplex \*y, int incy) This function supports the 64-bit Integer Interface. This function performs the symmetric matrix-vector multiplication. \\(\\textbf{y} = \\alpha A\\textbf{x} + \\beta\\textbf{y}\\) where \\(A\\) is a \\(n \\times n\\) symmetric matrix stored in lower or upper mode, \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) are vectors, and \\(\\alpha\\) and \\(\\beta\\) are scalars. This function has an alternate faster implementation using atomics that can be enabled with cublasSetAtomicsMode(). Please see the section on the function cublasSetAtomicsMode() for more details about the usage of atomics. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix A. alpha host or device input scalar used for multiplication. A device input array of dimension lda x n with lda >= max(1, n). lda input Leading dimension of two-dimensional array used to store matrix A. x device input vector with n elements. incx input Stride between consecutive elements of x. beta host or device input scalar used for multiplication. If beta == 0 then y does not have to be a valid input. y device in/out vector with n elements. incy input Stride between consecutive elements of y. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0 or incy == 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < n CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: ssymv(), dsymv() 2.6.9. cublas syr() cublasStatus\_t cublasSsyr(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const float \*alpha, const float \*x, int incx, float \*A, int lda) cublasStatus\_t cublasDsyr(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const double \*alpha, const double \*x, int incx, double \*A, int lda) cublasStatus\_t cublasCsyr(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuComplex \*alpha, const cuComplex \*x, int incx, cuComplex \*A, int lda) cublasStatus\_t cublasZsyr(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*x, int incx, cuDoubleComplex \*A, int lda) This function supports the 64-bit Integer Interface. This function performs the symmetric rank-1 update \\(A = \\alpha\\textbf{x}\\textbf{x}^{T} + A\\) where \\(A\\) is a \\(n \\times n\\) symmetric matrix stored in column-major format, \\(\\mathbf{x}\\) is a vector, and \\(\\alpha\\) is a scalar. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix A. alpha host or device input scalar used for multiplication. x device input vector with n elements. incx input Stride between consecutive elements of x. A device in/out array of dimensions lda x n, with lda >= max(1, n). lda input Leading dimension of two-dimensional array used to store matrix A. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, n), or if alpha is NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: ssyr(), dsyr() 2.6.10. cublas syr2() cublasStatus\_t cublasSsyr2(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const float \*alpha, const float \*x, int incx, const float \*y, int incy, float \*A, int lda cublasStatus\_t cublasDsyr2(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const double \*alpha, const double \*x, int incx, const double \*y, int incy, double \*A, int lda cublasStatus\_t cublasCsyr2(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuComplex \*alpha, const cuComplex \*x, int incx, const cuComplex \*y, int incy, cuComplex \*A, int lda cublasStatus\_t cublasZsyr2(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*y, int incy, cuDoubleComplex \*A, int lda This function supports the 64-bit Integer Interface. This function performs the symmetric rank-2 update \\(A = \\alpha\\left( {\\textbf{x}\\textbf{y}^{T} + \\textbf{y}\\textbf{x}^{T}} \\right) + A\\) where \\(A\\) is a \\(n \\times n\\) symmetric matrix stored in column-major format, \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) are vectors, and \\(\\alpha\\) is a scalar. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix A. alpha host or device input scalar used for multiplication. x device input vector with n elements. incx input Stride between consecutive elements of x. y device input vector with n elements. incy input Stride between consecutive elements of y. A device in/out array of dimensions lda x n, with lda >= max(1,n). lda input Leading dimension of two-dimensional array used to store matrix A. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0 or incy == 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if alpha is NULL, or if lda < max(1, n) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: ssyr2(), dsyr2() 2.6.11. cublas tbmv() cublasStatus\_t cublasStbmv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, int k, const float \*A, int lda, float \*x, int incx) cublasStatus\_t cublasDtbmv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, int k, const double \*A, int lda, double \*x, int incx) cublasStatus\_t cublasCtbmv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, int k, const cuComplex \*A, int lda, cuComplex \*x, int incx) cublasStatus\_t cublasZtbmv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, int k, const cuDoubleComplex \*A, int lda, cuDoubleComplex \*x, int incx) This function supports the 64-bit Integer Interface. This function performs the triangular banded matrix-vector multiplication \\(\\textbf{x} = \\text{op}(A)\\textbf{x}\\) where \\(A\\) is a triangular banded matrix, and \\(\\mathbf{x}\\) is a vector. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) If uplo == CUBLAS\_FILL\_MODE\_LOWER then the triangular banded matrix \\(A\\) is stored column by column, with the main diagonal of the matrix stored in row 1, the first subdiagonal in row 2 (starting at first position), the second subdiagonal in row 3 (starting at first position), etc. So that in general, the element \\(A(i,j)\\) is stored in the memory location A(1+i-j,j) for \\(j = 1,\\ldots,n\\) and \\(i \\in \\lbrack j,\\min(m,j + k)\\rbrack\\). Also, the elements in the array A that do not conceptually correspond to the elements in the banded matrix (the bottom right \\(k \\times k\\) triangle) are not referenced. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the triangular banded matrix \\(A\\) is stored column by column, with the main diagonal of the matrix stored in row k + 1, the first superdiagonal in row k (starting at second position), the second superdiagonal in row k-1 (starting at third position), etc. So that in general, the element \\(A(i,j)\\) is stored in the memory location A(1+k+i-j,j) for \\(j = 1,\\ldots,n\\) and \\(i \\in \\lbrack\\max(1,j - k,j)\\rbrack\\). Also, the elements in the array A that do not conceptually correspond to the elements in the banded matrix (the top left \\(k \\times k\\) triangle) are not referenced. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or (conj.) transpose. diag input Indicates if the elements on the main diagonal of matrix A are unity and should not be accessed. n input Number of rows and columns of matrix A. k input Number of sub- and super-diagonals of matrix. A device input array of dimension lda x n, with lda >= k + 1. lda input Leading dimension of two-dimensional array used to store matrix A. x device in/out vector with n elements. incx input Stride between consecutive elements of x. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if incx == 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if diag is not one of CUBLAS\_DIAG\_UNIT and CUBLAS\_DIAG\_NON\_UNIT, or if lda < (1 + k) CUBLAS\_STATUS\_ALLOC\_FAILED The allocation of internal scratch memory failed CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: stbmv(), dtbmv(), ctbmv(), ztbmv() 2.6.12. cublas tbsv() cublasStatus\_t cublasStbsv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, int k, const float \*A, int lda, float \*x, int incx) cublasStatus\_t cublasDtbsv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, int k, const double \*A, int lda, double \*x, int incx) cublasStatus\_t cublasCtbsv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, int k, const cuComplex \*A, int lda, cuComplex \*x, int incx) cublasStatus\_t cublasZtbsv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, int k, const cuDoubleComplex \*A, int lda, cuDoubleComplex \*x, int incx) This function supports the 64-bit Integer Interface. This function solves the triangular banded linear system with a single right-hand-side \\(\\text{op}(A)\\textbf{x} = \\textbf{b}\\) where \\(A\\) is a triangular banded matrix, and \\(\\mathbf{x}\\) and \\(\\mathbf{b}\\) are vectors. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) The solution \\(\\mathbf{x}\\) overwrites the right-hand-sides \\(\\mathbf{b}\\) on exit. No test for singularity or near-singularity is included in this function. If uplo == CUBLAS\_FILL\_MODE\_LOWER then the triangular banded matrix \\(A\\) is stored column by column, with the main diagonal of the matrix stored in row 1, the first subdiagonal in row 2 (starting at first position), the second subdiagonal in row 3 (starting at first position), etc. So that in general, the element \\(A(i,j)\\) is stored in the memory location A(1+i-j,j) for \\(j = 1,\\ldots,n\\) and \\(i \\in \\lbrack j,\\min(m,j + k)\\rbrack\\). Also, the elements in the array A that do not conceptually correspond to the elements in the banded matrix (the bottom right \\(k \\times k\\) triangle) are not referenced. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the triangular banded matrix \\(A\\) is stored column by column, with the main diagonal of the matrix stored in row k + 1, the first superdiagonal in row k (starting at second position), the second superdiagonal in row k-1 (starting at third position), etc. So that in general, the element \\(A(i,j)\\) is stored in the memory location A(1+k+i-j,j) for \\(j = 1,\\ldots,n\\) and \\(i \\in \\lbrack\\max(1,j - k,j)\\rbrack\\). Also, the elements in the array A that do not conceptually correspond to the elements in the banded matrix (the top left \\(k \\times k\\) triangle) are not referenced. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or (conj.) transpose. diag input Indicates if the elements on the main diagonal of matrix A are unity and should not be accessed. n input Number of rows and columns of matrix A. k input Number of sub- and super-diagonals of matrix A. A device input array of dimension lda x n, with lda >= k+1. lda input Leading dimension of two-dimensional array used to store matrix A. x device in/out vector with n elements. incx input Stride between consecutive elements of x. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if incx == 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if diag is not one of CUBLAS\_DIAG\_UNIT and CUBLAS\_DIAG\_NON\_UNIT, or if lda < (1 + k) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: stbsv(), dtbsv(), ctbsv(), ztbsv() 2.6.13. cublas tpmv() cublasStatus\_t cublasStpmv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const float \*AP, float \*x, int incx) cublasStatus\_t cublasDtpmv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const double \*AP, double \*x, int incx) cublasStatus\_t cublasCtpmv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const cuComplex \*AP, cuComplex \*x, int incx) cublasStatus\_t cublasZtpmv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const cuDoubleComplex \*AP, cuDoubleComplex \*x, int incx) This function supports the 64-bit Integer Interface. This function performs the triangular packed matrix-vector multiplication \\(\\textbf{x} = \\text{op}(A)\\textbf{x}\\) where \\(A\\) is a triangular matrix stored in packed format, and \\(\\mathbf{x}\\) is a vector. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) If uplo == CUBLAS\_FILL\_MODE\_LOWER then the elements in the lower triangular part of the triangular matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+((2\*n-j+1)\*j)/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\geq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the elements in the upper triangular part of the triangular matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+(j\*(j+1))/2\] for \\(A(i,j)\\) and \\(i \\leq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or (conj.) transpose. diag input Indicates if the elements on the main diagonal of matrix A are unity and should not be accessed. n input Number of rows and columns of matrix A. AP device input array with \\(A\\) stored in packed format. x device in/out vector with n elements. incx input Stride between consecutive elements of x. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if diag is not one of CUBLAS\_DIAG\_UNIT and CUBLAS\_DIAG\_NON\_UNIT CUBLAS\_STATUS\_ALLOC\_FAILED The allocation of internal scratch memory failed CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: stpmv(), dtpmv(), ctpmv(), ztpmv() 2.6.14. cublas tpsv() cublasStatus\_t cublasStpsv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const float \*AP, float \*x, int incx) cublasStatus\_t cublasDtpsv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const double \*AP, double \*x, int incx) cublasStatus\_t cublasCtpsv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const cuComplex \*AP, cuComplex \*x, int incx) cublasStatus\_t cublasZtpsv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const cuDoubleComplex \*AP, cuDoubleComplex \*x, int incx) This function supports the 64-bit Integer Interface. This function solves the packed triangular linear system with a single right-hand-side \\(\\text{op}(A)\\textbf{x} = \\textbf{b}\\) where \\(A\\) is a triangular matrix stored in packed format, and \\(\\mathbf{x}\\) and \\(\\mathbf{b}\\) are vectors. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) The solution \\(\\mathbf{x}\\) overwrites the right-hand-sides \\(\\mathbf{b}\\) on exit. No test for singularity or near-singularity is included in this function. If uplo == CUBLAS\_FILL\_MODE\_LOWER then the elements in the lower triangular part of the triangular matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+((2\*n-j+1)\*j)/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\geq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the elements in the upper triangular part of the triangular matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+(j\*(j+1))/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\leq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or (conj.) transpose. diag input Indicates if the elements on the main diagonal of matrix are unity and should not be accessed. n input Number of rows and columns of matrix A. AP device input array with \\(A\\) stored in packed format. x device in/out vector with n elements. incx input Stride between consecutive elements of x. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if diag is not one of CUBLAS\_DIAG\_UNIT and CUBLAS\_DIAG\_NON\_UNIT CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: stpsv(), dtpsv(), ctpsv(), ztpsv() 2.6.15. cublas trmv() cublasStatus\_t cublasStrmv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const float \*A, int lda, float \*x, int incx) cublasStatus\_t cublasDtrmv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const double \*A, int lda, double \*x, int incx) cublasStatus\_t cublasCtrmv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const cuComplex \*A, int lda, cuComplex \*x, int incx) cublasStatus\_t cublasZtrmv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const cuDoubleComplex \*A, int lda, cuDoubleComplex \*x, int incx) This function supports the 64-bit Integer Interface. This function performs the triangular matrix-vector multiplication \\(\\textbf{x} = \\text{op}(A)\\textbf{x}\\) where \\(A\\) is a triangular matrix stored in lower or upper mode with or without the main diagonal, and \\(\\mathbf{x}\\) is a vector. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or (conj.) transpose. diag input Indicates if the elements on the main diagonal of matrix A are unity and should not be accessed. n input Number of rows and columns of matrix A. A device input array of dimensions lda x n, with lda >= max(1, n). lda input Leading dimension of two-dimensional array used to store matrix A. x device in/out vector with n elements. incx input Stride between consecutive elements of x. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if diag is not one of CUBLAS\_DIAG\_UNIT and CUBLAS\_DIAG\_NON\_UNIT, or if lda < max(1, n) CUBLAS\_STATUS\_ALLOC\_FAILED The allocation of internal scratch memory failed CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: strmv(), dtrmv(), ctrmv(), ztrmv() 2.6.16. cublas trsv() cublasStatus\_t cublasStrsv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const float \*A, int lda, float \*x, int incx) cublasStatus\_t cublasDtrsv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const double \*A, int lda, double \*x, int incx) cublasStatus\_t cublasCtrsv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const cuComplex \*A, int lda, cuComplex \*x, int incx) cublasStatus\_t cublasZtrsv(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int n, const cuDoubleComplex \*A, int lda, cuDoubleComplex \*x, int incx) This function supports the 64-bit Integer Interface. This function solves the triangular linear system with a single right-hand-side \\(\\text{op}(A)\\textbf{x} = \\textbf{b}\\) where \\(A\\) is a triangular matrix stored in lower or upper mode with or without the main diagonal, and \\(\\mathbf{x}\\) and \\(\\mathbf{b}\\) are vectors. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) The solution \\(\\mathbf{x}\\) overwrites the right-hand-sides \\(\\mathbf{b}\\) on exit. No test for singularity or near-singularity is included in this function. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or (conj.) transpose. diag input Indicates if the elements on the main diagonal of matrix A are unity and should not be accessed. n input Number of rows and columns of matrix A. A device input array of dimension lda x n, with lda >= max(1, n). lda input Leading dimension of two-dimensional array used to store matrix A. x device in/out vector with n elements. incx input Stride between consecutive elements of x. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if diag is not one of CUBLAS\_DIAG\_UNIT and CUBLAS\_DIAG\_NON\_UNIT, or if lda < max(1, n) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: strsv(), dtrsv(), ctrsv(), ztrsv() 2.6.17. cublas hemv() cublasStatus\_t cublasChemv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*x, int incx, const cuComplex \*beta, cuComplex \*y, int incy) cublasStatus\_t cublasZhemv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*beta, cuDoubleComplex \*y, int incy) This function supports the 64-bit Integer Interface. This function performs the Hermitian matrix-vector multiplication \\(\\textbf{y} = \\alpha A\\textbf{x} + \\beta\\textbf{y}\\) where \\(A\\) is a \\(n \\times n\\) Hermitian matrix stored in lower or upper mode, \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) are vectors, and \\(\\alpha\\) and \\(\\beta\\) are scalars. This function has an alternate faster implementation using atomics that can be enabled with Please see the section on the for more details about the usage of atomics Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other Hermitian part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix A. alpha host or device input scalar used for multiplication. A device input array of dimension lda x n, with lda >= max(1, n). The imaginary parts of the diagonal elements are assumed to be zero. lda input Leading dimension of two-dimensional array used to store matrix A. x device input vector with n elements. incx input Stride between consecutive elements of x. beta host or device input scalar used for multiplication. If beta == 0 then y does not have to be a valid input. y device in/out vector with n elements. incy input Stride between consecutive elements of y. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0 or incy == 0, or if uplo!= CUBLAS\_FILL\_MODE\_LOWER and uplo!= CUBLAS\_FILL\_MODE\_UPPER, or if lda < n CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: chemv(), zhemv() 2.6.18. cublas hbmv() cublasStatus\_t cublasChbmv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, int k, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*x, int incx, const cuComplex \*beta, cuComplex \*y, int incy) cublasStatus\_t cublasZhbmv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, int k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*beta, cuDoubleComplex \*y, int incy) This function supports the 64-bit Integer Interface. This function performs the Hermitian banded matrix-vector multiplication \\(\\textbf{y} = \\alpha A\\textbf{x} + \\beta\\textbf{y}\\) where \\(A\\) is a \\(n \\times n\\) Hermitian banded matrix with \\(k\\) subdiagonals and superdiagonals, \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) are vectors, and \\(\\alpha\\) and \\(\\beta\\) are scalars. If uplo == CUBLAS\_FILL\_MODE\_LOWER then the Hermitian banded matrix \\(A\\) is stored column by column, with the main diagonal of the matrix stored in row 1, the first subdiagonal in row 2 (starting at first position), the second subdiagonal in row 3 (starting at first position), etc. So that in general, the element \\(A(i,j)\\) is stored in the memory location A(1+i-j,j) for \\(j = 1,\\ldots,n\\) and \\(i \\in \\lbrack j,\\min(m,j + k)\\rbrack\\). Also, the elements in the array A that do not conceptually correspond to the elements in the banded matrix (the bottom right \\(k \\times k\\) triangle) are not referenced. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the Hermitian banded matrix \\(A\\) is stored column by column, with the main diagonal of the matrix stored in row k + 1, the first superdiagonal in row k (starting at second position), the second superdiagonal in row k-1 (starting at third position), etc. So that in general, the element \\(A(i,j)\\) is stored in the memory location A(1+k+i-j,j) for \\(j = 1,\\ldots,n\\) and \\(i \\in \\lbrack\\max(1,j - k),j\\rbrack\\). Also, the elements in the array A that do not conceptually correspond to the elements in the banded matrix (the top left \\(k \\times k\\) triangle) are not referenced. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other Hermitian part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix A. k input Number of sub- and super-diagonals of matrix A. alpha host or device input scalar used for multiplication. A device input array of dimensions lda x n, with lda >= k + 1. The imaginary parts of the diagonal elements are assumed to be zero. lda input Leading dimension of two-dimensional array used to store matrix A. x device input vector with n elements. incx input Stride between consecutive elements of x. beta host or device input scalar used for multiplication. If beta == 0 then does not have to be a valid input. y device in/out vector with n elements. incy input Stride between consecutive elements of y. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if incx == 0 or incy == 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < (1 + k), or if alpha or beta are NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: chbmv(), zhbmv() 2.6.19. cublas hpmv() cublasStatus\_t cublasChpmv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuComplex \*alpha, const cuComplex \*AP, const cuComplex \*x, int incx, const cuComplex \*beta, cuComplex \*y, int incy) cublasStatus\_t cublasZhpmv(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*AP, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*beta, cuDoubleComplex \*y, int incy) This function supports the 64-bit Integer Interface. This function performs the Hermitian packed matrix-vector multiplication \\(\\textbf{y} = \\alpha A\\textbf{x} + \\beta\\textbf{y}\\) where \\(A\\) is a \\(n \\times n\\) Hermitian matrix stored in packed format, \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) are vectors, and \\(\\alpha\\) and \\(\\beta\\) are scalars. If uplo == CUBLAS\_FILL\_MODE\_LOWER then the elements in the lower triangular part of the Hermitian matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+((2\*n-j+1)\*j)/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\geq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the elements in the upper triangular part of the Hermitian matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+(j\*(j+1))/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\leq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other Hermitian part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix A. alpha host or device input scalar used for multiplication. AP device input array with \\(A\\) stored in packed format. The imaginary parts of the diagonal elements are assumed to be zero. x device input vector with n elements. incx input Stride between consecutive elements of x. beta host or device input scalar used for multiplication. If beta == 0 then y does not have to be a valid input. y device in/out vector with n elements. incy input Stride between consecutive elements of y. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0 or incy == 0, or if uplo!= CUBLAS\_FILL\_MODE\_LOWER and uplo!= CUBLAS\_FILL\_MODE\_UPPER, or if alpha or beta are NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: chpmv(), zhpmv() 2.6.20. cublas her() cublasStatus\_t cublasCher(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const float \*alpha, const cuComplex \*x, int incx, cuComplex \*A, int lda) cublasStatus\_t cublasZher(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const double \*alpha, const cuDoubleComplex \*x, int incx, cuDoubleComplex \*A, int lda) This function supports the 64-bit Integer Interface. This function performs the Hermitian rank-1 update \\(A = \\alpha\\textbf{x}\\textbf{x}^{H} + A\\) where \\(A\\) is a \\(n \\times n\\) Hermitian matrix stored in column-major format, \\(\\mathbf{x}\\) is a vector, and \\(\\alpha\\) is a scalar. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other Hermitian part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix A. alpha host or device input scalar used for multiplication. x device input vector with n elements. incx input Stride between consecutive elements of x. A device in/out array of dimensions lda x n, with lda >= max(1, n). The imaginary parts of the diagonal elements are assumed and set to zero. lda input Leading dimension of two-dimensional array used to store matrix A. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, n), or if alpha is NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: cher(), zher() 2.6.21. cublas her2() cublasStatus\_t cublasCher2(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuComplex \*alpha, const cuComplex \*x, int incx, const cuComplex \*y, int incy, cuComplex \*A, int lda) cublasStatus\_t cublasZher2(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*y, int incy, cuDoubleComplex \*A, int lda) This function supports the 64-bit Integer Interface. This function performs the Hermitian rank-2 update \\(A = \\alpha\\textbf{x}\\textbf{y}^{H} + \\overset{ˉ}{\\alpha}\\textbf{y}\\textbf{x}^{H} + A\\) where \\(A\\) is a \\(n \\times n\\) Hermitian matrix stored in column-major format, \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) are vectors, and \\(\\alpha\\) is a scalar. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other Hermitian part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix A. alpha host or device input scalar used for multiplication. x device input vector with n elements. incx input Stride between consecutive elements of x. y device input vector with n elements. incy input Stride between consecutive elements of y. A device in/out array of dimension lda x n with lda >= max(1, n). The imaginary parts of the diagonal elements are assumed and set to zero. lda input Leading dimension of two-dimensional array used to store matrix A. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, n), or if alpha is NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: cher2(), zher2() 2.6.22. cublas hpr() cublasStatus\_t cublasChpr(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const float \*alpha, const cuComplex \*x, int incx, cuComplex \*AP) cublasStatus\_t cublasZhpr(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const double \*alpha, const cuDoubleComplex \*x, int incx, cuDoubleComplex \*AP) This function supports the 64-bit Integer Interface. This function performs the packed Hermitian rank-1 update \\(A = \\alpha\\textbf{x}\\textbf{x}^{H} + A\\) where \\(A\\) is a \\(n \\times n\\) Hermitian matrix stored in packed format, \\(\\mathbf{x}\\) is a vector, and \\(\\alpha\\) is a scalar. If uplo == CUBLAS\_FILL\_MODE\_LOWER then the elements in the lower triangular part of the Hermitian matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+((2\*n-j+1)\*j)/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\geq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the elements in the upper triangular part of the Hermitian matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+(j\*(j+1))/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\leq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other Hermitian part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix A. alpha host or device input scalar used for multiplication. x device input vector with n elements. incx input Stride between consecutive elements of x. AP device in/out array with \\(A\\) stored in packed format. The imaginary parts of the diagonal elements are assumed and set to zero. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if alpha is NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: chpr(), zhpr() 2.6.23. cublas hpr2() cublasStatus\_t cublasChpr2(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuComplex \*alpha, const cuComplex \*x, int incx, const cuComplex \*y, int incy, cuComplex \*AP) cublasStatus\_t cublasZhpr2(cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*x, int incx, const cuDoubleComplex \*y, int incy, cuDoubleComplex \*AP) This function supports the 64-bit Integer Interface. This function performs the packed Hermitian rank-2 update \\(A = \\alpha\\textbf{x}\\textbf{y}^{H} + \\overset{ˉ}{\\alpha}\\textbf{y}\\textbf{x}^{H} + A\\) where \\(A\\) is a \\(n \\times n\\) Hermitian matrix stored in packed format, \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) are vectors, and \\(\\alpha\\) is a scalar. If uplo == CUBLAS\_FILL\_MODE\_LOWER then the elements in the lower triangular part of the Hermitian matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+((2\*n-j+1)\*j)/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\geq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the elements in the upper triangular part of the Hermitian matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+(j\*(j+1))/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\leq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix A lower or upper part is stored, the other Hermitian part is not referenced and is inferred from the stored elements. n input Number of rows and columns of matrix A. alpha host or device input scalar used for multiplication. x device input vector with n elements. incx input Stride between consecutive elements of x. y device input vector with n elements. incy input Stride between consecutive elements of y. AP device in/out array with \\(A\\) stored in packed format. The imaginary parts of the diagonal elements are assumed and set to zero. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if incx == 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if alpha is NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: chpr2, zhpr2 2.6.24. cublas gemvBatched() cublasStatus\_t cublasSgemvBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const float \*alpha, const float \*const Aarray\[\], int lda, const float \*const xarray\[\], int incx, const float \*beta, float \*const yarray\[\], int incy, int batchCount) cublasStatus\_t cublasDgemvBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const double \*alpha, const double \*const Aarray\[\], int lda, const double \*const xarray\[\], int incx, const double \*beta, double \*const yarray\[\], int incy, int batchCount) cublasStatus\_t cublasCgemvBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const cuComplex \*alpha, const cuComplex \*const Aarray\[\], int lda, const cuComplex \*const xarray\[\], int incx, const cuComplex \*beta, cuComplex \*const yarray\[\], int incy, int batchCount) cublasStatus\_t cublasZgemvBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*const Aarray\[\], int lda, const cuDoubleComplex \*const xarray\[\], int incx, const cuDoubleComplex \*beta, cuDoubleComplex \*const yarray\[\], int incy, int batchCount) #if defined(\_\_cplusplus) cublasStatus\_t cublasHSHgemvBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const float \*alpha, const \_\_half \*const Aarray\[\], int lda, const \_\_half \*const xarray\[\], int incx, const float \*beta, \_\_half \*const yarray\[\], int incy, int batchCount) cublasStatus\_t cublasHSSgemvBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const float \*alpha, const \_\_half \*const Aarray\[\], int lda, const \_\_half \*const xarray\[\], int incx, const float \*beta, float \*const yarray\[\], int incy, int batchCount) cublasStatus\_t cublasTSTgemvBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const float \*alpha, const \_\_nv\_bfloat16 \*const Aarray\[\], int lda, const \_\_nv\_bfloat16 \*const xarray\[\], int incx, const float \*beta, \_\_nv\_bfloat16 \*const yarray\[\], int incy, int batchCount) cublasStatus\_t cublasTSSgemvBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const float \*alpha, const \_\_nv\_bfloat16 \*const Aarray\[\], int lda, const \_\_nv\_bfloat16 \*const xarray\[\], int incx, const float \*beta, float \*const yarray\[\], int incy, int batchCount) #endif This function supports the 64-bit Integer Interface. This function performs the matrix-vector multiplication of a batch of matrices and vectors. The batch is considered to be “uniform”, i.e. all instances have the same dimensions (m, n), leading dimension (lda), increments (incx, incy) and transposition (trans) for their respective A matrix, x and y vectors. The address of the input matrix and vector, and the output vector of each instance of the batch are read from arrays of pointers passed to the function by the caller. \\(\\textbf{y}\\lbrack i\\rbrack = \\alpha\\text{op}(A\\lbrack i\\rbrack)\\textbf{x}\\lbrack i\\rbrack + \\beta\\textbf{y}\\lbrack i\\rbrack,\\text{ for i} \\in \\lbrack 0,batchCount - 1\\rbrack\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, and \\(A\\) is an array of pointers to matrice \\(A\\lbrack i\\rbrack\\) stored in column-major format with dimension \\(m \\times n\\), and \\(\\textbf{x}\\) and \\(\\textbf{y}\\) are arrays of pointers to vectors. Also, for matrix \\(A\\lbrack i\\rbrack\\), \\(\\text{op}(A\\lbrack i\\rbrack) = \\left\\{ \\begin{matrix} {A\\lbrack i\\rbrack} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ {A\\lbrack i\\rbrack}^{T} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ {A\\lbrack i\\rbrack}^{H} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) Note \\(\\textbf{y}\\lbrack i\\rbrack\\) vectors must not overlap, i.e. the individual gemv operations must be computable independently; otherwise, undefined behavior is expected. On certain problem sizes, it might be advantageous to make multiple calls to cublas gemv() in different CUDA streams, rather than use this API. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. trans input Operation op(A\[i\]) that is non- or (conj.) transpose. m input Number of rows of matrix A\[i\]. n input Number of columns of matrix A\[i\]. alpha host or device input scalar used for multiplication. Aarray device input Array of pointers to array, with each array of dim. lda x n with lda >= max(1, m). All pointers must meet certain alignment criteria. Please see below for details. lda input Leading dimension of two-dimensional array used to store each matrix A\[i\]. xarray device input Array of pointers to array, with each dimension n if trans == CUBLAS\_OP\_N and m otherwise. All pointers must meet certain alignment criteria. Please see below for details. incx input Stride of each one-dimensional array x\[i\]. beta host or device input scalar used for multiplication. If beta == 0, y does not have to be a valid input. yarray device in/out Array of pointers to array. It has dimensions m if trans == CUBLAS\_OP\_N and n otherwise. Vectors y\[i\] should not overlap; otherwise, undefined behavior is expected. All pointers must meet certain alignment criteria. Please see below for details. incy input Stride of each one-dimensional array y\[i\]. batchCount input Number of pointers contained in Aarray, xarray and yarray. If math mode enables fast math modes when using cublasSgemvBatched(), pointers (not the pointer arrays) placed in the GPU memory must be properly aligned to avoid misaligned memory access errors. Ideally all pointers are aligned to at least 16 Bytes. Otherwise it is recommended that they meet the following rule: if k % 4 == 0 then ensure intptr\_t(ptr) % 16 == 0, The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE m < 0, n < 0, or batchCount < 0 CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU 2.6.25. cublas gemvStridedBatched() cublasStatus\_t cublasSgemvStridedBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const float \*alpha, const float \*A, int lda, long long int strideA, const float \*x, int incx, long long int stridex, const float \*beta, float \*y, int incy, long long int stridey, int batchCount) cublasStatus\_t cublasDgemvStridedBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const double \*alpha, const double \*A, int lda, long long int strideA, const double \*x, int incx, long long int stridex, const double \*beta, double \*y, int incy, long long int stridey, int batchCount) cublasStatus\_t cublasCgemvStridedBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const cuComplex \*alpha, const cuComplex \*A, int lda, long long int strideA, const cuComplex \*x, int incx, long long int stridex, const cuComplex \*beta, cuComplex \*y, int incy, long long int stridey, int batchCount) cublasStatus\_t cublasZgemvStridedBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, long long int strideA, const cuDoubleComplex \*x, int incx, long long int stridex, const cuDoubleComplex \*beta, cuDoubleComplex \*y, int incy, long long int stridey, int batchCount) cublasStatus\_t cublasHSHgemvStridedBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const float \*alpha, const \_\_half \*A, int lda, long long int strideA, const \_\_half \*x, int incx, long long int stridex, const float \*beta, \_\_half \*y, int incy, long long int stridey, int batchCount) cublasStatus\_t cublasHSSgemvStridedBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const float \*alpha, const \_\_half \*A, int lda, long long int strideA, const \_\_half \*x, int incx, long long int stridex, const float \*beta, float \*y, int incy, long long int stridey, int batchCount) cublasStatus\_t cublasTSTgemvStridedBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const float \*alpha, const \_\_nv\_bfloat16 \*A, int lda, long long int strideA, const \_\_nv\_bfloat16 \*x, int incx, long long int stridex, const float \*beta, \_\_nv\_bfloat16 \*y, int incy, long long int stridey, int batchCount) cublasStatus\_t cublasTSSgemvStridedBatched(cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, const float \*alpha, const \_\_nv\_bfloat16 \*A, int lda, long long int strideA, const \_\_nv\_bfloat16 \*x, int incx, long long int stridex, const float \*beta, float \*y, int incy, long long int stridey, int batchCount) This function supports the 64-bit Integer Interface. This function performs the matrix-vector multiplication of a batch of matrices and vectors. The batch is considered to be “uniform”, i.e. all instances have the same dimensions (m, n), leading dimension (lda), increments (incx, incy) and transposition (trans) for their respective A matrix, x and y vectors. Input matrix A and vector x, and output vector y for each instance of the batch are located at fixed offsets in number of elements from their locations in the previous instance. Pointers to A matrix, x and y vectors for the first instance are passed to the function by the user along with offsets in number of elements - strideA, stridex and stridey that determine the locations of input matrices and vectors, and output vectors in future instances. \\(\\textbf{y} + i\*{stridey} = \\alpha\\text{op}(A + i\*{strideA})(\\textbf{x} + i\*{stridex}) + \\beta(\\textbf{y} + i\*{stridey}),\\text{ for i } \\in \\lbrack 0,batchCount - 1\\rbrack\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, and \\(A\\) is an array of pointers to matrix stored in column-major format with dimension \\(A\\lbrack i\\rbrack\\) \\(m \\times n\\), and \\(\\textbf{x}\\) and \\(\\textbf{y}\\) are arrays of pointers to vectors. Also, for matrix \\(A\\lbrack i\\rbrack\\) \\(\\text{op}(A\\lbrack i\\rbrack) = \\left\\{ \\begin{matrix} {A\\lbrack i\\rbrack} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ {A\\lbrack i\\rbrack}^{T} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ {A\\lbrack i\\rbrack}^{H} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) Note \\(\\textbf{y}\\lbrack i\\rbrack\\) matrices must not overlap, i.e. the individual gemv operations must be computable independently; otherwise, undefined behavior is expected. On certain problem sizes, it might be advantageous to make multiple calls to cublas gemv() in different CUDA streams, rather than use this API. Note In the table below, we use A\[i\], x\[i\], y\[i\] as notation for A matrix, and x and y vectors in the ith instance of the batch, implicitly assuming they are respectively offsets in number of elements strideA, stridex, stridey away from A\[i-1\], x\[i-1\], y\[i-1\]. The unit for the offset is number of elements and must not be zero. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. trans input Operation op(A\[i\]) that is non- or (conj.) transpose. m input Number of rows of matrix A\[i\]. n input Number of columns of matrix A\[i\]. alpha host or device input scalar used for multiplication. A device input \* pointer to the A matrix corresponding to the first instance of the batch, with dimensions lda x n with lda >= max(1, m). lda input Leading dimension of two-dimensional array used to store each matrix A\[i\]. strideA input Value of type long long int that gives the offset in number of elements between A\[i\] and A\[i+1\] x device input \* pointer to the x vector corresponding to the first instance of the batch, with each dimension n if trans == CUBLAS\_OP\_N and m otherwise. incx input Stride of each one-dimensional array x\[i\]. stridex input Value of type long long int that gives the offset in number of elements between x\[i\] and x\[i+1\] beta host or device input scalar used for multiplication. If beta == 0, y does not have to be a valid input. y device in/out \* pointer to the y vector corresponding to the first instance of the batch, with each dimension m if trans == CUBLAS\_OP\_N and n otherwise. Vectors y\[i\] should not overlap; otherwise, undefined behavior is expected. incy input Stride of each one-dimensional array y\[i\]. stridey input Value of type long long int that gives the offset in number of elements between y\[i\] and y\[i+1\] batchCount input Number of GEMVs to perform in the batch. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE m < 0, n < 0, or batchCount < 0 CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU 2.7. cuBLAS Level-3 Function Reference In this chapter we describe the Level-3 Basic Linear Algebra Subprograms (BLAS3) functions that perform matrix-matrix operations. 2.7.1. cublas gemm() cublasStatus\_t cublasSgemm(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const float \*alpha, const float \*A, int lda, const float \*B, int ldb, const float \*beta, float \*C, int ldc) cublasStatus\_t cublasDgemm(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const double \*alpha, const double \*A, int lda, const double \*B, int ldb, const double \*beta, double \*C, int ldc) cublasStatus\_t cublasCgemm(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*B, int ldb, const cuComplex \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasZgemm(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*B, int ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*C, int ldc) cublasStatus\_t cublasHgemm(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const \_\_half \*alpha, const \_\_half \*A, int lda, const \_\_half \*B, int ldb, const \_\_half \*beta, \_\_half \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs the matrix-matrix multiplication \\(C = \\alpha\\text{op}(A)\\text{op}(B) + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, and \\(A\\), \\(B\\) and \\(C\\) are matrices stored in column-major format with dimensions \\(\\text{op}(A)\\) \\(m \\times k\\), \\(\\text{op}(B)\\) \\(k \\times n\\) and \\(C\\) \\(m \\times n\\), respectively. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) and \\(\\text{op}(B)\\) is defined similarly for matrix \\(B\\). Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. transa input Operation op(A) that is non- or (conj.) transpose. transb input Operation op(B) that is non- or (conj.) transpose. m input Number of rows of matrix op(A) and C. n input Number of columns of matrix op(B) and C. k input Number of columns of op(A) and rows of op(B). alpha host or device input scalar used for multiplication. A device input array of dimensions lda x k with lda >= max(1, m) if transa == CUBLAS\_OP\_N and lda x m with lda >= max(1, k) otherwise. lda input Leading dimension of two-dimensional array used to store the matrix A. B device input array of dimension ldb x n with ldb >= max(1, k) if transb == CUBLAS\_OP\_N and ldb x k with ldb >= max(1,n) otherwise. ldb input Leading dimension of two-dimensional array used to store matrix B. beta host or device input scalar used for multiplication. If beta == 0, C does not have to be a valid input. C device in/out array of dimensions ldc x n with ldc >= max(1, m). ldc input Leading dimension of a two-dimensional array used to store the matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0 or k < 0, or if transa and transb are not one of CUBLAS\_OP\_N, CUBLAS\_OP\_C, CUBLAS\_OP\_T, or if lda < max(1, m) when transa == CUBLAS\_OP\_N and lda < max(1, k) otherwise, or if ldb < max(1, k) when transb == CUBLAS\_OP\_N and ldb < max(1, n) otherwise, or if ldc < max(1, m), or if alpha or beta are NULL, or if C is NULL when beta is not zero CUBLAS\_STATUS\_ARCH\_MISMATCH In the case of cublasHgemm() the device does not support math in half precision. CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sgemm(), dgemm(), cgemm(), zgemm() 2.7.2. cublas gemm3m() cublasStatus\_t cublasCgemm3m(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*B, int ldb, const cuComplex \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasZgemm3m(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*B, int ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs the complex matrix-matrix multiplication, using Gauss complexity reduction algorithm. This can lead to an increase in performance up to 25% \\(C = \\alpha\\text{op}(A)\\text{op}(B) + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, and \\(A\\), \\(B\\) and \\(C\\) are matrices stored in column-major format with dimensions \\(\\text{op}(A)\\) \\(m \\times k\\), \\(\\text{op}(B)\\) \\(k \\times n\\) and \\(C\\) \\(m \\times n\\), respectively. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) and \\(\\text{op}(B)\\) is defined similarly for matrix \\(B\\). Note These 2 routines are only supported on GPUs with architecture capabilities equal to or greater than 5.0 Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. transa input Operation op(A) that is non- or (conj.) transpose. transb input Operation op(B) that is non- or (conj.) transpose. m input Number of rows of matrix op(A) and C. n input Number of columns of matrix op(B) and C. k input Number of columns of op(A) and rows of op(B). alpha host or device input scalar used for multiplication. A device input array of dimensions lda x k with lda >= max(1, m) if transa == CUBLAS\_OP\_N and lda x m with lda >= max(1, k) otherwise. lda input Leading dimension of two-dimensional array used to store the matrix A. B device input array of dimension ldb x n with ldb >= max(1, k) if transb == CUBLAS\_OP\_N and ldb x k with ldb >= max(1,n) otherwise. ldb input Leading dimension of two-dimensional array used to store matrix B. beta host or device input scalar used for multiplication. If beta == 0, C does not have to be a valid input. C device in/out array of dimensions ldc x n with ldc >= max(1, m). ldc input Leading dimension of a two-dimensional array used to store the matrix C. The possible error values returned by this function and their meanings are listed in the following table: Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0 or k < 0, or if transa and transb are not one of CUBLAS\_OP\_N, CUBLAS\_OP\_C, CUBLAS\_OP\_T, or if lda < max(1, m) when transa == CUBLAS\_OP\_N and lda < max(1, k) otherwise, or if ldb < max(1, k) when transb == CUBLAS\_OP\_N and ldb < max(1, n) otherwise, or if ldc < max(1, m), or if alpha or beta are NULL, or if C is NULL when beta is not zero CUBLAS\_STATUS\_ARCH\_MISMATCH The device has a compute capabilites lower than 5.0. CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU. For references please refer to NETLIB documentation: cgemm(), zgemm() 2.7.3. cublas gemmBatched() cublasStatus\_t cublasHgemmBatched(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const \_\_half \*alpha, const \_\_half \*const Aarray\[\], int lda, const \_\_half \*const Barray\[\], int ldb, const \_\_half \*beta, \_\_half \*const Carray\[\], int ldc, int batchCount) cublasStatus\_t cublasSgemmBatched(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const float \*alpha, const float \*const Aarray\[\], int lda, const float \*const Barray\[\], int ldb, const float \*beta, float \*const Carray\[\], int ldc, int batchCount) cublasStatus\_t cublasDgemmBatched(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const double \*alpha, const double \*const Aarray\[\], int lda, const double \*const Barray\[\], int ldb, const double \*beta, double \*const Carray\[\], int ldc, int batchCount) cublasStatus\_t cublasCgemmBatched(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const cuComplex \*alpha, const cuComplex \*const Aarray\[\], int lda, const cuComplex \*const Barray\[\], int ldb, const cuComplex \*beta, cuComplex \*const Carray\[\], int ldc, int batchCount) cublasStatus\_t cublasZgemmBatched(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*const Aarray\[\], int lda, const cuDoubleComplex \*const Barray\[\], int ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*const Carray\[\], int ldc, int batchCount) This function supports the 64-bit Integer Interface. This function performs the matrix-matrix multiplication of a batch of matrices. The batch is considered to be “uniform”, i.e. all instances have the same dimensions (m, n, k), leading dimensions (lda, ldb, ldc) and transpositions (transa, transb) for their respective A, B and C matrices. The address of the input matrices and the output matrix of each instance of the batch are read from arrays of pointers passed to the function by the caller. \\(C\\lbrack i\\rbrack = \\alpha\\text{op}(A\\lbrack i\\rbrack)\\text{op}(B\\lbrack i\\rbrack) + \\beta C\\lbrack i\\rbrack,\\text{ for i } \\in \\lbrack 0,batchCount - 1\\rbrack\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, and \\(A\\), \\(B\\) and \\(C\\) are arrays of pointers to matrices stored in column-major format with dimensions \\(\\text{op}(A\\lbrack i\\rbrack)\\) \\(m \\times k\\), \\(\\text{op}(B\\lbrack i\\rbrack)\\) \\(k \\times n\\) and \\(C\\lbrack i\\rbrack\\) \\(m \\times n\\), respectively. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) and \\(\\text{op}(B\\lbrack i\\rbrack)\\) is defined similarly for matrix \\(B\\lbrack i\\rbrack\\). Note \\(C\\lbrack i\\rbrack\\) matrices must not overlap, that is, the individual gemm operations must be computable independently; otherwise, undefined behavior is expected. On certain problem sizes, it might be advantageous to make multiple calls to cublas gemm() in different CUDA streams, rather than use this API. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. transa input Operation op(A\[i\]) that is non- or (conj.) transpose. transb input Operation op(B\[i\]) that is non- or (conj.) transpose. m input Number of rows of matrix op(A\[i\]) and C\[i\]. n input Number of columns of op(B\[i\]) and C\[i\]. k input Number of columns of op(A\[i\]) and rows of op(B\[i\]). alpha host or device input scalar used for multiplication. Aarray device input Array of pointers to array, with each array of dim. lda x k with lda >= max(1, m) if transa == CUBLAS\_OP\_N and lda x m with lda >= max(1, k) otherwise. All pointers must meet certain alignment criteria. Please see below for details. lda input Leading dimension of two-dimensional array used to store each matrix A\[i\]. Barray device input Array of pointers to array, with each array of dim. ldb x n with ldb >= max(1, k) if transb == CUBLAS\_OP\_N and ldb x k with ldb >= max(1,n) otherwise. All pointers must meet certain alignment criteria. Please see below for details. ldb input Leading dimension of two-dimensional array used to store each matrix B\[i\]. beta host or device input scalar used for multiplication. If beta == 0, C does not have to be a valid input. Carray device in/out Array of pointers to array. It has dimensions ldc x n with ldc >= max(1, m). Matrices C\[i\] should not overlap; otherwise, undefined behavior is expected. All pointers must meet certain alignment criteria. Please see below for details. ldc input Leading dimension of two-dimensional array used to store each matrix C\[i\]. batchCount input Number of pointers contained in Aarray, Barray and Carray. If math mode enables fast math modes when using cublasSgemmBatched(), pointers (not the pointer arrays) placed in the GPU memory must be properly aligned to avoid misaligned memory access errors. Ideally all pointers are aligned to at least 16 Bytes. Otherwise it is recommended that they meet the following rule: if k % 4 == 0 then ensure intptr\_t(ptr) % 16 == 0, The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0 or k < 0, or if transa and transb are not one of CUBLAS\_OP\_N, CUBLAS\_OP\_C, CUBLAS\_OP\_T, or if lda < max(1, m) when transa == CUBLAS\_OP\_N and lda < max(1, k) otherwise, or if ldb < max(1, k) when transb == CUBLAS\_OP\_N and ldb < max(1, n) otherwise, or if ldc < max(1, m) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU CUBLAS\_STATUS\_ARCH\_MISMATCH cublasHgemmBatched() is only supported for GPU with architecture capabilities equal or greater than 5.3 2.7.4. cublas gemmStridedBatched() cublasStatus\_t cublasHgemmStridedBatched(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const \_\_half \*alpha, const \_\_half \*A, int lda, long long int strideA, const \_\_half \*B, int ldb, long long int strideB, const \_\_half \*beta, \_\_half \*C, int ldc, long long int strideC, int batchCount) cublasStatus\_t cublasSgemmStridedBatched(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const float \*alpha, const float \*A, int lda, long long int strideA, const float \*B, int ldb, long long int strideB, const float \*beta, float \*C, int ldc, long long int strideC, int batchCount) cublasStatus\_t cublasDgemmStridedBatched(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const double \*alpha, const double \*A, int lda, long long int strideA, const double \*B, int ldb, long long int strideB, const double \*beta, double \*C, int ldc, long long int strideC, int batchCount) cublasStatus\_t cublasCgemmStridedBatched(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const cuComplex \*alpha, const cuComplex \*A, int lda, long long int strideA, const cuComplex \*B, int ldb, long long int strideB, const cuComplex \*beta, cuComplex \*C, int ldc, long long int strideC, int batchCount) cublasStatus\_t cublasCgemm3mStridedBatched(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const cuComplex \*alpha, const cuComplex \*A, int lda, long long int strideA, const cuComplex \*B, int ldb, long long int strideB, const cuComplex \*beta, cuComplex \*C, int ldc, long long int strideC, int batchCount) cublasStatus\_t cublasZgemmStridedBatched(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, long long int strideA, const cuDoubleComplex \*B, int ldb, long long int strideB, const cuDoubleComplex \*beta, cuDoubleComplex \*C, int ldc, long long int strideC, int batchCount) This function supports the 64-bit Integer Interface. This function performs the matrix-matrix multiplication of a batch of matrices. The batch is considered to be “uniform”, i.e. all instances have the same dimensions (m, n, k), leading dimensions (lda, ldb, ldc) and transpositions (transa, transb) for their respective A, B and C matrices. Input matrices A, B and output matrix C for each instance of the batch are located at fixed offsets in number of elements from their locations in the previous instance. Pointers to A, B and C matrices for the first instance are passed to the function by the user along with offsets in number of elements - strideA, strideB and strideC that determine the locations of input and output matrices in future instances. \\(C + i\*{strideC} = \\alpha\\text{op}(A + i\*{strideA})\\text{op}(B + i\*{strideB}) + \\beta(C + i\*{strideC}),\\text{ for i } \\in \\lbrack 0,batchCount - 1\\rbrack\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, and \\(A\\), \\(B\\) and \\(C\\) are arrays of pointers to matrices stored in column-major format with dimensions \\(\\text{op}(A\\lbrack i\\rbrack)\\) \\(m \\times k\\), \\(\\text{op}(B\\lbrack i\\rbrack)\\) \\(k \\times n\\) and \\(C\\lbrack i\\rbrack\\) \\(m \\times n\\), respectively. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) and \\(\\text{op}(B\\lbrack i\\rbrack)\\) is defined similarly for matrix \\(B\\lbrack i\\rbrack\\). Note \\(C\\lbrack i\\rbrack\\) matrices must not overlap, i.e. the individual gemm operations must be computable independently; otherwise, undefined behavior is expected. On certain problem sizes, it might be advantageous to make multiple calls to cublas gemm() in different CUDA streams, rather than use this API. Note In the table below, we use A\[i\], B\[i\], C\[i\] as notation for A, B and C matrices in the ith instance of the batch, implicitly assuming they are respectively offsets in number of elements strideA, strideB, strideC away from A\[i-1\], B\[i-1\], C\[i-1\]. The unit for the offset is number of elements and must not be zero. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. transa input Operation op(A\[i\]) that is non- or (conj.) transpose. transb input Operation op(B\[i\]) that is non- or (conj.) transpose. m input Number of rows of matrix op(A\[i\]) and C\[i\]. n input Number of columns of op(B\[i\]) and C\[i\]. k input Number of columns of op(A\[i\]) and rows of op(B\[i\]). alpha host or device input scalar used for multiplication. A device input \* pointer to the A matrix corresponding to the first instance of the batch, with dimensions lda x k with lda >= max(1, m) if transa == CUBLAS\_OP\_N and lda x m with lda >= max(1, k) otherwise. lda input Leading dimension of two-dimensional array used to store each matrix A\[i\]. strideA input Value of type long long int that gives the offset in number of elements between A\[i\] and A\[i+1\] B device input \* pointer to the B matrix corresponding to the first instance of the batch, with dimensions ldb x n with ldb >= max(1, k) if transb == CUBLAS\_OP\_N and ldb x k with ldb >= max(1,n) otherwise. ldb input Leading dimension of two-dimensional array used to store each matrix B\[i\]. strideB input Value of type long long int that gives the offset in number of elements between B\[i\] and B\[i+1\] beta host or device input scalar used for multiplication. If beta == 0, C does not have to be a valid input. C device in/out \* pointer to the C matrix corresponding to the first instance of the batch, with dimensions ldc x n with ldc >= max(1, m). Matrices C\[i\] should not overlap; otherwise, undefined behavior is expected. ldc input Leading dimension of two-dimensional array used to store each matrix C\[i\]. strideC input Value of type long long int that gives the offset in number of elements between C\[i\] and C\[i+1\] batchCount input Number of GEMMs to perform in the batch. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0 or k < 0, or if transa and transb are not one of CUBLAS\_OP\_N, CUBLAS\_OP\_C, CUBLAS\_OP\_T, or if lda < max(1, m) when transa == CUBLAS\_OP\_N and lda < max(1, k) otherwise, or if ldb < max(1, k) when transb == CUBLAS\_OP\_N and ldb < max(1, n) otherwise, or if ldc < max(1, m) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU CUBLAS\_STATUS\_ARCH\_MISMATCH cublasHgemmStridedBatched() is only supported for GPU with architecture capabilities equal or greater than 5.3 2.7.5. cublas gemmGroupedBatched() cublasStatus\_t cublasSgemmGroupedBatched(cublasHandle\_t handle, const cublasOperation\_t transa\_array\[\], const cublasOperation\_t transb\_array\[\], const int m\_array\[\], const int n\_array\[\], const int k\_array\[\], const float alpha\_array\[\], const float \*const Aarray\[\], const int lda\_array\[\], const float \*const Barray\[\], const int ldb\_array\[\], const float beta\_array\[\], float \*const Carray\[\], const int ldc\_array\[\], int group\_count, const int group\_size\[\]) cublasStatus\_t cublasDgemmGroupedBatched(cublasHandle\_t handle, const cublasOperation\_t transa\_array\[\], const cublasOperation\_t transb\_array\[\], const int m\_array\[\], const int n\_array\[\], const int k\_array\[\], const double alpha\_array\[\], const double \*const Aarray\[\], const int lda\_array\[\], const double \*const Barray\[\], const int ldb\_array\[\], const double beta\_array\[\], double \*const Carray\[\], const int ldc\_array\[\], int group\_count, const int group\_size\[\]) This function supports the 64-bit Integer Interface. This function performs the matrix-matrix multiplication on groups of matrices. A given group is considered to be “uniform”, i.e. all instances have the same dimensions (m, n, k), leading dimensions (lda, ldb, ldc) and transpositions (transa, transb) for their respective A, B and C matrices. However, the dimensions, leading dimensions, transpositions, and scaling factors (alpha, beta) may vary between groups. The address of the input matrices and the output matrix of each instance of the batch are read from arrays of pointers passed to the function by the caller. This is functionally equivalent to the following: idx = 0; for i = 0:group\_count - 1 for j = 0:group\_size\[i\] - 1 gemm(transa\_array\[i\], transb\_array\[i\], m\_array\[i\], n\_array\[i\], k\_array\[i\], alpha\_array\[i\], Aarray\[idx\], lda\_array\[i\], Barray\[idx\], ldb\_array\[i\], beta\_array\[i\], Carray\[idx\], ldc\_array\[i\]); idx += 1; end end where \\(\\text{$\\mathrm{alpha\\\_array}$}\\) and \\(\\text{$\\mathrm{beta\\\_array}$}\\) are arrays of scaling factors, and \\(\\text{Aarray}\\), \\(\\text{Barray}\\) and \\(\\text{Carray}\\) are arrays of pointers to matrices stored in column-major format. For a given index, \\(\\text{idx}\\), that is part of group \\(i\\), the dimensions are: \\(\\text{op}(\\text{Aarray}\\lbrack\\text{idx}\\rbrack)\\): \\(\\text{$\\mathrm{m\\\_array}$}\\lbrack i\\rbrack \\times \\text{$\\mathrm{k\\\_array}$}\\lbrack i\\rbrack\\) \\(\\text{op}(\\text{Barray}\\lbrack\\text{idx}\\rbrack)\\): \\(\\text{$\\mathrm{k\\\_array}$}\\lbrack i\\rbrack \\times \\text{$\\mathrm{n\\\_array}$}\\lbrack i\\rbrack\\) \\(\\text{Carray}\\lbrack\\text{idx}\\rbrack\\): \\(\\text{$\\mathrm{m\\\_array}$}\\lbrack i\\rbrack \\times \\text{$\\mathrm{n\\\_array}$}\\lbrack i\\rbrack\\) Note This API takes arrays of two different lengths. The arrays of dimensions, leading dimensions, transpositions, and scaling factors are of length group\_count and the arrays of matrices are of length problem\_count where \\(\\text{$\\mathrm{problem\\\_count}$} = \\sum\_{i = 0}^{\\text{$\\mathrm{group\\\_count}$} - 1} \\text{$\\mathrm{group\\\_size}$}\\lbrack i\\rbrack\\) For matrix \\(A\[\\text{idx}\]\\) in group \\(i\\) \\(\\text{op}(A\[\\text{idx}\]) = \\left\\{ \\begin{matrix} A\[\\text{idx}\] & {\\text{if }\\textsf{$\\mathrm{transa\\\_array}\\lbrack i\\rbrack$ == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A\[\\text{idx}\]^{T} & {\\text{if }\\textsf{$\\mathrm{transa\\\_array}\\lbrack i\\rbrack$ == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A\[\\text{idx}\]^{H} & {\\text{if }\\textsf{$\\mathrm{transa\\\_array}\\lbrack i\\rbrack$ == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) and \\(\\text{op}(B\[\\text{idx}\])\\) is defined similarly for matrix \\(B\[\\text{idx}\]\\) in group \\(i\\). Note \\(C\\lbrack\\text{idx}\\rbrack\\) matrices must not overlap, that is, the individual gemm operations must be computable independently; otherwise, undefined behavior is expected. On certain problem sizes, it might be advantageous to make multiple calls to cublas gemmBatched() in different CUDA streams, rather than use this API. Param. Memory In/out Meaning Array Length handle input Handle to the cuBLAS library context. transa\_array host input Operation op(A\[idx\]) that is non- or (conj.) transpose for each group. group\_count transb\_array host input Operation op(B\[idx\]) that is non- or (conj.) transpose for each group. group\_count m\_array host input Array containing the number of rows of matrix op(A\[idx\]) and C\[idx\] for each group. group\_count n\_array host input Array containing the number of columns of op(B\[idx\]) and C\[idx\] for each group. group\_count k\_array host input Array containing the number of columns of op(A\[idx\]) and rows of op(B\[idx\]) for each group. group\_count alpha\_array host input Array containing the scalar used for multiplication for each group. group\_count Aarray device input Array of pointers to array, with each array of dim. lda\[i\] x k\[i\] with lda\[i\] >= max(1,m\[i\]) if transa\[i\] == CUBLAS\_OP\_N and lda\[i\] x m\[i\] with lda\[i\] >= max(1,k\[i\]) otherwise. All pointers must meet certain alignment criteria. Please see below for details. problem\_count lda\_array host input Array containing the leading dimensions of two-dimensional arrays used to store each matrix A\[idx\] for each group. group\_count Barray device input Array of pointers to array, with each array of dim. ldb\[i\] x n\[i\] with ldb\[i\] >= max(1,k\[i\]) if transb\[i\] == CUBLAS\_OP\_N and ldb\[i\] x k\[i\] with ldb\[i\] >= max(1,n\[i\]) otherwise. All pointers must meet certain alignment criteria. Please see below for details. problem\_count ldb\_array host input Array containing the leading dimensions of two-dimensional arrays used to store each matrix B\[idx\] for each group. group\_count beta\_array host input Array containing the scalar used for multiplication for each group. group\_count Carray device in/out Array of pointers to array. It has dimensions ldc\[i\] x n\[i\] with ldc\[i\] >= max(1,m\[i\]). Matrices C\[idx\] should not overlap; otherwise, undefined behavior is expected. All pointers must meet certain alignment criteria. Please see below for details. problem\_count ldc\_array host input Array containing the leading dimensions of two-dimensional arrays used to store each matrix C\[idx\] for each group. group\_count group\_count host input Number of groups group\_size host input Array containing the number of pointers contained in Aarray, Barray and Carray for each group. group\_count If math mode enables fast math modes when using cublasSgemmGroupedBatched(), pointers (not the pointer arrays) placed in the GPU memory must be properly aligned to avoid misaligned memory access errors. Ideally all pointers are aligned to at least 16 Bytes. Otherwise it is required that they meet the following rule: if k % 4 == 0 then ensure intptr\_t(ptr) % 16 == 0, The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If transa\_array, transb\_array, m\_array, n\_array, k\_array, alpha\_array, lda\_array, ldb\_array, beta\_array, ldc\_array, or group\_size are NULL, or if group\_count < 0, or if m\_array\[i\] < 0, n\_array\[i\] < 0, k\_array\[i\] < 0, group\_size\[i\] < 0, or if transa\_array\[i\] and transb\_array\[i\] are not one of CUBLAS\_OP\_N, CUBLAS\_OP\_C, CUBLAS\_OP\_T, or if lda\_array\[i\] < max(1, m\_array\[i\]) if transa\_array\[i\] == CUBLAS\_OP\_N and lda\_array\[i\] < max(1, k\_array\[i\]) otherwise, or if ldb\_array\[i\] < max(1, k\_array\[i\]) if transb\_array\[i\] == CUBLAS\_OP\_N and ldb\_array\[i\] < max(1, n\_array\[i\]) otherwise, or if ldc\_array\[i\] < max(1, m\_array\[i\]) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU CUBLAS\_STATUS\_NOT\_SUPPORTED The pointer mode is set to CUBLAS\_POINTER\_MODE\_DEVICE 2.7.6. cublas symm() cublasStatus\_t cublasSsymm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, int m, int n, const float \*alpha, const float \*A, int lda, const float \*B, int ldb, const float \*beta, float \*C, int ldc) cublasStatus\_t cublasDsymm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, int m, int n, const double \*alpha, const double \*A, int lda, const double \*B, int ldb, const double \*beta, double \*C, int ldc) cublasStatus\_t cublasCsymm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, int m, int n, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*B, int ldb, const cuComplex \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasZsymm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, int m, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*B, int ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs the symmetric matrix-matrix multiplication \\(C = \\left\\{ \\begin{matrix} {\\alpha AB + \\beta C} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_LEFT}$}} \\\\ {\\alpha BA + \\beta C} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_RIGHT}$}} \\\\ \\end{matrix} \\right.\\) where \\(A\\) is a symmetric matrix stored in lower or upper mode, \\(B\\) and \\(C\\) are \\(m \\times n\\) matrices, and \\(\\alpha\\) and \\(\\beta\\) are scalars. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. side input Indicates if matrix A is on the left or right of B. uplo input Indicates if matrix A lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. m input Number of rows of matrix C and B, with matrix A sized accordingly. n input Number of columns of matrix C and B, with matrix A sized accordingly. alpha host or device input scalar used for multiplication. A device input array of dimension lda x m with lda >= max(1, m) if side == CUBLAS\_SIDE\_LEFT and lda x n with lda >= max(1, n) otherwise. lda input Leading dimension of two-dimensional array used to store matrix A. B device input array of dimension ldb x n with ldb >= max(1, m). ldb input Leading dimension of two-dimensional array used to store matrix B. beta host or device input scalar used for multiplication. If beta == 0 then C does not have to be a valid input. C device in/out array of dimension ldc x n with ldc >= max(1, m). ldc input Leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0, or if side is not one of CUBLAS\_SIDE\_LEFT and CUBLAS\_SIDE\_RIGHT, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, m) when side == CUBLAS\_SIDE\_LEFT, and lda < max(1, n) otherwise, or if ldb < max(1, m), or if ldc < max(1, m), or if alpha or beta are NULL, or if C is NULL when beta is not zero CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: ssymm(), dsymm(), csymm(), zsymm() 2.7.7. cublas syrk() cublasStatus\_t cublasSsyrk(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const float \*alpha, const float \*A, int lda, const float \*beta, float \*C, int ldc) cublasStatus\_t cublasDsyrk(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const double \*alpha, const double \*A, int lda, const double \*beta, double \*C, int ldc) cublasStatus\_t cublasCsyrk(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasZsyrk(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*beta, cuDoubleComplex \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs the symmetric rank- \\(k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(A)^{T} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a symmetric matrix stored in lower or upper mode, and \\(A\\) is a matrix with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\). Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ \\end{matrix} \\right.\\) Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix C lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or transpose. n input Number of rows of matrix op(A) and C. k input Number of columns of matrix op(A). alpha host or device input scalar used for multiplication. A device input array of dimension lda x k with lda >= max(1, n) if trans == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. lda input Leading dimension of two-dimensional array used to store matrix A. beta host or device input scalar used for multiplication. If beta == 0 then C does not have to be a valid input. C device in/out array of dimension ldc x n, with ldc >= max(1, n). ldc input Leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, n) when trans == CUBLAS\_OP\_N, and lda < max(1, k) otherwise, or if ldc < max(1, n), or if alpha or beta are NULL, or if C is NULL when beta is not zero CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: ssyrk(), dsyrk(), csyrk(), zsyrk() 2.7.8. cublas syr2k() cublasStatus\_t cublasSsyr2k(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const float \*alpha, const float \*A, int lda, const float \*B, int ldb, const float \*beta, float \*C, int ldc) cublasStatus\_t cublasDsyr2k(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const double \*alpha, const double \*A, int lda, const double \*B, int ldb, const double \*beta, double \*C, int ldc) cublasStatus\_t cublasCsyr2k(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*B, int ldb, const cuComplex \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasZsyr2k(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*B, int ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs the symmetric rank- \\(2k\\) update \\(C = \\alpha(\\text{op}(A)\\text{op}(B)^{T} + \\text{op}(B)\\text{op}(A)^{T}) + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a symmetric matrix stored in lower or upper mode, and \\(A\\) and \\(B\\) are matrices with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\) and \\(\\text{op}(B)\\) \\(n \\times k\\), respectively. Also, for matrix \\(A\\) and \\(B\\) \\(\\text{op(}A\\text{) and op(}B\\text{)} = \\left\\{ \\begin{matrix} {A\\text{ and }B} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ {A^{T}\\text{ and }B^{T}} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ \\end{matrix} \\right.\\) Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix C lower or upper part, is stored, the other symmetric part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or transpose. n input Number of rows of matrix op(A), op(B) and C. k input Number of columns of matrix op(A) and op(B). alpha host or device input scalar used for multiplication. A device input array of dimension lda x k with lda >= max(1, n) if transa == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. lda input Leading dimension of two-dimensional array used to store matrix A. B device input array of dimensions ldb x k with ldb >= max(1, n) if transb == CUBLAS\_OP\_N and ldb x n with ldb >= max(1,k) otherwise. ldb input Leading dimension of two-dimensional array used to store matrix B. beta host or device input scalar used for multiplication. If beta == 0, then C does not have to be a valid input. C device in/out array of dimensions ldc x n with ldc >= max(1, n). ldc input Leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, n) when trans == CUBLAS\_OP\_N, and lda < max(1, k) otherwise, or if ldb < max(1, n) when trans == CUBLAS\_OP\_N, and ldb < max(1, k) otherwise, or if ldc < max(1, n), or if alpha or beta are NULL, or if C is NULL when beta is not zero CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: ssyr2k(), dsyr2k(), csyr2k(), zsyr2k() 2.7.9. cublas syrkx() cublasStatus\_t cublasSsyrkx(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const float \*alpha, const float \*A, int lda, const float \*B, int ldb, const float \*beta, float \*C, int ldc) cublasStatus\_t cublasDsyrkx(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const double \*alpha, const double \*A, int lda, const double \*B, int ldb, const double \*beta, double \*C, int ldc) cublasStatus\_t cublasCsyrkx(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*B, int ldb, const cuComplex \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasZsyrkx(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*B, int ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs a variation of the symmetric rank- \\(k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(B)^{T} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a symmetric matrix stored in lower or upper mode, and \\(A\\) and \\(B\\) are matrices with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\) and \\(\\text{op}(B)\\) \\(n \\times k\\), respectively. Also, for matrices \\(A\\) and \\(B\\) \\(\\text{op(}A\\text{) and op(}B\\text{)} = \\left\\{ \\begin{matrix} {A\\text{ and }B} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ {A^{T}\\text{ and }B^{T}} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ \\end{matrix} \\right.\\) This routine can be used when B is in such way that the result is guaranteed to be symmetric. A usual example is when the matrix B is a scaled form of the matrix A: this is equivalent to B being the product of the matrix A and a diagonal matrix. For an efficient computation of the product of a regular matrix with a diagonal matrix, refer to the routine cublas dgmm(). Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix C lower or upper part, is stored, the other symmetric part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or transpose. n input Number of rows of matrix op(A), op(B) and C. k input Number of columns of matrix op(A) and op(B). alpha host or device input scalar used for multiplication. A device input array of dimension lda x k with lda >= max(1, n) if transa == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. lda input Leading dimension of two-dimensional array used to store matrix A. B device input array of dimensions ldb x k with ldb >= max(1, n) if transb == CUBLAS\_OP\_N and ldb x n with ldb >= max(1,k) otherwise. ldb input Leading dimension of two-dimensional array used to store matrix B. beta host or device input scalar used for multiplication. If beta == 0, then C does not have to be a valid input. C device in/out array of dimensions ldc x n with ldc >= max(1, n). ldc input Leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, n) when trans == CUBLAS\_OP\_N, and lda < max(1, k) otherwise, or if ldb < max(1, n) when trans == CUBLAS\_OP\_N, and ldb < max(1, k) otherwise, or if ldc < max(1, n), or if alpha or beta are NULL, or if C is NULL when beta is not zero CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: ssyrk(), dsyrk(), csyrk(), zsyrk() and ssyr2k(), dsyr2k(), csyr2k(), zsyr2k() 2.7.10. cublas trmm() cublasStatus\_t cublasStrmm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int m, int n, const float \*alpha, const float \*A, int lda, const float \*B, int ldb, float \*C, int ldc) cublasStatus\_t cublasDtrmm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int m, int n, const double \*alpha, const double \*A, int lda, const double \*B, int ldb, double \*C, int ldc) cublasStatus\_t cublasCtrmm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int m, int n, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*B, int ldb, cuComplex \*C, int ldc) cublasStatus\_t cublasZtrmm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int m, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*B, int ldb, cuDoubleComplex \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs the triangular matrix-matrix multiplication \\(C = \\left\\{ \\begin{matrix} {\\alpha\\text{op}(A)B} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_LEFT}$}} \\\\ {\\alpha B\\text{op}(A)} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_RIGHT}$}} \\\\ \\end{matrix} \\right.\\) where \\(A\\) is a triangular matrix stored in lower or upper mode with or without the main diagonal, \\(B\\) and \\(C\\) are \\(m \\times n\\) matrix, and \\(\\alpha\\) is a scalar. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) Notice that in order to achieve better parallelism cuBLAS differs from the BLAS API only for this routine. The BLAS API assumes an in-place implementation (with results written back to B), while the cuBLAS API assumes an out-of-place implementation (with results written into C). The application can obtain the in-place functionality of BLAS in the cuBLAS API by passing the address of the matrix B in place of the matrix C. No other overlapping in the input parameters is supported. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. side input Indicates if matrix A is on the left or right of B. uplo input Indicates if matrix A lower or upper part is stored, the other part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or (conj.) transpose. diag input Indicates if the elements on the main diagonal of matrix A are unity and should not be accessed. m input Number of rows of matrix B, with matrix A sized accordingly. n input Number of columns of matrix B, with matrix A sized accordingly. alpha host or device input scalar used for multiplication, if alpha == 0 then A is not referenced and B does not have to be a valid input. A device input array of dimension lda x m with lda >= max(1, m) if side == CUBLAS\_SIDE\_LEFT and lda x n with lda >= max(1, n) otherwise. lda input Leading dimension of two-dimensional array used to store matrix A. B device input array of dimension ldb x n with ldb >= max(1, m). ldb input Leading dimension of two-dimensional array used to store matrix B. C device in/out array of dimension ldc x n with ldc >= max(1, m). ldc input Leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0, n < 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if side is not one of CUBLAS\_SIDE\_LEFT and CUBLAS\_SIDE\_RIGHT, or if lda < max(1, m) if side == CUBLAS\_SIDE\_LEFT, and lda < max(1, n) otherwise, or if ldb < max(1, m), or if ldc < max(1, m), or if alpha is NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: strmm(), dtrmm(), ctrmm(), ztrmm() 2.7.11. cublas trsm() cublasStatus\_t cublasStrsm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int m, int n, const float \*alpha, const float \*A, int lda, float \*B, int ldb) cublasStatus\_t cublasDtrsm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int m, int n, const double \*alpha, const double \*A, int lda, double \*B, int ldb) cublasStatus\_t cublasCtrsm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int m, int n, const cuComplex \*alpha, const cuComplex \*A, int lda, cuComplex \*B, int ldb) cublasStatus\_t cublasZtrsm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int m, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, cuDoubleComplex \*B, int ldb) This function supports the 64-bit Integer Interface. This function solves the triangular linear system with multiple right-hand-sides \\(\\left\\{ \\begin{matrix} {\\text{op}(A)X = \\alpha B} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_LEFT}$}} \\\\ {X\\text{op}(A) = \\alpha B} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_RIGHT}$}} \\\\ \\end{matrix} \\right.\\) where \\(A\\) is a triangular matrix stored in lower or upper mode with or without the main diagonal, \\(X\\) and \\(B\\) are \\(m \\times n\\) matrices, and \\(\\alpha\\) is a scalar. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) The solution \\(X\\) overwrites the right-hand-sides \\(B\\) on exit. No test for singularity or near-singularity is included in this function. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. side input Indicates if matrix A is on the left or right of X. uplo input Indicates if matrix A lower or upper part is stored, the other part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or (conj.) transpose. diag input Indicates if the elements on the main diagonal of matrix A are unity and should not be accessed. m input Number of rows of matrix B, with matrix A sized accordingly. n input Number of columns of matrix B, with matrix A is sized accordingly. alpha host or device input scalar used for multiplication, if alpha == 0 then A is not referenced and B does not have to be a valid input. A device input array of dimension lda x m with lda >= max(1, m) if side == CUBLAS\_SIDE\_LEFT and lda x n with lda >= max(1, n) otherwise. lda input Leading dimension of two-dimensional array used to store matrix A. B device in/out array. It has dimensions ldb x n with ldb >= max(1, m). ldb input Leading dimension of two-dimensional array used to store matrix B. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0, n < 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if side is not one of CUBLAS\_SIDE\_LEFT and CUBLAS\_SIDE\_RIGHT, or if diag is not one of CUBLAS\_DIAG\_UNIT and CUBLAS\_DIAG\_NON\_UNIT, or if lda < max(1, m) if side == CUBLAS\_SIDE\_LEFT, and lda < max(1, n) otherwise, or if ldb < max(1, m), or if alpha is NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: strsm(), dtrsm(), ctrsm(), ztrsm() 2.7.12. cublas trsmBatched() cublasStatus\_t cublasStrsmBatched( cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int m, int n, const float \*alpha, const float \*const A\[\], int lda, float \*const B\[\], int ldb, int batchCount); cublasStatus\_t cublasDtrsmBatched( cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int m, int n, const double \*alpha, const double \*const A\[\], int lda, double \*const B\[\], int ldb, int batchCount); cublasStatus\_t cublasCtrsmBatched( cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int m, int n, const cuComplex \*alpha, const cuComplex \*const A\[\], int lda, cuComplex \*const B\[\], int ldb, int batchCount); cublasStatus\_t cublasZtrsmBatched( cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, int m, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*const A\[\], int lda, cuDoubleComplex \*const B\[\], int ldb, int batchCount); This function supports the 64-bit Integer Interface. This function solves an array of triangular linear systems with multiple right-hand-sides \\(\\left\\{ \\begin{matrix} {\\text{op}(A\\lbrack i\\rbrack)X\\lbrack i\\rbrack = \\alpha B\\lbrack i\\rbrack} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_LEFT}$}} \\\\ {X\\lbrack i\\rbrack\\text{op}(A\\lbrack i\\rbrack) = \\alpha B\\lbrack i\\rbrack} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_RIGHT}$}} \\\\ \\end{matrix} \\right.\\) where \\(A\\lbrack i\\rbrack\\) is a triangular matrix stored in lower or upper mode with or without the main diagonal, \\(X\\lbrack i\\rbrack\\) and \\(B\\lbrack i\\rbrack\\) are \\(m \\times n\\) matrices, and \\(\\alpha\\) is a scalar. Also, for matrix \\(A\\) \\(\\text{op}(A\\lbrack i\\rbrack) = \\left\\{ \\begin{matrix} {A\\lbrack i\\rbrack} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ {A^{T}\\lbrack i\\rbrack} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ {A^{H}\\lbrack i\\rbrack} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) The solution \\(X\\lbrack i\\rbrack\\) overwrites the right-hand-sides \\(B\\lbrack i\\rbrack\\) on exit. No test for singularity or near-singularity is included in this function. This function works for any sizes but is intended to be used for matrices of small sizes where the launch overhead is a significant factor. For bigger sizes, it might be advantageous to call batchCount times the regular cublas trsm() within a set of CUDA streams. The current implementation is limited to devices with compute capability above or equal 2.0. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. side input Indicates if matrix A\[i\] is on the left or right of X\[i\]. uplo input Indicates if matrix A\[i\] lower or upper part is stored, the other part is not referenced and is inferred from the stored elements. trans input Operation op(A\[i\]) that is non- or (conj.) transpose. diag input Indicates if the elements on the main diagonal of matrix A\[i\] are unity and should not be accessed. m input Number of rows of matrix B\[i\], with matrix A\[i\] sized accordingly. n input Number of columns of matrix B\[i\], with matrix A\[i\] is sized accordingly. alpha host or device input scalar used for multiplication, if alpha == 0 then A\[i\] is not referenced and B\[i\] does not have to be a valid input. A device input Array of pointers to array, with each array of dim. lda x m with lda >= max(1, m) if side == CUBLAS\_SIDE\_LEFT and lda x n with lda >= max(1, n) otherwise. lda input Leading dimension of two-dimensional array used to store matrix A\[i\]. B device in/out Array of pointers to array, with each array of dim. ldb x n with ldb >= max(1, m). Matrices B\[i\] should not overlap; otherwise, undefined behavior is expected. ldb input Leading dimension of two-dimensional array used to store matrix B\[i\]. batchCount input Number of pointers contained in A and B. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0, n < 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if side is not one of CUBLAS\_SIDE\_LEFT and CUBLAS\_SIDE\_RIGHT, or if diag is not one of CUBLAS\_DIAG\_UNIT and CUBLAS\_DIAG\_NON\_UNIT, or if lda < max(1, m) if side == CUBLAS\_SIDE\_LEFT, and lda < max(1, n) otherwise, or if ldb < max(1, m) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: strsm(), dtrsm(), ctrsm(), ztrsm() 2.7.13. cublas hemm() cublasStatus\_t cublasChemm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, int m, int n, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*B, int ldb, const cuComplex \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasZhemm(cublasHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, int m, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*B, int ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs the Hermitian matrix-matrix multiplication \\(C = \\left\\{ \\begin{matrix} {\\alpha AB + \\beta C} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_LEFT}$}} \\\\ {\\alpha BA + \\beta C} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_RIGHT}$}} \\\\ \\end{matrix} \\right.\\) where \\(A\\) is a Hermitian matrix stored in lower or upper mode, \\(B\\) and \\(C\\) are \\(m \\times n\\) matrices, and \\(\\alpha\\) and \\(\\beta\\) are scalars. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. side input Indicates if matrix A is on the left or right of B. uplo input Indicates if matrix A lower or upper part is stored, the other Hermitian part is not referenced and is inferred from the stored elements. m input Number of rows of matrix C and B, with matrix A sized accordingly. n input Number of columns of matrix C and B, with matrix A sized accordingly. alpha host or device input scalar used for multiplication. A device input array of dimension lda x m with lda >= max(1, m) if side == CUBLAS\_SIDE\_LEFT and lda x n with lda >= max(1, n) otherwise. The imaginary parts of the diagonal elements are assumed to be zero. lda input Leading dimension of two-dimensional array used to store matrix A. B device input array of dimension ldb x n with ldb >= max(1, m). ldb input Leading dimension of two-dimensional array used to store matrix B. beta input scalar used for multiplication. If beta == 0 then C does not have to be a valid input. C device in/out array of dimensions ldc x n with ldc >= max(1, m). ldc input Leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0, or if side is not one of CUBLAS\_SIDE\_LEFT and CUBLAS\_SIDE\_RIGHT, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, m) when side == CUBLAS\_SIDE\_LEFT, and lda < max(1, n) otherwise, or if ldb < max(1, m), or if ldc < max(1, m), or if alpha or beta are NULL, or if C is NULL when beta is not zero CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: chemm(), zhemm() 2.7.14. cublas herk() cublasStatus\_t cublasCherk(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const float \*alpha, const cuComplex \*A, int lda, const float \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasZherk(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const double \*alpha, const cuDoubleComplex \*A, int lda, const double \*beta, cuDoubleComplex \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs the Hermitian rank- \\(k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(A)^{H} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a Hermitian matrix stored in lower or upper mode, and \\(A\\) is a matrix with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\). Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix C lower or upper part is stored, the other Hermitian part is not referenced. trans input Operation op(A) that is non- or (conj.) transpose. n input Number of rows of matrix op(A) and C. k input Number of columns of matrix op(A). alpha host or device input scalar used for multiplication. A device input array of dimension lda x k with lda >= max(1, n) if transa == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. lda input Leading dimension of two-dimensional array used to store matrix A. beta input scalar used for multiplication. If beta == 0 then C does not have to be a valid input. C device in/out array of dimension ldc x n, with ldc >= max(1, n). The imaginary parts of the diagonal elements are assumed and set to zero. ldc input Leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, n) when trans == CUBLAS\_OP\_N, and lda < max(1, k) otherwise, or if ldc < max(1, n), or if alpha or beta are NULL, or if C is NULL when beta is not zero CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: cherk(), zherk() 2.7.15. cublas her2k() cublasStatus\_t cublasCher2k(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*B, int ldb, const float \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasZher2k(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*B, int ldb, const double \*beta, cuDoubleComplex \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs the Hermitian rank- \\(2k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(B)^{H} + \\overset{ˉ}{\\alpha}\\text{op}(B)\\text{op}(A)^{H} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a Hermitian matrix stored in lower or upper mode, and \\(A\\) and \\(B\\) are matrices with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\) and \\(\\text{op}(B)\\) \\(n \\times k\\), respectively. Also, for matrix \\(A\\) and \\(B\\) \\(\\text{op(}A\\text{) and op(}B\\text{)} = \\left\\{ \\begin{matrix} {A\\text{ and }B} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ {A^{H}\\text{ and }B^{H}} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix C lower or upper part is stored, the other Hermitian part is not referenced. trans input Operation op(A) that is non- or (conj.) transpose. n input Number of rows of matrix op(A), op(B) and C. k input Number of columns of matrix op(A) and op(B). alpha host or device input scalar used for multiplication. A device input array of dimension lda x k with lda >= max(1, n) if transa == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. lda input Leading dimension of two-dimensional array used to store matrix A. B device input array of dimension ldb x k with ldb >= max(1, n) if transb == CUBLAS\_OP\_N and ldb x n with ldb >= max(1,k) otherwise. ldb input Leading dimension of two-dimensional array used to store matrix B. beta host or device input scalar used for multiplication. If beta == 0 then C does not have to be a valid input. C device in/out array of dimension ldc x n, with ldc >= max(1, n). The imaginary parts of the diagonal elements are assumed and set to zero. ldc input Leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, n) when trans == CUBLAS\_OP\_N, and lda < max(1, k) otherwise, or if ldc < max(1, n), or if alpha or beta are NULL, or if C is NULL when beta is not zero CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: cher2k(), zher2k() 2.7.16. cublas herkx() cublasStatus\_t cublasCherkx(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*B, int ldb, const float \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasZherkx(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*B, int ldb, const double \*beta, cuDoubleComplex \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs a variation of the Hermitian rank- \\(k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(B)^{H} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a Hermitian matrix stored in lower or upper mode, and \\(A\\) and \\(B\\) are matrices with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\) and \\(\\text{op}(B)\\) \\(n \\times k\\), respectively. Also, for matrix \\(A\\) and \\(B\\) \\(\\text{op(}A\\text{) and op(}B\\text{)} = \\left\\{ \\begin{matrix} {A\\text{ and }B} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ {A^{H}\\text{ and }B^{H}} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) This routine can be used when the matrix B is in such way that the result is guaranteed to be hermitian. An usual example is when the matrix B is a scaled form of the matrix A: this is equivalent to B being the product of the matrix A and a diagonal matrix. For an efficient computation of the product of a regular matrix with a diagonal matrix, refer to the routine cublas dgmm(). Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix C lower or upper part is stored, the other Hermitian part is not referenced. trans input Operation op(A) that is non- or (conj.) transpose. n input Number of rows of matrix op(A), op(B) and C. k input Number of columns of matrix op(A) and op(B). alpha host or device input scalar used for multiplication. A device input array of dimension lda x k with lda >= max(1, n) if transa == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. lda input Leading dimension of two-dimensional array used to store matrix A. B device input array of dimension ldb x k with ldb >= max(1, n) if transb == CUBLAS\_OP\_N and ldb x n with ldb >= max(1,k) otherwise. ldb input Leading dimension of two-dimensional array used to store matrix B. beta host or device input Real scalar used for multiplication. If beta == 0 then C does not have to be a valid input. C device in/out array of dimension ldc x n, with ldc >= max(1, n). The imaginary parts of the diagonal elements are assumed and set to zero. ldc input Leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, n) when trans == CUBLAS\_OP\_N, and lda < max(1, k) otherwise, or if ldc < max(1, n), or if alpha or beta are NULL, or if C is NULL when beta is not zero CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: cherk(), zherk() and cher2k(), zher2k() 2.8. BLAS-like Extension This section describes the BLAS-extension functions that perform matrix-matrix operations. 2.8.1. cublas geam() cublasStatus\_t cublasSgeam(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, const float \*alpha, const float \*A, int lda, const float \*beta, const float \*B, int ldb, float \*C, int ldc) cublasStatus\_t cublasDgeam(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, const double \*alpha, const double \*A, int lda, const double \*beta, const double \*B, int ldb, double \*C, int ldc) cublasStatus\_t cublasCgeam(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*beta, const cuComplex \*B, int ldb, cuComplex \*C, int ldc) cublasStatus\_t cublasZgeam(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*beta, const cuDoubleComplex \*B, int ldb, cuDoubleComplex \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs the matrix-matrix addition/transposition \\(C = \\alpha\\text{op}(A) + \\beta\\text{op}(B)\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, and \\(A\\), \\(B\\) and \\(C\\) are matrices stored in column-major format with dimensions \\(\\text{op}(A)\\) \\(m \\times n\\), \\(\\text{op}(B)\\) \\(m \\times n\\) and \\(C\\) \\(m \\times n\\), respectively. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) and \\(\\text{op}(B)\\) is defined similarly for matrix \\(B\\). The operation is out-of-place if C does not overlap A or B. The in-place mode supports the following two operations, \\(C = \\alpha\\text{\*}C + \\beta\\text{op}(B)\\) \\(C = \\alpha\\text{op}(A) + \\beta\\text{\*}C\\) For in-place mode, if C == A, ldc == lda and transa == CUBLAS\_OP\_N. If C === B, ldc == ldb and transb == CUBLAS\_OP\_N. If the user does not meet above requirements, CUBLAS\_STATUS\_INVALID\_VALUE is returned. The operation includes the following special cases: the user can reset matrix C to zero by setting \*alpha = beta = 0. the user can transpose matrix A by setting \*alpha = 1 and \*beta = 0. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. transa input Operation op(A) that is non- or (conj.) transpose. transb input Operation op(B) that is non- or (conj.) transpose. m input Number of rows of matrix op(A) and C. n input Number of columns of matrix op(B) and C. alpha host or device input scalar used for multiplication. If \*alpha == 0, A does not have to be a valid input. A device input array of dimensions lda x n with lda >= max(1, m) if transa == CUBLAS\_OP\_N and lda x m with lda >= max(1, n) otherwise. lda input Leading dimension of two-dimensional array used to store the matrix A. B device input array of dimension ldb x n with ldb >= max(1, m) if transb == CUBLAS\_OP\_N and ldb x m with ldb >= max(1,n) otherwise. ldb input Leading dimension of two-dimensional array used to store matrix B. beta host or device input scalar used for multiplication. If \*beta == 0, B does not have to be a valid input. C device output array of dimensions ldc x n with ldc >= max(1, m). ldc input Leading dimension of a two-dimensional array used to store the matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0, or if transa is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if transb is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if lda < max(1, m) when transa == CUBLAS\_OP\_N, and lda < max(1, n) otherwise, or if ldb < max(1, m) if transb == CUBLAS\_OP\_N, and ldb < max(1, n) otherwise, or if ldc < max(1, m), or if A == C and (transa!= CUBLAS\_OP\_N) || (lda!= ldc), or if B == C and (transb!= CUBLAS\_OP\_N) || (ldb!= ldc), or if alpha or beta are NULL CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU 2.8.2. cublas dgmm() cublasStatus\_t cublasSdgmm(cublasHandle\_t handle, cublasSideMode\_t mode, int m, int n, const float \*A, int lda, const float \*x, int incx, float \*C, int ldc) cublasStatus\_t cublasDdgmm(cublasHandle\_t handle, cublasSideMode\_t mode, int m, int n, const double \*A, int lda, const double \*x, int incx, double \*C, int ldc) cublasStatus\_t cublasCdgmm(cublasHandle\_t handle, cublasSideMode\_t mode, int m, int n, const cuComplex \*A, int lda, const cuComplex \*x, int incx, cuComplex \*C, int ldc) cublasStatus\_t cublasZdgmm(cublasHandle\_t handle, cublasSideMode\_t mode, int m, int n, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*x, int incx, cuDoubleComplex \*C, int ldc) This function supports the 64-bit Integer Interface. This function performs the matrix-matrix multiplication \\(C = \\left\\{ \\begin{matrix} {A \\times diag(X)} & {\\text{if }\\textsf{mode == $\\mathrm{CUBLAS\\\_SIDE\\\_RIGHT}$}} \\\\ {diag(X) \\times A} & {\\text{if }\\textsf{mode == $\\mathrm{CUBLAS\\\_SIDE\\\_LEFT}$}} \\\\ \\end{matrix} \\right.\\) where \\(A\\) and \\(C\\) are matrices stored in column-major format with dimensions \\(m \\times n\\). \\(X\\) is a vector of size \\(n\\) if mode == CUBLAS\_SIDE\_RIGHT and of size \\(m\\) if mode == CUBLAS\_SIDE\_LEFT. \\(X\\) is gathered from one-dimensional array x with stride incx. The absolute value of incx is the stride and the sign of incx is direction of the stride. If incx is positive, then we forward x from the first element. Otherwise, we backward x from the last element. The formula of X is \\(X\\lbrack j\\rbrack = \\left\\{ \\begin{matrix} {x\\lbrack j \\times incx\\rbrack} & {\\text{if }incx \\geq 0} \\\\ {x\\lbrack(\\chi - 1) \\times |incx| - j \\times |incx|\\rbrack} & {\\text{if }incx < 0} \\\\ \\end{matrix} \\right.\\) where \\(\\chi = m\\) if mode == CUBLAS\_SIDE\_LEFT and \\(\\chi = n\\) if mode == CUBLAS\_SIDE\_RIGHT. Example 1: if the user wants to perform \\(diag(diag(B)) \\times A\\), then \\(incx = ldb + 1\\) where \\(ldb\\) is leading dimension of matrix B, either row-major or column-major. Example 2: if the user wants to perform \\(\\alpha \\times A\\), then there are two choices, either cublas geam() with \*beta == 0 and transa == CUBLAS\_OP\_N or cublas dgmm() with incx == 0 and x\[0\] == alpha. The operation is out-of-place. The in-place only works if lda == ldc. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. mode input Left multiply if mode == CUBLAS\_SIDE\_LEFT or right multiply if mode == CUBLAS\_SIDE\_RIGHT m input Number of rows of matrix A and C. n input Number of columns of matrix A and C. A device input array of dimensions lda x n with lda >= max(1, m) lda input Leading dimension of two-dimensional array used to store the matrix A. x device input One-dimensional array of size abs(incx) x m if mode == CUBLAS\_SIDE\_LEFT and abs(incx) x n if mode == CUBLAS\_SIDE\_RIGHT incx input Stride of one-dimensional array x. C device in/out array of dimensions ldc x n with ldc >= max(1, m). ldc input Leading dimension of a two-dimensional array used to store the matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0, or if mode is not one of CUBLAS\_SIDE\_LEFT and CUBLAS\_SIDE\_RIGHT, or if lda < max(1, m), or if ldc < max(1, m) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU 2.8.3. cublas getrfBatched() cublasStatus\_t cublasSgetrfBatched(cublasHandle\_t handle, int n, float \*const Aarray\[\], int lda, int \*PivotArray, int \*infoArray, int batchSize); cublasStatus\_t cublasDgetrfBatched(cublasHandle\_t handle, int n, double \*const Aarray\[\], int lda, int \*PivotArray, int \*infoArray, int batchSize); cublasStatus\_t cublasCgetrfBatched(cublasHandle\_t handle, int n, cuComplex \*const Aarray\[\], int lda, int \*PivotArray, int \*infoArray, int batchSize); cublasStatus\_t cublasZgetrfBatched(cublasHandle\_t handle, int n, cuDoubleComplex \*const Aarray\[\], int lda, int \*PivotArray, int \*infoArray, int batchSize); Aarray is an array of pointers to matrices stored in column-major format with dimensions nxn and leading dimension lda. This function performs the LU factorization of each Aarray\[i\] for i = 0, …, batchSize-1 by the following equation \\(\\text{P}\\text{\*}{Aarray}\\lbrack i\\rbrack = L\\text{\*}U\\) where P is a permutation matrix which represents partial pivoting with row interchanges. L is a lower triangular matrix with unit diagonal and U is an upper triangular matrix. Formally P is written by a product of permutation matrices Pj, for j = 1,2,...,n, say P = P1 \* P2 \* P3 \*.... \* Pn. Pj is a permutation matrix which interchanges two rows of vector x when performing Pj\*x. Pj can be constructed by j element of PivotArray\[i\] by the following Matlab code // In Matlab PivotArray\[i\] is an array of base-1. // In C, PivotArray\[i\] is base-0. Pj = eye(n); swap Pj(j,:) and Pj(PivotArray\[i\]\[j\],:) L and U are written back to original matrix A, and diagonal elements of L are discarded. The L and U can be constructed by the following Matlab code // A is a matrix of nxn after getrf. L = eye(n); for j = 1:n L(j+1:n,j) = A(j+1:n,j) end U = zeros(n); for i = 1:n U(i,i:n) = A(i,i:n) end If matrix A(=Aarray\[i\]) is singular, getrf still works and the value of info(=infoArray\[i\]) reports first row index that LU factorization cannot proceed. If info is k, U(k,k) is zero. The equation P\*A == L\*U still holds, however L and U reconstruction needs a different Matlab code as follows: // A is a matrix of nxn after getrf. // info is k, which means U(k,k) is zero. L = eye(n); for j = 1:k-1 L(j+1:n,j) = A(j+1:n,j) end U = zeros(n); for i = 1:k-1 U(i,i:n) = A(i,i:n) end for i = k:n U(i,k:n) = A(i,k:n) end This function is intended to be used for matrices of small sizes where the launch overhead is a significant factor. cublas getrfBatched supports non-pivot LU factorization if PivotArray is NULL. cublas getrfBatched supports arbitrary dimension. cublas getrfBatched only supports compute capability 2.0 or above. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of rows and columns of Aarray\[i\]. Aarray device input/output Array of pointers to array, with each array of dim. n x n with lda >= max(1, n). Matrices Aarray\[i\] should not overlap; otherwise, undefined behavior is expected. lda input Leading dimension of two-dimensional array used to store each matrix Aarray\[i\]. PivotArray device output Array of size n x batchSize that contains the pivoting sequence of each factorization of Aarray\[i\] stored in a linear fashion. If PivotArray is NULL, pivoting is disabled. infoArray device output Array of size batchSize that info(=infoArray\[i\]) contains the information of factorization of Aarray\[i\]. If info == 0, the execution is successful. If info = -j, the j-th parameter had an illegal value. If info = k, U(k, k) == 0. The factorization has been completed, but U is exactly singular. batchSize input Number of pointers contained in A The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE The parameters n < 0 or batchSize < 0 or lda <0 CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sgeqrf(), dgeqrf(), cgeqrf(), zgeqrf() 2.8.4. cublas getrsBatched() cublasStatus\_t cublasSgetrsBatched(cublasHandle\_t handle, cublasOperation\_t trans, int n, int nrhs, const float \*const Aarray\[\], int lda, const int \*devIpiv, float \*const Barray\[\], int ldb, int \*info, int batchSize); cublasStatus\_t cublasDgetrsBatched(cublasHandle\_t handle, cublasOperation\_t trans, int n, int nrhs, const double \*const Aarray\[\], int lda, const int \*devIpiv, double \*const Barray\[\], int ldb, int \*info, int batchSize); cublasStatus\_t cublasCgetrsBatched(cublasHandle\_t handle, cublasOperation\_t trans, int n, int nrhs, const cuComplex \*const Aarray\[\], int lda, const int \*devIpiv, cuComplex \*const Barray\[\], int ldb, int \*info, int batchSize); cublasStatus\_t cublasZgetrsBatched(cublasHandle\_t handle, cublasOperation\_t trans, int n, int nrhs, const cuDoubleComplex \*const Aarray\[\], int lda, const int \*devIpiv, cuDoubleComplex \*const Barray\[\], int ldb, int \*info, int batchSize); This function solves an array of systems of linear equations of the form: \\(\\text{op}(A\\lbrack i \\rbrack) X\\lbrack i\\rbrack = B\\lbrack i\\rbrack\\) where \\(A\\lbrack i\\rbrack\\) is a matrix which has been LU factorized with pivoting, \\(X\\lbrack i\\rbrack\\) and \\(B\\lbrack i\\rbrack\\) are \\(n \\times {nrhs}\\) matrices. Also, for matrix \\(A\\) \\(\\text{op}(A\\lbrack i\\rbrack) = \\left\\{ \\begin{matrix} {A\\lbrack i\\rbrack} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ {A^{T}\\lbrack i\\rbrack} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ {A^{H}\\lbrack i\\rbrack} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) This function is intended to be used for matrices of small sizes where the launch overhead is a significant factor. cublas getrsBatched() supports non-pivot LU factorization if devIpiv is NULL. cublas getrsBatched() supports arbitrary dimension. cublas getrsBatched() only supports compute capability 2.0 or above. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. trans input Operation op(A) that is non- or (conj.) transpose. n input Number of rows and columns of Aarray\[i\]. nrhs input Number of columns of Barray\[i\]. Aarray device input Array of pointers to array, with each array of dim. n x n with lda >= max(1, n). lda input Leading dimension of two-dimensional array used to store each matrix Aarray\[i\]. devIpiv device input Array of size n x batchSize that contains the pivoting sequence of each factorization of Aarray\[i\] stored in a linear fashion. If devIpiv is NULL, pivoting for all Aarray\[i\] is ignored. Barray device input/output Array of pointers to array, with each array of dim. n x nrhs with ldb >= max(1, n). Matrices Barray\[i\] should not overlap; otherwise, undefined behavior is expected. ldb input Leading dimension of two-dimensional array used to store each solution matrix Barray\[i\]. info host output If info == 0, the execution is successful. If info = -j, the j-th parameter had an illegal value. batchSize input Number of pointers contained in A The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or nrhs < 0, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if lda < max(1, n), or if ldb < max(1, n) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sgeqrs(), dgeqrs(), cgeqrs(), zgeqrs() 2.8.5. cublas getriBatched() cublasStatus\_t cublasSgetriBatched(cublasHandle\_t handle, int n, const float \*const Aarray\[\], int lda, int \*PivotArray, float \*const Carray\[\], int ldc, int \*infoArray, int batchSize); cublasStatus\_t cublasDgetriBatched(cublasHandle\_t handle, int n, const double \*const Aarray\[\], int lda, int \*PivotArray, double \*const Carray\[\], int ldc, int \*infoArray, int batchSize); cublasStatus\_t cublasCgetriBatched(cublasHandle\_t handle, int n, const cuComplex \*const Aarray\[\], int lda, int \*PivotArray, cuComplex \*const Carray\[\], int ldc, int \*infoArray, int batchSize); cublasStatus\_t cublasZgetriBatched(cublasHandle\_t handle, int n, const cuDoubleComplex \*const Aarray\[\], int lda, int \*PivotArray, cuDoubleComplex \*const Carray\[\], int ldc, int \*infoArray, int batchSize); Aarray and Carray are arrays of pointers to matrices stored in column-major format with dimensions n\*n and leading dimension lda and ldc respectively. This function performs the inversion of matrices A\[i\] for i = 0, …, batchSize-1. Prior to calling cublas getriBatched, the matrix A\[i\] must be factorized first using the routine cublas getrfBatched. After the call of cublas getrfBatched, the matrix pointing by Aarray\[i\] will contain the LU factors of the matrix A\[i\] and the vector pointing by (PivotArray+i) will contain the pivoting sequence. Following the LU factorization, cublas getriBatched uses forward and backward triangular solvers to complete inversion of matrices A\[i\] for i = 0, …, batchSize-1. The inversion is out-of-place, so memory space of Carray\[i\] cannot overlap memory space of Array\[i\]. Typically all parameters in cublas getrfBatched would be passed into cublas getriBatched. For example, // step 1: perform in-place LU decomposition, P\*A = L\*U. // Aarray\[i\] is n\*n matrix A\[i\] cublasDgetrfBatched(handle, n, Aarray, lda, PivotArray, infoArray, batchSize); // check infoArray\[i\] to see if factorization of A\[i\] is successful or not. // Array\[i\] contains LU factorization of A\[i\] // step 2: perform out-of-place inversion, Carray\[i\] = inv(A\[i\]) cublasDgetriBatched(handle, n, Aarray, lda, PivotArray, Carray, ldc, infoArray, batchSize); // check infoArray\[i\] to see if inversion of A\[i\] is successful or not. The user can check singularity from either cublas getrfBatched or cublas getriBatched. This function is intended to be used for matrices of small sizes where the launch overhead is a significant factor. If cublas getrfBatched is performed by non-pivoting, PivotArray of cublas getriBatched should be NULL. cublas getriBatched supports arbitrary dimension. cublas getriBatched only supports compute capability 2.0 or above. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of rows and columns of Aarray\[i\]. Aarray device input Array of pointers to array, with each array of dimension n\*n with lda >= max(1, n). lda input Leading dimension of two-dimensional array used to store each matrix Aarray\[i\]. PivotArray device output Array of size n\*batchSize that contains the pivoting sequence of each factorization of Aarray\[i\] stored in a linear fashion. If PivotArray is NULL, pivoting is disabled. Carray device output Array of pointers to array, with each array of dimension n\*n with ldc >= max(1, n). Matrices Carray\[i\] should not overlap; otherwise, undefined behavior is expected. ldc input Leading dimension of two-dimensional array used to store each matrix Carray\[i\]. infoArray device output Array of size batchSize that info(=infoArray\[i\]) contains the information of inversion of A\[i\]. If info == 0, the execution is successful. If info == k, U(k, k) == 0. The U is exactly singular and the inversion failed. batchSize input Number of pointers contained in A The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or lda < 0 or ldc < 0 or batchSize < 0, or if lda < n or ldc < n CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU 2.8.6. cublas matinvBatched() cublasStatus\_t cublasSmatinvBatched(cublasHandle\_t handle, int n, const float \*const A\[\], int lda, float \*const Ainv\[\], int lda\_inv, int \*info, int batchSize); cublasStatus\_t cublasDmatinvBatched(cublasHandle\_t handle, int n, const double \*const A\[\], int lda, double \*const Ainv\[\], int lda\_inv, int \*info, int batchSize); cublasStatus\_t cublasCmatinvBatched(cublasHandle\_t handle, int n, const cuComplex \*const A\[\], int lda, cuComplex \*const Ainv\[\], int lda\_inv, int \*info, int batchSize); cublasStatus\_t cublasZmatinvBatched(cublasHandle\_t handle, int n, const cuDoubleComplex \*const A\[\], int lda, cuDoubleComplex \*const Ainv\[\], int lda\_inv, int \*info, int batchSize); A and Ainv are arrays of pointers to matrices stored in column-major format with dimensions n\*n and leading dimension lda and lda\_inv respectively. This function performs the inversion of matrices A\[i\] for i = 0, …, batchSize-1. This function is a short cut of cublas getrfBatched() plus cublas getriBatched(). However it doesn’t work if n is greater than 32. If not, the user has to go through cublas getrfBatched() and cublas getriBatched(). If the matrix A\[i\] is singular, then info\[i\] reports singularity, the same as cublas getrfBatched(). Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of rows and columns of A\[i\]. A device input Array of pointers to array, with each array of dimension n\*n with lda >= max(1, n). lda input Leading dimension of two-dimensional array used to store each matrix A\[i\]. Ainv device output Array of pointers to array, with each array of dimension n\*n with lda\_inv >= max(1, n). Matrices Ainv\[i\] should not overlap; otherwise, undefined behavior is expected. lda\_inv input Leading dimension of two-dimensional array used to store each matrix Ainv\[i\]. info device output Array of size batchSize that info\[i\] contains the information of inversion of A\[i\]. If info\[i\] == 0, the execution is successful. If info\[i\] == k, then U(k, k) == 0. The U is exactly singular and the inversion failed. batchSize input Number of pointers contained in A. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or lda < 0 or lda\_inv < 0 or batchSize < 0, or if lda < n or lda\_inv < n, or if n > 32 CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU 2.8.7. cublas geqrfBatched() cublasStatus\_t cublasSgeqrfBatched( cublasHandle\_t handle, int m, int n, float \*const Aarray\[\], int lda, float \*const TauArray\[\], int \*info, int batchSize); cublasStatus\_t cublasDgeqrfBatched( cublasHandle\_t handle, int m, int n, double \*const Aarray\[\], int lda, double \*const TauArray\[\], int \*info, int batchSize); cublasStatus\_t cublasCgeqrfBatched( cublasHandle\_t handle, int m, int n, cuComplex \*const Aarray\[\], int lda, cuComplex \*const TauArray\[\], int \*info, int batchSize); cublasStatus\_t cublasZgeqrfBatched( cublasHandle\_t handle, int m, int n, cuDoubleComplex \*const Aarray\[\], int lda, cuDoubleComplex \*const TauArray\[\], int \*info, int batchSize); Aarray is an array of pointers to matrices stored in column-major format with dimensions m x n and leading dimension lda. TauArray is an array of pointers to vectors of dimension of at least max (1, min(m, n). This function performs the QR factorization of each Aarray\[i\] for i = 0,...,batchSize-1 using Householder reflections. Each matrix Q\[i\] is represented as a product of elementary reflectors and is stored in the lower part of each Aarray\[i\] as follows: Q\[j\] = H\[j\]\[1\] H\[j\]\[2\]... H\[j\](k), where k = min(m,n). Each H\[j\]\[i\] has the form H\[j\]\[i\] = I - tau\[j\] \* v \* v' where tau\[j\] is a real scalar, and v is a real vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in Aarray\[j\]\[i+1:m,i\], and tau in TauArray\[j\]\[i\]. This function is intended to be used for matrices of small sizes where the launch overhead is a significant factor. cublas geqrfBatched supports arbitrary dimension. cublas geqrfBatched only supports compute capability 2.0 or above. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. m input Number of rows Aarray\[i\]. n input Number of columns of Aarray\[i\]. Aarray device input Array of pointers to array, with each array of dim. m x n with lda >= max(1, m). lda input Leading dimension of two-dimensional array used to store each matrix Aarray\[i\]. TauArray device output Array of pointers to vector, with each vector of dim. max(1,min(m, n)). info host output If info == 0, the parameters passed to the function are valid If info < 0, the parameter in postion -info is invalid batchSize input Number of pointers contained in Aarray The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0 or batchSize < 0, or if lda < max(1, m) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sgeqrf(), dgeqrf(), cgeqrf(), zgeqrf() 2.8.8. cublas gelsBatched() cublasStatus\_t cublasSgelsBatched( cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, int nrhs, float \*const Aarray\[\], int lda, float \*const Carray\[\], int ldc, int \*info, int \*devInfoArray, int batchSize ); cublasStatus\_t cublasDgelsBatched( cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, int nrhs, double \*const Aarray\[\], int lda, double \*const Carray\[\], int ldc, int \*info, int \*devInfoArray, int batchSize ); cublasStatus\_t cublasCgelsBatched( cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, int nrhs, cuComplex \*const Aarray\[\], int lda, cuComplex \*const Carray\[\], int ldc, int \*info, int \*devInfoArray, int batchSize ); cublasStatus\_t cublasZgelsBatched( cublasHandle\_t handle, cublasOperation\_t trans, int m, int n, int nrhs, cuDoubleComplex \*const Aarray\[\], int lda, cuDoubleComplex \*const Carray\[\], int ldc, int \*info, int \*devInfoArray, int batchSize ); Aarray is an array of pointers to matrices stored in column-major format. Carray is an array of pointers to matrices stored in column-major format. This function find the least squares solution of a batch of overdetermined systems: it solves the least squares problem described as follows: minimize || Carray\[i\] - Aarray\[i\]\*Xarray\[i\] ||, with i = 0,...,batchSize-1 On exit, each Aarray\[i\] is overwritten with their QR factorization and each Carray\[i\] is overwritten with the least square solution cublas gelsBatched supports only the non-transpose operation and only solves over-determined systems (m >= n). cublas gelsBatched only supports compute capability 2.0 or above. This function is intended to be used for matrices of small sizes where the launch overhead is a significant factor. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. trans input Operation op(Aarray\[i\]) that is non- or (conj.) transpose. Only non-transpose operation is currently supported. m input Number of rows of each Aarray\[i\] and Carray\[i\] if trans == CUBLAS\_OP\_N, numbers of columns of each Aarray\[i\] otherwise (not supported currently). n input Number of columns of each Aarray\[i\] if trans == CUBLAS\_OP\_N, and number of rows of each Aarray\[i\] and Carray\[i\] otherwise (not supported currently). nrhs input Number of columns of each Carray\[i\]. Aarray device input/output Array of pointers to array, with each array of dim. m x n with lda >= max(1, m) if trans == CUBLAS\_OP\_N, and n x m with lda >= max(1, n) otherwise (not supported currently). Matrices Aarray\[i\] should not overlap; otherwise, behavior is undefined. lda input Leading dimension of two-dimensional array used to store each matrix Aarray\[i\]. Carray device input/output Array of pointers to array, with each array of dim. m x nrhs with ldc >= max(1, m) if trans == CUBLAS\_OP\_N, and n x nrhs with lda >= max(1, n) otherwise (not supported currently). Matrices Carray\[i\] should not overlap; otherwise, behavior is undefined. ldc input Leading dimension of two-dimensional array used to store each matrix Carray\[i\]. info host output If info == 0 the parameters passed to the function are valid If info < 0 the parameter in position -info is invalid devInfoArray device output Optional array of integers of dimension batchsize. If non-null, every element of devInfoArray\[i\] == V has the following meaning: V == 0: the i-th problem was sucessfully solved V > 0: the V-th diagonal element of the Aarray\[i\] is zero. Aarray\[i\] does not have full rank. batchSize input Number of pointers contained in Aarray and Carray The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0 or nrhs < 0 or batchSize < 0 or if lda < max(1, m) or ldc < max(1, m) CUBLAS\_STATUS\_NOT\_SUPPORTED The parameters m tpttr() cublasStatus\_t cublasStpttr ( cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const float \*AP, float \*A, int lda ); cublasStatus\_t cublasDtpttr ( cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const double \*AP, double \*A, int lda ); cublasStatus\_t cublasCtpttr ( cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuComplex \*AP, cuComplex \*A, int lda ); cublasStatus\_t cublasZtpttr ( cublasHandle\_t handle, cublasFillMode\_t uplo int n, const cuDoubleComplex \*AP, cuDoubleComplex \*A, int lda ); This function performs the conversion from the triangular packed format to the triangular format If uplo == CUBLAS\_FILL\_MODE\_LOWER then the elements of AP are copied into the lower triangular part of the triangular matrix A and the upper part of A is left untouched. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the elements of AP are copied into the upper triangular part of the triangular matrix A and the lower part of A is left untouched. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix AP contains lower or upper part of matrix A. n input Number of rows and columns of matrix A. AP device input array with \\(A\\) stored in packed format. A device output array of dimensions lda x n, with lda >= max(1, n). The opposite side of A is left untouched. lda input Leading dimension of two-dimensional array used to store matrix A. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, n) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: stpttr(), dtpttr(), ctpttr(), ztpttr() 2.8.10. cublas trttp() cublasStatus\_t cublasStrttp ( cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const float \*A, int lda, float \*AP ); cublasStatus\_t cublasDtrttp ( cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const double \*A, int lda, double \*AP ); cublasStatus\_t cublasCtrttp ( cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuComplex \*A, int lda, cuComplex \*AP ); cublasStatus\_t cublasZtrttp ( cublasHandle\_t handle, cublasFillMode\_t uplo, int n, const cuDoubleComplex \*A, int lda, cuDoubleComplex \*AP ); This function performs the conversion from the triangular format to the triangular packed format If uplo == CUBLAS\_FILL\_MODE\_LOWER then the lower triangular part of the triangular matrix A is copied into the array AP. If uplo == CUBLAS\_FILL\_MODE\_UPPER then then the upper triangular part of the triangular matrix A is copied into the array AP. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates which matrix A lower or upper part is referenced. n input Number of rows and columns of matrix A. A device input array of dimensions lda x n, with lda >= max(1, n). lda input Leading dimension of two-dimensional array used to store matrix A. AP device output array with A stored in packed format. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if lda < max(1, n) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: strttp(), dtrttp(), ctrttp(), ztrttp() 2.8.11. cublas gemmEx() cublasStatus\_t cublasSgemmEx(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const float \*alpha, const void \*A, cudaDataType\_t Atype, int lda, const void \*B, cudaDataType\_t Btype, int ldb, const float \*beta, void \*C, cudaDataType\_t Ctype, int ldc) cublasStatus\_t cublasCgemmEx(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const cuComplex \*alpha, const void \*A, cudaDataType\_t Atype, int lda, const void \*B, cudaDataType\_t Btype, int ldb, const cuComplex \*beta, void \*C, cudaDataType\_t Ctype, int ldc) This function supports the 64-bit Integer Interface. This function is an extension of cublas gemm(). In this function the input matrices and output matrices can have a lower precision but the computation is still done in the type . For example, in the type float for cublasSgemmEx() and in the type cuComplex for cublasCgemmEx(). \\(C = \\alpha\\text{op}(A)\\text{op}(B) + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, and \\(A\\), \\(B\\) and \\(C\\) are matrices stored in column-major format with dimensions \\(\\text{op}(A)\\) \\(m \\times k\\), \\(\\text{op}(B)\\) \\(k \\times n\\) and \\(C\\) \\(m \\times n\\), respectively. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) and \\(\\text{op}(B)\\) is defined similarly for matrix \\(B\\). Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. transa input Operation op(A) that is non- or (conj.) transpose. transb input Operation op(B) that is non- or (conj.) transpose. m input Number of rows of matrix op(A) and C. n input Number of columns of matrix op(B) and C. k input Number of columns of op(A) and rows of op(B). alpha host or device input scalar used for multiplication. A device input array of dimensions lda x k with lda >= max(1, m) if transa == CUBLAS\_OP\_N and lda x m with lda >= max(1, k) otherwise. Atype input Enumerant specifying the datatype of matrix A. lda input Leading dimension of two-dimensional array used to store the matrix A. B device input array of dimension ldb x n with ldb >= max(1, k) if transb == CUBLAS\_OP\_N and ldb x k with ldb >= max(1,n) otherwise. Btype input Enumerant specifying the datatype of matrix B. ldb input Leading dimension of two-dimensional array used to store matrix B. beta host or device input scalar used for multiplication. If beta == 0, C does not have to be a valid input. C device in/out array of dimensions ldc x n with ldc >= max(1, m). Ctype input Enumerant specifying the datatype of matrix C. ldc input Leading dimension of a two-dimensional array used to store the matrix C. The matrix types combinations supported for cublasSgemmEx() are listed below: C A/B CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_32F CUDA\_R\_8I CUDA\_R\_16BF CUDA\_R\_16F CUDA\_R\_32F The matrix types combinations supported for cublasCgemmEx() are listed below: C A/B CUDA\_C\_32F CUDA\_C\_8I CUDA\_C\_32F The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_ARCH\_MISMATCH cublasCgemmEx() is only supported for GPU with architecture capabilities equal or greater than 5.0 CUBLAS\_STATUS\_NOT\_SUPPORTED The combination of the parameters Atype, Btype and Ctype is not supported CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0 or k < 0, or if transa and transb are not one of CUBLAS\_OP\_N, CUBLAS\_OP\_C, CUBLAS\_OP\_T, or if lda < max(1, m) when transa == CUBLAS\_OP\_N and lda < max(1, k) otherwise, or if ldb < max(1, k) when transb == CUBLAS\_OP\_N and ldb < max(1, n) otherwise, or if ldc < max(1, m), or if alpha or beta are NULL, or if C is NULL when beta is not zero CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: sgemm() For more information about the numerical behavior of some GEMM algorithms, refer to the GEMM Algorithms Numerical Behavior section. 2.8.12. cublasGemmEx() cublasStatus\_t cublasGemmEx(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const void \*alpha, const void \*A, cudaDataType\_t Atype, int lda, const void \*B, cudaDataType\_t Btype, int ldb, const void \*beta, void \*C, cudaDataType\_t Ctype, int ldc, cublasComputeType\_t computeType, cublasGemmAlgo\_t algo) #if defined(\_\_cplusplus) cublasStatus\_t cublasGemmEx(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const void \*alpha, const void \*A, cudaDataType Atype, int lda, const void \*B, cudaDataType Btype, int ldb, const void \*beta, void \*C, cudaDataType Ctype, int ldc, cudaDataType computeType, cublasGemmAlgo\_t algo) #endif This function supports the 64-bit Integer Interface. This function is an extension of cublas gemm() that allows the user to individually specify the data types for each of the A, B and C matrices, the precision of computation and the GEMM algorithm to be run. Supported combinations of arguments are listed further down in this section. Note The second variant of cublasGemmEx() function is provided for backward compatibility with C++ applications code, where the computeType parameter is of cudaDataType instead of cublasComputeType\_t. C applications would still compile with the updated function signature. This function is only supported on devices with compute capability 5.0 or later. \\(C = \\alpha\\text{op}(A)\\text{op}(B) + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, and \\(A\\), \\(B\\) and \\(C\\) are matrices stored in column-major format with dimensions \\(\\text{op}(A)\\) \\(m \\times k\\), \\(\\text{op}(B)\\) \\(k \\times n\\) and \\(C\\) \\(m \\times n\\), respectively. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) and \\(\\text{op}(B)\\) is defined similarly for matrix \\(B\\). Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. transa input Operation op(A) that is non- or (conj.) transpose. transb input Operation op(B) that is non- or (conj.) transpose. m input Number of rows of matrix op(A) and C. n input Number of columns of matrix op(B) and C. k input Number of columns of op(A) and rows of op(B). alpha host or device input Scaling factor for A\*B of the type that corresponds to the computeType and Ctype, see the table below for details. A device input array of dimensions lda x k with lda >= max(1, m) if transa == CUBLAS\_OP\_N and lda x m with lda >= max(1, k) otherwise. Atype input Enumerant specifying the datatype of matrix A. lda input Leading dimension of two-dimensional array used to store the matrix A. B device input array of dimension ldb x n with ldb >= max(1, k) if transb == CUBLAS\_OP\_N and ldb x k with ldb >= max(1,n) otherwise. Btype input Enumerant specifying the datatype of matrix B. ldb input Leading dimension of two-dimensional array used to store matrix B. beta host or device input Scaling factor for C of the type that corresponds to the computeType and Ctype, see the table below for details. If beta == 0, C does not have to be a valid input. C device in/out array of dimensions ldc x n with ldc >= max(1, m). Ctype input Enumerant specifying the datatype of matrix C. ldc input Leading dimension of a two-dimensional array used to store the matrix C. computeType input Enumerant specifying the computation type. algo input Enumerant specifying the algorithm. See cublasGemmAlgo\_t. cublasGemmEx() supports the following Compute Type, Scale Type, Atype/Btype, and Ctype: Compute Type Scale Type (alpha and beta) Atype/Btype Ctype CUBLAS\_COMPUTE\_16F or CUBLAS\_COMPUTE\_16F\_PEDANTIC CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_16F CUBLAS\_COMPUTE\_32I or CUBLAS\_COMPUTE\_32I\_PEDANTIC CUDA\_R\_32I CUDA\_R\_8I CUDA\_R\_32I CUBLAS\_COMPUTE\_32F or CUBLAS\_COMPUTE\_32F\_PEDANTIC CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_8I CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_32F CUDA\_R\_16F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_C\_32F CUDA\_C\_8I CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F CUBLAS\_COMPUTE\_32F\_FAST\_16F or CUBLAS\_COMPUTE\_32F\_FAST\_16BF or CUBLAS\_COMPUTE\_32F\_FAST\_TF32 or CUBLAS\_COMPUTE\_32F\_EMULATED\_16BFX9 CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F CUBLAS\_COMPUTE\_64F or CUBLAS\_COMPUTE\_64F\_PEDANTIC CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F CUDA\_C\_64F CUDA\_C\_64F CUDA\_C\_64F Note CUBLAS\_COMPUTE\_32I and CUBLAS\_COMPUTE\_32I\_PEDANTIC compute types are only supported with A, B being 4-byte aligned and lda, ldb being multiples of 4. For better performance, it is also recommended that IMMA kernels requirements for a regular data ordering listed here are met. The possible error values returned by this function and their meanings are listed in the following table. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. CUBLAS\_STATUS\_ARCH\_MISMATCH cublasGemmEx() is only supported for GPU with architecture capabilities equal or greater than 5.0. CUBLAS\_STATUS\_NOT\_SUPPORTED The combination of the parameters Atype, Btype and Ctype or the algorithm, algo is not supported. CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0 or k < 0, or if transa and transb are not one of CUBLAS\_OP\_N, CUBLAS\_OP\_C, CUBLAS\_OP\_T, or if lda < max(1, m) when transa == CUBLAS\_OP\_N and lda < max(1, k) otherwise, or if ldb < max(1, k) when transb == CUBLAS\_OP\_N and ldb < max(1, n) otherwise, or if ldc < max(1, m), or if alpha or beta are NULL, or if C is NULL when beta is not zero if Atype or Btype or Ctype or algo are not supported CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU. Starting with release 11.2, using the typed functions instead of the extension functions (cublas\*\*Ex()) helps in reducing the binary size when linking to static cuBLAS Library. Also refer to: sgemm.() For more information about the numerical behavior of some GEMM algorithms, refer to the GEMM Algorithms Numerical Behavior section. 2.8.13. cublasGemmBatchedEx() cublasStatus\_t cublasGemmBatchedEx(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const void \*alpha, const void \*const Aarray\[\], cudaDataType\_t Atype, int lda, const void \*const Barray\[\], cudaDataType\_t Btype, int ldb, const void \*beta, void \*const Carray\[\], cudaDataType\_t Ctype, int ldc, int batchCount, cublasComputeType\_t computeType, cublasGemmAlgo\_t algo) #if defined(\_\_cplusplus) cublasStatus\_t cublasGemmBatchedEx(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const void \*alpha, const void \*const Aarray\[\], cudaDataType Atype, int lda, const void \*const Barray\[\], cudaDataType Btype, int ldb, const void \*beta, void \*const Carray\[\], cudaDataType Ctype, int ldc, int batchCount, cudaDataType computeType, cublasGemmAlgo\_t algo) #endif This function supports the 64-bit Integer Interface. This function is an extension of cublas gemmBatched() that performs the matrix-matrix multiplication of a batch of matrices and allows the user to individually specify the data types for each of the A, B and C matrix arrays, the precision of computation and the GEMM algorithm to be run. Like cublas gemmBatched(), the batch is considered to be “uniform”, i.e. all instances have the same dimensions (m, n, k), leading dimensions (lda, ldb, ldc) and transpositions (transa, transb) for their respective A, B and C matrices. The address of the input matrices and the output matrix of each instance of the batch are read from arrays of pointers passed to the function by the caller. Supported combinations of arguments are listed further down in this section. Note The second variant of cublasGemmBatchedEx() function is provided for backward compatibility with C++ applications code, where the computeType parameter is of cudaDataType instead of cublasComputeType\_t. C applications would still compile with the updated function signature. \\(C\\lbrack i\\rbrack = \\alpha\\text{op}(A\\lbrack i\\rbrack)\\text{op}(B\\lbrack i\\rbrack) + \\beta C\\lbrack i\\rbrack,\\text{ for i } \\in \\lbrack 0,batchCount - 1\\rbrack\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, and \\(A\\), \\(B\\) and \\(C\\) are arrays of pointers to matrices stored in column-major format with dimensions \\(\\text{op}(A\\lbrack i\\rbrack)\\) \\(m \\times k\\), \\(\\text{op}(B\\lbrack i\\rbrack)\\) \\(k \\times n\\) and \\(C\\lbrack i\\rbrack\\) \\(m \\times n\\), respectively. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) and \\(\\text{op}(B\\lbrack i\\rbrack)\\) is defined similarly for matrix \\(B\\lbrack i\\rbrack\\). Note \\(C\\lbrack i\\rbrack\\) matrices must not overlap, i.e. the individual gemm operations must be computable independently; otherwise, behavior is undefined. On certain problem sizes, it might be advantageous to make multiple calls to cublas gemm() in different CUDA streams, rather than use this API. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. transa input Operation op(Aarray\[i\]) that is non- or (conj.) transpose. transb input Operation op(Barray\[i\]) that is non- or (conj.) transpose. m input Number of rows of matrix op(Aarray\[i\]) and Carray\[i\]. n input Number of columns of matrix op(Barray\[i\]) and Carray\[i\]. k input Number of columns of op(Aarray\[i\]) and rows of op(Barray\[i\]). alpha host or device input Scaling factor for matrix products of the type that corresponds to the computeType and Ctype, see the table below for details. Aarray device input Array of pointers to array, with each array of dim. lda x k with lda >= max(1, m) if transa == CUBLAS\_OP\_N and lda x m with lda >= max(1, k) otherwise. All pointers must meet certain alignment criteria. Please see below for details. Atype input Enumerant specifying the datatype of Aarray. lda input Leading dimension of two-dimensional array used to store the matrix Aarray\[i\]. Barray device input Array of pointers to array, with each array of dim. ldb x n with ldb >= max(1, k) if transb == CUBLAS\_OP\_N and ldb x k with ldb >= max(1,n) otherwise. All pointers must meet certain alignment criteria. Please see below for details. Btype input Enumerant specifying the datatype of Barray. ldb input Leading dimension of two-dimensional array used to store matrix Barray\[i\]. beta host or device input Scaling factor for Carray of the type that corresponds to the computeType and Ctype, see the table below for details. If beta == 0, Carray\[i\] does not have to be a valid input. Carray device in/out Array of pointers to array. It has dimensions ldc x n with ldc >= max(1, m). Matrices Carray\[i\] should not overlap; otherwise, the behavior is undefined. All pointers must meet certain alignment criteria. Please see below for details. Ctype input Enumerant specifying the datatype of Carray. ldc input Leading dimension of a two-dimensional array used to store each matrix Carray\[i\]. batchCount input Number of pointers contained in Aarray, Barray and Carray. computeType input Enumerant specifying the computation type. algo input Enumerant specifying the algorithm. See cublasGemmAlgo\_t. cublasGemmBatchedEx() supports the following Compute Type, Scale Type, Atype/Btype, and Ctype: Compute Type Scale Type (alpha and beta) Atype/Btype Ctype CUBLAS\_COMPUTE\_16F or CUBLAS\_COMPUTE\_16F\_PEDANTIC CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_16F CUBLAS\_COMPUTE\_32I or CUBLAS\_COMPUTE\_32I\_PEDANTIC CUDA\_R\_32I CUDA\_R\_8I CUDA\_R\_32I CUBLAS\_COMPUTE\_32F or CUBLAS\_COMPUTE\_32F\_PEDANTIC CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_8I CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_32F CUDA\_R\_16F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_C\_32F CUDA\_C\_8I CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F CUBLAS\_COMPUTE\_32F\_FAST\_16F or CUBLAS\_COMPUTE\_32F\_FAST\_16BF or CUBLAS\_COMPUTE\_32F\_FAST\_TF32 or CUBLAS\_COMPUTE\_32F\_EMULATED\_16BFX9 CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F CUBLAS\_COMPUTE\_64F or CUBLAS\_COMPUTE\_64F\_PEDANTIC CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F CUDA\_C\_64F CUDA\_C\_64F CUDA\_C\_64F If Atype is CUDA\_R\_16F or CUDA\_R\_16BF, or computeType is any of the FAST options, or when math mode or algo enable fast math modes, pointers (not the pointer arrays) placed in the GPU memory must be properly aligned to avoid misaligned memory access errors. Ideally all pointers are aligned to at least 16 Bytes. Otherwise it is recommended that they meet the following rule: if k % 8 == 0 then ensure intptr\_t(ptr) % 16 == 0, if k % 2 == 0 then ensure intptr\_t(ptr) % 4 == 0. Note Compute types CUBLAS\_COMPUTE\_32I and CUBLAS\_COMPUTE\_32I\_PEDANTIC are only supported with all pointers A\[i\], B\[i\] being 4-byte aligned and lda, ldb being multiples of 4. For a better performance, it is also recommended that IMMA kernels requirements for the regular data ordering listed here are met. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. CUBLAS\_STATUS\_ARCH\_MISMATCH cublasGemmBatchedEx() is only supported for GPU with architecture capabilities equal to or greater than 5.0. CUBLAS\_STATUS\_NOT\_SUPPORTED The combination of the parameters Atype, Btype and Ctype or the algorithm, algo is not supported. CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0 or k < 0, or if transa and transb are not one of CUBLAS\_OP\_N, CUBLAS\_OP\_C, CUBLAS\_OP\_T, or if lda < max(1, m) when transa == CUBLAS\_OP\_N and lda < max(1, k) otherwise, or if ldb < max(1, k) when transb == CUBLAS\_OP\_N and ldb < max(1, n) otherwise, or if ldc < max(1, m), or if alpha or beta are NULL, or if Atype or Btype or Ctype or algo or computeType is not supported CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU. Also refer to: sgemm.() 2.8.14. cublasGemmStridedBatchedEx() cublasStatus\_t cublasGemmStridedBatchedEx(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const void \*alpha, const void \*A, cudaDataType\_t Atype, int lda, long long int strideA, const void \*B, cudaDataType\_t Btype, int ldb, long long int strideB, const void \*beta, void \*C, cudaDataType\_t Ctype, int ldc, long long int strideC, int batchCount, cublasComputeType\_t computeType, cublasGemmAlgo\_t algo) #if defined(\_\_cplusplus) cublasStatus\_t cublasGemmStridedBatchedEx(cublasHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const void \*alpha, const void \*A, cudaDataType Atype, int lda, long long int strideA, const void \*B, cudaDataType Btype, int ldb, long long int strideB, const void \*beta, void \*C, cudaDataType Ctype, int ldc, long long int strideC, int batchCount, cudaDataType computeType, cublasGemmAlgo\_t algo) #endif This function supports the 64-bit Integer Interface. This function is an extension of cublas gemmStridedBatched() that performs the matrix-matrix multiplication of a batch of matrices and allows the user to individually specify the data types for each of the A, B and C matrices, the precision of computation and the GEMM algorithm to be run. Like cublas gemmStridedBatched(), the batch is considered to be “uniform”, i.e. all instances have the same dimensions (m, n, k), leading dimensions (lda, ldb, ldc) and transpositions (transa, transb) for their respective A, B and C matrices. Input matrices A, B and output matrix C for each instance of the batch are located at fixed offsets in number of elements from their locations in the previous instance. Pointers to A, B and C matrices for the first instance are passed to the function by the user along with the offsets in number of elements - strideA, strideB and strideC that determine the locations of input and output matrices in future instances. Note The second variant of cublasGemmStridedBatchedEx() function is provided for backward compatibility with C++ applications code, where the computeType parameter is of cudaDataType\_t instead of cublasComputeType\_t. C applications would still compile with the updated function signature. \\(C + i\*{strideC} = \\alpha\\text{op}(A + i\*{strideA})\\text{op}(B + i\*{strideB}) + \\beta(C + i\*{strideC}),\\text{ for i } \\in \\lbrack 0,batchCount - 1\\rbrack\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, and \\(A\\), \\(B\\) and \\(C\\) are arrays of pointers to matrices stored in column-major format with dimensions \\(\\text{op}(A\\lbrack i\\rbrack)\\) \\(m \\times k\\), \\(\\text{op}(B\\lbrack i\\rbrack)\\) \\(k \\times n\\) and \\(C\\lbrack i\\rbrack\\) \\(m \\times n\\), respectively. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) and \\(\\text{op}(B\\lbrack i\\rbrack)\\) is defined similarly for matrix \\(B\\lbrack i\\rbrack\\). Note \\(C\\lbrack i\\rbrack\\) matrices must not overlap, i.e. the individual gemm operations must be computable independently; otherwise, the behavior is undefined. On certain problem sizes, it might be advantageous to make multiple calls to cublas gemm() in different CUDA streams, rather than use this API. Note In the table below, we use A\[i\], B\[i\], C\[i\] as notation for A, B and C matrices in the ith instance of the batch, implicitly assuming they are respectively offsets in number of elements strideA, strideB, strideC away from A\[i-1\], B\[i-1\], C\[i-1\]. The unit for the offset is number of elements and must not be zero. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. transa input Operation op(A\[i\]) that is non- or (conj.) transpose. transb input Operation op(B\[i\]) that is non- or (conj.) transpose. m input Number of rows of matrix op(A\[i\]) and C\[i\]. n input Number of columns of matrix op(B\[i\]) and C\[i\]. k input Number of columns of op(A\[i\]) and rows of op(B\[i\]). alpha host or device input Scaling factor for A\*B of the that corresponds to the computeType and Ctype, see the table below for details. A device input Pointer to matrix, A, corresponds to the first instance of the batch, with dimensions lda x k with lda >= max(1, m) if transa == CUBLAS\_OP\_N and lda x m with lda >= max(1, k) otherwise. Atype input Enumerant specifying the datatype of A. lda input Leading dimension of two-dimensional array used to store the matrix A\[i\]. strideA input Value of type long long int that gives the offset in number of elements between A\[i\] and A\[i+1\]. B device input Pointer to matrix, B, corresponds to the first instance of the batch, with dimensions ldb x n with ldb >= max(1, k) if transb == CUBLAS\_OP\_N and ldb x k with ldb >= max(1,n) otherwise. Btype input Enumerant specifying the datatype of B. ldb input Leading dimension of two-dimensional array used to store matrix B\[i\]. strideB input Value of type long long int that gives the offset in number of elements between B\[i\] and B\[i+1\]. beta host or device input Scaling factor for C of the that corresponds to the computeType and Ctype, see the table below for details. If beta == 0, C\[i\] does not have to be a valid input. C device in/out Pointer to matrix, C, corresponds to the first instance of the batch, with dimensions ldc x n with ldc >= max(1, m). Matrices C\[i\] should not overlap; otherwise, undefined behavior is expected. Ctype input Enumerant specifying the datatype of C. ldc input Leading dimension of a two-dimensional array used to store each matrix C\[i\]. strideC input Value of type long long int that gives the offset in number of elements between C\[i\] and C\[i+1\]. batchCount input Number of GEMMs to perform in the batch. computeType input Enumerant specifying the computation type. algo input Enumerant specifying the algorithm. See cublasGemmAlgo\_t. cublasGemmStridedBatchedEx() supports the following Compute Type, Scale Type, Atype/Btype, and Ctype: Compute Type Scale Type (alpha and beta) Atype/Btype Ctype CUBLAS\_COMPUTE\_16F or CUBLAS\_COMPUTE\_16F\_PEDANTIC CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_16F CUBLAS\_COMPUTE\_32I or CUBLAS\_COMPUTE\_32I\_PEDANTIC CUDA\_R\_32I CUDA\_R\_8I CUDA\_R\_32I CUBLAS\_COMPUTE\_32F or CUBLAS\_COMPUTE\_32F\_PEDANTIC CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_8I CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_32F CUDA\_R\_16F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_C\_32F CUDA\_C\_8I CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F CUBLAS\_COMPUTE\_32F\_FAST\_16F or CUBLAS\_COMPUTE\_32F\_FAST\_16BF or CUBLAS\_COMPUTE\_32F\_FAST\_TF32 or CUBLAS\_COMPUTE\_32F\_EMULATED\_16BFX9 CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F CUBLAS\_COMPUTE\_64F or CUBLAS\_COMPUTE\_64F\_PEDANTIC CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F CUDA\_C\_64F CUDA\_C\_64F CUDA\_C\_64F Note Compute types CUBLAS\_COMPUTE\_32I and CUBLAS\_COMPUTE\_32I\_PEDANTIC are only supported with all pointers A\[i\], B\[i\] being 4-byte aligned and lda, ldb being multiples of 4. For a better performance, it is also recommended that IMMA kernels requirements for the regular data ordering listed here are met. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. CUBLAS\_STATUS\_ARCH\_MISMATCH cublasGemmBatchedEx() is only supported for GPU with architecture capabilities equal or greater than 5.0. CUBLAS\_STATUS\_NOT\_SUPPORTED The combination of the parameters Atype, Btype and Ctype or the algorithm, algo is not supported. CUBLAS\_STATUS\_INVALID\_VALUE If m < 0 or n < 0 or k < 0, or if transa and transb are not one of CUBLAS\_OP\_N, CUBLAS\_OP\_C, CUBLAS\_OP\_T, or if lda < max(1, m) when transa == CUBLAS\_OP\_N and lda < max(1, k) otherwise, or if ldb < max(1, k) when transb == CUBLAS\_OP\_N and ldb < max(1, n) otherwise, or if ldc < max(1, m), or if alpha or beta are NULL, or if Atype or Btype or Ctype or algo or computeType is not supported CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU Also refer to: sgemm.() 2.8.15. cublasGemmGroupedBatchedEx() cublasStatus\_t cublasGemmGroupedBatchedEx(cublasHandle\_t handle, const cublasOperation\_t transa\_array\[\], const cublasOperation\_t transb\_array\[\], const int m\_array\[\], const int n\_array\[\], const int k\_array\[\], const void \*alpha\_array, const void \*const Aarray\[\], cudaDataType\_t Atype, const int lda\_array\[\], const void \*const Barray\[\], cudaDataType\_t Btype, const int ldb\_array\[\], const void \*beta\_array, void \*const Carray\[\], cudaDataType\_t Ctype, const int ldc\_array\[\], int group\_count, const int group\_size\[\], cublasComputeType\_t computeType) This function supports the 64-bit Integer Interface. This function performs the matrix-matrix multiplication on groups of matrices. A given group is considered to be “uniform”, i.e. all instances have the same dimensions (m, n, k), leading dimensions (lda, ldb, ldc) and transpositions (transa, transb) for their respective A, B and C matrices. However, the dimensions, leading dimensions, transpositions, and scaling factors (alpha, beta) may vary between groups. The address of the input matrices and the output matrix of each instance of the batch are read from arrays of pointers passed to the function by the caller. This is functionally equivalent to the following: idx = 0; for i = 0:group\_count - 1 for j = 0:group\_size\[i\] - 1 gemmEx(transa\_array\[i\], transb\_array\[i\], m\_array\[i\], n\_array\[i\], k\_array\[i\], alpha\_array\[i\], Aarray\[idx\], Atype, lda\_array\[i\], Barray\[idx\], Btype, ldb\_array\[i\], beta\_array\[i\], Carray\[idx\], Ctype, ldc\_array\[i\], computeType, CUBLAS\_GEMM\_DEFAULT); idx += 1; end end where \\(\\text{$\\mathrm{alpha\\\_array}$}\\) and \\(\\text{$\\mathrm{beta\\\_array}$}\\) are arrays of scaling factors, and \\(\\text{Aarray}\\), \\(\\text{Barray}\\) and \\(\\text{Carray}\\) are arrays of pointers to matrices stored in column-major format. For a given index, \\(\\text{idx}\\), that is part of group \\(i\\), the dimensions are: \\(\\text{op}(\\text{Aarray}\\lbrack\\text{idx}\\rbrack)\\): \\(\\text{$\\mathrm{m\\\_array}$}\\lbrack i\\rbrack \\times \\text{$\\mathrm{k\\\_array}$}\\lbrack i\\rbrack\\) \\(\\text{op}(\\text{Barray}\\lbrack\\text{idx}\\rbrack)\\): \\(\\text{$\\mathrm{k\\\_array}$}\\lbrack i\\rbrack \\times \\text{$\\mathrm{n\\\_array}$}\\lbrack i\\rbrack\\) \\(\\text{Carray}\\lbrack\\text{idx}\\rbrack\\): \\(\\text{$\\mathrm{m\\\_array}$}\\lbrack i\\rbrack \\times \\text{$\\mathrm{n\\\_array}$}\\lbrack i\\rbrack\\) Note This API takes arrays of two different lengths. The arrays of dimensions, leading dimensions, transpositions, and scaling factors are of length group\_count and the arrays of matrices are of length problem\_count where \\(\\text{$\\mathrm{problem\\\_count}$} = \\sum\_{i = 0}^{\\text{$\\mathrm{group\\\_count}$} - 1} \\text{$\\mathrm{group\\\_size}$}\\lbrack i\\rbrack\\) For matrix \\(A\[\\text{idx}\]\\) in group \\(i\\) \\(\\text{op}(A\[\\text{idx}\]) = \\left\\{ \\begin{matrix} A\[\\text{idx}\] & {\\text{if }\\textsf{$\\mathrm{transa\\\_array}\\lbrack i\\rbrack$ == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A\[\\text{idx}\]^{T} & {\\text{if }\\textsf{$\\mathrm{transa\\\_array}\\lbrack i\\rbrack$ == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A\[\\text{idx}\]^{H} & {\\text{if }\\textsf{$\\mathrm{transa\\\_array}\\lbrack i\\rbrack$ == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) and \\(\\text{op}(B\[\\text{idx}\])\\) is defined similarly for matrix \\(B\[\\text{idx}\]\\) in group \\(i\\). Note \\(C\\lbrack\\text{idx}\\rbrack\\) matrices must not overlap, that is, the individual gemm operations must be computable independently; otherwise, undefined behavior is expected. On certain problem sizes, it might be advantageous to make multiple calls to cublasGemmBatchedEx() in different CUDA streams, rather than use this API. Param. Memory In/out Meaning Array Length handle input Handle to the cuBLAS library context. transa\_array host input Array containing the operations, op(A\[idx\]), that is non- or (conj.) transpose for each group. group\_count transb\_array host input Array containing the operations, op(B\[idx\]), that is non- or (conj.) transpose for each group. group\_count m\_array host input Array containing the number of rows of matrix op(A\[idx\]) and C\[idx\] for each group. group\_count n\_array host input Array containing the number of columns of op(B\[idx\]) and C\[idx\] for each group. group\_count k\_array host input Array containing the number of columns of op(A\[idx\]) and rows of op(B\[idx\]) for each group. group\_count alpha\_array host input Array containing the scalar used for multiplication for each group. group\_count Aarray device input Array of pointers to array, with each array of dim. lda\[i\] x k\[i\] with lda\[i\] >= max(1,m\[i\]) if transa\[i\] == CUBLAS\_OP\_N and lda\[i\] x m\[i\] with lda\[i\] >= max(1,k\[i\]) otherwise. All pointers must meet certain alignment criteria. Please see below for details. problem\_count Atype input Enumerant specifying the datatype of A. lda\_array host input Array containing the leading dimensions of two-dimensional arrays used to store each matrix A\[idx\] for each group. group\_count Barray device input Array of pointers to array, with each array of dim. ldb\[i\] x n\[i\] with ldb\[i\] >= max(1,k\[i\]) if transb\[i\] == CUBLAS\_OP\_N and ldb\[i\] x k\[i\] with ldb\[i\] >= max(1,n\[i\]) otherwise. All pointers must meet certain alignment criteria. Please see below for details. problem\_count Btype input Enumerant specifying the datatype of B. ldb\_array host input Array containing the leading dimensions of two-dimensional arrays used to store each matrix B\[idx\] for each group. group\_count beta\_array host input Array containing the scalar used for multiplication for each group. group\_count Carray device in/out Array of pointers to array. It has dimensions ldc\[i\] x n\[i\] with ldc\[i\] >= max(1,m\[i\]). Matrices C\[idx\] should not overlap; otherwise, undefined behavior is expected. All pointers must meet certain alignment criteria. Please see below for details. problem\_count Ctype input Enumerant specifying the datatype of C. ldc\_array host input Array containing the leading dimensions of two-dimensional arrays used to store each matrix C\[idx\] for each group. group\_count group\_count host input Number of groups group\_size host input Array containing the number of pointers contained in Aarray, Barray and Carray for each group. group\_count computeType input Enumerant specifying the computation type. cublasGemmGroupedBatchedEx() supports the following Compute Type, Scale Type, Atype/Btype, and Ctype: Compute Type Scale Type (alpha and beta) Atype/Btype Ctype CUBLAS\_COMPUTE\_32F CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_32F CUDA\_R\_32F CUBLAS\_COMPUTE\_32F\_PEDANTIC CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUBLAS\_COMPUTE\_32F\_FAST\_TF32 CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUBLAS\_COMPUTE\_64F or CUBLAS\_COMPUTE\_64F\_PEDANTIC CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F If Atype is CUDA\_R\_16F or CUDA\_R\_16BF or if the computeType is any of the FAST options, pointers (not the pointer arrays) placed in the GPU memory must be properly aligned to avoid misaligned memory access errors. Ideally all pointers are aligned to at least 16 Bytes. Otherwise it is required that they meet the following rule: if (k \* AtypeSize) % 16 == 0 then ensure intptr\_t(ptr) % 16 == 0, if (k \* AtypeSize) % 4 == 0 then ensure intptr\_t(ptr) % 4 == 0. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE If transa\_array, transb\_array, m\_array, n\_array, k\_array, alpha\_array, lda\_array, ldb\_array, beta\_array, ldc\_array, or group\_size are NULL, or if group\_count < 0, or if m\_array\[i\] < 0, n\_array\[i\] < 0, k\_array\[i\] < 0, group\_size\[i\] < 0, or if transa\_array\[i\] and transb\_array\[i\] are not one of CUBLAS\_OP\_N, CUBLAS\_OP\_C, CUBLAS\_OP\_T, or if lda\_array\[i\] < max(1, m\_array\[i\]) if transa\_array\[i\] == CUBLAS\_OP\_N and lda\_array\[i\] < max(1, k\_array\[i\]) otherwise, or if ldb\_array\[i\] < max(1, k\_array\[i\]) if transb\_array\[i\] == CUBLAS\_OP\_N and ldb\_array\[i\] < max(1, n\_array\[i\]) otherwise, or if ldc\_array\[i\] < max(1, m\_array\[i\]) CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU CUBLAS\_STATUS\_NOT\_SUPPORTED the pointer mode is set to CUBLAS\_POINTER\_MODE\_DEVICE Atype or Btype or Ctype or computeType are not supported 2.8.16. cublasCsyrkEx() cublasStatus\_t cublasCsyrkEx(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuComplex \*alpha, const void \*A, cudaDataType Atype, int lda, const cuComplex \*beta, cuComplex \*C, cudaDataType Ctype, int ldc) This function supports the 64-bit Integer Interface. This function is an extension of cublasCsyrk() where the input matrix and output matrix can have a lower precision but the computation is still done in the type cuComplex This function performs the symmetric rank- \\(k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(A)^{T} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a symmetric matrix stored in lower or upper mode, and \\(A\\) is a matrix with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\). Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ \\end{matrix} \\right.\\) Note This routine is only supported on GPUs with architecture capabilities equal to or greater than 5.0 Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix C lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or transpose. n input Number of rows of matrix op(A) and C. k input Number of columns of matrix op(A). alpha host or device input scalar used for multiplication. A device input array of dimension lda x k with lda >= max(1, n) if trans == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. Atype input Enumerant specifying the datatype of matrix A. lda input Leading dimension of two-dimensional array used to store matrix A. beta host or device input scalar used for multiplication. If beta == 0 then C does not have to be a valid input. C device in/out array of dimension ldc x n, with ldc >= max(1, n). Ctype input Enumerant specifying the datatype of matrix C. ldc input Leading dimension of two-dimensional array used to store matrix C. The matrix types combinations supported for cublasCsyrkEx() are listed below: A C CUDA\_C\_8I CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if lda < max(1, n) if trans == CUBLAS\_OP\_N and lda < max(1, k) otherwise, or if ldc < max(1, n), or if Atype or Ctype are not supported CUBLAS\_STATUS\_NOT\_SUPPORTED The combination of the parameters Atype and Ctype is not supported. CUBLAS\_STATUS\_ARCH\_MISMATCH The device has a compute capability lower than 5.0. CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU. For references please refer to NETLIB documentation: ssyrk(), dsyrk(), csyrk(), zsyrk() 2.8.17. cublasCsyrk3mEx() cublasStatus\_t cublasCsyrk3mEx(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuComplex \*alpha, const void \*A, cudaDataType Atype, int lda, const cuComplex \*beta, cuComplex \*C, cudaDataType Ctype, int ldc) This function supports the 64-bit Integer Interface. This function is an extension of cublasCsyrk() where the input matrix and output matrix can have a lower precision but the computation is still done in the type cuComplex. This routine is implemented using the Gauss complexity reduction algorithm which can lead to an increase in performance up to 25% This function performs the symmetric rank- \\(k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(A)^{T} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a symmetric matrix stored in lower or upper mode, and \\(A\\) is a matrix with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\). Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ \\end{matrix} \\right.\\) Note This routine is only supported on GPUs with architecture capabilities equal to or greater than 5.0 Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix C lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. trans input Operation op(A) that is non- or transpose. n input Number of rows of matrix op(A) and C. k input Number of columns of matrix op(A). alpha host or device input scalar used for multiplication. A device input array of dimension lda x k with lda >= max(1, n) if trans == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. Atype input Enumerant specifying the datatype of matrix A. lda input Leading dimension of two-dimensional array used to store matrix A. beta host or device input scalar used for multiplication. If beta == 0 then C does not have to be a valid input. C device in/out array of dimension ldc x n, with ldc >= max(1, n). Ctype input Enumerant specifying the datatype of matrix C. ldc input Leading dimension of two-dimensional array used to store matrix C. The matrix types combinations supported for cublasCsyrk3mEx() are listed below: A C CUDA\_C\_8I CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if lda < max(1, n) if trans == CUBLAS\_OP\_N and lda < max(1, k) otherwise, or if ldc < max(1, n), or if Atype or Ctype are not supported CUBLAS\_STATUS\_NOT\_SUPPORTED The combination of the parameters Atype and Ctype is not supported. CUBLAS\_STATUS\_ARCH\_MISMATCH The device has a compute capability lower than 5.0. CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU. For references please refer to NETLIB documentation: ssyrk(), dsyrk(), csyrk(), zsyrk() 2.8.18. cublasCherkEx() cublasStatus\_t cublasCherkEx(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const float \*alpha, const void \*A, cudaDataType Atype, int lda, const float \*beta, cuComplex \*C, cudaDataType Ctype, int ldc) This function supports the 64-bit Integer Interface. This function is an extension of cublasCherk() where the input matrix and output matrix can have a lower precision but the computation is still done in the type cuComplex This function performs the Hermitian rank- \\(k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(A)^{H} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a Hermitian matrix stored in lower or upper mode, and \\(A\\) is a matrix with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\). Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) Note This routine is only supported on GPUs with architecture capabilities equal to or greater than 5.0 Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix C lower or upper part is stored, the other Hermitian part is not referenced. trans input Operation op(A) that is non- or (conj.) transpose. n input Number of rows of matrix op(A) and C. k input Number of columns of matrix op(A). alpha host or device input scalar used for multiplication. A device input array of dimension lda x k with lda >= max(1, n) if transa == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. Atype input Enumerant specifying the datatype of matrix A. lda input Leading dimension of two-dimensional array used to store matrix A. beta input scalar used for multiplication. If beta == 0 then C does not have to be a valid input. C device in/out array of dimension ldc x n, with ldc >= max(1, n). The imaginary parts of the diagonal elements are assumed and set to zero. Ctype input Enumerant specifying the datatype of matrix C. ldc input Leading dimension of two-dimensional array used to store matrix C. The matrix types combinations supported for cublasCherkEx() are listed in the following table: A C CUDA\_C\_8I CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if lda < max(1, n) if trans == CUBLAS\_OP\_N and lda < max(1, k) otherwise, or if ldc < max(1, n), or if Atype or Ctype are not supported CUBLAS\_STATUS\_NOT\_SUPPORTED The combination of the parameters Atype and Ctype is not supported. CUBLAS\_STATUS\_ARCH\_MISMATCH The device has a compute capability lower than 5.0. CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU. For references please refer to NETLIB documentation: cherk() 2.8.19. cublasCherk3mEx() cublasStatus\_t cublasCherk3mEx(cublasHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const float \*alpha, const void \*A, cudaDataType Atype, int lda, const float \*beta, cuComplex \*C, cudaDataType Ctype, int ldc) This function supports the 64-bit Integer Interface. This function is an extension of cublasCherk() where the input matrix and output matrix can have a lower precision but the computation is still done in the type cuComplex. This routine is implemented using the Gauss complexity reduction algorithm which can lead to an increase in performance up to 25% This function performs the Hermitian rank- \\(k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(A)^{H} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a Hermitian matrix stored in lower or upper mode, and \\(A\\) is a matrix with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\). Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) Note This routine is only supported on GPUs with architecture capabilities equal to or greater than 5.0 Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. uplo input Indicates if matrix C lower or upper part is stored, the other Hermitian part is not referenced. trans input Operation op(A) that is non- or (conj.) transpose. n input Number of rows of matrix op(A) and C. k input Number of columns of matrix op(A). alpha host or device input scalar used for multiplication. A device input array of dimension lda x k with lda >= max(1, n) if trans == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. Atype input Enumerant specifying the datatype of matrix A. lda input Leading dimension of two-dimensional array used to store matrix A. beta input scalar used for multiplication. If beta == 0 then C does not have to be a valid input. C device in/out array of dimension ldc x n, with ldc >= max(1, n). The imaginary parts of the diagonal elements are assumed and set to zero. Ctype input Enumerant specifying the datatype of matrix C. ldc input Leading dimension of two-dimensional array used to store matrix C. The matrix types combinations supported for cublasCherk3mEx() are listed in the following table: A C CUDA\_C\_8I CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. CUBLAS\_STATUS\_INVALID\_VALUE If n < 0 or k < 0, or if uplo is not one of CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, or if trans is not one of CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, or if lda < max(1, n) if trans == CUBLAS\_OP\_N and lda < max(1, k) otherwise, or if ldc < max(1, n), or if Atype or Ctype are not supported CUBLAS\_STATUS\_NOT\_SUPPORTED The combination of the parameters Atype and Ctype is not supported. CUBLAS\_STATUS\_ARCH\_MISMATCH The device has a compute capability lower than 5.0. CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU. For references please refer to NETLIB documentation: cherk() 2.8.20. cublasNrm2Ex() cublasStatus\_t cublasNrm2Ex( cublasHandle\_t handle, int n, const void \*x, cudaDataType xType, int incx, void \*result, cudaDataType resultType, cudaDataType executionType) This function supports the 64-bit Integer Interface. This function is an API generalization of the routine cublas nrm2() where input data, output data and compute type can be specified independently. This function computes the Euclidean norm of the vector x. The code uses a multiphase model of accumulation to avoid intermediate underflow and overflow, with the result being equivalent to \\(\\sqrt{\\sum\_{i = 1}^{n}\\left( {\\mathbf{x}\\lbrack j\\rbrack \\times \\mathbf{x}\\lbrack j\\rbrack} \\right)}\\) where \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\) in exact arithmetic. Notice that the last equation reflects 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vector x. x device input vector with n elements. xType input Enumerant specifying the datatype of vector x. incx input Stride between consecutive elements of x. result host or device output The resulting norm, which is set to 0 if n <= 0 or incx <= 0. resultType input Enumerant specifying the datatype of the result. executionType input Enumerant specifying the datatype in which the computation is executed. The datatypes combinations currently supported for cublasNrm2Ex() are listed below: x result execution CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_C\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F CUDA\_C\_64F CUDA\_R\_64F CUDA\_R\_64F The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_ALLOC\_FAILED The reduction buffer could not be allocated CUBLAS\_STATUS\_NOT\_SUPPORTED The combination of the parameters xType, resultType and executionType is not supported CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU CUBLAS\_STATUS\_INVALID\_VALUE If xType or resultType or executionType is not supported, or if result is NULL For references please refer to NETLIB documentation: snrm2(), dnrm2(), scnrm2(), dznrm2() 2.8.21. cublasAxpyEx() cublasStatus\_t cublasAxpyEx (cublasHandle\_t handle, int n, const void \*alpha, cudaDataType alphaType, const void \*x, cudaDataType xType, int incx, void \*y, cudaDataType yType, int incy, cudaDataType executiontype); This function supports the 64-bit Integer Interface. This function is an API generalization of the routine cublas axpy() where input data, output data and compute type can be specified independently. This function multiplies the vector x by the scalar \\(\\alpha\\) and adds it to the vector y overwriting the latest vector with the result. Hence, the performed operation is \\(\\mathbf{y}\\lbrack j\\rbrack = \\alpha \\times \\mathbf{x}\\lbrack k\\rbrack + \\mathbf{y}\\lbrack j\\rbrack\\) for \\(i = 1,\\ldots,n\\), \\(k = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incy}\\). Notice that the last two equations reflect 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vector x and y. alpha host or device input scalar used for multiplication. alphaType input Enumerant specifying the datatype of scalar alpha. x device input vector with n elements. xType input Enumerant specifying the datatype of vector x. incx input Stride between consecutive elements of x. y device in/out vector with n elements. yType input Enumerant specifying the datatype of vector y. incy input Stride between consecutive elements of y. executionType input Enumerant specifying the datatype in which the computation is executed. The datatypes combinations currently supported for cublasAxpyEx() are listed in the following table: alpha x y execution CUDA\_R\_32F CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_64F CUDA\_C\_64F CUDA\_C\_64F CUDA\_C\_64F The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. CUBLAS\_STATUS\_NOT\_SUPPORTED The combination of the parameters xType, yType, and executionType is not supported. CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU. CUBLAS\_STATUS\_INVALID\_VALUE alphaType or xType or yType or executionType is not supported. For references please refer to NETLIB documentation: saxpy(), daxpy(), caxpy(), zaxpy() 2.8.22. cublasDotEx() cublasStatus\_t cublasDotEx (cublasHandle\_t handle, int n, const void \*x, cudaDataType xType, int incx, const void \*y, cudaDataType yType, int incy, void \*result, cudaDataType resultType, cudaDataType executionType); cublasStatus\_t cublasDotcEx (cublasHandle\_t handle, int n, const void \*x, cudaDataType xType, int incx, const void \*y, cudaDataType yType, int incy, void \*result, cudaDataType resultType, cudaDataType executionType); These functions support the 64-bit Integer Interface. These functions are an API generalization of the routines cublas dot() and cublas dotc() where input data, output data and compute type can be specified independently. Note: cublas dotc() is dot product conjugated, cublas dotu() is dot product unconjugated. This function computes the dot product of vectors x and y. Hence, the result is \\(\\sum\_{i = 1}^{n}\\left( {\\mathbf{x}\\lbrack k\\rbrack \\times \\mathbf{y}\\lbrack j\\rbrack} \\right)\\) where \\(k = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incy}\\). Notice that in the first equation the conjugate of the element of vector x should be used if the function name ends in character ‘c’ and that the last two equations reflect 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vectors x and y. x device input vector with n elements. xType input Enumerant specifying the datatype of vector x. incx input Stride between consecutive elements of x. y device input vector with n elements. yType input Enumerant specifying the datatype of vector y. incy input Stride between consecutive elements of y. result host or device output The resulting dot product, which is set to 0 if n <= 0 resultType input Enumerant specifying the datatype of the result. executionType input Enumerant specifying the datatype in which the computation is executed. The datatypes combinations currently supported for cublasDotEx() and cublasDotcEx() are listed below: x y result execution CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_64F CUDA\_C\_64F CUDA\_C\_64F CUDA\_C\_64F The possible error values returned by this function and their meanings are listed in the following table: Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully. CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized. CUBLAS\_STATUS\_ALLOC\_FAILED The reduction buffer could not be allocated. CUBLAS\_STATUS\_NOT\_SUPPORTED The combination of the parameters xType, yType, resultType and executionType is not supported. CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU. CUBLAS\_STATUS\_INVALID\_VALUE xType or yType or resultType or executionType is not supported. For references please refer to NETLIB documentation: sdot(), ddot(), cdotu(), cdotc(), zdotu(), zdotc() 2.8.23. cublasRotEx() cublasStatus\_t cublasRotEx(cublasHandle\_t handle, int n, void \*x, cudaDataType xType, int incx, void \*y, cudaDataType yType, int incy, const void \*c, /\* host or device pointer \*/ const void \*s, cudaDataType csType, cudaDataType executiontype); This function supports the 64-bit Integer Interface. This function is an extension to the routine cublas rot() where input data, output data, cosine/sine type, and compute type can be specified independently. This function applies Givens rotation matrix (i.e., rotation in the x,y plane counter-clockwise by angle defined by \\(cos(alpha) = c\\), \\(sin(alpha) = s\\)): \\(G = \\begin{pmatrix} c & s \\\\ {- s} & c \\\\ \\end{pmatrix}\\) to vectors x and y. Hence, the result is \\(\\mathbf{x}\\lbrack k\\rbrack = c \\times \\mathbf{x}\\lbrack k\\rbrack + s \\times \\mathbf{y}\\lbrack j\\rbrack\\) and \\(\\mathbf{y}\\lbrack j\\rbrack = - s \\times \\mathbf{x}\\lbrack k\\rbrack + c \\times \\mathbf{y}\\lbrack j\\rbrack\\) where \\(k = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incy}\\). Notice that the last two equations reflect 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vectors x and y. x device in/out vector with n elements. xType input Enumerant specifying the datatype of vector x. incx input Stride between consecutive elements of x. y device in/out vector with n elements. yType input Enumerant specifying the datatype of vector y. incy input Stride between consecutive elements of y. c host or device input Cosine element of the rotation matrix. s host or device input Sine element of the rotation matrix. csType input Enumerant specifying the datatype of c and s. executionType input Enumerant specifying the datatype in which the computation is executed. The datatypes combinations currently supported for cublasRotEx() are listed below: executionType xType / yType csType CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_16F CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_16F CUDA\_R\_32F CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F CUDA\_R\_32F CUDA\_C\_32F CUDA\_C\_64F CUDA\_C\_64F CUDA\_C\_64F CUDA\_R\_64F CUDA\_C\_64F The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU For references please refer to NETLIB documentation: srot(), drot(), crot(), csrot(), zrot(), zdrot() 2.8.24. cublasScalEx() cublasStatus\_t cublasScalEx(cublasHandle\_t handle, int n, const void \*alpha, cudaDataType alphaType, void \*x, cudaDataType xType, int incx, cudaDataType executionType); This function supports the 64-bit Integer Interface. This function scales the vector x by the scalar \\(\\alpha\\) and overwrites it with the result. Hence, the performed operation is \\(\\mathbf{x}\\lbrack j\\rbrack = \\alpha \\times \\mathbf{x}\\lbrack j\\rbrack\\) for \\(i = 1,\\ldots,n\\) and \\(j = 1 + \\left( {i - 1} \\right)\*\\text{incx}\\). Notice that the last two equations reflect 1-based indexing used for compatibility with Fortran. Param. Memory In/out Meaning handle input Handle to the cuBLAS library context. n input Number of elements in the vector x. alpha host or device input scalar used for multiplication. alphaType input Enumerant specifying the datatype of scalar alpha. x device in/out vector with n elements. xType input Enumerant specifying the datatype of vector x. incx input Stride between consecutive elements of x. executionType input Enumerant specifying the datatype in which the computation is executed. The datatypes combinations currently supported for cublasScalEx() are listed below: alpha x execution CUDA\_R\_32F CUDA\_R\_16F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_32F CUDA\_C\_64F CUDA\_C\_64F CUDA\_C\_64F The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS The operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED The library was not initialized CUBLAS\_STATUS\_NOT\_SUPPORTED The combination of the parameters xType and executionType is not supported CUBLAS\_STATUS\_EXECUTION\_FAILED The function failed to launch on the GPU CUBLAS\_STATUS\_INVALID\_VALUE alphaType or xType or executionType is not supported For references please refer to NETLIB documentation: sscal(), dscal(), csscal(), cscal(), zdscal(), zscal() 3. Using the cuBLASLt API 3.1. General Description The cuBLASLt library is a new lightweight library dedicated to GEneral Matrix-to-matrix Multiply (GEMM) operations with a new flexible API. This new library adds flexibility in matrix data layouts, input types, compute types, and also in choosing the algorithmic implementations and heuristics through parameter programmability. Once a set of options for the intended GEMM operation are identified by the user, these options can be used repeatedly for different inputs. This is analogous to how cuFFT and FFTW first create a plan and reuse for same size and type FFTs with different input data. Note The cuBLASLt library does not guarantee the support of all possible sizes and configurations, however, since CUDA 12.2 update 2, the problem size limitations on m, n, and batch size have been largely resolved. The main focus of the library is to provide the most performant kernels, which might have some implied limitations. Some non-standard configurations may require a user to handle them manually, typically by decomposing the problem into smaller parts (see Problem Size Limitations). 3.1.1. Problem Size Limitations There are inherent problem size limitations that are a result of limitations in CUDA grid dimensions. For example, many kernels do not support batch sizes greater than 65535 due to a limitation on the z dimension of a grid. There are similar restriction on the m and n values for a given problem. In cases where a problem cannot be run by a single kernel, cuBLASLt will attempt to decompose the problem into multiple sub-problems and solve it by running the kernel on each sub-problem. There are some restrictions on cuBLASLt internal problem decomposition which are summarized below: Amax computations are not supported. This means that CUBLASLT\_MATMUL\_DESC\_AMAX\_D\_POINTER and CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_AMAX\_POINTER must be left unset (see cublasLtMatmulDescAttributes\_t) All matrix layouts must have CUBLASLT\_MATRIX\_LAYOUT\_ORDER set to CUBLASLT\_ORDER\_COL (see cublasLtOrder\_t) cuBLASLt will not partition along the n dimension when CUBLASLT\_MATMUL\_DESC\_EPILOGUE is set to CUBLASLT\_EPILOGUE\_DRELU\_BGRAD or CUBLASLT\_EPILOGUE\_DGELU\_BGRAD (see cublasLtEpilogue\_t) To overcome these limitations, a user may want to partition the problem themself, launch kernels for each sub-problem, and compute any necessary reductions to combine the results. 3.1.2. Heuristics Cache cuBLASLt uses heuristics to pick the most suitable matmul kernel for execution based on the problem sizes, GPU configuration, and other parameters. This requires performing some computations on the host CPU, which could take tens of microseconds. To overcome this overhead, it is recommended to query the heuristics once using cublasLtMatmulAlgoGetHeuristic() and then reuse the result for subsequent computations using cublasLtMatmul(). For the cases where querying heuristics once and then reusing them is not feasible, cuBLASLt implements a heuristics cache that maps matmul problems to kernels previously selected by heuristics. The heuristics cache uses an LRU-like eviction policy and is thread-safe. The user can control the heuristics cache capacity with the CUBLASLT\_HEURISTICS\_CACHE\_CAPACITY environment variable or with the cublasLtHeuristicsCacheSetCapacity() function which has higher precedence. The capacity is measured in number of entries and might be rounded up to the nearest multiple of some factor for performance reasons. Each entry takes about 360 bytes but is subject to change. The default capacity is 8192 entries. Note Setting capacity to zero disables the cache completely. This can be useful for workloads that do not have a steady state and for which cache operations may have higher overhead than regular heuristics computations. Note The cache is not ideal for performance reasons, so it is sometimes necessary to increase its capacity 1.5x-2.x over the anticipated number of unique matmul problems to achieve a nearly perfect hit rate. See also: cublasLtHeuristicsCacheGetCapacity(), cublasLtHeuristicsCacheSetCapacity(). 3.1.3. cuBLASLt Logging cuBLASLt logging mechanism can be enabled by setting the following environment variables before launching the target application: CUBLASLT\_LOG\_LEVEL= where is one of the following levels: 0 - Off - logging is disabled (default) 1 - Error - only errors will be logged 2 - Trace - API calls that launch CUDA kernels will log their parameters and important information 3 - Hints - hints that can potentially improve the application’s performance 4 - Info - provides general information about the library execution, may contain details about heuristic status 5 - API Trace - API calls will log their parameter and important information CUBLASLT\_LOG\_MASK=, where is a combination of the following flags: 0 - Off 1 - Error 2 - Trace 4 - Hints 8 - Info 16 - API Trace For example, use CUBLASLT\_LOG\_MASK=5 to enable Error and Hints messages. CUBLASLT\_LOG\_FILE=, where is a path to a logging file. The file name may contain %i, which will be replaced with the process ID. For example file\_name\_%i.log. If CUBLASLT\_LOG\_FILE is not set, the log messages are printed to stdout. Another option is to use the experimental cuBLASLt logging API. See: cublasLtLoggerSetCallback(), cublasLtLoggerSetFile(), cublasLtLoggerOpenFile(), cublasLtLoggerSetLevel(), cublasLtLoggerSetMask(), cublasLtLoggerForceDisable() 3.1.4. Narrow Precision Data Types Usage What we call here narrow precision data types were first introduced as 8-bit floating point data types (FP8) with Ada and Hopper GPUs (compute capability 8.9 and above), and were designed to further accelerate matrix multiplications. There are two types of FP8 available: CUDA\_R\_8F\_E4M3 is designed to be accurate at a smaller dynamic range than half precision. The E4 and M3 indicate a 4-bit exponent and a 3-bit mantissa respectively. For more details, see \_\_nv\_\_fp8\_e4m3. CUDA\_R\_8F\_E5M2 is designed to be accurate at a similar dynamic range as half precision. The E5 and M2 indicate a 5-bit exponent and a 2-bit mantissa respectively. For more information see \_\_nv\_\_fp8\_e5m2. Note Unless otherwise stated, FP8 refers to both CUDA\_R\_8F\_E4M3 and CUDA\_R\_8F\_E5M2. With the Blackwell GPUs (compute capability 10.0 and above), cuBLAS adds support for 4-bit floating data type (FP4) CUDA\_R\_4F\_E2M1. The E2 and M1 indicate a 2-bit exponent and a 1-bit mantissa respectively. For more details, see \_\_nv\_fp4\_e2m1. In order to maintain accuracy, data in narrow precisions needs to be scaled or dequantized before and potentially quantized after computations. cuBLAS provides several modes how the scaling factors are applied, defined in cublasLtMatmulMatrixScale\_t and configured via the CUBLASLT\_MATMUL\_DESC\_X\_SCALE\_MODE attributes (here X stands for A, B, C, D, D\_OUT, or EPILOGUE\_AUX; see cublasLtMatmulDescAttributes\_t). The scaling modes overview is given in the next table, and more details are available in the subsequent sections. Scaling Mode Support Overview Mode Supported compute capabilities Tensor values data type Scaling factors data type Scaling factor layout Tensorwide scaling 8.9+ CUDA\_R\_8F\_E4M3 / CUDA\_R\_8F\_E5M2 CUDA\_R\_32F \[#fp32\] Scalar Outer vector scaling 9.0 CUDA\_R\_8F\_E4M3 / CUDA\_R\_8F\_E5M2 CUDA\_R\_32F Vector 128-element 1D block scaling 9.0 CUDA\_R\_8F\_E4M3 / CUDA\_R\_8F\_E5M2 CUDA\_R\_32F Tensor 128x128-element 2D block scaling 9.0 CUDA\_R\_8F\_E4M3 / CUDA\_R\_8F\_E5M2 CUDA\_R\_32F Tensor 32-element 1D block scaling 10.0+ CUDA\_R\_8F\_E4M3 / CUDA\_R\_8F\_E5M2 CUDA\_R\_8F\_UE8M0 2 Tiled tensor 4 16-element 1D block scaling 10.0+ CUDA\_R\_4F\_E2M1 CUDA\_R\_8F\_UE4M3 3 Tiled tensor 4 NOTES: 1 Scaling factors that have CUDA\_R\_32F data type can be negative and are applied as-is without taking their absolute value first. 2 CUDA\_R\_8F\_UE8M0 is an 8-bit unsigned exponent-only floating data type. For more information see \_\_nv\_fp8\_e8m0. 3 CUDA\_R\_8F\_UE4M3 is an unsigned version of CUDA\_R\_E4M3. The sign bit is ignored, so this enumerant is provided for convenience. 4(1,2) See 1D Block Scaling Factors Layout for more details. Note Scales are only applicable to narrow precisions matmuls. If any scale is set for a non-narrow precisions matmul, cuBLAS will return an error. Furthermore, scales are generally only supported for narrow precision tensors. If the corresponding scale is set for a non-narrow precisions tensor, cuBLAS will return an error. The one exception is that the C tensor is allowed to have a scale for non-narrow data types with tensorwide scaling mode. Note Only Tensorwide scaling is supported when cublasLtBatchMode\_t of any matrix is set to CUBLASLT\_BATCH\_MODE\_POINTER\_ARRAY. 3.1.4.1. Tensorwide Scaling For FP8 Data Types Tensorwide scaling is enabled when CUBLASLT\_MATMUL\_DESC\_X\_SCALE\_MODE attributes (here X stands for A, B, C, D, or EPILOGUE\_AUX; see cublasLtMatmulDescAttributes\_t) for all FP8-precision tensors is set to CUBLASLT\_MATMUL\_MATRIX\_SCALE\_SCALAR\_32F (this is the default value for FP8 tensors). In such case, the matmul operation in cuBLAS is defined in the following way (assuming, for exposition, that all tensors are using an FP8 precision): \\\[D = scale\_D \\cdot (\\alpha \\cdot scale\_A \\cdot scale\_B \\cdot \\text{op}(A) \\text{op}(B) + \\beta \\cdot scale\_C \\cdot C).\\\] Here \\(A\\), \\(B\\), and \\(C\\) are input tensors, and \\(scale\_A\\), \\(scale\_B\\), \\(scale\_C\\), \\(scale\_D\\), \\(\\alpha\\), and \\(\\beta\\) are input scalars. This differs from the other matrix multiplication routines because of this addition of scaling factors for each matrix. The \\(scale\_A\\), \\(scale\_B\\), and \\(scale\_C\\) are used for de-quantization, and \\(scale\_D\\) is used for quantization. Note that all the scaling factors are applied multiplicatively. This means that sometimes it is necessary to use a scaling factor or its reciprocal depending on the context in which it is applied. For more information on FP8, see cublasLtMatmul() and cublasLtMatmulDescAttributes\_t. For such matrix multiplications, epilogues and the absolute maximums of intermediate values are computed as follows: \\\[\\begin{split}Aux\_{temp} & = \\alpha \\cdot scale\_A \\cdot scale\_B \\cdot \\text{op}(A) \\text{op}(B) + \\beta \\cdot scale\_C \\cdot C + bias, \\\\ D\_{temp} & = \\mathop{Epilogue}(Aux\_{temp}), \\\\ amax\_{D} & = \\mathop{absmax}(D\_{temp}), \\\\ amax\_{Aux} & = \\mathop{absmax}(Aux\_{temp}), \\\\ D & = scale\_D \* D\_{temp}, \\\\ Aux & = scale\_{Aux} \* Aux\_{temp}. \\\\\\end{split}\\\] Here \\(Aux\\) is an auxiliary output of matmul consisting of the values that are passed to an epilogue function like GELU, \\(scale\_{Aux}\\) is an optional scaling factor that can be applied to \\(Aux\\), and \\(amax\_{Aux}\\) is the maximum absolute value in \\(Aux\\) before scaling. For more information, see attributes CUBLASLT\_MATMUL\_DESC\_AMAX\_D\_POINTER and CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_AMAX\_POINTER in cublasLtMatmulDescAttributes\_t. Note As indicated in equation above, bias is applied before calculating \\(Aux\_{temp}\\). 3.1.4.2. Outer Vector Scaling for FP8 Data Types This scaling mode (also known as channelwise or rowwise scaling) is a refinement of the tensorwide scaling. Instead of multiplying a matrix by a single scalar, a scaling factor is associated with each row of \\(A\\) and each column of \\(B\\): \\\[D\_{ij} = \\alpha \\cdot scale\_A^i \\cdot scale\_B^j \\sum\_{l=1}^k a\_{il}\\cdot b\_{lj} + \\beta \\cdot scale\_C \\cdot C\_{ij}.\\\] Notably, \\(scale\_D\\) is not supported because the only supported precisions for \\(D\\) are CUDA\_R\_16F, CUDA\_R\_16BF, and CUDA\_R\_32F. To enable outer vector scaling, the CUBLASLT\_MATMUL\_DESC\_A\_SCALE\_MODE and CUBLASLT\_MATMUL\_DESC\_B\_SCALE\_MODE attributes, must be set to CUBLASLT\_MATMUL\_MATRIX\_SCALE\_OUTER\_VEC\_32F, while all the other scaling modes must not be modified. When using this scaling mode, the \\(scale\_A\\) and \\(scale\_B\\) must be vectors of length \\(M\\) and \\(N\\) respectively. 3.1.4.3. 16/32-Element 1D Block Scaling for FP8 and FP4 Data Types 1D block scaling aims to overcome limitations of having a single scalar to scale a whole tensor. It is described in more details in the OCP MXFP specification, so we give just a brief overview here. Block scaling means that elements within the same 16- or 32-element block of adjacent values are assigned a shared scaling factor. Currently, block scaling is supported for FP8-precision and FP4-precision tensors and mixing precisions is not supported. To enable block scaling, the CUBLASLT\_MATMUL\_DESC\_X\_SCALE\_MODE attributes (here X stands for A, B, C, DOUT, or EPILOGUE\_AUX; see cublasLtMatmulDescAttributes\_t) must be set to CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC32\_UE8M0 for all FP8-precision tensors or to CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC16\_UE4M3 for all FP4-precision tensors. With block scaling, the matmul operation in cuBLAS is defined in the following way (assuming, for exposition, that all tensors are using a narrow precision). We loosely follow the OCP MXFP specification notation. First, a scaled block (or an MX-compliant format vector in the OCP MXFP specification) is a tuple \\(x = \\left(S^x, \\left\[x^i\\right\]\_{i=1}^k\\right)\\), where \\(S^x\\) is a shared scaling factor, and each \\(x^i\\) is stored using an FP8 or FP4 data type. A dot product of two scaled blocks \\(x = \\left(S^x, \\left\[x^i\\right\]\_{i=1}^{k}\\right)\\) and \\(y = \\left(S^y, \\left\[y^i\\right\]\_{i=1}^{k}\\right)\\) is defined as follows: \\\[Dot(x, y) = S^x S^y \\cdot \\sum\_{i=1}^{k} x^i y^i.\\\] For a sequence of \\(n\\) blocks \\(X = \\{x\_j\\}\_{j=1}^n\\) and \\(Y = \\{y\_j\\}\_{j=1}^n\\), the generalized dot product is defined as: \\\[DotGeneral(X, Y) = \\sum\_{j=1}^n Dot(x\_j, y\_j).\\\] The generalized dot product can be used to define the matrix multiplication by combining together one scaling factor per \\(k\\) elements of \\(A\\) and \\(B\\) in the \\(K\\) dimension (assuming, for simplicity, that \\(K\\) is divisible by \\(k\\) without a remainder): \\\[\\begin{split}L & = \\frac{K}{k}, \\\\ A\_i & = \\left\\{{scale\_A}\_{i,b}, \\left\[A\_{i,(b-1)k+l}\\right\]\_{l=1}^{k}\\right\\}\_{b=1}^L, \\\\ B\_j & = \\left\\{{scale\_B}\_{i,b}, \\left\[B\_{(b-1)k+l,j}\\right\]\_{l=1}^{k}\\right\\}\_{b=1}^L, \\\\ (\\left\\{scale\_A, A\\right\\} \\times \\left\\{scale\_B, B\\right\\})\_{i,j} & = DotGeneral(A\_i, B\_j).\\end{split}\\\] Now, the full matmul can be written as: \\\[\\left\\{scale\_D^{out}, D\\right\\} = Quantize\\left(scale\_D^{in}\\left(\\alpha \\cdot \\left\\{scale\_A, \\text{op}(A)\\right\\} \\times \\left\\{scale\_B, \\text{op}(B)\\right\\} + \\beta \\cdot Dequantize(\\left\\{scale\_C, C\\right\\})\\right)\\right).\\\] The \\(Quantize\\) is explained in the 1D Block Quantization section, and \\(Dequantize\\) is defined as: \\\[Dequantize\\left(\\left\\{scale\_C, C\\right\\})\\right)\_{i,j} = {scale\_C}\_{i/k,j} \\cdot C\_{i,j}.\\\] Note In addition to \\(scale\_D^{out}\\) that is computed during quantization, there is also an input scalar tensor-wide scaling factor \\(scale\_D^{in}\\) for \\(D\\) that is available only when scaling factors use the CUDA\_R\_8F\_UE4M3 data type. It is used to ‘compress’ computed values prior to quantization. 3.1.4.3.1. 1D Block Quantization Consider a single block of \\(k\\) elements of \\(D\\) in the \\(M\\) dimension: \\(D^b\_{fp32} = \\left\[d^i\_{fp32}\\right\]\_{i=1}^k\\). Quantization of partial blocks is performed as if the missing values are zero. Let \\(Amax(DType)\\) be the maximal value representable in the destination precision. The following computations steps are common to all combinations of output and scaling factors data types. Compute the block absolute maximum value \\(Amax(D^b\_{fp32}) = max(\\{|d\_i|\\}\_{i=1}^k)\\). Compute the block scaling factor in single precision as \\(S^b\_{fp32} = \\frac{Amax(D^b\_{fp32})}{Amax(DType)}\\). Computing scaling and conversion factors for FP8 with UE8M0 scales Note RNE rounding is assumed unless noted otherwise. Computations consist of the following steps: Extract the block scaling factor exponent without bias adjustment as an integer \\(E^b\_{int}\\) and mantissa as a fixed point number \\(M^b\_{fixp}\\) from \\(S^b\_{fp32}\\) (the actual implementation operates on bit representation directly). Round the block exponent up keeping it within the range of values representable in UE8M0: \\(E^b\_{int} = \\left\\{\\begin{array}{ll} E^b\_{int} + 1, & \\text{if } S^b\_{fp32} \\text{ is a normal number and } E^b\_{int} < 254 \\text{ and } M^b\_{fixp} > 0 \\\\ E^b\_{int} + 1, & \\text{if } S^b\_{fp32} \\text{is a denormal number and } M^b\_{fixp} > 0.5, \\\\ E^b\_{int}, & \\text{otherwise.} \\end{array}\\right.\\) Compute the block scaling factor as \\(S^b\_{ue8m0} = 2^{E^b\_{int}}\\). Note that UE8M0 data type has exponent bias of 127. Compute the block conversion factor \\(R^b\_{fp32} = \\frac{1}{fp32(S^b\_{ue8m0})}\\). Note The algorithm above differs from the OCP MXFP suggested rounding scheme. Computing scaling and conversion factors for FP4 with UE4M3 scales Here we assume that the algorithm is provided with a precomputed input tensorwide scaling factor \\(scale\_D^{in}\\) which in general case is computed as \\\[scale\_D^{in} = \\frac{Amax(e2m1) \\cdot Amax(e4m3)}{Amax(D\_{temp})},\\\] where \\(Amax(D\_{temp})\\) is a global absolute maximum of matmul results before quantization. Since computing this value requires knowing the result of the whole computation, an approximate value from e.g. the previous iteration is used in practice. Computations consist of the following steps: Compute the narrow precision value of the block scaling factor \\(S^b\_{e4m3} = e4m3(S^b\_{fp32} \\cdot scale\_D^{in})\\). Compute the block conversion factor \\(R^b\_{fp32} = \\frac{scale\_D^{in}}{fp32(S^b\_{e4m3})}\\). Applying conversion factors For each \\(i = 1 \\ldots k\\), compute \\(d^i = DType(d^i\_{fp32} \\cdot R^n\_{fp32})\\). The resulting quantized block is \\(\\left(S^b, \\left\[d^i\\right\]\_{i=1}^k\\right)\\), where \\(S^b\\) is \\(S^b\_{ue8m0}\\) for FP8 with UE8M0 scaling factors, and \\(S^b\_{ue4m3}\\) for FP4 with UE4M3 scaling factors. 3.1.4.3.2. 1D Block Scaling Factors Layout Scaling factors are stored using a tiled layout. The following figure shows how each 128x4 tile is laid out in memory. The offset in memory is increasing from left to right, and then from top to bottom. The following pseudocode can be used to translate from inner (K for A and B, and M for C or D) and outer (M for A, and N for B, C and D) indices to linear offset within a tile and back: // Indices -> offset offset = (outer % 32) \* 16 + (outer / 32) \* 4 + inner // Offset -> Indices outer = ((offset % 16) / 4) \* 32 + (offset / 16) inner = (offset % 4) A single tile of scaling factors is applied to a 128x64 block when the scaling mode is CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC16\_UE4M3 and to a 128x128 block when it is CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC32\_UE8M0. Multiple blocks are arranged in the row-major manner. The next picture shows an example. The offset in memory is increasing from left to right, and then from top to bottom. In general, for a scaling factors tensor with sf\_inner\_dim scaling factors per row, offset of a block with top left coordinate (sf\_outer, sf\_inner) (using the same correspondence to matrix coordinates as noted above) can be computed using the following pseudocode: // Indices -> offset // note that sf\_inner is a multiple of 4 due to the tiling layout offset = (sf\_inner + sf\_outer \* sf\_inner\_dim) \* 128 Note Starting addresses of scaling factors must be 16B aligned. Note Note that the layout described above does not allow transposition. This means that even though the input tensors can be transposed, the layout of scaling factors does not change. Note Note that when tensor dimensions are not multiples of the tile size above, it is necessary to still allocate full tile for storage and fill out of bounds values with zeroes. Moreover, when writing output scaling factors, kernels may write additional zeroes, so it is best to not make any assuptions regarding the persistence of out of bounds values. 3.1.4.4. 128-element 1D and 128x128 2D Block Scaling For FP8 Data Types These two scaling modes apply principles of the scaling approach described 16/32-Element 1D Block Scaling for FP8 and FP4 Data Types to the Hopper GPU architecture. However, here the scaling data type is CUDA\_R\_32F, and different scaling modes can be used for \\(A\\) and \\(B\\), and the only supported precisions for \\(D\\) are CUDA\_R\_16F, CUDA\_R\_16BF, and CUDA\_R\_32F. To enable this scaling mode, the CUBLASLT\_MATMUL\_DESC\_X\_SCALE\_MODE attributes (here X stands for A or B), must be set to CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC128\_32F or CUBLASLT\_MATMUL\_MATRIX\_SCALE\_BLK128x128\_32F, while all the other scaling modes must not be modified. The following table shows supported combinations: CUBLASLT\_MATMUL\_DESC\_A\_SCALE\_MODE CUBLASLT\_MATMUL\_DESC\_B\_SCALE\_MODE Supported? CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC128\_32F CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC128\_32F Yes CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC128\_32F CUBLASLT\_MATMUL\_MATRIX\_SCALE\_BLK128x128\_32F Yes CUBLASLT\_MATMUL\_MATRIX\_SCALE\_BLK128x128\_32F CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC128\_32F Yes CUBLASLT\_MATMUL\_MATRIX\_SCALE\_BLK128x128\_32F CUBLASLT\_MATMUL\_MATRIX\_SCALE\_BLK128x128\_32F No Using the notation from the 16/32-Element 1D Block Scaling for FP8 and FP4 Data Types, we can define sequences of scaled blocks for the \\(i\\)-th row of \\(A\\) in the following way: \\\[\\begin{split}L & = \\lceil \\frac{K}{128} \\rceil, \\\\ A^{128}\_i & = \\left\\{{scale\_A}\_{i,b}, \\left\[A\_{i,(b-1)128+l}\\right\]\_{l=1}^{128}\\right\\}\_{b=1}^L, \\text{(this is the 128-element 1D block scaling)} \\\\ \\\\ p & = \\lceil \\frac{i}{128} \\rceil, \\\\ A^{128 \\times 128}\_i & = \\left\\{{scale\_A}\_{p,b}, \\left\[A\_{i,(b-1)128+l}\\right\]\_{l=1}^{128}\\right\\}\_{b=1}^L. \\text{(this is the 128x128-element 2D block scaling)} \\\\\\end{split}\\\] Definitions for \\(B\\) are similar. The matmul is then defined as in 16/32-Element 1D Block Scaling for FP8 and FP4 Data Types with the notable difference that when using the 2D block scaling a single scaling factor is used for the whole 128x128 block of elements. 3.1.4.4.1. Scaling factors layouts Note Starting addresses of scaling factors must be 16B aligned. Note \\(M\\) and \\(N\\) must be multiples of 4. Then for the CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC128\_32F scaling mode, the scaling factors are: \\(M\\)-major for \\(A\\) with shape \\(M \\times L\\) (\\(M\\)-major means that elements along the \\(M\\) dimension are contiguous in memory), \\(N\\)-major for \\(B\\) with shape \\(N \\times L\\). For the CUBLASLT\_MATMUL\_MATRIX\_SCALE\_BLK128x128\_32F scaling mode, the scaling factors are \\(K\\)-major and the stride between the consecutive columns must be a multiple of 4. Let \\(L\_4 = \\lceil L \\rceil\_4\\), where the \\(\\lceil \\cdot \\rceil\_4\\) denotes rounding up to the nearest multiple of 4. Then for \\(A\\), the shape of the scaling factors is \\(L\_4 \\times \\lceil \\frac{M}{128} \\rceil\\), for \\(B\\), the shape of the scaling factors is \\(L\_4 \\times \\lceil \\frac{N}{128} \\rceil\\). 3.1.5. Disabling CPU Instructions As mentioned in the Heuristics Cache section, cuBLASLt heuristics perform some compute-intensive operations on the host CPU. To speed-up the operations, the implementation detects CPU capabilities and may use special instructions, such as Advanced Vector Extensions (AVX) on x86-64 CPUs. However, in some rare cases this might be not desirable. For instance, using advanced instructions may result in CPU running at a lower frequency, which would affect performance of the other host code. The user can optionally instruct the cuBLASLt library to not use some CPU instructions with the CUBLASLT\_DISABLE\_CPU\_INSTRUCTIONS\_MASK environment variable or with the cublasLtDisableCpuInstructionsSetMask() function which has higher precedence. The default mask is 0, meaning that there are no restrictions. Please check cublasLtDisableCpuInstructionsSetMask() for more information. 3.2. cuBLASLt Code Examples Please visit https://github.com/NVIDIA/CUDALibrarySamples/tree/master/cuBLASLt for updated code examples. 3.3. cuBLASLt Datatypes Reference 3.3.1. cublasLtClusterShape\_t cublasLtClusterShape\_t is an enumerated type used to configure thread block cluster dimensions. Thread block clusters add an optional hierarchical level and are made up of thread blocks. Similar to thread blocks, these can be one, two, or three-dimensional. See also Thread Block Clusters. Value Description CUBLASLT\_CLUSTER\_SHAPE\_AUTO Cluster shape is automatically selected. CUBLASLT\_CLUSTER\_SHAPE\_1x1x1 Cluster shape is 1 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x2x1 Cluster shape is 1 x 2 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x4x1 Cluster shape is 1 x 4 x 1. CUBLASLT\_CLUSTER\_SHAPE\_2x1x1 Cluster shape is 2 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_2x2x1 Cluster shape is 2 x 2 x 1. CUBLASLT\_CLUSTER\_SHAPE\_2x4x1 Cluster shape is 2 x 4 x 1. CUBLASLT\_CLUSTER\_SHAPE\_4x1x1 Cluster shape is 4 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_4x2x1 Cluster shape is 4 x 2 x 1. CUBLASLT\_CLUSTER\_SHAPE\_4x4x1 Cluster shape is 4 x 4 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x8x1 Cluster shape is 1 x 8 x 1. CUBLASLT\_CLUSTER\_SHAPE\_8x1x1 Cluster shape is 8 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_2x8x1 Cluster shape is 2 x 8 x 1. CUBLASLT\_CLUSTER\_SHAPE\_8x2x1 Cluster shape is 8 x 2 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x16x1 Cluster shape is 1 x 16 x 1. CUBLASLT\_CLUSTER\_SHAPE\_16x1x1 Cluster shape is 16 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x3x1 Cluster shape is 1 x 3 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x5x1 Cluster shape is 1 x 5 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x6x1 Cluster shape is 1 x 6 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x7x1 Cluster shape is 1 x 7 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x9x1 Cluster shape is 1 x 9 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x10x1 Cluster shape is 1 x 10 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x11x1 Cluster shape is 1 x 11 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x12x1 Cluster shape is 1 x 12 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x13x1 Cluster shape is 1 x 13 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x14x1 Cluster shape is 1 x 14 x 1. CUBLASLT\_CLUSTER\_SHAPE\_1x15x1 Cluster shape is 1 x 15 x 1. CUBLASLT\_CLUSTER\_SHAPE\_2x3x1 Cluster shape is 2 x 3 x 1. CUBLASLT\_CLUSTER\_SHAPE\_2x5x1 Cluster shape is 2 x 5 x 1. CUBLASLT\_CLUSTER\_SHAPE\_2x6x1 Cluster shape is 2 x 6 x 1. CUBLASLT\_CLUSTER\_SHAPE\_2x7x1 Cluster shape is 2 x 7 x 1. CUBLASLT\_CLUSTER\_SHAPE\_3x1x1 Cluster shape is 3 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_3x2x1 Cluster shape is 3 x 2 x 1. CUBLASLT\_CLUSTER\_SHAPE\_3x3x1 Cluster shape is 3 x 3 x 1. CUBLASLT\_CLUSTER\_SHAPE\_3x4x1 Cluster shape is 3 x 4 x 1. CUBLASLT\_CLUSTER\_SHAPE\_3x5x1 Cluster shape is 3 x 5 x 1. CUBLASLT\_CLUSTER\_SHAPE\_4x3x1 Cluster shape is 4 x 3 x 1. CUBLASLT\_CLUSTER\_SHAPE\_5x1x1 Cluster shape is 5 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_5x2x1 Cluster shape is 5 x 2 x 1. CUBLASLT\_CLUSTER\_SHAPE\_5x3x1 Cluster shape is 5 x 3 x 1. CUBLASLT\_CLUSTER\_SHAPE\_6x1x1 Cluster shape is 6 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_6x2x1 Cluster shape is 6 x 2 x 1. CUBLASLT\_CLUSTER\_SHAPE\_7x1x1 Cluster shape is 7 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_7x2x1 Cluster shape is 7 x 2 x 1. CUBLASLT\_CLUSTER\_SHAPE\_9x1x1 Cluster shape is 9 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_10x1x1 Cluster shape is 10 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_11x1x1 Cluster shape is 11 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_12x1x1 Cluster shape is 12 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_13x1x1 Cluster shape is 13 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_14x1x1 Cluster shape is 14 x 1 x 1. CUBLASLT\_CLUSTER\_SHAPE\_15x1x1 Cluster shape is 15 x 1 x 1. 3.3.2. cublasLtEpilogue\_t The cublasLtEpilogue\_t is an enum type to set the postprocessing options for the epilogue. Value Description CUBLASLT\_EPILOGUE\_DEFAULT = 1 No special postprocessing, just scale and quantize the results if necessary. CUBLASLT\_EPILOGUE\_RELU = 2 Apply ReLU point-wise transform to the results (x:= max(x, 0)). CUBLASLT\_EPILOGUE\_RELU\_AUX = CUBLASLT\_EPILOGUE\_RELU | 128 Apply ReLU point-wise transform to the results (x:= max(x, 0)). This epilogue mode produces an extra output, see CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_POINTER of cublasLtMatmulDescAttributes\_t. CUBLASLT\_EPILOGUE\_BIAS = 4 Apply (broadcast) bias from the bias vector. Bias vector length must match matrix D rows, and it must be packed (such as stride between vector elements is 1). Bias vector is broadcast to all columns and added before applying the final postprocessing. CUBLASLT\_EPILOGUE\_RELU\_BIAS = CUBLASLT\_EPILOGUE\_RELU = CUBLASLT\_EPILOGUE\_BIAS Apply bias and then ReLU transform. CUBLASLT\_EPILOGUE\_RELU\_AUX\_BIAS = CUBLASLT\_EPILOGUE\_RELU\_AUX = CUBLASLT\_EPILOGUE\_BIAS Apply bias and then ReLU transform. This epilogue mode produces an extra output, see CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_POINTER of cublasLtMatmulDescAttributes\_t. CUBLASLT\_EPILOGUE\_DRELU = 8 | 128 Apply ReLu gradient to matmul output. Store ReLu gradient in the output matrix. This epilogue mode requires an extra input, see CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_POINTER of cublasLtMatmulDescAttributes\_t. CUBLASLT\_EPILOGUE\_DRELU\_BGRAD = CUBLASLT\_EPILOGUE\_DRELU | 16 Apply independently ReLu and Bias gradient to matmul output. Store ReLu gradient in the output matrix, and Bias gradient in the bias buffer (see CUBLASLT\_MATMUL\_DESC\_BIAS\_POINTER). This epilogue mode requires an extra input, see CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_POINTER of cublasLtMatmulDescAttributes\_t. CUBLASLT\_EPILOGUE\_GELU = 32 Apply GELU point-wise transform to the results (x:= GELU(x)). CUBLASLT\_EPILOGUE\_GELU\_AUX = CUBLASLT\_EPILOGUE\_GELU | 128 Apply GELU point-wise transform to the results (x:= GELU(x)). This epilogue mode outputs GELU input as a separate matrix (useful for training). See CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_POINTER of cublasLtMatmulDescAttributes\_t. CUBLASLT\_EPILOGUE\_GELU\_BIAS = CUBLASLT\_EPILOGUE\_GELU = CUBLASLT\_EPILOGUE\_BIAS Apply Bias and then GELU transform 5. CUBLASLT\_EPILOGUE\_GELU\_AUX\_BIAS = CUBLASLT\_EPILOGUE\_GELU\_AUX = CUBLASLT\_EPILOGUE\_BIAS Apply Bias and then GELU transform 5. This epilogue mode outputs GELU input as a separate matrix (useful for training). See CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_POINTER of cublasLtMatmulDescAttributes\_t. CUBLASLT\_EPILOGUE\_DGELU = 64 | 128 Apply GELU gradient to matmul output. Store GELU gradient in the output matrix. This epilogue mode requires an extra input, see CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_POINTER of cublasLtMatmulDescAttributes\_t. CUBLASLT\_EPILOGUE\_DGELU\_BGRAD = CUBLASLT\_EPILOGUE\_DGELU | 16 Apply independently GELU and Bias gradient to matmul output. Store GELU gradient in the output matrix, and Bias gradient in the bias buffer (see CUBLASLT\_MATMUL\_DESC\_BIAS\_POINTER). This epilogue mode requires an extra input, see CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_POINTER of cublasLtMatmulDescAttributes\_t. CUBLASLT\_EPILOGUE\_BGRADA = 256 Apply Bias gradient to the input matrix A. The bias size corresponds to the number of rows of the matrix D. The reduction happens over the GEMM’s “k” dimension. Store Bias gradient in the bias buffer, see CUBLASLT\_MATMUL\_DESC\_BIAS\_POINTER of cublasLtMatmulDescAttributes\_t. CUBLASLT\_EPILOGUE\_BGRADB = 512 Apply Bias gradient to the input matrix B. The bias size corresponds to the number of columns of the matrix D. The reduction happens over the GEMM’s “k” dimension. Store Bias gradient in the bias buffer, see CUBLASLT\_MATMUL\_DESC\_BIAS\_POINTER of cublasLtMatmulDescAttributes\_t. NOTES: 5(1,2) GELU (Gaussian Error Linear Unit) is approximated by: \\({0.5}x\\left( 1 + \\text{tanh}\\left( \\sqrt{2/\\pi}\\left( x + {0.044715}x^{3} \\right) \\right) \\right)\\) Note Only CUBLASLT\_EPILOGUE\_DEFAULT is supported when cublasLtBatchMode\_t of any matrix is set to CUBLASLT\_BATCH\_MODE\_POINTER\_ARRAY. 3.3.3. cublasLtHandle\_t The cublasLtHandle\_t type is a pointer type to an opaque structure holding the cuBLASLt library context. Use cublasLtCreate() to initialize the cuBLASLt library context and return a handle to an opaque structure holding the cuBLASLt library context, and use cublasLtDestroy() to destroy a previously created cuBLASLt library context descriptor and release the resources. Note cuBLAS handle (cublasHandle\_t) encapsulates a cuBLASLt handle. Any valid cublasHandle\_t can be used in place of cublasLtHandle\_t with a simple cast. However, unlike a cuBLAS handle, a cuBLASLt handle is not tied to any particular CUDA context with the exception of CUDA contexts tied to a graphics context (starting from CUDA 12.8). If a cuBLASLt handle is created when the current CUDA context is tied to a graphics context, then cuBLASLt detects the corresponding shared memory limitations and records it in the handle. 3.3.4. cublasLtLoggerCallback\_t cublasLtLoggerCallback\_t is a callback function pointer type. A callback function can be set using cublasLtLoggerSetCallback(). Parameters: Parameter Memory Input / Output Description logLevel Output See cuBLASLt Logging. functionName Output The name of the API that logged this message. message Output The log message. 3.3.5. cublasLtMatmulAlgo\_t cublasLtMatmulAlgo\_t is an opaque structure holding the description of the matrix multiplication algorithm. This structure can be trivially serialized and later restored for use with the same version of cuBLAS library to save on selecting the right configuration again. 3.3.6. cublasLtMatmulAlgoCapAttributes\_t cublasLtMatmulAlgoCapAttributes\_t enumerates matrix multiplication algorithm capability attributes that can be retrieved from an initialized cublasLtMatmulAlgo\_t descriptor using cublasLtMatmulAlgoCapGetAttribute(). Value Description Data Type CUBLASLT\_ALGO\_CAP\_SPLITK\_SUPPORT Support for split-K. Boolean (0 or 1) to express if split-K implementation is supported. 0 means no support, and supported otherwise. See CUBLASLT\_ALGO\_CONFIG\_SPLITK\_NUM of cublasLtMatmulAlgoConfigAttributes\_t. int32\_t CUBLASLT\_ALGO\_CAP\_REDUCTION\_SCHEME\_MASK Mask to express the types of reduction schemes supported, see cublasLtReductionScheme\_t. If the reduction scheme is not masked out then it is supported. For example: int isReductionSchemeComputeTypeSupported? (reductionSchemeMask & CUBLASLT\_REDUCTION\_SCHEME\_COMPUTE\_TYPE) == CUBLASLT\_REDUCTION\_SCHEME\_COMPUTE\_TYPE? 1: 0; uint32\_t CUBLASLT\_ALGO\_CAP\_CTA\_SWIZZLING\_SUPPORT Support for CTA-swizzling. Boolean (0 or 1) to express if CTA-swizzling implementation is supported. 0 means no support, and 1 means supported value of 1; other values are reserved. See also CUBLASLT\_ALGO\_CONFIG\_CTA\_SWIZZLING of cublasLtMatmulAlgoConfigAttributes\_t. uint32\_t CUBLASLT\_ALGO\_CAP\_STRIDED\_BATCH\_SUPPORT Support strided batch. 0 means no support, supported otherwise. int32\_t CUBLASLT\_ALGO\_CAP\_POINTER\_ARRAY\_BATCH\_SUPPORT Support pointer array batch. 0 means no support, supported otherwise. int32\_t CUBLASLT\_ALGO\_CAP\_OUT\_OF\_PLACE\_RESULT\_SUPPORT Support results out of place (D!= C in D = alpha.A.B + beta.C). 0 means no support, supported otherwise. int32\_t CUBLASLT\_ALGO\_CAP\_UPLO\_SUPPORT Syrk (symmetric rank k update)/herk (Hermitian rank k update) support (on top of regular gemm). 0 means no support, supported otherwise. int32\_t CUBLASLT\_ALGO\_CAP\_TILE\_IDS The tile ids possible to use. See cublasLtMatmulTile\_t. If no tile ids are supported then use CUBLASLT\_MATMUL\_TILE\_UNDEFINED. Use cublasLtMatmulAlgoCapGetAttribute() with sizeInBytes = 0 to query the actual count. uint32\_t\[\] CUBLASLT\_ALGO\_CAP\_STAGES\_IDS The stages ids possible to use. See cublasLtMatmulStages\_t. If no stages ids are supported then use CUBLASLT\_MATMUL\_STAGES\_UNDEFINED. Use cublasLtMatmulAlgoCapGetAttribute() with sizeInBytes = 0 to query the actual count. uint32\_t\[\] CUBLASLT\_ALGO\_CAP\_CUSTOM\_OPTION\_MAX Custom option range is from 0 to CUBLASLT\_ALGO\_CAP\_CUSTOM\_OPTION\_MAX (inclusive). See CUBLASLT\_ALGO\_CONFIG\_CUSTOM\_OPTION of cublasLtMatmulAlgoConfigAttributes\_t. int32\_t CUBLASLT\_ALGO\_CAP\_MATHMODE\_IMPL Indicates whether the algorithm is using regular compute or tensor operations. 0 means regular compute, 1 means tensor operations. DEPRECATED int32\_t CUBLASLT\_ALGO\_CAP\_GAUSSIAN\_IMPL Indicate whether the algorithm implements the Gaussian optimization of complex matrix multiplication. 0 means regular compute; 1 means Gaussian. See cublasMath\_t. DEPRECATED int32\_t CUBLASLT\_ALGO\_CAP\_CUSTOM\_MEMORY\_ORDER Indicates whether the algorithm supports custom (not COL or ROW memory order). 0 means only COL and ROW memory order is allowed, non-zero means that algo might have different requirements. See cublasLtOrder\_t. int32\_t CUBLASLT\_ALGO\_CAP\_POINTER\_MODE\_MASK Bitmask enumerating the pointer modes the algorithm supports. See cublasLtPointerModeMask\_t. uint32\_t CUBLASLT\_ALGO\_CAP\_EPILOGUE\_MASK Bitmask enumerating the kinds of postprocessing algorithm supported in the epilogue. See cublasLtEpilogue\_t. uint32\_t CUBLASLT\_ALGO\_CAP\_LD\_NEGATIVE Support for negative leading dimension for all of the matrices. 0 means no support, supported otherwise. uint32\_t CUBLASLT\_ALGO\_CAP\_NUMERICAL\_IMPL\_FLAGS Details about algorithm’s implementation that affect it’s numerical behavior. See cublasLtNumericalImplFlags\_t. uint64\_t CUBLASLT\_ALGO\_CAP\_MIN\_ALIGNMENT\_A\_BYTES Minimum alignment required for A matrix in bytes. uint32\_t CUBLASLT\_ALGO\_CAP\_MIN\_ALIGNMENT\_B\_BYTES Minimum alignment required for B matrix in bytes. uint32\_t CUBLASLT\_ALGO\_CAP\_MIN\_ALIGNMENT\_C\_BYTES Minimum alignment required for C matrix in bytes. uint32\_t CUBLASLT\_ALGO\_CAP\_MIN\_ALIGNMENT\_D\_BYTES Minimum alignment required for D matrix in bytes. uint32\_t CUBLASLT\_ALGO\_CAP\_FLOATING\_POINT\_EMULATION\_SUPPORT Support for for floating point emulation. See Floating Point Emulation. int32\_t 3.3.7. cublasLtMatmulAlgoConfigAttributes\_t cublasLtMatmulAlgoConfigAttributes\_t is an enumerated type that contains the configuration attributes for cuBLASLt matrix multiply algorithms. The configuration attributes are algorithm-specific, and can be set. The attributes configuration of a given algorithm should agree with its capability attributes. Use cublasLtMatmulAlgoConfigGetAttribute() and cublasLtMatmulAlgoConfigSetAttribute() to get and set the attribute value of a matmul algorithm descriptor. Value Description Data Type CUBLASLT\_ALGO\_CONFIG\_ID Read-only attribute. Algorithm index. See cublasLtMatmulAlgoGetIds(). Set by cublasLtMatmulAlgoInit(). int32\_t CUBLASLT\_ALGO\_CONFIG\_TILE\_ID Tile id. See cublasLtMatmulTile\_t. Default: CUBLASLT\_MATMUL\_TILE\_UNDEFINED. uint32\_t CUBLASLT\_ALGO\_CONFIG\_STAGES\_ID stages id, see cublasLtMatmulStages\_t. Default: CUBLASLT\_MATMUL\_STAGES\_UNDEFINED. uint32\_t CUBLASLT\_ALGO\_CONFIG\_SPLITK\_NUM Number of K splits. If the number of K splits is greater than one, SPLITK\_NUM parts of matrix multiplication will be computed in parallel. The results will be accumulated according to CUBLASLT\_ALGO\_CONFIG\_REDUCTION\_SCHEME. uint32\_t CUBLASLT\_ALGO\_CONFIG\_REDUCTION\_SCHEME Reduction scheme to use when splitK value > 1. Default: CUBLASLT\_REDUCTION\_SCHEME\_NONE. See cublasLtReductionScheme\_t. uint32\_t CUBLASLT\_ALGO\_CONFIG\_CTA\_SWIZZLING Enable/Disable CTA swizzling. Change mapping from CUDA grid coordinates to parts of the matrices. Possible values: 0 and 1; other values reserved. uint32\_t CUBLASLT\_ALGO\_CONFIG\_CUSTOM\_OPTION Custom option value. Each algorithm can support some custom options that don’t fit the description of the other configuration attributes. See the CUBLASLT\_ALGO\_CAP\_CUSTOM\_OPTION\_MAX of cublasLtMatmulAlgoCapAttributes\_t for the accepted range for a specific case. uint32\_t CUBLASLT\_ALGO\_CONFIG\_INNER\_SHAPE\_ID Inner shape ID. Refer to cublasLtMatmulInnerShape\_t. Default: CUBLASLT\_MATMUL\_INNER\_SHAPE\_UNDEFINED. uint16\_t CUBLASLT\_ALGO\_CONFIG\_CLUSTER\_SHAPE\_ID Cluster shape ID. Refer to cublasLtClusterShape\_t. Default: CUBLASLT\_CLUSTER\_SHAPE\_AUTO. uint16\_t 3.3.8. cublasLtMatmulDesc\_t The cublasLtMatmulDesc\_t is a pointer to an opaque structure holding the description of the matrix multiplication operation cublasLtMatmul(). A descriptor can be created by calling cublasLtMatmulDescCreate() and destroyed by calling cublasLtMatmulDescDestroy(). 3.3.9. cublasLtMatmulDescAttributes\_t cublasLtMatmulDescAttributes\_t is a descriptor structure containing the attributes that define the specifics of the matrix multiply operation. Use cublasLtMatmulDescGetAttribute() and cublasLtMatmulDescSetAttribute() to get and set the attribute value of a matmul descriptor. Value Description Data Type CUBLASLT\_MATMUL\_DESC\_COMPUTE\_TYPE Compute type. Defines the data type used for multiply and accumulate operations, and the accumulator during the matrix multiplication. See cublasComputeType\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_SCALE\_TYPE Scale type. Defines the data type of the scaling factors alpha and beta. The accumulator value and the value from matrix C are typically converted to scale type before final scaling. The value is then converted from scale type to the type of matrix D before storing in memory. The default value depends on CUBLASLT\_MATMUL\_DESC\_COMPUTE\_TYPE. See cudaDataType\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_POINTER\_MODE Specifies alpha and beta are passed by reference, whether they are scalars on the host or on the device, or device vectors. Default value is: CUBLASLT\_POINTER\_MODE\_HOST (i.e., on the host). See cublasLtPointerMode\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_TRANSA Specifies the type of transformation operation that should be performed on matrix A. Default value is: CUBLAS\_OP\_N (i.e., non-transpose operation). See cublasOperation\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_TRANSB Specifies the type of transformation operation that should be performed on matrix B. Default value is: CUBLAS\_OP\_N (i.e., non-transpose operation). See cublasOperation\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_TRANSC Specifies the type of transformation operation that should be performed on matrix C. Currently only CUBLAS\_OP\_N is supported. Default value is: CUBLAS\_OP\_N (i.e., non-transpose operation). See cublasOperation\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_FILL\_MODE Indicates whether the lower or upper part of the dense matrix was filled, and consequently should be used by the function. Currently this flag is not supported for bfloat16 or FP8 data types and is not supported on the following GPUs: Hopper, Blackwell. Default value is: CUBLAS\_FILL\_MODE\_FULL. See cublasFillMode\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_EPILOGUE Epilogue function. See cublasLtEpilogue\_t. Default value is: CUBLASLT\_EPILOGUE\_DEFAULT. uint32\_t CUBLASLT\_MATMUL\_DESC\_BIAS\_POINTER Bias or Bias gradient vector pointer in the device memory. Input vector with length that matches the number of rows of matrix D when one of the following epilogues is used: CUBLASLT\_EPILOGUE\_BIAS, CUBLASLT\_EPILOGUE\_RELU\_BIAS, CUBLASLT\_EPILOGUE\_RELU\_AUX\_BIAS, CUBLASLT\_EPILOGUE\_GELU\_BIAS, CUBLASLT\_EPILOGUE\_GELU\_AUX\_BIAS. Output vector with length that matches the number of rows of matrix D when one of the following epilogues is used: CUBLASLT\_EPILOGUE\_DRELU\_BGRAD, CUBLASLT\_EPILOGUE\_DGELU\_BGRAD, CUBLASLT\_EPILOGUE\_BGRADA. Output vector with length that matches the number of columns of matrix D when one of the following epilogues is used: CUBLASLT\_EPILOGUE\_BGRADB. Bias vector elements are the same type as alpha and beta (see CUBLASLT\_MATMUL\_DESC\_SCALE\_TYPE in this table) when matrix D datatype is CUDA\_R\_8I and same as matrix D datatype otherwise. See the datatypes table under cublasLtMatmul() for detailed mapping. Default value is: NULL. void \* / const void \* CUBLASLT\_MATMUL\_DESC\_BIAS\_BATCH\_STRIDE Stride (in elements) to the next bias or bias gradient vector for strided batch operations. The default value is 0. int64\_t CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_POINTER Pointer for epilogue auxiliary buffer. Output vector for ReLu bit-mask in forward pass when CUBLASLT\_EPILOGUE\_RELU\_AUX or CUBLASLT\_EPILOGUE\_RELU\_AUX\_BIAS epilogue is used. Input vector for ReLu bit-mask in backward pass when CUBLASLT\_EPILOGUE\_DRELU or CUBLASLT\_EPILOGUE\_DRELU\_BGRAD epilogue is used. Output of GELU input matrix in forward pass when CUBLASLT\_EPILOGUE\_GELU\_AUX\_BIAS epilogue is used. Input of GELU input matrix for backward pass when CUBLASLT\_EPILOGUE\_DGELU or CUBLASLT\_EPILOGUE\_DGELU\_BGRAD epilogue is used. For aux data type, see CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_DATA\_TYPE. Routines that don’t dereference this pointer, like cublasLtMatmulAlgoGetHeuristic() depend on its value to determine expected pointer alignment. Requires setting the CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_LD attribute. void \* / const void \* CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_LD Leading dimension for epilogue auxiliary buffer. ReLu bit-mask matrix leading dimension in elements (i.e. bits) when CUBLASLT\_EPILOGUE\_RELU\_AUX, CUBLASLT\_EPILOGUE\_RELU\_AUX\_BIAS, CUBLASLT\_EPILOGUE\_DRELU\_BGRAD, or CUBLASLT\_EPILOGUE\_DRELU\_BGRAD epilogue is used. Must be divisible by 128 and be no less than the number of rows in the output matrix. GELU input matrix leading dimension in elements when CUBLASLT\_EPILOGUE\_GELU\_AUX\_BIAS, CUBLASLT\_EPILOGUE\_DGELU, or CUBLASLT\_EPILOGUE\_DGELU\_BGRAD epilogue used. Must be divisible by 8 and be no less than the number of rows in the output matrix. int64\_t CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_BATCH\_STRIDE Batch stride for epilogue auxiliary buffer. ReLu bit-mask matrix batch stride in elements (i.e. bits) when CUBLASLT\_EPILOGUE\_RELU\_AUX, CUBLASLT\_EPILOGUE\_RELU\_AUX\_BIAS or CUBLASLT\_EPILOGUE\_DRELU\_BGRAD epilogue is used. Must be divisible by 128. GELU input matrix batch stride in elements when CUBLASLT\_EPILOGUE\_GELU\_AUX\_BIAS, CUBLASLT\_EPILOGUE\_DRELU, or CUBLASLT\_EPILOGUE\_DGELU\_BGRAD epilogue used. Must be divisible by 8. Default value: 0. int64\_t CUBLASLT\_MATMUL\_DESC\_ALPHA\_VECTOR\_BATCH\_STRIDE Batch stride for alpha vector. Used together with CUBLASLT\_POINTER\_MODE\_ALPHA\_DEVICE\_VECTOR\_BETA\_HOST when matrix D’s CUBLASLT\_MATRIX\_LAYOUT\_BATCH\_COUNT is greater than 1. If CUBLASLT\_POINTER\_MODE\_ALPHA\_DEVICE\_VECTOR\_BETA\_ZERO is set then CUBLASLT\_MATMUL\_DESC\_ALPHA\_VECTOR\_BATCH\_STRIDE must be set to 0 as this mode doesn’t support batched alpha vector. If cublasLtBatchMode\_t of any matrix is set to CUBLASLT\_BATCH\_MODE\_POINTER\_ARRAY then CUBLASLT\_MATMUL\_DESC\_ALPHA\_VECTOR\_BATCH\_STRIDE must be set to 0. Default value: 0. int64\_t CUBLASLT\_MATMUL\_DESC\_SM\_COUNT\_TARGET Number of SMs to target for parallel execution. Optimizes heuristics for execution on a different number of SMs when user expects a concurrent stream to be using some of the device resources. Default value: 0. int32\_t CUBLASLT\_MATMUL\_DESC\_A\_SCALE\_POINTER Device pointer to the scale factor value that converts data in matrix A to the compute data type range. The scaling factor must have the same type as the compute type. If not specified, or set to NULL, the scaling factor is assumed to be 1. If set for an unsupported matrix data, scale, and compute type combination, calling cublasLtMatmul() will return CUBLAS\_INVALID\_VALUE. Default value: NULL const void \* CUBLASLT\_MATMUL\_DESC\_B\_SCALE\_POINTER Equivalent to CUBLASLT\_MATMUL\_DESC\_A\_SCALE\_POINTER for matrix B. Default value: NULL const void \* CUBLASLT\_MATMUL\_DESC\_C\_SCALE\_POINTER Equivalent to CUBLASLT\_MATMUL\_DESC\_A\_SCALE\_POINTER for matrix C. Default value: NULL const void \* CUBLASLT\_MATMUL\_DESC\_D\_SCALE\_POINTER Equivalent to CUBLASLT\_MATMUL\_DESC\_A\_SCALE\_POINTER for matrix D. Default value: NULL const void \* CUBLASLT\_MATMUL\_DESC\_AMAX\_D\_POINTER Device pointer to the memory location that on completion will be set to the maximum of absolute values in the output matrix. The computed value has the same type as the compute type. If not specified, or set to NULL, the maximum absolute value is not computed. If set for an unsupported matrix data, scale, and compute type combination, calling cublasLtMatmul() will return CUBLAS\_INVALID\_VALUE. Default value: NULL void \* CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_DATA\_TYPE The type of the data that will be stored in CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_POINTER. If unset (or set to the default value of -1), the data type is set to be the output matrix element data type (DType) with some exceptions: ReLu uses a bit-mask. For FP8 kernels with an output type (DType) of CUDA\_R\_8F\_E4M3, the data type can be set to a non-default value if: AType and BType are CUDA\_R\_8F\_E4M3. Bias Type is CUDA\_R\_16F. CType is CUDA\_R\_16BF or CUDA\_R\_16F CUBLASLT\_MATMUL\_DESC\_EPILOGUE is set to CUBLASLT\_EPILOGUE\_GELU\_AUX When CType is CUDA\_R\_16F, the data type may be set to CUDA\_R\_16F or CUDA\_R\_8F\_E4M3. When CType is CUDA\_R\_16BF, the data type may be set to CUDA\_R\_16BF. Otherwise, the data type should be left unset or set to the default value of -1. If set for an unsupported matrix data, scale, and compute type combination, calling cublasLtMatmul() will return CUBLAS\_INVALID\_VALUE. Default value: -1 int32\_t (cudaDataType\_t) CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_SCALE\_POINTER Device pointer to the scaling factor value to convert results from compute type data range to storage data range in the auxiliary matrix that is set via CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_POINTER. The scaling factor value must have the same type as the compute type. If not specified, or set to NULL, the scaling factor is assumed to be 1. If set for an unsupported matrix data, scale, and compute type combination, calling cublasLtMatmul() will return CUBLAS\_INVALID\_VALUE. Default value: NULL void \* CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_AMAX\_POINTER Device pointer to the memory location that on completion will be set to the maximum of absolute values in the buffer that is set via CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_POINTER. The computed value has the same type as the compute type. If not specified, or set to NULL, the maximum absolute value is not computed. If set for an unsupported matrix data, scale, and compute type combination, calling cublasLtMatmul() will return CUBLAS\_INVALID\_VALUE. Default value: NULL void \* CUBLASLT\_MATMUL\_DESC\_FAST\_ACCUM Flag for managing FP8 fast accumulation mode. When enabled, on some GPUs problem execution might be faster but at the cost of lower accuracy because intermediate results will not periodically be promoted to a higher precision. Currently this flag has an effect on the following GPUs: Ada, Hopper. Default value: 0 - fast accumulation mode is disabled int8\_t CUBLASLT\_MATMUL\_DESC\_BIAS\_DATA\_TYPE Type of the bias or bias gradient vector in the device memory. Bias case: see CUBLASLT\_EPILOGUE\_BIAS. If unset (or set to the default value of -1), the bias vector elements are the same type as the elements of the output matrix (Dtype) with the following exceptions: IMMA kernels with computeType=CUDA\_R\_32I and Ctype=CUDA\_R\_8I where the bias vector elements are the same type as alpha, beta (CUBLASLT\_MATMUL\_DESC\_SCALE\_TYPE=CUDA\_R\_32F) For FP8 kernels with an output type of CUDA\_R\_32F, CUDA\_R\_8F\_E4M3 or CUDA\_R\_8F\_E5M2. See cublasLtMatmul() for more details. Default value: -1 int32\_t (cudaDataType\_t) CUBLASLT\_MATMUL\_DESC\_A\_SCALE\_MODE Scaling mode that defines how the matrix scaling factor for matrix A is interpreted. Default value: 0. See cublasLtMatmulMatrixScale\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_B\_SCALE\_MODE Scaling mode that defines how the matrix scaling factor for matrix B is interpreted. Default value: 0. See cublasLtMatmulMatrixScale\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_C\_SCALE\_MODE Scaling mode that defines how the matrix scaling factor for matrix C is interpreted. Default value: 0. See cublasLtMatmulMatrixScale\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_D\_SCALE\_MODE Scaling mode that defines how the matrix scaling factor for matrix D is interpreted. Default value: 0. See cublasLtMatmulMatrixScale\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_EPILOGUE\_AUX\_SCALE\_MODE Scaling mode that defines how the matrix scaling factor for the auxiliary matrix is interpreted. Default value: 0. See cublasLtMatmulMatrixScale\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_D\_OUT\_SCALE\_POINTER Device pointer to the scale factors that are used to convert data in matrix D to the compute data type range. The scaling factor value type is defined by the scaling mode (see CUBLASLT\_MATMUL\_DESC\_D\_OUT\_SCALE\_MODE). If set for an unsupported matrix data, scale, scale mode, and compute type combination, or missing for a supported combination, then calling cublasLtMatmul() will return CUBLAS\_INVALID\_VALUE. Default value: NULL. void \* CUBLASLT\_MATMUL\_DESC\_D\_OUT\_SCALE\_MODE Scaling mode that defines how the output matrix scaling factor for matrix D is interpreted. Default value: 0. See cublasLtMatmulMatrixScale\_t. int32\_t CUBLASLT\_MATMUL\_DESC\_EMULATION\_DESCRIPTOR Emulation descriptor to configure floating point emulation parameters. Default value: NULL. int32\_t 3.3.10. cublasLtMatmulHeuristicResult\_t cublasLtMatmulHeuristicResult\_t is a descriptor that holds the configured matrix multiplication algorithm descriptor and its runtime properties. Member Description cublasLtMatmulAlgo\_t algo Must be initialized with cublasLtMatmulAlgoInit() if the preference CUBLASLT\_MATMUL\_PERF\_SEARCH\_MODE is set to CUBLASLT\_SEARCH\_LIMITED\_BY\_ALGO\_ID. See cublasLtMatmulSearch\_t. size\_t workspaceSize; Actual size of workspace memory required. cublasStatus\_t state; Result status. Other fields are valid only if, after call to cublasLtMatmulAlgoGetHeuristic(), this member is set to CUBLAS\_STATUS\_SUCCESS. float wavesCount; Waves count is a device utilization metric. A wavesCount value of 1.0f suggests that when the kernel is launched it will fully occupy the GPU. int reserved\[4\]; Reserved. 3.3.11. cublasLtMatmulInnerShape\_t cublasLtMatmulInnerShape\_t is an enumerated type used to configure various aspects of the internal kernel design. This does not impact the CUDA grid size. Value Description CUBLASLT\_MATMUL\_INNER\_SHAPE\_UNDEFINED Inner shape is undefined. CUBLASLT\_MATMUL\_INNER\_SHAPE\_MMA884 Inner shape is MMA884. CUBLASLT\_MATMUL\_INNER\_SHAPE\_MMA1684 Inner shape is MMA1684. CUBLASLT\_MATMUL\_INNER\_SHAPE\_MMA1688 Inner shape is MMA1688. CUBLASLT\_MATMUL\_INNER\_SHAPE\_MMA16816 Inner shape is MMA16816. 3.3.12. cublasLtMatmulPreference\_t The cublasLtMatmulPreference\_t is a pointer to an opaque structure holding the description of the preferences for cublasLtMatmulAlgoGetHeuristic() configuration. Use cublasLtMatmulPreferenceCreate() to create one instance of the descriptor and cublasLtMatmulPreferenceDestroy() to destroy a previously created descriptor and release the resources. 3.3.13. cublasLtMatmulPreferenceAttributes\_t cublasLtMatmulPreferenceAttributes\_t is an enumerated type used to apply algorithm search preferences while fine-tuning the heuristic function. Use cublasLtMatmulPreferenceGetAttribute() and cublasLtMatmulPreferenceSetAttribute() to get and set the attribute value of a matmul preference descriptor. Value Description Data Type CUBLASLT\_MATMUL\_PREF\_SEARCH\_MODE Search mode. See cublasLtMatmulSearch\_t. Default is CUBLASLT\_SEARCH\_BEST\_FIT. uint32\_t CUBLASLT\_MATMUL\_PREF\_MAX\_WORKSPACE\_BYTES Maximum allowed workspace memory. Default is 0 (no workspace memory allowed). uint64\_t CUBLASLT\_MATMUL\_PREF\_REDUCTION\_SCHEME\_MASK Reduction scheme mask. See cublasLtReductionScheme\_t. Only algorithm configurations specifying CUBLASLT\_ALGO\_CONFIG\_REDUCTION\_SCHEME that is not masked out by this attribute are allowed. For example, a mask value of 0x03 will allow only INPLACE and COMPUTE\_TYPE reduction schemes. Default is CUBLASLT\_REDUCTION\_SCHEME\_MASK (i.e., allows all reduction schemes). uint32\_t CUBLASLT\_MATMUL\_PREF\_MIN\_ALIGNMENT\_A\_BYTES Minimum buffer alignment for matrix A (in bytes). Selecting a smaller value will exclude algorithms that can not work with matrix A, which is not as strictly aligned as the algorithms need. Default is 256 bytes. uint32\_t CUBLASLT\_MATMUL\_PREF\_MIN\_ALIGNMENT\_B\_BYTES Minimum buffer alignment for matrix B (in bytes). Selecting a smaller value will exclude algorithms that can not work with matrix B, which is not as strictly aligned as the algorithms need. Default is 256 bytes. uint32\_t CUBLASLT\_MATMUL\_PREF\_MIN\_ALIGNMENT\_C\_BYTES Minimum buffer alignment for matrix C (in bytes). Selecting a smaller value will exclude algorithms that can not work with matrix C, which is not as strictly aligned as the algorithms need. Default is 256 bytes. uint32\_t CUBLASLT\_MATMUL\_PREF\_MIN\_ALIGNMENT\_D\_BYTES Minimum buffer alignment for matrix D (in bytes). Selecting a smaller value will exclude algorithms that can not work with matrix D, which is not as strictly aligned as the algorithms need. Default is 256 bytes. uint32\_t CUBLASLT\_MATMUL\_PREF\_MAX\_WAVES\_COUNT Maximum wave count. See cublasLtMatmulHeuristicResult\_t::wavesCount. Selecting a non-zero value will exclude algorithms that report device utilization higher than specified. Default is 0.0f. float CUBLASLT\_MATMUL\_PREF\_IMPL\_MASK Numerical implementation details mask. See cublasLtNumericalImplFlags\_t. Filters heuristic result to only include algorithms that use the allowed implementations. default: uint64\_t(-1) (allow everything) uint64\_t 3.3.14. cublasLtMatmulSearch\_t cublasLtMatmulSearch\_t is an enumerated type that contains the attributes for heuristics search type. Value Description Data Type CUBLASLT\_SEARCH\_BEST\_FIT Request heuristics for the best algorithm for the given use case. CUBLASLT\_SEARCH\_LIMITED\_BY\_ALGO\_ID Request heuristics only for the pre-configured algo id. 3.3.15. cublasLtMatmulTile\_t cublasLtMatmulTile\_t is an enumerated type used to set the tile size in rows x columns. See also CUTLASS: Fast Linear Algebra in CUDA C++. Value Description CUBLASLT\_MATMUL\_TILE\_UNDEFINED Tile size is undefined. CUBLASLT\_MATMUL\_TILE\_8x8 Tile size is 8 rows x 8 columns. CUBLASLT\_MATMUL\_TILE\_8x16 Tile size is 8 rows x 16 columns. CUBLASLT\_MATMUL\_TILE\_16x8 Tile size is 16 rows x 8 columns. CUBLASLT\_MATMUL\_TILE\_8x32 Tile size is 8 rows x 32 columns. CUBLASLT\_MATMUL\_TILE\_16x16 Tile size is 16 rows x 16 columns. CUBLASLT\_MATMUL\_TILE\_32x8 Tile size is 32 rows x 8 columns. CUBLASLT\_MATMUL\_TILE\_8x64 Tile size is 8 rows x 64 columns. CUBLASLT\_MATMUL\_TILE\_16x32 Tile size is 16 rows x 32 columns. CUBLASLT\_MATMUL\_TILE\_32x16 Tile size is 32 rows x 16 columns. CUBLASLT\_MATMUL\_TILE\_64x8 Tile size is 64 rows x 8 columns. CUBLASLT\_MATMUL\_TILE\_32x32 Tile size is 32 rows x 32 columns. CUBLASLT\_MATMUL\_TILE\_32x64 Tile size is 32 rows x 64 columns. CUBLASLT\_MATMUL\_TILE\_64x32 Tile size is 64 rows x 32 columns. CUBLASLT\_MATMUL\_TILE\_32x128 Tile size is 32 rows x 128 columns. CUBLASLT\_MATMUL\_TILE\_64x64 Tile size is 64 rows x 64 columns. CUBLASLT\_MATMUL\_TILE\_128x32 Tile size is 128 rows x 32 columns. CUBLASLT\_MATMUL\_TILE\_64x128 Tile size is 64 rows x 128 columns. CUBLASLT\_MATMUL\_TILE\_128x64 Tile size is 128 rows x 64 columns. CUBLASLT\_MATMUL\_TILE\_64x256 Tile size is 64 rows x 256 columns. CUBLASLT\_MATMUL\_TILE\_128x128 Tile size is 128 rows x 128 columns. CUBLASLT\_MATMUL\_TILE\_256x64 Tile size is 256 rows x 64 columns. CUBLASLT\_MATMUL\_TILE\_64x512 Tile size is 64 rows x 512 columns. CUBLASLT\_MATMUL\_TILE\_128x256 Tile size is 128 rows x 256 columns. CUBLASLT\_MATMUL\_TILE\_256x128 Tile size is 256 rows x 128 columns. CUBLASLT\_MATMUL\_TILE\_512x64 Tile size is 512 rows x 64 columns. CUBLASLT\_MATMUL\_TILE\_64x96 Tile size is 64 rows x 96 columns. CUBLASLT\_MATMUL\_TILE\_96x64 Tile size is 96 rows x 64 columns. CUBLASLT\_MATMUL\_TILE\_96x128 Tile size is 96 rows x 128 columns. CUBLASLT\_MATMUL\_TILE\_128x160 Tile size is 128 rows x 160 columns. CUBLASLT\_MATMUL\_TILE\_160x128 Tile size is 160 rows x 128 columns. CUBLASLT\_MATMUL\_TILE\_192x128 Tile size is 192 rows x 128 columns. CUBLASLT\_MATMUL\_TILE\_128x192 Tile size is 128 rows x 192 columns. CUBLASLT\_MATMUL\_TILE\_128x96 Tile size is 128 rows x 96 columns. 3.3.16. cublasLtMatmulStages\_t cublasLtMatmulStages\_t is an enumerated type used to configure the size and number of shared memory buffers where input elements are staged. Number of staging buffers defines kernel’s pipeline depth. Value Description CUBLASLT\_MATMUL\_STAGES\_UNDEFINED Stage size is undefined. CUBLASLT\_MATMUL\_STAGES\_16x1 Stage size is 16, number of stages is 1. CUBLASLT\_MATMUL\_STAGES\_16x2 Stage size is 16, number of stages is 2. CUBLASLT\_MATMUL\_STAGES\_16x3 Stage size is 16, number of stages is 3. CUBLASLT\_MATMUL\_STAGES\_16x4 Stage size is 16, number of stages is 4. CUBLASLT\_MATMUL\_STAGES\_16x5 Stage size is 16, number of stages is 5. CUBLASLT\_MATMUL\_STAGES\_16x6 Stage size is 16, number of stages is 6. CUBLASLT\_MATMUL\_STAGES\_32x1 Stage size is 32, number of stages is 1. CUBLASLT\_MATMUL\_STAGES\_32x2 Stage size is 32, number of stages is 2. CUBLASLT\_MATMUL\_STAGES\_32x3 Stage size is 32, number of stages is 3. CUBLASLT\_MATMUL\_STAGES\_32x4 Stage size is 32, number of stages is 4. CUBLASLT\_MATMUL\_STAGES\_32x5 Stage size is 32, number of stages is 5. CUBLASLT\_MATMUL\_STAGES\_32x6 Stage size is 32, number of stages is 6. CUBLASLT\_MATMUL\_STAGES\_64x1 Stage size is 64, number of stages is 1. CUBLASLT\_MATMUL\_STAGES\_64x2 Stage size is 64, number of stages is 2. CUBLASLT\_MATMUL\_STAGES\_64x3 Stage size is 64, number of stages is 3. CUBLASLT\_MATMUL\_STAGES\_64x4 Stage size is 64, number of stages is 4. CUBLASLT\_MATMUL\_STAGES\_64x5 Stage size is 64, number of stages is 5. CUBLASLT\_MATMUL\_STAGES\_64x6 Stage size is 64, number of stages is 6. CUBLASLT\_MATMUL\_STAGES\_128x1 Stage size is 128, number of stages is 1. CUBLASLT\_MATMUL\_STAGES\_128x2 Stage size is 128, number of stages is 2. CUBLASLT\_MATMUL\_STAGES\_128x3 Stage size is 128, number of stages is 3. CUBLASLT\_MATMUL\_STAGES\_128x4 Stage size is 128, number of stages is 4. CUBLASLT\_MATMUL\_STAGES\_128x5 Stage size is 128, number of stages is 5. CUBLASLT\_MATMUL\_STAGES\_128x6 Stage size is 128, number of stages is 6. CUBLASLT\_MATMUL\_STAGES\_32x10 Stage size is 32, number of stages is 10. CUBLASLT\_MATMUL\_STAGES\_8x4 Stage size is 8, number of stages is 4. CUBLASLT\_MATMUL\_STAGES\_16x10 Stage size is 16, number of stages is 10. CUBLASLT\_MATMUL\_STAGES\_8x5 Stage size is 8, number of stages is 5. CUBLASLT\_MATMUL\_STAGES\_8x3 Stage size is 8, number of stages is 3. CUBLASLT\_MATMUL\_STAGES\_8xAUTO Stage size is 8, number of stages is selected automatically. CUBLASLT\_MATMUL\_STAGES\_16xAUTO Stage size is 16, number of stages is selected automatically. CUBLASLT\_MATMUL\_STAGES\_32xAUTO Stage size is 32, number of stages is selected automatically. CUBLASLT\_MATMUL\_STAGES\_64xAUTO Stage size is 64, number of stages is selected automatically. CUBLASLT\_MATMUL\_STAGES\_128xAUTO Stage size is 128, number of stages is selected automatically. CUBLASLT\_MATMUL\_STAGES\_256xAUTO Stage size is 256, number of stages is selected automatically. CUBLASLT\_MATMUL\_STAGES\_768xAUTO Stage size is 768, number of stages is selected automatically. 3.3.17. cublasLtNumericalImplFlags\_t cublasLtNumericalImplFlags\_t: a set of bit-flags that can be specified to select implementation details that may affect numerical behavior of algorithms. Flags below can be combined using the bit OR operator “|”. Value Description CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_FMA Specify that the implementation is based on \[H,F,D\]FMA (fused multiply-add) family instructions. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_HMMA Specify that the implementation is based on HMMA (tensor operation) family instructions. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_IMMA Specify that the implementation is based on IMMA (integer tensor operation) family instructions. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_DMMA Specify that the implementation is based on DMMA (double precision tensor operation) family instructions. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_TENSOR\_OP\_MASK Mask to filter implementations using any of the above kinds of tensor operations. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_OP\_TYPE\_MASK Mask to filter implementation details about multiply-accumulate instructions used. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_ACCUMULATOR\_16F Specify that the implementation’s inner dot product is using half precision accumulator. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_ACCUMULATOR\_32F Specify that the implementation’s inner dot product is using single precision accumulator. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_ACCUMULATOR\_64F Specify that the implementation’s inner dot product is using double precision accumulator. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_ACCUMULATOR\_32I Specify that the implementation’s inner dot product is using 32 bit signed integer precision accumulator. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_ACCUMULATOR\_TYPE\_MASK Mask to filter implementation details about accumulator used. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_INPUT\_16F Specify that the implementation’s inner dot product multiply-accumulate instruction is using half-precision inputs. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_INPUT\_16BF Specify that the implementation’s inner dot product multiply-accumulate instruction is using bfloat16 inputs. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_INPUT\_TF32 Specify that the implementation’s inner dot product multiply-accumulate instruction is using TF32 inputs. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_INPUT\_32F Specify that the implementation’s inner dot product multiply-accumulate instruction is using single-precision inputs. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_INPUT\_64F Specify that the implementation’s inner dot product multiply-accumulate instruction is using double-precision inputs. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_INPUT\_8I Specify that the implementation’s inner dot product multiply-accumulate instruction is using 8-bit integer inputs. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_OP\_INPUT\_TYPE\_MASK Mask to filter implementation details about accumulator input used. CUBLASLT\_NUMERICAL\_IMPL\_FLAGS\_GAUSSIAN Specify that the implementation applies Gauss complexity reduction algorithm to reduce arithmetic complexity of the complex matrix multiplication problem 3.3.18. cublasLtMatrixLayout\_t The cublasLtMatrixLayout\_t is a pointer to an opaque structure holding the description of a matrix layout. Use cublasLtMatrixLayoutCreate() to create one instance of the descriptor and cublasLtMatrixLayoutDestroy() to destroy a previously created descriptor and release the resources. 3.3.19. cublasLtMatrixLayoutAttribute\_t cublasLtMatrixLayoutAttribute\_t is a descriptor structure containing the attributes that define the details of the matrix operation. Use cublasLtMatrixLayoutGetAttribute() and cublasLtMatrixLayoutSetAttribute() to get and set the attribute value of a matrix layout descriptor. Value Description Data Type CUBLASLT\_MATRIX\_LAYOUT\_TYPE Specifies the data precision type. See cudaDataType\_t. uint32\_t CUBLASLT\_MATRIX\_LAYOUT\_ORDER Specifies the memory order of the data of the matrix. Default value is CUBLASLT\_ORDER\_COL. See cublasLtOrder\_t. int32\_t CUBLASLT\_MATRIX\_LAYOUT\_ROWS Describes the number of rows in the matrix. Normally only values that can be expressed as int32\_t are supported. uint64\_t CUBLASLT\_MATRIX\_LAYOUT\_COLS Describes the number of columns in the matrix. Normally only values that can be expressed as int32\_t are supported. uint64\_t CUBLASLT\_MATRIX\_LAYOUT\_LD The leading dimension of the matrix. For CUBLASLT\_ORDER\_COL this is the stride (in elements) of matrix column. See also cublasLtOrder\_t. Currently only non-negative values are supported. Must be large enough so that matrix memory locations are not overlapping (e.g., greater or equal to CUBLASLT\_MATRIX\_LAYOUT\_ROWS in case of CUBLASLT\_ORDER\_COL). int64\_t CUBLASLT\_MATRIX\_LAYOUT\_BATCH\_COUNT Number of matmul operations to perform in the batch. Default value is 1. See also CUBLASLT\_ALGO\_CAP\_STRIDED\_BATCH\_SUPPORT and CUBLASLT\_ALGO\_CAP\_POINTER\_ARRAY\_BATCH\_SUPPORT in cublasLtMatmulAlgoCapAttributes\_t. int32\_t CUBLASLT\_MATRIX\_LAYOUT\_STRIDED\_BATCH\_OFFSET Stride (in elements) to the next matrix for the strided batch operation. Default value is 0. When matrix type is planar-complex (CUBLASLT\_MATRIX\_LAYOUT\_PLANE\_OFFSET!= 0), batch stride is interpreted by cublasLtMatmul() in number of real valued sub-elements. E.g. for data of type CUDA\_C\_16F, offset of 1024B is encoded as a stride of value 512 (since each element of the real and imaginary matrices is a 2B (16bit) floating point type). NOTE: A bug in cublasLtMatrixTransform() causes it to interpret the batch stride for a planar-complex matrix as if it was specified in number of complex elements. Therefore an offset of 1024B must be encoded as stride value 256 when calling cublasLtMatrixTransform() (each complex element is 4B with real and imaginary values 2B each). This behavior is expected to be corrected in the next major cuBLAS version. int64\_t CUBLASLT\_MATRIX\_LAYOUT\_PLANE\_OFFSET Stride (in bytes) to the imaginary plane for planar-complex layout. Default value is 0, indicating that the layout is regular (real and imaginary parts of complex numbers are interleaved in memory for each element). int64\_t CUBLASLT\_MATRIX\_LAYOUT\_BATCH\_MODE The batch mode of the matrix. Default value is CUBLASLT\_BATCH\_MODE\_STRIDED. See cublasLtBatchMode\_t. int32\_t 3.3.20. cublasLtMatrixTransformDesc\_t The cublasLtMatrixTransformDesc\_t is a pointer to an opaque structure holding the description of a matrix transformation operation. Use cublasLtMatrixTransformDescCreate() to create one instance of the descriptor and cublasLtMatrixTransformDescDestroy() to destroy a previously created descriptor and release the resources. 3.3.21. cublasLtMatrixTransformDescAttributes\_t cublasLtMatrixTransformDescAttributes\_t is a descriptor structure containing the attributes that define the specifics of the matrix transform operation. Use cublasLtMatrixTransformDescGetAttribute() and cublasLtMatrixTransformDescSetAttribute() to set the attribute value of a matrix transform descriptor. Value Description Data Type CUBLASLT\_MATRIX\_TRANSFORM\_DESC\_SCALE\_TYPE Scale type. Inputs are converted to the scale type for scaling and summation, and results are then converted to the output type to store in the memory. For the supported data types see cudaDataType\_t. int32\_t CUBLASLT\_MATRIX\_TRANSFORM\_DESC\_POINTER\_MODE Specifies the scalars alpha and beta are passed by reference whether on the host or on the device. Default value is: CUBLASLT\_POINTER\_MODE\_HOST (i.e., on the host). See cublasLtPointerMode\_t. int32\_t CUBLASLT\_MATRIX\_TRANSFORM\_DESC\_TRANSA Specifies the type of operation that should be performed on the matrix A. Default value is: CUBLAS\_OP\_N (i.e., non-transpose operation). See cublasOperation\_t. int32\_t CUBLASLT\_MATRIX\_TRANSFORM\_DESC\_TRANSB Specifies the type of operation that should be performed on the matrix B. Default value is: CUBLAS\_OP\_N (i.e., non-transpose operation). See cublasOperation\_t. int32\_t 3.3.22. cublasLtOrder\_t cublasLtOrder\_t is an enumerated type used to indicate the data ordering of the matrix. Value Description CUBLASLT\_ORDER\_COL Data is ordered in column-major format. The leading dimension is the stride (in elements) to the beginning of next column in memory. CUBLASLT\_ORDER\_ROW Data is ordered in row-major format. The leading dimension is the stride (in elements) to the beginning of next row in memory. CUBLASLT\_ORDER\_COL32 Data is ordered in column-major ordered tiles of 32 columns. The leading dimension is the stride (in elements) to the beginning of next group of 32-columns. For example, if the matrix has 33 columns and 2 rows, then the leading dimension must be at least 32 \* 2 = 64. CUBLASLT\_ORDER\_COL4\_4R2\_8C Data is ordered in column-major ordered tiles of composite tiles with total 32 columns and 8 rows. A tile is composed of interleaved inner tiles of 4 columns within 4 even or odd rows in an alternating pattern. The leading dimension is the stride (in elements) to the beginning of the first 32 column x 8 row tile for the next 32-wide group of columns. For example, if the matrix has 33 columns and 1 row, the leading dimension must be at least (32 \* 8) \* 1 = 256. CUBLASLT\_ORDER\_COL32\_2R\_4R4 Data is ordered in column-major ordered tiles of composite tiles with total 32 columns ands 32 rows. Element offset within the tile is calculated as (((row % 8) / 2 \* 4 + row / 8) \* 2 + row % 2) \* 32 + col. Leading dimension is the stride (in elements) to the beginning of the first 32 column x 32 row tile for the next 32-wide group of columns. E.g. if matrix has 33 columns and 1 row, then its leading dimensions must be at least (32 \* 32) \* 1 = 1024. 3.3.23. cublasLtPointerMode\_t cublasLtPointerMode\_t is an enumerated type used to set the pointer mode for the scaling factors alpha and beta. Value Description CUBLASLT\_POINTER\_MODE\_HOST = CUBLAS\_POINTER\_MODE\_HOST Matches CUBLAS\_POINTER\_MODE\_HOST, and the pointer targets a single value host memory. CUBLASLT\_POINTER\_MODE\_DEVICE = CUBLAS\_POINTER\_MODE\_DEVICE Matches CUBLAS\_POINTER\_MODE\_DEVICE, and the pointer targets a single value device memory. CUBLASLT\_POINTER\_MODE\_DEVICE\_VECTOR = 2 Pointers target device memory vectors of length equal to the number of rows of matrix D. CUBLASLT\_POINTER\_MODE\_ALPHA\_DEVICE\_VECTOR\_BETA\_ZERO = 3 alpha pointer targets a device memory vector of length equal to the number of rows of matrix D, and beta is zero. CUBLASLT\_POINTER\_MODE\_ALPHA\_DEVICE\_VECTOR\_BETA\_HOST = 4 alpha pointer targets a device memory vector of length equal to the number of rows of matrix D, and beta is a single value in host memory. Note Only pointer modes CUBLASLT\_POINTER\_MODE\_HOST and CUBLASLT\_POINTER\_MODE\_DEVICE are supported when cublasLtBatchMode\_t of any matrix is set to CUBLASLT\_BATCH\_MODE\_POINTER\_ARRAY. 3.3.24. cublasLtPointerModeMask\_t cublasLtPointerModeMask\_t is an enumerated type used to define and query the pointer mode capability. Value Description CUBLASLT\_POINTER\_MODE\_MASK\_HOST = 1 See CUBLASLT\_POINTER\_MODE\_HOST in cublasLtPointerMode\_t. CUBLASLT\_POINTER\_MODE\_MASK\_DEVICE = 2 See CUBLASLT\_POINTER\_MODE\_DEVICE in cublasLtPointerMode\_t. CUBLASLT\_POINTER\_MODE\_MASK\_DEVICE\_VECTOR = 4 See CUBLASLT\_POINTER\_MODE\_DEVICE\_VECTOR in cublasLtPointerMode\_t CUBLASLT\_POINTER\_MODE\_MASK\_ALPHA\_DEVICE\_VECTOR\_BETA\_ZERO = 8 See CUBLASLT\_POINTER\_MODE\_ALPHA\_DEVICE\_VECTOR\_BETA\_ZERO in cublasLtPointerMode\_t CUBLASLT\_POINTER\_MODE\_MASK\_ALPHA\_DEVICE\_VECTOR\_BETA\_HOST = 16 See CUBLASLT\_POINTER\_MODE\_ALPHA\_DEVICE\_VECTOR\_BETA\_HOST in cublasLtPointerMode\_t 3.3.25. cublasLtReductionScheme\_t cublasLtReductionScheme\_t is an enumerated type used to specify a reduction scheme for the portions of the dot-product calculated in parallel (i.e., “split - K”). Value Description CUBLASLT\_REDUCTION\_SCHEME\_NONE Do not apply reduction. The dot-product will be performed in one sequence. CUBLASLT\_REDUCTION\_SCHEME\_INPLACE Reduction is performed “in place” using the output buffer, parts are added up in the output data type. Workspace is only used for counters that guarantee sequentiality. CUBLASLT\_REDUCTION\_SCHEME\_COMPUTE\_TYPE Reduction done out of place in a user-provided workspace. The intermediate results are stored in the compute type in the workspace and reduced in a separate step. CUBLASLT\_REDUCTION\_SCHEME\_OUTPUT\_TYPE Reduction done out of place in a user-provided workspace. The intermediate results are stored in the output type in the workspace and reduced in a separate step. CUBLASLT\_REDUCTION\_SCHEME\_MASK Allows all reduction schemes. 3.3.26. cublasLtMatmulMatrixScale\_t cublasLtMatmulMatrixScale\_t is an enumerated type used to specify scaling mode that defines how scaling factor pointers are interpreted. Value Description CUBLASLT\_MATMUL\_MATRIX\_SCALE\_SCALAR\_32F Scaling factors are single-precision scalars applied to the whole tensors (this mode is the default for fp8). This is the only value valid for CUBLASLT\_MATMUL\_DESC\_D\_SCALE\_MODE when the D tensor uses a narrow precision data type. CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC16\_UE4M3 Scaling factors are tensors that contain a dedicated scaling factor stored as an 8-bit CUDA\_R\_8F\_UE4M3 value for each 16-element block in the innermost dimension of the corresponding data tensor. CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC32\_UE8M0 Scaling factors are tensors that contain a dedicated scaling factor stored as an 8-bit CUDA\_R\_8F\_UE8M0 value for each 32-element block in the innermost dimension of the corresponding data tensor. CUBLASLT\_MATMUL\_MATRIX\_SCALE\_OUTER\_VEC\_32F Scaling factors are vectors of CUDA\_R\_32F values. This mode is only applicable to matrices A and B, in which case the vectors are expected to have M and N elements respectively, and each (i, j)-th element of product of A and B is multiplied by i-th element of A scale and j-th element of B scale. CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC128\_32F Scaling factors are tensors that contain a dedicated CUDA\_R\_32F scaling factor for each 128-element block in the innermost dimension of the corresponding data tensor. CUBLASLT\_MATMUL\_MATRIX\_SCALE\_BLK128x128\_32F Scaling factors are tensors that contain a dedicated CUDA\_R\_32F scaling factor for each 128x128-element block in the the corresponding data tensor. 3.3.27. cublasLtBatchMode\_t Value Description CUBLASLT\_BATCH\_MODE\_STRIDED The matrices of each instance of the batch are located at fixed offsets in number of elements from their locations in the previous instance. CUBLASLT\_BATCH\_MODE\_POINTER\_ARRAY The address of the matrix of each instance of the batch are read from arrays of pointers. 3.3.28. cublasLtEmulationDesc\_t cublasLtEmulationDesc\_t is a pointer to an opaque structure holding the emulation descriptor. Use cublasLtEmulationDescCreate() to create a new emulation descriptor, and cublasLtEmulationDescDestroy() to destroy it and release the resources. 3.3.29. cublasLtEmulationDescAttributes\_t cublasLtEmulationDescAttributes\_t is an enumerated type used to configure floating point emulation parameters. See Floating Point Emulation documentation for more details. Value Description Data Type CUBLASLT\_EMULATION\_DESC\_STRATEGY Strategy, see cublasEmulationStrategy\_t. Defines when to use floating point emulation algorithms. Default: EMULATION\_STRATEGY\_DEFAULT. int32\_t CUBLASLT\_EMULATION\_DESC\_SPECIAL\_VALUES\_SUPPORT Special values support, see cudaEmulationSpecialValuesSupport\_t. Defines a bit mask of special cases in floating-point representations that must be supported. Default: EMULATION\_SPECIAL\_VALUE\_HANDLING\_DEFAULT. int32\_t CUBLASLT\_EMULATION\_DESC\_FIXEDPOINT\_MANTISSA\_CONTROL Mantissa control, see cudaEmulationMantissaControl\_t. For fixed-point emulation, defines how to compute the number of retained mantissa bits. See Floating Point Emulation documentation for more details. int32\_t CUBLASLT\_EMULATION\_DESC\_FIXEDPOINT\_MAX\_MANTISSA\_BIT\_COUNT For fixed-point emulation only. An int32\_t representing the maximum (up to quantization) number of mantissa bits to retain during fixed-point emulation. A default value of 0 allows the library to select a reasonable value based on device properties. Default: 0. int32\_t CUBLASLT\_EMULATION\_DESC\_FIXEDPOINT\_MANTISSA\_BIT\_OFFSET This parameter is for fixed-point emulation with CUDA\_EMULATION\_MANTISSA\_CONTROL\_DYNAMIC mantissa control (see cudaEmulationMantissaControl\_t). An integer which can be used to bias the number of recommended mantissa bits. Default: 0. int32\_t CUBLASLT\_EMULATION\_DESC\_FIXEDPOINT\_MANTISSA\_BIT\_COUNT\_POINTER This parameter is for fixed-point emulation. A device pointer which will contain the number of mantissa bits that were retained. If emulation is not used, the pointer will contain -1. Default: nullptr. int32\_t \* 3.4. cuBLASLt API Reference 3.4.1. cublasLtCreate() cublasStatus\_t cublasLtCreate(cublasLtHandle\_t \*lighthandle) This function initializes the cuBLASLt library and creates a handle to an opaque structure holding the cuBLASLt library context. It allocates light hardware resources on the host and device, and must be called prior to making any other cuBLASLt library calls. The cuBLASLt library context is tied to the current CUDA device. To use the library on multiple devices, one cuBLASLt handle must be created for each device. Furthermore, the device must be set as the current before invoking cuBLASLt functions with a handle tied to that device. See also: cuBLAS Context. Parameters: Parameter Memory Input / Output Description lightHandle Output Pointer to the allocated cuBLASLt handle for the created cuBLASLt context. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS The allocation completed successfully. CUBLAS\_STATUS\_NOT\_INITIALIZED The cuBLASLt library was not initialized. This usually happens: when cublasLtCreate() is not called first an error in the CUDA Runtime API called by the cuBLASLt routine, or an error in the hardware setup. CUBLAS\_STATUS\_ALLOC\_FAILED Resource allocation failed inside the cuBLASLt library. This is usually caused by a cudaMalloc() failure. To correct: prior to the function call, deallocate the previously allocated memory as much as possible. CUBLAS\_STATUS\_INVALID\_VALUE lighthandle is NULL See cublasStatus\_t for a complete list of valid return codes. 3.4.2. cublasLtDestroy() cublasStatus\_t cublasLtDestroy(cublasLtHandle\_t lightHandle) This function releases hardware resources used by the cuBLASLt library. This function is usually the last call with a particular handle to the cuBLASLt library. Because cublasLtCreate() allocates some internal resources and the release of those resources by calling cublasLtDestroy() will implicitly call cudaDeviceSynchronize(), it is recommended to minimize the number of times these functions are called. Parameters: Parameter Memory Input / Output Description lightHandle Input Pointer to the cuBLASLt handle to be destroyed. Returns: Return Value Meaning CUBLAS\_STATUS\_SUCCESS The cuBLASLt context was successfully destroyed. CUBLAS\_STATUS\_NOT\_INITIALIZED The cuBLASLt library was not initialized. CUBLAS\_STATUS\_INVALID\_VALUE lightHandle is NULL See cublasStatus\_t for a complete list of valid return codes. 3.4.3. cublasLtDisableCpuInstructionsSetMask() unsigned cublasLtDisableCpuInstructionsSetMask(unsigned mask); Instructs cuBLASLt library to not use CPU instructions specified by the flags in the mask. The function takes precedence over the CUBLASLT\_DISABLE\_CPU\_INSTRUCTIONS\_MASK environment variable. Parameters: mask – the flags combined with bitwise OR(|) operator that specify which CPU instructions should not be used. Supported flags: Value Description 0x1 x86-64 AVX512 ISA. Returns: the previous value of the mask. 3.4.4. cublasLtGetCudartVersion() size\_t cublasLtGetCudartVersion(void); This function returns the version number of the CUDA Runtime library. Parameters: None. Returns:size\_t - The version number of the CUDA Runtime library. 3.4.5. cublasLtGetProperty() cublasStatus\_t cublasLtGetProperty(libraryPropertyType type, int \*value); This function returns the value of the requested property by writing it to the memory location pointed to by the value parameter. Parameters: Parameter Memory Input / Output Description type Input Of the type libraryPropertyType, whose value is requested from the property. See libraryPropertyType\_t. value Output Pointer to the host memory location where the requested information should be written. Returns: Return Value Meaning CUBLAS\_STATUS\_SUCCESS The requested libraryPropertyType information is successfully written at the provided address. CUBLAS\_STATUS\_INVALID\_VALUE If invalid value of the type input argument, or if value is NULL See cublasStatus\_t for a complete list of valid return codes. 3.4.6. cublasLtGetStatusName() const char\* cublasLtGetStatusName(cublasStatus\_t status); Returns the string representation of a given status. Parameters: cublasStatus\_t - the status. Returns: const char\* - the NULL-terminated string. 3.4.7. cublasLtGetStatusString() const char\* cublasLtGetStatusString(cublasStatus\_t status); Returns the description string for a given status. Parameters: cublasStatus\_t - the status. Returns: const char\* - the NULL-terminated string. 3.4.8. cublasLtHeuristicsCacheGetCapacity() cublasStatus\_t cublasLtHeuristicsCacheGetCapacity(size\_t\* capacity); Returns the Heuristics Cache capacity. Parameters: Parameter Description capacity The pointer to the returned capacity value. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS The capacity was successfully written. CUBLAS\_STATUS\_INVALID\_VALUE The capacity was successfully set. 3.4.9. cublasLtHeuristicsCacheSetCapacity() cublasStatus\_t cublasLtHeuristicsCacheSetCapacity(size\_t capacity); Sets the Heuristics Cache capacity. Set the capacity to 0 to disable the heuristics cache. This function takes precedence over CUBLASLT\_HEURISTICS\_CACHE\_CAPACITY environment variable. Parameters: Parameter Description capacity The desirable heuristics cache capacity. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS The capacity was successfully set. 3.4.10. cublasLtGetVersion() size\_t cublasLtGetVersion(void); This function returns the version number of cuBLASLt library. Parameters: None. Returns:size\_t - The version number of cuBLASLt library. 3.4.11. cublasLtLoggerSetCallback() cublasStatus\_t cublasLtLoggerSetCallback(cublasLtLoggerCallback\_t callback); Experimental: This function sets the logging callback function. Parameters: Parameter Memory Input / Output Description callback Input Pointer to a callback function. See cublasLtLoggerCallback\_t. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS If the callback function was successfully set. See cublasStatus\_t for a complete list of valid return codes. 3.4.12. cublasLtLoggerSetFile() cublasStatus\_t cublasLtLoggerSetFile(FILE\* file); Experimental: This function sets the logging output file. Note: once registered using this function call, the provided file handle must not be closed unless the function is called again to switch to a different file handle. Parameters: Parameter Memory Input / Output Description file Input Pointer to an open file. File should have write permission. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS If logging file was successfully set. See cublasStatus\_t for a complete list of valid return codes. 3.4.13. cublasLtLoggerOpenFile() cublasStatus\_t cublasLtLoggerOpenFile(const char\* logFile); Experimental: This function opens a logging output file in the given path. Parameters: Parameter Memory Input / Output Description logFile Input Path of the logging output file. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS If the logging file was successfully opened. See cublasStatus\_t for a complete list of valid return codes. 3.4.14. cublasLtLoggerSetLevel() cublasStatus\_t cublasLtLoggerSetLevel(int level); Experimental: This function sets the value of the logging level. Parameters: Parameter Memory Input / Output Description level Input Value of the logging level. See cuBLASLt Logging. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If the value was not a valid logging level. See cuBLASLt Logging. CUBLAS\_STATUS\_SUCCESS If the logging level was successfully set. See cublasStatus\_t for a complete list of valid return codes. 3.4.15. cublasLtLoggerSetMask() cublasStatus\_t cublasLtLoggerSetMask(int mask); Experimental: This function sets the value of the logging mask. Parameters: Parameter Memory Input / Output Description mask Input Value of the logging mask. See cuBLASLt Logging. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS If the logging mask was successfully set. See cublasStatus\_t for a complete list of valid return codes. 3.4.16. cublasLtLoggerForceDisable() cublasStatus\_t cublasLtLoggerForceDisable(); Experimental: This function disables logging for the entire run. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS If logging was successfully disabled. See cublasStatus\_t for a complete list of valid return codes. 3.4.17. cublasLtMatmul() cublasStatus\_t cublasLtMatmul( cublasLtHandle\_t lightHandle, cublasLtMatmulDesc\_t computeDesc, const void \*alpha, const void \*A, cublasLtMatrixLayout\_t Adesc, const void \*B, cublasLtMatrixLayout\_t Bdesc, const void \*beta, const void \*C, cublasLtMatrixLayout\_t Cdesc, void \*D, cublasLtMatrixLayout\_t Ddesc, const cublasLtMatmulAlgo\_t \*algo, void \*workspace, size\_t workspaceSizeInBytes, cudaStream\_t stream); This function computes the matrix multiplication of matrices A and B to produce the output matrix D, according to the following operation: D = alpha\*(A\*B) + beta\*(C), where A, B, and C are input matrices, and alpha and beta are input scalars. Note This function supports both in-place matrix multiplication (C == D and Cdesc == Ddesc) and out-of-place matrix multiplication (C!= D, both matrices must have the same data type, number of rows, number of columns, batch size, and memory order). In the out-of-place case, the leading dimension of C can be different from the leading dimension of D. Specifically the leading dimension of C can be 0 to achieve row or column broadcast. If Cdesc is omitted, this function assumes it to be equal to Ddesc. The workspace pointer must be aligned to at least a multiple of 256 bytes. The recommendations on workspaceSizeInBytes are the same as mentioned in the cublasSetWorkspace() section. Datatypes Supported: cublasLtMatmul() supports the following computeType, scaleType, Atype/Btype, and Ctype. Footnotes can be found at the end of this section. Table 1. When A, B, C, and D are Regular Column- or Row-major Matrices computeType scaleType Atype/Btype Ctype Bias Type 6 CUBLAS\_COMPUTE\_16F or CUBLAS\_COMPUTE\_16F\_PEDANTIC CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_16F 6 CUBLAS\_COMPUTE\_32I or CUBLAS\_COMPUTE\_32I\_PEDANTIC CUDA\_R\_32I CUDA\_R\_8I CUDA\_R\_32I Epilogue is not supported. CUDA\_R\_32F CUDA\_R\_8I CUDA\_R\_8I Epilogue is not supported. CUBLAS\_COMPUTE\_32F or CUBLAS\_COMPUTE\_32F\_PEDANTIC CUDA\_R\_32F CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_16BF 6 CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_16F 6 CUDA\_R\_8I CUDA\_R\_32F Epilogue is not supported. CUDA\_R\_16BF CUDA\_R\_32F CUDA\_R\_32F 6 CUDA\_R\_16F CUDA\_R\_32F CUDA\_R\_32F 6 CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F 6 CUDA\_C\_32F 7 CUDA\_C\_8I 7 CUDA\_C\_32F 7 Epilogue is not supported. CUDA\_C\_32F 7 CUDA\_C\_32F 7 CUBLAS\_COMPUTE\_32F\_FAST\_16F or CUBLAS\_COMPUTE\_32F\_FAST\_16BF or CUBLAS\_COMPUTE\_32F\_FAST\_TF32 or CUBLAS\_COMPUTE\_32F\_EMULATED\_16BFX9 CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_32F 6 CUDA\_C\_32F 7 CUDA\_C\_32F 7 CUDA\_C\_32F 7 Epilogue is not supported. CUBLAS\_COMPUTE\_64F or CUBLAS\_COMPUTE\_64F\_PEDANTIC or CUBLAS\_COMPUTE\_64F\_EMULATED\_FIXEDPOINT CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F CUDA\_R\_64F 6 CUDA\_C\_64F 7 CUDA\_C\_64F 7 CUDA\_C\_64F 7 Epilogue is not supported. To use IMMA kernels, one of the following sets of requirements, with the first being the preferred one, must be met: Using a regular data ordering: All matrix pointers must be 4-byte aligned. For even better performance, this condition should hold with 16 instead of 4. Leading dimensions of matrices A, B, C must be multiples of 4. Only the “TN” format is supported - A must be transposed and B non-transposed. Pointer mode can be CUBLASLT\_POINTER\_MODE\_HOST, CUBLASLT\_POINTER\_MODE\_DEVICE or CUBLASLT\_POINTER\_MODE\_ALPHA\_DEVICE\_VECTOR\_BETA\_HOST. With the latter mode, the kernels support the CUBLASLT\_MATMUL\_DESC\_ALPHA\_VECTOR\_BATCH\_STRIDE attribute. Dimensions m and k must be multiples of 4. Using the IMMA-specific data ordering on Ampere (compute capability 8.0) or Turing (compute capability 7.5) (but not Hopper, compute capability 9.0, or later) architecture - CUBLASLT\_ORDER\_COL32\` for matrices A, C, D, and CUBLASLT\_ORDER\_COL4\_4R2\_8C (on Turing or Ampere architecture) or CUBLASLT\_ORDER\_COL32\_2R\_4R4 (on Ampere architecture) for matrix B: Leading dimensions of matrices A, B, C must fulfill conditions specific to the memory ordering (see cublasLtOrder\_t). Matmul descriptor must specify CUBLAS\_OP\_T on matrix B and CUBLAS\_OP\_N (default) on matrix A and C. If scaleType CUDA\_R\_32I is used, the only supported values for alpha and beta are 0 or 1. Pointer mode can be CUBLASLT\_POINTER\_MODE\_HOST, CUBLASLT\_POINTER\_MODE\_DEVICE, CUBLASLT\_POINTER\_MODE\_DEVICE\_VECTOR or CUBLASLT\_POINTER\_MODE\_ALPHA\_DEVICE\_VECTOR\_BETA\_ZERO. These kernels do not support CUBLASLT\_MATMUL\_DESC\_ALPHA\_VECTOR\_BATCH\_STRIDE. Only the “NT” format is supported - A must be non-transposed and B transposed. Table 2. When A, B, C, and D Use Layouts for IMMA computeType scaleType Atype/Btype Ctype Bias Type CUBLAS\_COMPUTE\_32I or CUBLAS\_COMPUTE\_32I\_PEDANTIC CUDA\_R\_32I CUDA\_R\_8I CUDA\_R\_32I Non-default epilogue not supported. CUDA\_R\_32F CUDA\_R\_8I CUDA\_R\_8I CUDA\_R\_32F To use tensor- or block-scaled FP8 kernels, the following set of requirements must be satisfied: All matrix dimensions must meet the optimal requirements listed in Tensor Core Usage (i.e. pointers and matrix dimension must support 16-byte alignment). Scaling mode must meet the restrictions noted in the Scaling Mode Support Overview table. A must be transposed and B non-transposed (The “TN” format) on Ada (compute capability 8.9), Hopper (compute capability 9.0), and Blackwell GeForce (compute capability 12.x) GPUs. The compute type must be CUBLAS\_COMPUTE\_32F. The scale type must be CUDA\_R\_32F. See the table below when using FP8 kernels: Table 3. When A, B, C, and D Use Layouts for FP8 AType BType CType DType Bias Type CUDA\_R\_8F\_E4M3 CUDA\_R\_8F\_E4M3 CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_16BF 6 CUDA\_R\_8F\_E4M3 8 CUDA\_R\_16BF 6 CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_16F 6 CUDA\_R\_8F\_E4M3 8 CUDA\_R\_16F 6 CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_16BF 6 CUDA\_R\_8F\_E5M2 CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_16BF 6 CUDA\_R\_8F\_E4M3 8 CUDA\_R\_16BF 6 CUDA\_R\_8F\_E5M2 8 CUDA\_R\_16BF 6 CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_16F 6 CUDA\_R\_8F\_E4M3 8 CUDA\_R\_16F 6 CUDA\_R\_8F\_E5M2 8 CUDA\_R\_16F 6 CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_16BF 6 CUDA\_R\_8F\_E5M2 CUDA\_R\_8F\_E4M3 CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_16BF 6 CUDA\_R\_8F\_E4M3 8 CUDA\_R\_16BF 6 CUDA\_R\_8F\_E5M2 8 CUDA\_R\_16BF 6 CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_16F 6 CUDA\_R\_8F\_E4M3 8 CUDA\_R\_16F 6 CUDA\_R\_8F\_E5M2 8 CUDA\_R\_16F 6 CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_16BF 6 To use block-scaled FP4 kernels, the following set of requirements must be satisfied: All matrix dimensions must meet the optimal requirements listed in Tensor Core Usage (i.e. pointers and matrix dimension must support 16-byte alignment). Scaling mode must be CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC16\_UE4M3 A must be transposed and B non-transposed (The “TN” format) The compute type must be CUBLAS\_COMPUTE\_32F. The scale type must be CUDA\_R\_32F. Table 4. When A, B, C, and D Use Layouts for FP4 AType BType CType DType Bias Type CUDA\_R\_4F\_E2M1 CUDA\_R\_4F\_E2M1 CUDA\_R\_16BF CUDA\_R\_16BF CUDA\_R\_16BF 6 CUDA\_R\_4F\_E2M1 CUDA\_R\_16BF 6 CUDA\_R\_16F CUDA\_R\_16F CUDA\_R\_16F 6 CUDA\_R\_4F\_E2M1 CUDA\_R\_16F 6 CUDA\_R\_32F CUDA\_R\_32F CUDA\_R\_16BF 6 And finally, see below table when A,B,C,D are planar-complex matrices (CUBLASLT\_MATRIX\_LAYOUT\_PLANE\_OFFSET!= 0, see cublasLtMatrixLayoutAttribute\_t) to make use of mixed precision tensor core acceleration. Table 5. When A, B, C, and D are Planar-Complex Matrices computeType scaleType Atype/Btype Ctype CUBLAS\_COMPUTE\_32F CUDA\_C\_32F CUDA\_C\_16F 7 CUDA\_C\_16F 7 CUDA\_C\_32F 7 CUDA\_C\_16BF 7 CUDA\_C\_16BF 7 CUDA\_C\_32F 7 NOTES: 6(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33) ReLU, dReLu, GELU, dGELU and Bias epilogue modes (see CUBLASLT\_MATMUL\_DESC\_EPILOGUE in cublasLtMatmulDescAttributes\_t) are not supported when D matrix memory order is defined as CUBLASLT\_ORDER\_ROW. For best performance when using the bias vector, specify zero beta and set pointer mode to CUBLASLT\_POINTER\_MODE\_HOST. 7(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17) Use of CUBLAS\_ORDER\_ROW together with CUBLAS\_OP\_C (Hermitian operator) is not supported unless all of A, B, C, and D matrices use the CUBLAS\_ORDER\_ROW ordering. 8(1,2,3,4,5,6,7,8,9,10) FP8 DType is not supported when scaling modes are one of CUBLASLT\_MATMUL\_MATRIX\_SCALE\_OUTER\_VEC\_32F, CUBLASLT\_MATMUL\_MATRIX\_SCALE\_VEC128\_32F, and CUBLASLT\_MATMUL\_MATRIX\_SCALE\_BLK128x128\_32F. Parameters: Parameter Memory Input / Output Description lightHandle Input Pointer to the allocated cuBLASLt handle for the cuBLASLt context. See cublasLtHandle\_t. computeDesc Input Handle to a previously created matrix multiplication descriptor of type cublasLtMatmulDesc\_t. alpha, beta Device or host Input Pointers to the scalars used in the multiplication. A, B, and C Device Input Pointers to the GPU memory associated with the corresponding descriptors Adesc, Bdesc and Cdesc. Adesc, Bdesc and Cdesc Input Handles to the previous created descriptors of the type cublasLtMatrixLayout\_t. D Device Output Pointer to the GPU memory associated with the descriptor Ddesc. Ddesc Input Handle to the previous created descriptor of the type cublasLtMatrixLayout\_t. algo Input Handle for matrix multiplication algorithm to be used. See cublasLtMatmulAlgo\_t. When NULL, an implicit heuristics query with default search preferences will be performed to determine actual algorithm to use. workspace Device Pointer to the workspace buffer allocated in the GPU memory. Must be 256B aligned (i.e. lowest 8 bits of address must be 0). workspaceSizeInBytes Input Size of the workspace. stream Host Input The CUDA stream where all the GPU work will be submitted. Returns: Return Value Description CUBLAS\_STATUS\_NOT\_INITIALIZED If cuBLASLt handle has not been initialized. CUBLAS\_STATUS\_INVALID\_VALUE If the parameters are unexpectedly NULL, in conflict or in an impossible configuration. For example, when workspaceSizeInBytes is less than workspace required by the configured algo. CUBLAS\_STATUS\_NOT\_SUPPORTED If the current implementation on the selected device doesn’t support the configured operation. CUBLAS\_STATUS\_ARCH\_MISMATCH If the configured operation cannot be run using the selected device. CUBLAS\_STATUS\_EXECUTION\_FAILED If CUDA reported an execution error from the device. CUBLAS\_STATUS\_SUCCESS If the operation completed successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.18. cublasLtMatmulAlgoCapGetAttribute() cublasStatus\_t cublasLtMatmulAlgoCapGetAttribute( const cublasLtMatmulAlgo\_t \*algo, cublasLtMatmulAlgoCapAttributes\_t attr, void \*buf, size\_t sizeInBytes, size\_t \*sizeWritten); This function returns the value of the queried capability attribute for an initialized cublasLtMatmulAlgo\_t descriptor structure. The capability attribute value is retrieved from the enumerated type cublasLtMatmulAlgoCapAttributes\_t. For example, to get list of supported Tile IDs: cublasLtMatmulTile\_t tiles\[CUBLASLT\_MATMUL\_TILE\_END\]; size\_t num\_tiles, size\_written; if (cublasLtMatmulAlgoCapGetAttribute(algo, CUBLASLT\_ALGO\_CAP\_TILE\_IDS, tiles, sizeof(tiles), &size\_written) == CUBLAS\_STATUS\_SUCCESS) { num\_tiles = size\_written / sizeof(tiles\[0\]);} Parameters: Parameter Memory Input / Output Description algo Input Pointer to the previously created opaque structure holding the matrix multiply algorithm descriptor. See cublasLtMatmulAlgo\_t. attr Input The capability attribute whose value will be retrieved by this function. See cublasLtMatmulAlgoCapAttributes\_t. buf Output The attribute value returned by this function. sizeInBytes Input Size of buf buffer (in bytes) for verification. sizeWritten Output Valid only when the return value is CUBLAS\_STATUS\_SUCCESS. If sizeInBytes is non-zero: then sizeWritten is the number of bytes actually written; if sizeInBytes is 0: then sizeWritten is the number of bytes needed to write full contents. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If sizeInBytes is 0 and sizeWritten is NULL, or if sizeInBytes is non-zero and buf is NULL, or if sizeInBytes doesn’t match size of internal storage for the selected attribute CUBLAS\_STATUS\_SUCCESS If attribute’s value was successfully written to user memory. See cublasStatus\_t for a complete list of valid return codes. 3.4.19. cublasLtMatmulAlgoCheck() cublasStatus\_t cublasLtMatmulAlgoCheck( cublasLtHandle\_t lightHandle, cublasLtMatmulDesc\_t operationDesc, cublasLtMatrixLayout\_t Adesc, cublasLtMatrixLayout\_t Bdesc, cublasLtMatrixLayout\_t Cdesc, cublasLtMatrixLayout\_t Ddesc, const cublasLtMatmulAlgo\_t \*algo, cublasLtMatmulHeuristicResult\_t \*result); This function performs the correctness check on the matrix multiply algorithm descriptor for the matrix multiply operation cublasLtMatmul() function with the given input matrices A, B and C, and the output matrix D. It checks whether the descriptor is supported on the current device, and returns the result containing the required workspace and the calculated wave count. Note CUBLAS\_STATUS\_SUCCESS doesn’t fully guarantee that the algo will run. The algo will fail if, for example, the buffers are not correctly aligned. However, if cublasLtMatmulAlgoCheck() fails, the algo will not run. Parameters: Parameter Memory Input / Output Description lightHandle Input Pointer to the allocated cuBLASLt handle for the cuBLASLt context. See cublasLtHandle\_t. operationDesc Input Handle to a previously created matrix multiplication descriptor of type cublasLtMatmulDesc\_t. Adesc, Bdesc, Cdesc, and Ddesc Input Handles to the previously created matrix layout descriptors of the type cublasLtMatrixLayout\_t. algo Input Descriptor which specifies which matrix multiplication algorithm should be used. See cublasLtMatmulAlgo\_t. May point to result->algo. result Output Pointer to the structure holding the results returned by this function. The results comprise of the required workspace and the calculated wave count. The algo field is never updated. See cublasLtMatmulHeuristicResult\_t. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If matrix layout descriptors or the operation descriptor do not match the algo descriptor. CUBLAS\_STATUS\_NOT\_SUPPORTED If the algo configuration or data type combination is not currently supported on the given device. CUBLAS\_STATUS\_ARCH\_MISMATCH If the algo configuration cannot be run using the selected device. CUBLAS\_STATUS\_SUCCESS If the check was successful. See cublasStatus\_t for a complete list of valid return codes. 3.4.20. cublasLtMatmulAlgoConfigGetAttribute() cublasStatus\_t cublasLtMatmulAlgoConfigGetAttribute( const cublasLtMatmulAlgo\_t \*algo, cublasLtMatmulAlgoConfigAttributes\_t attr, void \*buf, size\_t sizeInBytes, size\_t \*sizeWritten); This function returns the value of the queried configuration attribute for an initialized cublasLtMatmulAlgo\_t descriptor. The configuration attribute value is retrieved from the enumerated type cublasLtMatmulAlgoConfigAttributes\_t. Parameters: Parameter Memory Input / Output Description algo Input Pointer to the previously created opaque structure holding the matrix multiply algorithm descriptor. See cublasLtMatmulAlgo\_t. attr Input The configuration attribute whose value will be retrieved by this function. See cublasLtMatmulAlgoConfigAttributes\_t. buf Output The attribute value returned by this function. sizeInBytes Input Size of buf buffer (in bytes) for verification. sizeWritten Output Valid only when the return value is CUBLAS\_STATUS\_SUCCESS. If sizeInBytes is non-zero: then sizeWritten is the number of bytes actually written; if sizeInBytes is 0: then sizeWritten is the number of bytes needed to write full contents. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If sizeInBytes is 0 and sizeWritten is NULL, or if sizeInBytes is non-zero and buf is NULL, or if sizeInBytes doesn’t match size of internal storage for the selected attribute CUBLAS\_STATUS\_SUCCESS If attribute’s value was successfully written to user memory. See cublasStatus\_t for a complete list of valid return codes. 3.4.21. cublasLtMatmulAlgoConfigSetAttribute() cublasStatus\_t cublasLtMatmulAlgoConfigSetAttribute( cublasLtMatmulAlgo\_t \*algo, cublasLtMatmulAlgoConfigAttributes\_t attr, const void \*buf, size\_t sizeInBytes); This function sets the value of the specified configuration attribute for an initialized cublasLtMatmulAlgo\_t descriptor. The configuration attribute is an enumerant of the type cublasLtMatmulAlgoConfigAttributes\_t. Parameters: Parameter Memory Input / Output Description algo Input Pointer to the previously created opaque structure holding the matrix multiply algorithm descriptor. See cublasLtMatmulAlgo\_t. attr Input The configuration attribute whose value will be set by this function. See cublasLtMatmulAlgoConfigAttributes\_t. buf Input The value to which the configuration attribute should be set. sizeInBytes Input Size of buf buffer (in bytes) for verification. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If buf is NULL or sizeInBytes doesn’t match the size of the internal storage for the selected attribute. CUBLAS\_STATUS\_SUCCESS If the attribute was set successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.22. cublasLtMatmulAlgoGetHeuristic() cublasStatus\_t cublasLtMatmulAlgoGetHeuristic( cublasLtHandle\_t lightHandle, cublasLtMatmulDesc\_t operationDesc, cublasLtMatrixLayout\_t Adesc, cublasLtMatrixLayout\_t Bdesc, cublasLtMatrixLayout\_t Cdesc, cublasLtMatrixLayout\_t Ddesc, cublasLtMatmulPreference\_t preference, int requestedAlgoCount, cublasLtMatmulHeuristicResult\_t heuristicResultsArray\[\], int \*returnAlgoCount); This function retrieves the possible algorithms for the matrix multiply operation cublasLtMatmul() function with the given input matrices A, B and C, and the output matrix D. The output is placed in heuristicResultsArray\[\] in the order of increasing estimated compute time. Parameters: Parameter Memory Input / Output Description lightHandle Input Pointer to the allocated cuBLASLt handle for the cuBLASLt context. See cublasLtHandle\_t. operationDesc Input Handle to a previously created matrix multiplication descriptor of type cublasLtMatmulDesc\_t. Adesc, Bdesc, Cdesc, and Ddesc Input Handles to the previously created matrix layout descriptors of the type cublasLtMatrixLayout\_t. preference Input Pointer to the structure holding the heuristic search preferences descriptor. See cublasLtMatmulPreference\_t. requestedAlgoCount Input Size of the heuristicResultsArray (in elements). This is the requested maximum number of algorithms to return. heuristicResultsArray\[\] Output Array containing the algorithm heuristics and associated runtime characteristics, returned by this function, in the order of increasing estimated compute time. returnAlgoCount Output Number of algorithms returned by this function. This is the number of heuristicResultsArray elements written. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If requestedAlgoCount is less or equal to zero. CUBLAS\_STATUS\_NOT\_SUPPORTED If no heuristic function available for current configuration. CUBLAS\_STATUS\_SUCCESS If query was successful. Inspect heuristicResultsArray\[0 to (returnAlgoCount -1)\].state for the status of the results. See cublasStatus\_t for a complete list of valid return codes. Note This function may load some kernels using CUDA Driver API which may fail when there is no available GPU memory. Do not allocate the entire VRAM before running cublasLtMatmulAlgoGetHeuristic(). 3.4.23. cublasLtMatmulAlgoGetIds() cublasStatus\_t cublasLtMatmulAlgoGetIds( cublasLtHandle\_t lightHandle, cublasComputeType\_t computeType, cudaDataType\_t scaleType, cudaDataType\_t Atype, cudaDataType\_t Btype, cudaDataType\_t Ctype, cudaDataType\_t Dtype, int requestedAlgoCount, int algoIdsArray\[\], int \*returnAlgoCount); This function retrieves the IDs of all the matrix multiply algorithms that are valid, and can potentially be run by the cublasLtMatmul() function, for given types of the input matrices A, B and C, and of the output matrix D. Note The IDs are returned in no particular order. To make sure the best possible algo is contained in the list, make requestedAlgoCount large enough to receive the full list. The list is guaranteed to be full if returnAlgoCount < requestedAlgoCount. Parameters: Parameter Memory Input / Output Description lightHandle Input Pointer to the allocated cuBLASLt handle for the cuBLASLt context. See cublasLtHandle\_t. computeType, scaleType, Atype, Btype, Ctype, and Dtype Inputs Data types of the computation type, scaling factors and of the operand matrices. See cudaDataType\_t. requestedAlgoCount Input Number of algorithms requested. Must be > 0. algoIdsArray\[\] Output Array containing the algorithm IDs returned by this function. returnAlgoCount Output Number of algorithms actually returned by this function. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If requestedAlgoCount is less or equal to zero. CUBLAS\_STATUS\_SUCCESS If query was successful. Inspect returnAlgoCount to get actual number of IDs available. See cublasStatus\_t for a complete list of valid return codes. 3.4.24. cublasLtMatmulAlgoInit() cublasStatus\_t cublasLtMatmulAlgoInit( cublasLtHandle\_t lightHandle, cublasComputeType\_t computeType, cudaDataType\_t scaleType, cudaDataType\_t Atype, cudaDataType\_t Btype, cudaDataType\_t Ctype, cudaDataType\_t Dtype, int algoId, cublasLtMatmulAlgo\_t \*algo); This function initializes the matrix multiply algorithm structure for the cublasLtMatmul(), for a specified matrix multiply algorithm and input matrices A, B and C, and the output matrix D. Parameters: Parameter Memory Input / Output Description lightHandle Input Pointer to the allocated cuBLASLt handle for the cuBLASLt context. See cublasLtHandle\_t. computeType Input Compute type. See CUBLASLT\_MATMUL\_DESC\_COMPUTE\_TYPE of cublasLtMatmulDescAttributes\_t. scaleType Input Scale type. See CUBLASLT\_MATMUL\_DESC\_SCALE\_TYPEof cublasLtMatmulDescAttributes\_t. Usually same as computeType. Atype, Btype, Ctype, and Dtype Input Datatype precision for the input and output matrices. See cudaDataType\_t. algoId Input Specifies the algorithm being initialized. Should be a valid algoId returned by the cublasLtMatmulAlgoGetIds() function. algo Input Pointer to the opaque structure to be initialized. See cublasLtMatmulAlgo\_t. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If algo is NULL or algoId is outside the recognized range. CUBLAS\_STATUS\_NOT\_SUPPORTED If algoId is not supported for given combination of data types. CUBLAS\_STATUS\_SUCCESS If the structure was successfully initialized. See cublasStatus\_t for a complete list of valid return codes. 3.4.25. cublasLtMatmulDescCreate() cublasStatus\_t cublasLtMatmulDescCreate( cublasLtMatmulDesc\_t \*matmulDesc, cublasComputeType\_t computeType, cudaDataType\_t scaleType); This function creates a matrix multiply descriptor by allocating the memory needed to hold its opaque structure. Parameters: Parameter Memory Input / Output Description matmulDesc Output Pointer to the structure holding the matrix multiply descriptor created by this function. See cublasLtMatmulDesc\_t. computeType Input Enumerant that specifies the data precision for the matrix multiply descriptor this function creates. See cublasComputeType\_t. scaleType Input Enumerant that specifies the data precision for the matrix transform descriptor this function creates. See cudaDataType\_t. Returns: Return Value Description CUBLAS\_STATUS\_ALLOC\_FAILED If memory could not be allocated. CUBLAS\_STATUS\_SUCCESS If the descriptor was created successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.26. cublasLtMatmulDescInit() cublasStatus\_t cublasLtMatmulDescInit( cublasLtMatmulDesc\_t matmulDesc, cublasComputeType\_t computeType, cudaDataType\_t scaleType); This function initializes a matrix multiply descriptor in a previously allocated one. Parameters: Parameter Memory Input / Output Description matmulDesc Output Pointer to the structure holding the matrix multiply descriptor initialized by this function. See cublasLtMatmulDesc\_t. computeType Input Enumerant that specifies the data precision for the matrix multiply descriptor this function initializes. See cublasComputeType\_t. scaleType Input Enumerant that specifies the data precision for the matrix transform descriptor this function initializes. See cudaDataType\_t. Returns: Return Value Description CUBLAS\_STATUS\_ALLOC\_FAILED If memory could not be allocated. CUBLAS\_STATUS\_SUCCESS If the descriptor was created successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.27. cublasLtMatmulDescDestroy() cublasStatus\_t cublasLtMatmulDescDestroy( cublasLtMatmulDesc\_t matmulDesc); This function destroys a previously created matrix multiply descriptor object. Parameters: Parameter Memory Input / Output Description matmulDesc Input Pointer to the structure holding the matrix multiply descriptor that should be destroyed by this function. See cublasLtMatmulDesc\_t. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS If operation was successful. See cublasStatus\_t for a complete list of valid return codes. 3.4.28. cublasLtMatmulDescGetAttribute() cublasStatus\_t cublasLtMatmulDescGetAttribute( cublasLtMatmulDesc\_t matmulDesc, cublasLtMatmulDescAttributes\_t attr, void \*buf, size\_t sizeInBytes, size\_t \*sizeWritten); This function returns the value of the queried attribute belonging to a previously created matrix multiply descriptor. Parameters: Parameter Memory Input / Output Description matmulDesc Input Pointer to the previously created structure holding the matrix multiply descriptor queried by this function. See cublasLtMatmulDesc\_t. attr Input The attribute that will be retrieved by this function. See cublasLtMatmulDescAttributes\_t. buf Output Memory address containing the attribute value retrieved by this function. sizeInBytes Input Size of buf buffer (in bytes) for verification. sizeWritten Output Valid only when the return value is CUBLAS\_STATUS\_SUCCESS. If sizeInBytes is non-zero: then sizeWritten is the number of bytes actually written; if sizeInBytes is 0: then sizeWritten is the number of bytes needed to write full contents. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If sizeInBytes is 0 and sizeWritten is NULL, or if sizeInBytes is non-zero and buf is NULL, or sizeInBytes doesn’t match size of internal storage for the selected attribute CUBLAS\_STATUS\_SUCCESS If attribute’s value was successfully written to user memory. See cublasStatus\_t for a complete list of valid return codes. 3.4.29. cublasLtMatmulDescSetAttribute() cublasStatus\_t cublasLtMatmulDescSetAttribute( cublasLtMatmulDesc\_t matmulDesc, cublasLtMatmulDescAttributes\_t attr, const void \*buf, size\_t sizeInBytes); This function sets the value of the specified attribute belonging to a previously created matrix multiply descriptor. Parameters: Parameter Memory Input / Output Description matmulDesc Input Pointer to the previously created structure holding the matrix multiply descriptor queried by this function. See cublasLtMatmulDesc\_t. attr Input The attribute that will be set by this function. See cublasLtMatmulDescAttributes\_t. buf Input The value to which the specified attribute should be set. sizeInBytes Input Size of buf buffer (in bytes) for verification. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If buf is NULL or sizeInBytes doesn’t match the size of the internal storage for the selected attribute. CUBLAS\_STATUS\_SUCCESS If the attribute was set successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.30. cublasLtMatmulPreferenceCreate() cublasStatus\_t cublasLtMatmulPreferenceCreate( cublasLtMatmulPreference\_t \*pref); This function creates a matrix multiply heuristic search preferences descriptor by allocating the memory needed to hold its opaque structure. Parameters: Parameter Memory Input / Output Description pref Output Pointer to the structure holding the matrix multiply preferences descriptor created by this function. See cublasLtMatrixLayout\_t. Returns: Return Value Description CUBLAS\_STATUS\_ALLOC\_FAILED If memory could not be allocated. CUBLAS\_STATUS\_SUCCESS If the descriptor was created successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.31. cublasLtMatmulPreferenceInit() cublasStatus\_t cublasLtMatmulPreferenceInit( cublasLtMatmulPreference\_t pref); This function initializes a matrix multiply heuristic search preferences descriptor in a previously allocated one. Parameters: Parameter Memory Input / Output Description pref Output Pointer to the structure holding the matrix multiply preferences descriptor created by this function. See cublasLtMatrixLayout\_t. Returns: Return Value Description CUBLAS\_STATUS\_ALLOC\_FAILED If memory could not be allocated. CUBLAS\_STATUS\_SUCCESS If the descriptor was created successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.32. cublasLtMatmulPreferenceDestroy() cublasStatus\_t cublasLtMatmulPreferenceDestroy( cublasLtMatmulPreference\_t pref); This function destroys a previously created matrix multiply preferences descriptor object. Parameters: Parameter Memory Input / Output Description pref Input Pointer to the structure holding the matrix multiply preferences descriptor that should be destroyed by this function. See cublasLtMatmulPreference\_t. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS If the operation was successful. See cublasStatus\_t for a complete list of valid return codes. 3.4.33. cublasLtMatmulPreferenceGetAttribute() cublasStatus\_t cublasLtMatmulPreferenceGetAttribute( cublasLtMatmulPreference\_t pref, cublasLtMatmulPreferenceAttributes\_t attr, void \*buf, size\_t sizeInBytes, size\_t \*sizeWritten); This function returns the value of the queried attribute belonging to a previously created matrix multiply heuristic search preferences descriptor. Parameters: Parameter Memory Input / Output Description pref Input Pointer to the previously created structure holding the matrix multiply heuristic search preferences descriptor queried by this function. See cublasLtMatmulPreference\_t. attr Input The attribute that will be queried by this function. See cublasLtMatmulPreferenceAttributes\_t. buf Output Memory address containing the attribute value retrieved by this function. sizeInBytes Input Size of buf buffer (in bytes) for verification. sizeWritten Output Valid only when the return value is CUBLAS\_STATUS\_SUCCESS. If sizeInBytes is non-zero: then sizeWritten is the number of bytes actually written; if sizeInBytes is 0: then sizeWritten is the number of bytes needed to write full contents. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If sizeInBytes is 0 and sizeWritten is NULL, or if sizeInBytes is non-zero and buf is NULL, or sizeInBytes doesn’t match size of internal storage for the selected attribute CUBLAS\_STATUS\_SUCCESS If attribute’s value was successfully written to user memory. See cublasStatus\_t for a complete list of valid return codes. 3.4.34. cublasLtMatmulPreferenceSetAttribute() cublasStatus\_t cublasLtMatmulPreferenceSetAttribute( cublasLtMatmulPreference\_t pref, cublasLtMatmulPreferenceAttributes\_t attr, const void \*buf, size\_t sizeInBytes); This function sets the value of the specified attribute belonging to a previously created matrix multiply preferences descriptor. Parameters: Parameter Memory Input / Output Description pref Input Pointer to the previously created structure holding the matrix multiply preferences descriptor queried by this function. See cublasLtMatmulPreference\_t. attr Input The attribute that will be set by this function. See cublasLtMatmulPreferenceAttributes\_t. buf Input The value to which the specified attribute should be set. sizeInBytes Input Size of buf buffer (in bytes) for verification. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If buf is NULL or sizeInBytes doesn’t match the size of the internal storage for the selected attribute. CUBLAS\_STATUS\_SUCCESS If the attribute was set successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.35. cublasLtMatrixLayoutCreate() cublasStatus\_t cublasLtMatrixLayoutCreate( cublasLtMatrixLayout\_t \*matLayout, cudaDataType type, uint64\_t rows, uint64\_t cols, int64\_t ld); This function creates a matrix layout descriptor by allocating the memory needed to hold its opaque structure. Parameters: Parameter Memory Input / Output Description matLayout Output Pointer to the structure holding the matrix layout descriptor created by this function. See cublasLtMatrixLayout\_t. type Input Enumerant that specifies the data precision for the matrix layout descriptor this function creates. See cudaDataType\_t. rows, cols Input Number of rows and columns of the matrix. ld Input The leading dimension of the matrix. In column major layout, this is the number of elements to jump to reach the next column. Thus ld >= m (number of rows). Returns: Return Value Description CUBLAS\_STATUS\_ALLOC\_FAILED If the memory could not be allocated. CUBLAS\_STATUS\_SUCCESS If the descriptor was created successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.36. cublasLtMatrixLayoutInit() cublasStatus\_t cublasLtMatrixLayoutInit( cublasLtMatrixLayout\_t matLayout, cudaDataType type, uint64\_t rows, uint64\_t cols, int64\_t ld); This function initializes a matrix layout descriptor in a previously allocated one. Parameters: Parameter Memory Input / Output Description matLayout Output Pointer to the structure holding the matrix layout descriptor initialized by this function. See cublasLtMatrixLayout\_t. type Input Enumerant that specifies the data precision for the matrix layout descriptor this function initializes. See cudaDataType\_t. rows, cols Input Number of rows and columns of the matrix. ld Input The leading dimension of the matrix. In column major layout, this is the number of elements to jump to reach the next column. Thus ld >= m (number of rows). Returns: Return Value Description CUBLAS\_STATUS\_ALLOC\_FAILED If the memory could not be allocated. CUBLAS\_STATUS\_SUCCESS If the descriptor was created successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.37. cublasLtMatrixLayoutDestroy() cublasStatus\_t cublasLtMatrixLayoutDestroy( cublasLtMatrixLayout\_t matLayout); This function destroys a previously created matrix layout descriptor object. Parameters: Parameter Memory Input / Output Description matLayout Input Pointer to the structure holding the matrix layout descriptor that should be destroyed by this function. See cublasLtMatrixLayout\_t. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS If the operation was successful. See cublasStatus\_t for a complete list of valid return codes. 3.4.38. cublasLtMatrixLayoutGetAttribute() cublasStatus\_t cublasLtMatrixLayoutGetAttribute( cublasLtMatrixLayout\_t matLayout, cublasLtMatrixLayoutAttribute\_t attr, void \*buf, size\_t sizeInBytes, size\_t \*sizeWritten); This function returns the value of the queried attribute belonging to the specified matrix layout descriptor. Parameters: Parameter Memory Input / Output Description matLayout Input Pointer to the previously created structure holding the matrix layout descriptor queried by this function. See cublasLtMatrixLayout\_t. attr Input The attribute being queried for. See cublasLtMatrixLayoutAttribute\_t. buf Output The attribute value returned by this function. sizeInBytes Input Size of buf buffer (in bytes) for verification. sizeWritten Output Valid only when the return value is CUBLAS\_STATUS\_SUCCESS. If sizeInBytes is non-zero: then sizeWritten is the number of bytes actually written; if sizeInBytes is 0: then sizeWritten is the number of bytes needed to write full contents. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If sizeInBytes is 0 and sizeWritten is NULL, or if sizeInBytes is non-zero and buf is NULL, or sizeInBytes doesn’t match size of internal storage for the selected attribute CUBLAS\_STATUS\_SUCCESS If attribute’s value was successfully written to user memory. See cublasStatus\_t for a complete list of valid return codes. 3.4.39. cublasLtMatrixLayoutSetAttribute() cublasStatus\_t cublasLtMatrixLayoutSetAttribute( cublasLtMatrixLayout\_t matLayout, cublasLtMatrixLayoutAttribute\_t attr, const void \*buf, size\_t sizeInBytes); This function sets the value of the specified attribute belonging to a previously created matrix layout descriptor. Parameters: Parameter Memory Input / Output Description matLayout Input Pointer to the previously created structure holding the matrix layout descriptor queried by this function. See cublasLtMatrixLayout\_t. attr Input The attribute that will be set by this function. See cublasLtMatrixLayoutAttribute\_t. buf Input The value to which the specified attribute should be set. sizeInBytes Input Size of buf, the attribute buffer. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If buf is NULL or sizeInBytes doesn’t match size of internal storage for the selected attribute. CUBLAS\_STATUS\_SUCCESS If attribute was set successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.40. cublasLtMatrixTransform() cublasStatus\_t cublasLtMatrixTransform( cublasLtHandle\_t lightHandle, cublasLtMatrixTransformDesc\_t transformDesc, const void \*alpha, const void \*A, cublasLtMatrixLayout\_t Adesc, const void \*beta, const void \*B, cublasLtMatrixLayout\_t Bdesc, void \*C, cublasLtMatrixLayout\_t Cdesc, cudaStream\_t stream); This function computes the matrix transformation operation on the input matrices A and B, to produce the output matrix C, according to the below operation: C = alpha\*transformation(A) + beta\*transformation(B), where A, B are input matrices, and alpha and beta are input scalars. The transformation operation is defined by the transformDesc pointer. This function can be used to change the memory order of data or to scale and shift the values. Parameters: Parameter Memory Input / Output Description lightHandle Input Pointer to the allocated cuBLASLt handle for the cuBLASLt context. See cublasLtHandle\_t. transformDesc Input Pointer to the opaque descriptor holding the matrix transformation operation. See cublasLtMatrixTransformDesc\_t. alpha, beta Device or host Input Pointers to the scalars used in the multiplication. A, B Device Input Pointers to the GPU memory associated with the corresponding descriptors Adesc and Bdesc. C Device Output Pointer to the GPU memory associated with the Cdesc descriptor. Adesc, Bdesc and Cdesc Input Handles to the previous created descriptors of the type cublasLtMatrixLayout\_t. Adesc or Bdesc can be NULL if the corresponding pointer is NULL and the corresponding scalar is zero. stream Host Input The CUDA stream where all the GPU work will be submitted. Returns: Return Value Description CUBLAS\_STATUS\_NOT\_INITIALIZED If cuBLASLt handle has not been initialized. CUBLAS\_STATUS\_INVALID\_VALUE If the parameters are in conflict or in an impossible configuration. For example, when A is not NULL, but Adesc is NULL. CUBLAS\_STATUS\_NOT\_SUPPORTED If the current implementation on the selected device does not support the configured operation. CUBLAS\_STATUS\_ARCH\_MISMATCH If the configured operation cannot be run using the selected device. CUBLAS\_STATUS\_EXECUTION\_FAILED If CUDA reported an execution error from the device. CUBLAS\_STATUS\_SUCCESS If the operation completed successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.41. cublasLtMatrixTransformDescCreate() cublasStatus\_t cublasLtMatrixTransformDescCreate( cublasLtMatrixTransformDesc\_t \*transformDesc, cudaDataType scaleType); This function creates a matrix transform descriptor by allocating the memory needed to hold its opaque structure. Parameters: Parameter Memory Input / Output Description transformDesc Output Pointer to the structure holding the matrix transform descriptor created by this function. See cublasLtMatrixTransformDesc\_t. scaleType Input Enumerant that specifies the data precision for the matrix transform descriptor this function creates. See cudaDataType\_t. Returns: Return Value Description CUBLAS\_STATUS\_ALLOC\_FAILED If memory could not be allocated. CUBLAS\_STATUS\_SUCCESS If the descriptor was created successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.42. cublasLtMatrixTransformDescInit() cublasStatus\_t cublasLtMatrixTransformDescInit( cublasLtMatrixTransformDesc\_t transformDesc, cudaDataType scaleType); This function initializes a matrix transform descriptor in a previously allocated one. Parameters: Parameter Memory Input / Output Description transformDesc Output Pointer to the structure holding the matrix transform descriptor initialized by this function. See cublasLtMatrixTransformDesc\_t. scaleType Input Enumerant that specifies the data precision for the matrix transform descriptor this function initializes. See cudaDataType\_t. Returns: Return Value Description CUBLAS\_STATUS\_ALLOC\_FAILED If memory could not be allocated. CUBLAS\_STATUS\_SUCCESS If the descriptor was created successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.43. cublasLtMatrixTransformDescDestroy() cublasStatus\_t cublasLtMatrixTransformDescDestroy( cublasLtMatrixTransformDesc\_t transformDesc); This function destroys a previously created matrix transform descriptor object. Parameters: Parameter Memory Input / Output Description transformDesc Input Pointer to the structure holding the matrix transform descriptor that should be destroyed by this function. See cublasLtMatrixTransformDesc\_t. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS If the operation was successful. See cublasStatus\_t for a complete list of valid return codes. 3.4.44. cublasLtMatrixTransformDescGetAttribute() cublasStatus\_t cublasLtMatrixTransformDescGetAttribute( cublasLtMatrixTransformDesc\_t transformDesc, cublasLtMatrixTransformDescAttributes\_t attr, void \*buf, size\_t sizeInBytes, size\_t \*sizeWritten); This function returns the value of the queried attribute belonging to a previously created matrix transform descriptor. Parameters: Parameter Memory Input / Output Description transformDesc Input Pointer to the previously created structure holding the matrix transform descriptor queried by this function. See cublasLtMatrixTransformDesc\_t. attr Input The attribute that will be retrieved by this function. See cublasLtMatrixTransformDescAttributes\_t. buf Output Memory address containing the attribute value retrieved by this function. sizeInBytes Input Size of buf buffer (in bytes) for verification. sizeWritten Output Valid only when the return value is CUBLAS\_STATUS\_SUCCESS. If sizeInBytes is non-zero: then sizeWritten is the number of bytes actually written; if sizeInBytes is 0: then sizeWritten is the number of bytes needed to write full contents. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If sizeInBytes is zero and sizeWritten is NULL, or if sizeInBytes is non-zero and buf is NULL, or if sizeInBytes doesn’t match size of internal storage for the selected attribute CUBLAS\_STATUS\_SUCCESS If attribute’s value was successfully written to user memory. See cublasStatus\_t for a complete list of valid return codes. 3.4.45. cublasLtMatrixTransformDescSetAttribute() cublasStatus\_t cublasLtMatrixTransformDescSetAttribute( cublasLtMatrixTransformDesc\_t transformDesc, cublasLtMatrixTransformDescAttributes\_t attr, const void \*buf, size\_t sizeInBytes); This function sets the value of the specified attribute belonging to a previously created matrix transform descriptor. Parameters: Parameter Memory Input / Output Description transformDesc Input Pointer to the previously created structure holding the matrix transform descriptor queried by this function. See cublasLtMatrixTransformDesc\_t. attr Input The attribute that will be set by this function. See cublasLtMatrixTransformDescAttributes\_t. buf Input The value to which the specified attribute should be set. sizeInBytes Input Size of buf buffer (in bytes) for verification. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If buf is NULL or sizeInBytes does not match size of the internal storage for the selected attribute. CUBLAS\_STATUS\_SUCCESS If the attribute was set successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.46. cublasLtEmulationDescInit() cublasStatus\_t cublasLtEmulationDescInit(cublasLtEmulationDesc\_t emulationDesc); This function initializes a previously allocated emulation descriptor. Parameters: Parameter Memory Input / Output Description emulationDesc Input Pointer to the previously created structure holding the emulation descriptor queried by this function. See cublasLtEmulationDesc\_t. Returns: Return Value Description CUBLAS\_STATUS\_ALLOC\_FAILED If the size of the pre-allocated space is insufficient. CUBLAS\_STATUS\_SUCCESS If the descriptor was created successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.47. cublasLtEmulationDescCreate() cublasStatus\_t cublasLtEmulationDescCreate(cublasLtEmulationDesc\_t\* emulationDesc); This function creates a new emulation descriptor. Parameters: Parameter Memory Input / Output Description emulationDesc Input Pointer to the previously created structure holding the emulation descriptor queried by this function. See cublasLtEmulationDesc\_t. Returns: Return Value Description CUBLAS\_STATUS\_ALLOC\_FAILED If memory could not be allocated. CUBLAS\_STATUS\_SUCCESS If the descriptor was created successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.48. cublasLtEmulationDescDestroy() cublasStatus\_t cublasLtEmulationDescDestroy(cublasLtEmulationDesc\_t emulationDesc); This function destroys a previously created emulation descriptor. Parameters: Parameter Memory Input / Output Description emulationDesc Input Pointer to the previously created structure holding the emulation descriptor queried by this function. See cublasLtEmulationDesc\_t. Returns: Return Value Description CUBLAS\_STATUS\_SUCCESS If the descriptor was destroyed successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.49. cublasLtEmulationDescSetAttribute() cublasStatus\_t cublasLtEmulationDescSetAttribute( cublasLtEmulationDesc\_t emulationDesc, cublasLtEmulationDescAttributes\_t attr, const void \*buf, size\_t sizeInBytes); This function sets the value of the specified attribute belonging to a previously created emulation descriptor. Parameters: Parameter Memory Input / Output Description emulationDesc Input Pointer to the previously created structure holding the emulation descriptor queried by this function. See cublasLtEmulationDesc\_t. attr Input The attribute that will be set by this function. See cublasLtEmulationDescAttributes\_t. buf Input The value to which the specified attribute should be set. sizeInBytes Input Size of buf buffer (in bytes) for verification. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If buf is NULL or sizeInBytes does not match size of the internal storage for the selected attribute. CUBLAS\_STATUS\_SUCCESS If the attribute was set successfully. See cublasStatus\_t for a complete list of valid return codes. 3.4.50. cublasLtEmulationDescGetAttribute() cublasStatus\_t cublasLtEmulationDescGetAttribute( cublasLtEmulationDesc\_t emulationDesc, cublasLtEmulationDescAttributes\_t attr, void \*buf, size\_t sizeInBytes, size\_t \*sizeWritten); This function returns the value of the queried attribute belonging to a previously created emulation descriptor. Parameters: Parameter Memory Input / Output Description emulationDesc Input Pointer to the previously created structure holding the emulation descriptor queried by this function. See cublasLtEmulationDesc\_t. attr Input The attribute that will be retrieved by this function. See cublasLtEmulationDescAttributes\_t. buf Output Memory address containing the attribute value retrieved by this function. sizeInBytes Input Size of buf buffer (in bytes) for verification. sizeWritten Output Valid only when the return value is CUBLAS\_STATUS\_SUCCESS. If sizeInBytes is non-zero: then sizeWritten is the number of bytes actually written; If sizeInBytes is 0: then sizeWritten is the number of bytes needed to write full contents. Returns: Return Value Description CUBLAS\_STATUS\_INVALID\_VALUE If sizeInBytes is zero and sizeWritten is NULL, or if sizeInBytes is non-zero and buf is NULL, or if sizeInBytes doesn’t match size of internal storage for the selected attribute CUBLAS\_STATUS\_SUCCESS If attribute’s value was successfully written to user memory. 4. Using the cuBLASXt API 4.1. General description The cuBLASXt API of cuBLAS exposes a multi-GPU capable host interface: when using this API the application only needs to allocate the required matrices on the host memory space. Additionally, the current implementation supports managed memory on Linux with GPU devices that have compute capability 6.x or greater but treats it as host memory. Managed memory is not supported on Windows. There are no restriction on the sizes of the matrices as long as they can fit into the host memory. The cuBLASXt API takes care of allocating the memory across the designated GPUs and dispatched the workload between them and finally retrieves the results back to the host. The cuBLASXt API supports only the compute-intensive BLAS3 routines (e.g matrix-matrix operations) where the PCI transfers back and forth from the GPU can be amortized. The cuBLASXt API has its own header file cublasXt.h. Starting with release 8.0, cuBLASXt API allows any of the matrices to be located on a GPU device. Note When providing matrices allocated on the GPU using the Stream Ordered Memory Allocator, ensure visibility across all devices by using cudaMemPoolSetAccess. Note The cuBLASXt API is only supported on 64-bit platforms. 4.1.1. Tiling design approach To be able to share the workload between multiple GPUs, the cuBLASXt API uses a tiling strategy: every matrix is divided in square tiles of user-controllable dimension BlockDim x BlockDim. The resulting matrix tiling defines the static scheduling policy: each resulting tile is affected to a GPU in a round robin fashion One CPU thread is created per GPU and is responsible to do the proper memory transfers and cuBLAS operations to compute all the tiles that it is responsible for. From a performance point of view, due to this static scheduling strategy, it is better that compute capabilities and PCI bandwidth are the same for every GPU. The figure below illustrates the tiles distribution between 3 GPUs. To compute the first tile G0 from C, the CPU thread 0 responsible of GPU0, have to load 3 tiles from the first row of A and tiles from the first column of B in a pipeline fashion in order to overlap memory transfer and computations and sum the results into the first tile G0 of C before to move on to the next tile G0. Example of cublasXt gemm() tiling for 3 Gpus When the tile dimension is not an exact multiple of the dimensions of C, some tiles are partially filled on the right border or/and the bottom border. The current implementation does not pad the incomplete tiles but simply keep track of those incomplete tiles by doing the right reduced cuBLAS operations: this way, no extra computation is done. However it still can lead to some load unbalance when all GPUS do not have the same number of incomplete tiles to work on. When one or more matrices are located on some GPU devices, the same tiling approach and workload sharing is applied. The memory transfers are in this case done between devices. However, when the computation of a tile and some data are located on the same GPU device, the memory transfer to/from the local data into tiles is bypassed and the GPU operates directly on the local data. This can lead to a significant performance increase, especially when only one GPU is used for the computation. The matrices can be located on any GPU device, and do not have to be located on the same GPU device. Furthermore, the matrices can even be located on a GPU device that do not participate to the computation. On the contrary of the cuBLAS API, even if all matrices are located on the same device, the cuBLASXt API is still a blocking API from the host point of view: the data results wherever located will be valid on the call return and no device synchronization is required. 4.1.2. Hybrid CPU-GPU computation In the case of very large problems, the cuBLASXt API offers the possibility to offload some of the computation to the host CPU. This feature can be setup with the routines cublasXtSetCpuRoutine() and cublasXtSetCpuRatio() The workload affected to the CPU is put aside: it is simply a percentage of the resulting matrix taken from the bottom and the right side whichever dimension is bigger. The GPU tiling is done after that on the reduced resulting matrix. If any of the matrices is located on a GPU device, the feature is ignored and all computation will be done only on the GPUs This feature should be used with caution because it could interfere with the CPU threads responsible of feeding the GPUs. Currently, only the routine cublasXt gemm() supports this feature. 4.1.3. Results reproducibility Currently all cuBLASXt API routines from a given toolkit version, generate the same bit-wise results when the following conditions are respected: all GPUs participating to the computation have the same compute capabilities and the same number of SMs. the tiles size is kept the same between run. either the CPU hybrid computation is not used or the CPU Blas provided is also guaranteed to produce reproducible results. 4.2. cuBLASXt API Datatypes Reference 4.2.1. cublasXtHandle\_t The cublasXtHandle\_t type is a pointer type to an opaque structure holding the cuBLASXt API context. The cuBLASXt API context must be initialized using cublasXtCreate() and the returned handle must be passed to all subsequent cuBLASXt API function calls. The context should be destroyed at the end using cublasXtDestroy(). 4.2.2. cublasXtOpType\_t The cublasOpType\_t enumerates the four possible types supported by BLAS routines. This enum is used as parameters of the routines cublasXtSetCpuRoutine and cublasXtSetCpuRatio to setup the hybrid configuration. Value Meaning CUBLASXT\_FLOAT float or single precision type CUBLASXT\_DOUBLE double precision type CUBLASXT\_COMPLEX single precision complex CUBLASXT\_DOUBLECOMPLEX double precision complex 4.2.3. cublasXtBlasOp\_t The cublasXtBlasOp\_t type enumerates the BLAS3 or BLAS-like routine supported by cuBLASXt API. This enum is used as parameters of the routines cublasXtSetCpuRoutine and cublasXtSetCpuRatio to setup the hybrid configuration. Value Meaning CUBLASXT\_GEMM GEMM routine CUBLASXT\_SYRK SYRK routine CUBLASXT\_HERK HERK routine CUBLASXT\_SYMM SYMM routine CUBLASXT\_HEMM HEMM routine CUBLASXT\_TRSM TRSM routine CUBLASXT\_SYR2K SYR2K routine CUBLASXT\_HER2K HER2K routine CUBLASXT\_SPMM SPMM routine CUBLASXT\_SYRKX SYRKX routine CUBLASXT\_HERKX HERKX routine 4.2.4. cublasXtPinningMemMode\_t The type is used to enable or disable the Pinning Memory mode through the routine cubasMgSetPinningMemMode Value Meaning CUBLASXT\_PINNING\_DISABLED the Pinning Memory mode is disabled CUBLASXT\_PINNING\_ENABLED the Pinning Memory mode is enabled 4.3. cuBLASXt API Helper Function Reference 4.3.1. cublasXtCreate() cublasStatus\_t cublasXtCreate(cublasXtHandle\_t \*handle) This function initializes the cuBLASXt API and creates a handle to an opaque structure holding the cuBLASXt API context. It allocates hardware resources on the host and device and must be called prior to making any other cuBLASXt API calls. Return Value Meaning CUBLAS\_STATUS\_SUCCESS the initialization succeeded CUBLAS\_STATUS\_ALLOC\_FAILED the resources could not be allocated CUBLAS\_STATUS\_NOT\_SUPPORTED cuBLASXt API is only supported on 64-bit platform 4.3.2. cublasXtDestroy() cublasStatus\_t cublasXtDestroy(cublasXtHandle\_t handle) This function releases hardware resources used by the cuBLASXt API context. The release of GPU resources may be deferred until the application exits. This function is usually the last call with a particular handle to the cuBLASXt API. Return Value Meaning CUBLAS\_STATUS\_SUCCESS the shut down succeeded CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized 4.3.3. cublasXtDeviceSelect() cublasXtDeviceSelect(cublasXtHandle\_t handle, int nbDevices, int deviceId\[\]) This function allows the user to provide the number of GPU devices and their respective Ids that will participate to the subsequent cuBLASXt API Math function calls. This function will create a cuBLAS context for every GPU provided in that list. Currently the device configuration is static and cannot be changed between Math function calls. In that regard, this function should be called only once after cublasXtCreate. To be able to run multiple configurations, multiple cuBLASXt API contexts should be created. Return Value Meaning CUBLAS\_STATUS\_SUCCESS User call was successful CUBLAS\_STATUS\_INVALID\_VALUE Access to at least one of the device could not be done or a cuBLAS context could not be created on at least one of the device CUBLAS\_STATUS\_ALLOC\_FAILED Some resources could not be allocated. 4.3.4. cublasXtSetBlockDim() cublasXtSetBlockDim(cublasXtHandle\_t handle, int blockDim) This function allows the user to set the block dimension used for the tiling of the matrices for the subsequent Math function calls. Matrices are split in square tiles of blockDim x blockDim dimension. This function can be called anytime and will take effect for the following Math function calls. The block dimension should be chosen in a way to optimize the math operation and to make sure that the PCI transfers are well overlapped with the computation. Return Value Meaning CUBLAS\_STATUS\_SUCCESS the call has been successful CUBLAS\_STATUS\_INVALID\_VALUE blockDim <= 0 4.3.5. cublasXtGetBlockDim() cublasXtGetBlockDim(cublasXtHandle\_t handle, int \*blockDim) This function allows the user to query the block dimension used for the tiling of the matrices. Return Value Meaning CUBLAS\_STATUS\_SUCCESS the call has been successful 4.3.6. cublasXtSetCpuRoutine() cublasXtSetCpuRoutine(cublasXtHandle\_t handle, cublasXtBlasOp\_t blasOp, cublasXtOpType\_t type, void \*blasFunctor) This function allows the user to provide a CPU implementation of the corresponding BLAS routine. This function can be used with the function cublasXtSetCpuRatio() to define an hybrid computation between the CPU and the GPUs. Currently the hybrid feature is only supported for the xGEMM routines. Return Value Meaning CUBLAS\_STATUS\_SUCCESS the call has been successful CUBLAS\_STATUS\_INVALID\_VALUE blasOp or type define an invalid combination CUBLAS\_STATUS\_NOT\_SUPPORTED CPU-GPU Hybridization for that routine is not supported 4.3.7. cublasXtSetCpuRatio() cublasXtSetCpuRatio(cublasXtHandle\_t handle, cublasXtBlasOp\_t blasOp, cublasXtOpType\_t type, float ratio ) This function allows the user to define the percentage of workload that should be done on a CPU in the context of an hybrid computation. This function can be used with the function cublasXtSetCpuRoutine() to define an hybrid computation between the CPU and the GPUs. Currently the hybrid feature is only supported for the xGEMM routines. Return Value Meaning CUBLAS\_STATUS\_SUCCESS the call has been successful CUBLAS\_STATUS\_INVALID\_VALUE blasOp or type define an invalid combination CUBLAS\_STATUS\_NOT\_SUPPORTED CPU-GPU Hybridization for that routine is not supported 4.3.8. cublasXtSetPinningMemMode() cublasXtSetPinningMemMode(cublasXtHandle\_t handle, cublasXtPinningMemMode\_t mode) This function allows the user to enable or disable the Pinning Memory mode. When enabled, the matrices passed in subsequent cuBLASXt API calls will be pinned/unpinned using the CUDART routine cudaHostRegister() and cudaHostUnregister() respectively if the matrices are not already pinned. If a matrix happened to be pinned partially, it will also not be pinned. Pinning the memory improve PCI transfer performance and allows to overlap PCI memory transfer with computation. However pinning/unpinning the memory take some time which might not be amortized. It is advised that the user pins the memory on its own using cudaMallocHost() or cudaHostRegister() and unpin it when the computation sequence is completed. By default, the Pinning Memory mode is disabled. Note The Pinning Memory mode should not be enabled when matrices used for different calls to cuBLASXt API overlap. cuBLASXt determines that a matrix is pinned or not if the first address of that matrix is pinned using cudaHostGetFlags(), thus cannot know if the matrix is already partially pinned or not. This is especially true in multi-threaded application where memory could be partially or totally pinned or unpinned while another thread is accessing that memory. Return Value Meaning CUBLAS\_STATUS\_SUCCESS the call has been successful CUBLAS\_STATUS\_INVALID\_VALUE the mode value is different from CUBLASXT\_PINNING\_DISABLED and CUBLASXT\_PINNING\_ENABLED 4.3.9. cublasXtGetPinningMemMode() cublasXtGetPinningMemMode(cublasXtHandle\_t handle, cublasXtPinningMemMode\_t \*mode) This function allows the user to query the Pinning Memory mode. By default, the Pinning Memory mode is disabled. Return Value Meaning CUBLAS\_STATUS\_SUCCESS the call has been successful 4.4. cuBLASXt API Math Functions Reference In this chapter we describe the actual Linear Algebra routines that cuBLASXt API supports. We will use abbreviations for type and for the corresponding short type to make a more concise and clear presentation of the implemented functions. Unless otherwise specified and have the following meanings:Meaning float ‘s’ or ‘S’ real single-precision double ‘d’ or ‘D’ real double-precision cuComplex ‘c’ or ‘C’ complex single-precision cuDoubleComplex ‘z’ or ‘Z’ complex double-precision The abbreviation \\(\\mathbf{Re}(\\cdot)\\) and \\(\\mathbf{Im}(\\cdot)\\) will stand for the real and imaginary part of a number, respectively. Since imaginary part of a real number does not exist, we will consider it to be zero and can usually simply discard it from the equation where it is being used. Also, the \\(\\bar{\\alpha}\\) will denote the complex conjugate of \\(\\alpha\\). In general throughout the documentation, the lower case Greek symbols \\(\\alpha\\) and \\(\\beta\\) will denote scalars, lower case English letters in bold type \\(\\mathbf{x}\\) and \\(\\mathbf{y}\\) will denote vectors and capital English letters \\(A\\), \\(B\\) and \\(C\\) will denote matrices. 4.4.1. cublasXt gemm() cublasStatus\_t cublasXtSgemm(cublasXtHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, size\_t m, size\_t n, size\_t k, const float \*alpha, const float \*A, int lda, const float \*B, int ldb, const float \*beta, float \*C, int ldc) cublasStatus\_t cublasXtDgemm(cublasXtHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const double \*alpha, const double \*A, int lda, const double \*B, int ldb, const double \*beta, double \*C, int ldc) cublasStatus\_t cublasXtCgemm(cublasXtHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*B, int ldb, const cuComplex \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasXtZgemm(cublasXtHandle\_t handle, cublasOperation\_t transa, cublasOperation\_t transb, int m, int n, int k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*B, int ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*C, int ldc) This function performs the matrix-matrix multiplication \\(C = \\alpha\\text{op}(A)\\text{op}(B) + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, and \\(A\\), \\(B\\) and \\(C\\) are matrices stored in column-major format with dimensions \\(\\text{op}(A)\\) \\(m \\times k\\), \\(\\text{op}(B)\\) \\(k \\times n\\) and \\(C\\) \\(m \\times n\\), respectively. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) and \\(\\text{op}(B)\\) is defined similarly for matrix \\(B\\). Param. Memory In/out Meaning handle input handle to the cuBLASXt API context. transa input operation op(A) that is non- or (conj.) transpose. transb input operation op(B) that is non- or (conj.) transpose. m input number of rows of matrix op(A) and C. n input number of columns of matrix op(B) and C. k input number of columns of op(A) and rows of op(B). alpha host input scalar used for multiplication. A host or device input array of dimensions lda x k with lda >= max(1, m) if transa == CUBLAS\_OP\_N and lda x m with lda >= max(1, k) otherwise. lda input leading dimension of two-dimensional array used to store the matrix A. B host or device input array of dimension ldb x n with ldb >= max(1, k) if transb == CUBLAS\_OP\_N and ldb x k with ldb >= max(1, n) otherwise. ldb input leading dimension of two-dimensional array used to store matrix B. beta host input scalar used for multiplication. If beta == 0, C does not have to be a valid input. C host or device in/out array of dimensions ldc x n with ldc >= max(1, m). ldc input leading dimension of a two-dimensional array used to store the matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE the parameters m,n,k<0 CUBLAS\_STATUS\_EXECUTION\_FAILED the function failed to launch on the GPU For references please refer to NETLIB documentation: sgemm(), dgemm(), cgemm(), zgemm() 4.4.2. cublasXt hemm() cublasStatus\_t cublasXtChemm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, size\_t m, size\_t n, const cuComplex \*alpha, const cuComplex \*A, size\_t lda, const cuComplex \*B, size\_t ldb, const cuComplex \*beta, cuComplex \*C, size\_t ldc) cublasStatus\_t cublasXtZhemm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, size\_t m, size\_t n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, size\_t lda, const cuDoubleComplex \*B, size\_t ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*C, size\_t ldc) This function performs the Hermitian matrix-matrix multiplication \\(C = \\left\\{ \\begin{matrix} {\\alpha AB + \\beta C} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_LEFT}$}} \\\\ {\\alpha BA + \\beta C} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_RIGHT}$}} \\\\ \\end{matrix} \\right.\\) where \\(A\\) is a Hermitian matrix stored in lower or upper mode, \\(B\\) and \\(C\\) are \\(m \\times n\\) matrices, and \\(\\alpha\\) and \\(\\beta\\) are scalars. Param. Memory In/out Meaning handle input handle to the cuBLASXt API context. side input indicates if matrix A is on the left or right of B. uplo input indicates if matrix A lower or upper part is stored, the other Hermitian part is not referenced and is inferred from the stored elements. m input number of rows of matrix C and B, with matrix A sized accordingly. n input number of columns of matrix C and B, with matrix A sized accordingly. alpha host input scalar used for multiplication. A host or device input array of dimension lda x m with lda >= max(1, m) if side = CUBLAS\_SIDE\_LEFT and lda x n with lda >= max(1, n) otherwise. The imaginary parts of the diagonal elements are assumed to be zero. lda input leading dimension of two-dimensional array used to store matrix A. B host or device input array of dimension ldb x n with ldb >= max(1, m). ldb input leading dimension of two-dimensional array used to store matrix B. beta host input scalar used for multiplication, if beta == 0 then C does not have to be a valid input. C host or device in/out array of dimensions ldc x n with ldc >= max(1, m). ldc input leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE the parameters m < 0 or n < 0 CUBLAS\_STATUS\_EXECUTION\_FAILED the function failed to launch on the GPU For references please refer to NETLIB documentation: chemm(), zhemm() 4.4.3. cublasXt symm() cublasStatus\_t cublasXtSsymm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, size\_t m, size\_t n, const float \*alpha, const float \*A, size\_t lda, const float \*B, size\_t ldb, const float \*beta, float \*C, size\_t ldc) cublasStatus\_t cublasXtDsymm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, size\_t m, size\_t n, const double \*alpha, const double \*A, size\_t lda, const double \*B, size\_t ldb, const double \*beta, double \*C, size\_t ldc) cublasStatus\_t cublasXtCsymm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, size\_t m, size\_t n, const cuComplex \*alpha, const cuComplex \*A, size\_t lda, const cuComplex \*B, size\_t ldb, const cuComplex \*beta, cuComplex \*C, size\_t ldc) cublasStatus\_t cublasXtZsymm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, size\_t m, size\_t n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, size\_t lda, const cuDoubleComplex \*B, size\_t ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*C, size\_t ldc) This function performs the symmetric matrix-matrix multiplication \\(C = \\left\\{ \\begin{matrix} {\\alpha AB + \\beta C} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_LEFT}$}} \\\\ {\\alpha BA + \\beta C} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_RIGHT}$}} \\\\ \\end{matrix} \\right.\\) where \\(A\\) is a symmetric matrix stored in lower or upper mode, \\(A\\) and \\(A\\) are \\(m \\times n\\) matrices, and \\(\\alpha\\) and \\(\\beta\\) are scalars. Param. Memory In/out Meaning handle input handle to the cuBLASXt API context. side input indicates if matrix A is on the left or right of B. uplo input indicates if matrix A lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. m input number of rows of matrix A and B, with matrix A sized accordingly. n input number of columns of matrix C and A, with matrix A sized accordingly. alpha host input scalar used for multiplication. A host or device input array of dimension lda x m with lda >= max(1, m) if side == CUBLAS\_SIDE\_LEFT and lda x n with lda >= max(1, n) otherwise. lda input leading dimension of two-dimensional array used to store matrix A. B host or device input array of dimension ldb x n with ldb >= max(1, m). ldb input leading dimension of two-dimensional array used to store matrix B. beta host input scalar used for multiplication, if beta == 0 then C does not have to be a valid input. C host or device in/out array of dimension ldc x n with ldc >= max(1, m). ldc input leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE the parameters m < 0 or n < 0 CUBLAS\_STATUS\_EXECUTION\_FAILED the function failed to launch on the GPU For references please refer to NETLIB documentation: ssymm(), dsymm(), csymm(), zsymm() 4.4.4. cublasXt syrk() cublasStatus\_t cublasXtSsyrk(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const float \*alpha, const float \*A, int lda, const float \*beta, float \*C, int ldc) cublasStatus\_t cublasXtDsyrk(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const double \*alpha, const double \*A, int lda, const double \*beta, double \*C, int ldc) cublasStatus\_t cublasXtCsyrk(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuComplex \*alpha, const cuComplex \*A, int lda, const cuComplex \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasXtZsyrk(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, int lda, const cuDoubleComplex \*beta, cuDoubleComplex \*C, int ldc) This function performs the symmetric rank- \\(k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(A)^{T} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a symmetric matrix stored in lower or upper mode, and \\(A\\) is a matrix with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\). Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ \\end{matrix} \\right.\\) Param. Memory In/out Meaning handle input handle to the cuBLASXt API context. uplo input indicates if matrix C lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. trans input operation op(A) that is non- or transpose. n input number of rows of matrix op(A) and C. k input number of columns of matrix op(A). alpha host input scalar used for multiplication. A host or device input array of dimension lda x k with lda >= max(1, n) if trans == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. lda input leading dimension of two-dimensional array used to store matrix A. beta host input scalar used for multiplication, if beta == 0 then C does not have to be a valid input. C host or device in/out array of dimension ldc x n, with ldc >= max(1, n). ldc input leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE the parameters n < 0 or k < 0 CUBLAS\_STATUS\_EXECUTION\_FAILED the function failed to launch on the GPU For references please refer to NETLIB documentation: ssyrk(), dsyrk(), csyrk(), zsyrk() 4.4.5. cublasXt syr2k() cublasStatus\_t cublasXtSsyr2k(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, size\_t n, size\_t k, const float \*alpha, const float \*A, size\_t lda, const float \*B, size\_t ldb, const float \*beta, float \*C, size\_t ldc) cublasStatus\_t cublasXtDsyr2k(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, size\_t n, size\_t k, const double \*alpha, const double \*A, size\_t lda, const double \*B, size\_t ldb, const double \*beta, double \*C, size\_t ldc) cublasStatus\_t cublasXtCsyr2k(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, size\_t n, size\_t k, const cuComplex \*alpha, const cuComplex \*A, size\_t lda, const cuComplex \*B, size\_t ldb, const cuComplex \*beta, cuComplex \*C, size\_t ldc) cublasStatus\_t cublasXtZsyr2k(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, size\_t n, size\_t k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, size\_t lda, const cuDoubleComplex \*B, size\_t ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*C, size\_t ldc) This function performs the symmetric rank- \\(2k\\) update \\(C = \\alpha(\\text{op}(A)\\text{op}(B)^{T} + \\text{op}(B)\\text{op}(A)^{T}) + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a symmetric matrix stored in lower or upper mode, and \\(A\\) and \\(B\\) are matrices with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\) and \\(\\text{op}(B)\\) \\(n \\times k\\), respectively. Also, for matrix \\(A\\) and \\(B\\) \\(\\text{op(}A\\text{) and op(}B\\text{)} = \\left\\{ \\begin{matrix} {A\\text{ and }B} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ {A^{T}\\text{ and }B^{T}} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ \\end{matrix} \\right.\\) Param. Memory In/out Meaning handle input handle to the cuBLASXt API context. uplo input indicates if matrix C lower or upper part, is stored, the other symmetric part is not referenced and is inferred from the stored elements. trans input operation op(A) that is non- or transpose. n input number of rows of matrix op(A), op(B) and C. k input number of columns of matrix op(A) and op(B). alpha host input scalar used for multiplication. A host or device input array of dimension lda x k with lda >= max(1, n) if transa == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. lda input leading dimension of two-dimensional array used to store matrix A. B host or device input array of dimensions ldb x k with ldb >= max(1, n) if transb == CUBLAS\_OP\_N and ldb x n with ldb >= max(1, k) otherwise. ldb input leading dimension of two-dimensional array used to store matrix B. beta host input scalar used for multiplication, if beta == 0, then C does not have to be a valid input. C host or device in/out array of dimensions ldc x n with ldc >= max(1, n). ldc input leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE the parameters n < 0 or k < 0 CUBLAS\_STATUS\_EXECUTION\_FAILED the function failed to launch on the GPU For references please refer to NETLIB documentation: ssyr2k(), dsyr2k(), csyr2k(), zsyr2k() 4.4.6. cublasXt syrkx() cublasStatus\_t cublasXtSsyrkx(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, size\_t n, size\_t k, const float \*alpha, const float \*A, size\_t lda, const float \*B, size\_t ldb, const float \*beta, float \*C, size\_t ldc) cublasStatus\_t cublasXtDsyrkx(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, size\_t n, size\_t k, const double \*alpha, const double \*A, size\_t lda, const double \*B, size\_t ldb, const double \*beta, double \*C, size\_t ldc) cublasStatus\_t cublasXtCsyrkx(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, size\_t n, size\_t k, const cuComplex \*alpha, const cuComplex \*A, size\_t lda, const cuComplex \*B, size\_t ldb, const cuComplex \*beta, cuComplex \*C, size\_t ldc) cublasStatus\_t cublasXtZsyrkx(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, size\_t n, size\_t k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, size\_t lda, const cuDoubleComplex \*B, size\_t ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*C, size\_t ldc) This function performs a variation of the symmetric rank- \\(k\\) update \\(C = \\alpha(\\text{op}(A)\\text{op}(B)^{T} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a symmetric matrix stored in lower or upper mode, and \\(A\\) and \\(B\\) are matrices with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\) and \\(\\text{op}(B)\\) \\(n \\times k\\), respectively. Also, for matrix \\(A\\) and \\(B\\) \\(\\text{op(}A\\text{) and op(}B\\text{)} = \\left\\{ \\begin{matrix} {A\\text{ and }B} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ {A^{T}\\text{ and }B^{T}} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ \\end{matrix} \\right.\\) This routine can be used when B is in such way that the result is guaranteed to be symmetric. A usual example is when the matrix B is a scaled form of the matrix A: this is equivalent to B being the product of the matrix A and a diagonal matrix. Param. Memory In/out Meaning handle input handle to the cuBLASXt API context. uplo input indicates if matrix C lower or upper part, is stored, the other symmetric part is not referenced and is inferred from the stored elements. trans input operation op(A) that is non- or transpose. n input number of rows of matrix op(A), op(B) and C. k input number of columns of matrix op(A) and op(B). alpha host input scalar used for multiplication. A host or device input array of dimension lda x k with lda >= max(1, n) if transa == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. lda input leading dimension of two-dimensional array used to store matrix A. B host or device input array of dimensions ldb x k with ldb >= max(1, n) if transb == CUBLAS\_OP\_N and ldb x n with ldb >= max(1, k) otherwise. ldb input leading dimension of two-dimensional array used to store matrix B. beta host input scalar used for multiplication, if beta == 0, then C does not have to be a valid input. C host or device in/out array of dimensions ldc x n with ldc >= max(1, n). ldc input leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE the parameters n < 0 or k < 0 CUBLAS\_STATUS\_EXECUTION\_FAILED the function failed to launch on the GPU For references please refer to NETLIB documentation: ssyrk(), dsyrk(), csyrk(), zsyrk() and ssyr2k(), dsyr2k(), csyr2k(), zsyr2k() 4.4.7. cublasXt herk() cublasStatus\_t cublasXtCherk(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const float \*alpha, const cuComplex \*A, int lda, const float \*beta, cuComplex \*C, int ldc) cublasStatus\_t cublasXtZherk(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, int n, int k, const double \*alpha, const cuDoubleComplex \*A, int lda, const double \*beta, cuDoubleComplex \*C, int ldc) This function performs the Hermitian rank- \\(k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(A)^{H} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a Hermitian matrix stored in lower or upper mode, and \\(A\\) is a matrix with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\). Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) Param. Memory In/out Meaning handle input handle to the cuBLASXt API context. uplo input indicates if matrix C lower or upper part is stored, the other Hermitian part is not referenced. trans input operation op(A) that is non- or (conj.) transpose. n input number of rows of matrix op(A) and C. k input number of columns of matrix op(A). alpha host input scalar used for multiplication. A host or device input array of dimension lda x k with lda >= max(1, n) if transa == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. lda input leading dimension of two-dimensional array used to store matrix A. beta host input scalar used for multiplication, if beta == 0 then C does not have to be a valid input. C host or device in/out array of dimension ldc x n, with ldc >= max(1, n). The imaginary parts of the diagonal elements are assumed and set to zero. ldc input leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE the parameters n < 0 or k < 0 CUBLAS\_STATUS\_EXECUTION\_FAILED the function failed to launch on the GPU For references please refer to NETLIB documentation: cherk(), zherk() 4.4.8. cublasXt her2k() cublasStatus\_t cublasXtCher2k(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, size\_t n, size\_t k, const cuComplex \*alpha, const cuComplex \*A, size\_t lda, const cuComplex \*B, size\_t ldb, const float \*beta, cuComplex \*C, size\_t ldc) cublasStatus\_t cublasXtZher2k(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, size\_t n, size\_t k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, size\_t lda, const cuDoubleComplex \*B, size\_t ldb, const double \*beta, cuDoubleComplex \*C, size\_t ldc) This function performs the Hermitian rank- \\(2k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(B)^{H} + \\overset{ˉ}{\\alpha}\\text{op}(B)\\text{op}(A)^{H} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a Hermitian matrix stored in lower or upper mode, and \\(A\\) and \\(B\\) are matrices with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\) and \\(\\text{op}(B)\\) \\(n \\times k\\), respectively. Also, for matrix \\(A\\) and \\(B\\) \\(\\text{op(}A\\text{) and op(}B\\text{)} = \\left\\{ \\begin{matrix} {A\\text{ and }B} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ {A^{H}\\text{ and }B^{H}} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) Param. Memory In/out Meaning handle input handle to the cuBLASXt API context. uplo input indicates if matrix C lower or upper part is stored, the other Hermitian part is not referenced. trans input operation op(A) that is non- or (conj.) transpose. n input number of rows of matrix op(A), op(B) and C. k input number of columns of matrix op(A) and op(B). alpha host input scalar used for multiplication. A host or device input array of dimension lda x k with lda >= max(1, n) if transa == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. lda input leading dimension of two-dimensional array used to store matrix A. B host or device input array of dimension ldb x k with ldb >= max(1, n) if transb == CUBLAS\_OP\_N and ldb x n with ldb >= max(1, k) otherwise. ldb input leading dimension of two-dimensional array used to store matrix B. beta host input scalar used for multiplication, if beta == 0 then C does not have to be a valid input. C host or device in/out array of dimension ldc x n, with ldc >= max(1, n). The imaginary parts of the diagonal elements are assumed and set to zero. ldc input leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE the parameters n < 0 or k < 0 CUBLAS\_STATUS\_EXECUTION\_FAILED the function failed to launch on the GPU For references please refer to NETLIB documentation: cher2k(), zher2k() 4.4.9. cublasXt herkx() cublasStatus\_t cublasXtCherkx(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, size\_t n, size\_t k, const cuComplex \*alpha, const cuComplex \*A, size\_t lda, const cuComplex \*B, size\_t ldb, const float \*beta, cuComplex \*C, size\_t ldc) cublasStatus\_t cublasXtZherkx(cublasXtHandle\_t handle, cublasFillMode\_t uplo, cublasOperation\_t trans, size\_t n, size\_t k, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, size\_t lda, const cuDoubleComplex \*B, size\_t ldb, const double \*beta, cuDoubleComplex \*C, size\_t ldc) This function performs a variation of the Hermitian rank- \\(k\\) update \\(C = \\alpha\\text{op}(A)\\text{op}(B)^{H} + \\beta C\\) where \\(\\alpha\\) and \\(\\beta\\) are scalars, \\(C\\) is a Hermitian matrix stored in lower or upper mode, and \\(A\\) and \\(B\\) are matrices with dimensions \\(\\text{op}(A)\\) \\(n \\times k\\) and \\(\\text{op}(B)\\) \\(n \\times k\\), respectively. Also, for matrix \\(A\\) and \\(B\\) \\(\\text{op(}A\\text{) and op(}B\\text{)} = \\left\\{ \\begin{matrix} {A\\text{ and }B} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ {A^{H}\\text{ and }B^{H}} & {\\text{if }\\textsf{trans == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) This routine can be used when the matrix B is in such way that the result is guaranteed to be hermitian. A usual example is when the matrix B is a scaled form of the matrix A: this is equivalent to B being the product of the matrix A and a diagonal matrix. Param. Memory In/out Meaning handle input handle to the cuBLASXt API context. uplo input indicates if matrix C lower or upper part is stored, the other Hermitian part is not referenced. trans input operation op(A) that is non- or (conj.) transpose. n input number of rows of matrix op(A), op(B) and C. k input number of columns of matrix op(A) and op(B). alpha host input scalar used for multiplication. A host or device input array of dimension lda x k with lda >= max(1, n) if transa == CUBLAS\_OP\_N and lda x n with lda >= max(1, k) otherwise. lda input leading dimension of two-dimensional array used to store matrix A. B host or device input array of dimension ldb x k with ldb >= max(1, n) if transb == CUBLAS\_OP\_N and ldb x n with ldb >= max(1, k) otherwise. ldb input leading dimension of two-dimensional array used to store matrix B. beta host input real scalar used for multiplication, if beta == 0 then C does not have to be a valid input. C host or device in/out array of dimension ldc x n, with ldc >= max(1, n). The imaginary parts of the diagonal elements are assumed and set to zero. ldc input leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE the parameters n < 0 or k < 0 CUBLAS\_STATUS\_EXECUTION\_FAILED the function failed to launch on the GPU For references please refer to NETLIB documentation: cherk(), zherk() and cher2k(), zher2k() 4.4.10. cublasXt trsm() cublasStatus\_t cublasXtStrsm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasXtDiagType\_t diag, size\_t m, size\_t n, const float \*alpha, const float \*A, size\_t lda, float \*B, size\_t ldb) cublasStatus\_t cublasXtDtrsm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasXtDiagType\_t diag, size\_t m, size\_t n, const double \*alpha, const double \*A, size\_t lda, double \*B, size\_t ldb) cublasStatus\_t cublasXtCtrsm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasXtDiagType\_t diag, size\_t m, size\_t n, const cuComplex \*alpha, const cuComplex \*A, size\_t lda, cuComplex \*B, size\_t ldb) cublasStatus\_t cublasXtZtrsm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasXtDiagType\_t diag, size\_t m, size\_t n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, size\_t lda, cuDoubleComplex \*B, size\_t ldb) This function solves the triangular linear system with multiple right-hand-sides \\(\\left\\{ \\begin{matrix} {\\text{op}(A)X = \\alpha B} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_LEFT}$}} \\\\ {X\\text{op}(A) = \\alpha B} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_RIGHT}$}} \\\\ \\end{matrix} \\right.\\) where \\(A\\) is a triangular matrix stored in lower or upper mode with or without the main diagonal, \\(X\\) and \\(B\\) are \\(m \\times n\\) matrices, and \\(\\alpha\\) is a scalar. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) The solution \\(X\\) overwrites the right-hand-sides \\(B\\) on exit. No test for singularity or near-singularity is included in this function. Param. Memory In/out Meaning handle input handle to the cuBLASXt API context. side input indicates if matrix A is on the left or right of X. uplo input indicates if matrix A lower or upper part is stored, the other part is not referenced and is inferred from the stored elements. trans input operation op(A) that is non- or (conj.) transpose. diag input indicates if the elements on the main diagonal of matrix A are unity and should not be accessed. m input number of rows of matrix B, with matrix A sized accordingly. n input number of columns of matrix B, with matrix A is sized accordingly. alpha host input scalar used for multiplication, if alpha == 0 then A is not referenced and B does not have to be a valid input. A host or device input array of dimension lda x m with lda >= max(1, m) if side == CUBLAS\_SIDE\_LEFT and lda x n with lda >= max(1, n) otherwise. lda input leading dimension of two-dimensional array used to store matrix A. B host or device in/out array. It has dimensions ldb x n with ldb >= max(1, m). ldb input leading dimension of two-dimensional array used to store matrix B. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE the parameters m < 0 or n < 0 CUBLAS\_STATUS\_EXECUTION\_FAILED the function failed to launch on the GPU For references please refer to NETLIB documentation: strsm(), dtrsm(), ctrsm(), ztrsm() 4.4.11. cublasXt trmm() cublasStatus\_t cublasXtStrmm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, size\_t m, size\_t n, const float \*alpha, const float \*A, size\_t lda, const float \*B, size\_t ldb, float \*C, size\_t ldc) cublasStatus\_t cublasXtDtrmm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, size\_t m, size\_t n, const double \*alpha, const double \*A, size\_t lda, const double \*B, size\_t ldb, double \*C, size\_t ldc) cublasStatus\_t cublasXtCtrmm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, size\_t m, size\_t n, const cuComplex \*alpha, const cuComplex \*A, size\_t lda, const cuComplex \*B, size\_t ldb, cuComplex \*C, size\_t ldc) cublasStatus\_t cublasXtZtrmm(cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, cublasOperation\_t trans, cublasDiagType\_t diag, size\_t m, size\_t n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*A, size\_t lda, const cuDoubleComplex \*B, size\_t ldb, cuDoubleComplex \*C, size\_t ldc) This function performs the triangular matrix-matrix multiplication \\(C = \\left\\{ \\begin{matrix} {\\alpha\\text{op}(A)B} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_LEFT}$}} \\\\ {\\alpha B\\text{op}(A)} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_RIGHT}$}} \\\\ \\end{matrix} \\right.\\) where \\(A\\) is a triangular matrix stored in lower or upper mode with or without the main diagonal, \\(B\\) and \\(C\\) are \\(m \\times n\\) matrix, and \\(\\alpha\\) is a scalar. Also, for matrix \\(A\\) \\(\\text{op}(A) = \\left\\{ \\begin{matrix} A & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_N}$}} \\\\ A^{T} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_T}$}} \\\\ A^{H} & {\\text{if }\\textsf{transa == $\\mathrm{CUBLAS\\\_OP\\\_C}$}} \\\\ \\end{matrix} \\right.\\) Notice that in order to achieve better parallelism, similarly to the cublas API, cuBLASXt API differs from the BLAS API for this routine. The BLAS API assumes an in-place implementation (with results written back to B), while the cuBLASXt API assumes an out-of-place implementation (with results written into C). The application can still obtain the in-place functionality of BLAS in the cuBLASXt API by passing the address of the matrix B in place of the matrix C. No other overlapping in the input parameters is supported. Param. Memory In/out Meaning handle input handle to the cuBLASXt API context. side input indicates if matrix A is on the left or right of B. uplo input indicates if matrix A lower or upper part is stored, the other part is not referenced and is inferred from the stored elements. trans input operation op(A) that is non- or (conj.) transpose. diag input indicates if the elements on the main diagonal of matrix A are unity and should not be accessed. m input number of rows of matrix B, with matrix A sized accordingly. n input number of columns of matrix B, with matrix A sized accordingly. alpha host input scalar used for multiplication, if alpha then A is not referenced and B does not have to be a valid input. A host or device input array of dimension lda x m with lda >= max(1, m) if side == CUBLAS\_SIDE\_LEFT and lda x n with lda >= max(1, n) otherwise. lda input leading dimension of two-dimensional array used to store matrix A. B host or device input array of dimension ldb x n with ldb >= max(1, m). ldb input leading dimension of two-dimensional array used to store matrix B. C host or device in/out array of dimension ldc x n with ldc >= max(1, m). ldc input leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE the parameters m < 0 or n < 0 CUBLAS\_STATUS\_EXECUTION\_FAILED the function failed to launch on the GPU For references please refer to NETLIB documentation: strmm(), dtrmm(), ctrmm(), ztrmm() 4.4.12. cublasXt spmm() cublasStatus\_t cublasXtSspmm( cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, size\_t m, size\_t n, const float \*alpha, const float \*AP, const float \*B, size\_t ldb, const float \*beta, float \*C, size\_t ldc ); cublasStatus\_t cublasXtDspmm( cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, size\_t m, size\_t n, const double \*alpha, const double \*AP, const double \*B, size\_t ldb, const double \*beta, double \*C, size\_t ldc ); cublasStatus\_t cublasXtCspmm( cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, size\_t m, size\_t n, const cuComplex \*alpha, const cuComplex \*AP, const cuComplex \*B, size\_t ldb, const cuComplex \*beta, cuComplex \*C, size\_t ldc ); cublasStatus\_t cublasXtZspmm( cublasXtHandle\_t handle, cublasSideMode\_t side, cublasFillMode\_t uplo, size\_t m, size\_t n, const cuDoubleComplex \*alpha, const cuDoubleComplex \*AP, const cuDoubleComplex \*B, size\_t ldb, const cuDoubleComplex \*beta, cuDoubleComplex \*C, size\_t ldc ); This function performs the symmetric packed matrix-matrix multiplication \\(C = \\left\\{ \\begin{matrix} {\\alpha AB + \\beta C} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_LEFT}$}} \\\\ {\\alpha BA + \\beta C} & {\\text{if }\\textsf{side == $\\mathrm{CUBLAS\\\_SIDE\\\_RIGHT}$}} \\\\ \\end{matrix} \\right.\\) where \\(A\\) is a \\(n \\times n\\) symmetric matrix stored in packed format, \\(B\\) and \\(C\\) are \\(m \\times n\\) matrices, and \\(\\alpha\\) and \\(\\beta\\) are scalars. If uplo == CUBLAS\_FILL\_MODE\_LOWER then the elements in the lower triangular part of the symmetric matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+((2\*n-j+1)\*j)/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\geq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. If uplo == CUBLAS\_FILL\_MODE\_UPPER then the elements in the upper triangular part of the symmetric matrix \\(A\\) are packed together column by column without gaps, so that the element \\(A(i,j)\\) is stored in the memory location AP\[i+(j\*(j+1))/2\] for \\(j = 1,\\ldots,n\\) and \\(i \\leq j\\). Consequently, the packed format requires only \\(\\frac{n(n + 1)}{2}\\) elements for storage. Note The packed matrix AP must be located on the host or managed memory whereas the other matrices can be located on the host or any GPU device Param. Memory In/out Meaning handle input handle to the cuBLASXt API context. side input indicates if matrix A is on the left or right of B. uplo input indicates if matrix A lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements. m input number of rows of matrix A and B, with matrix A sized accordingly. n input number of columns of matrix C and A, with matrix A sized accordingly. alpha host input scalar used for multiplication. AP host input array with \\(A\\) stored in packed format. B host or device input array of dimension ldb x n with ldb >= max(1, m). ldb input leading dimension of two-dimensional array used to store matrix B. beta host input scalar used for multiplication, if beta == 0 then C does not have to be a valid input. C host or device in/out array of dimension ldc x n with ldc >= max(1, m). ldc input leading dimension of two-dimensional array used to store matrix C. The possible error values returned by this function and their meanings are listed below. Error Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_INVALID\_VALUE the parameters m < 0 or n < 0 CUBLAS\_STATUS\_NOT\_SUPPORTED the matrix AP is located on a GPU device CUBLAS\_STATUS\_EXECUTION\_FAILED the function failed to launch on the GPU For references please refer to NETLIB documentation: ssymm(), dsymm(), csymm(), zsymm() 5. Using the cuBLASDx API The cuBLASDx library (preview) is a device side API extension for performing BLAS calculations inside CUDA kernels. By fusing numerical operations you can decrease latency and further improve performance of your applications. You can access cuBLASDx documentation here. cuBLASDx is not a part of the CUDA Toolkit. You can download cuBLASDx separately from here. 6. Using the cuBLAS Legacy API This section does not provide a full reference of each Legacy API datatype and entry point. Instead, it describes how to use the API, especially where this is different from the regular cuBLAS API. Note that in this section, all references to the “cuBLAS Library” refer to the Legacy cuBLAS API only. Warning The legacy cuBLAS API is deprecated and will be removed in future release. 6.1. Error Status The cublasStatus type is used for function status returns. The cuBLAS Library helper functions return status directly, while the status of core functions can be retrieved using cublasGetError(). Notice that reading the error status via cublasGetError(), resets the internal error state to CUBLAS\_STATUS\_SUCCESS. Currently, the following values are defined: Value Meaning CUBLAS\_STATUS\_SUCCESS the operation completed successfully CUBLAS\_STATUS\_NOT\_INITIALIZED the library was not initialized CUBLAS\_STATUS\_ALLOC\_FAILED the resource allocation failed CUBLAS\_STATUS\_INVALID\_VALUE an invalid numerical value was used as an argument CUBLAS\_STATUS\_ARCH\_MISMATCH an absent device architectural feature is required CUBLAS\_STATUS\_MAPPING\_ERROR an access to GPU memory space failed CUBLAS\_STATUS\_EXECUTION\_FAILED the GPU program failed to execute CUBLAS\_STATUS\_INTERNAL\_ERROR an internal operation failed CUBLAS\_STATUS\_NOT\_SUPPORTED the feature required is not supported This legacy type corresponds to type cublasStatus\_t in the cuBLAS library API. 6.2. Initialization and Shutdown The functions cublasInit() and cublasShutdown() are used to initialize and shutdown the cuBLAS library. It is recommended for cublasInit() to be called before any other function is invoked. It allocates hardware resources on the GPU device that is currently bound to the host thread from which it was invoked. The legacy initialization and shutdown functions are similar to the cuBLAS library API routines cublasCreate() and cublasDestroy(). 6.3. Thread Safety The legacy API is not thread safe when used with multiple host threads and devices. It is recommended to be used only when utmost compatibility with Fortran is required and when a single host thread is used to setup the library and make all the functions calls. 6.4. Memory Management The memory used by the legacy cuBLAS library API is allocated and released using functions cublasAlloc() and cublasFree(), respectively. These functions create and destroy an object in the GPU memory space capable of holding an array of n elements, where each element requires elemSize bytes of storage. Please see the legacy cuBLAS API header file “cublas.h” for the prototypes of these functions. The function cublasAlloc() is a wrapper around the function cudaMalloc(), therefore device pointers returned by cublasAlloc() can be passed to any CUDA™ device kernel functions. However, these device pointers can not be dereferenced in the host code. The function cublasFree() is a wrapper around the function cudaFree(). 6.5. Scalar Parameters In the legacy cuBLAS API, scalar parameters are passed by value from the host. Also, the few functions that do return a scalar result, such as dot() and nrm2(), return the resulting value on the host, and hence these routines will wait for kernel execution on the device to complete before returning, which makes parallelism with streams impractical. However, the majority of functions do not return any value, in order to be more compatible with Fortran and the existing BLAS libraries. 6.6. Helper Functions In this section we list the helper functions provided by the legacy cuBLAS API and their functionality. For the exact prototypes of these functions please refer to the legacy cuBLAS API header file “cublas.h”. Helper function Meaning cublasInit() initialize the library cublasShutdown() shuts down the library cublasGetError() retrieves the error status of the library cublasSetKernelStream() sets the stream to be used by the library cublasAlloc() allocates the device memory for the library cublasFree() releases the device memory allocated for the library cublasSetVector() copies a vector x on the host to a vector on the GPU cublasGetVector() copies a vector x on the GPU to a vector on the host cublasSetMatrix() copies a \\(m \\times n\\) tile from a matrix on the host to the GPU cublasGetMatrix() copies a \\(m \\times n\\) tile from a matrix on the GPU to the host cublasSetVectorAsync() similar to cublasSetVector(), but the copy is asynchronous cublasGetVectorAsync() similar to cublasGetVector(), but the copy is asynchronous cublasSetMatrixAsync() similar to cublasSetMatrix(), but the copy is asynchronous cublasGetMatrixAsync() similar to cublasGetMatrix(), but the copy is asynchronous 6.7. Level-1,2,3 Functions The Level-1,2,3 cuBLAS functions (also called core functions) have the same name and behavior as the ones listed in the chapters 3, 4 and 5 in this document. Please refer to the legacy cuBLAS API header file “cublas.h” for their exact prototype. Also, the next section talks a bit more about the differences between the legacy and the cuBLAS API prototypes, more specifically how to convert the function calls from one API to another. 6.8. Converting Legacy to the cuBLAS API There are a few general rules that can be used to convert from legacy to the cuBLAS API: Exchange the header file “cublas.h” for “cublas\_v2.h”. Exchange the type cublasStatus for cublasStatus\_t. Exchange the function cublasSetKernelStream() for cublasSetStream(). Exchange the function cublasAlloc() and cublasFree() for cudaMalloc() and cudaFree(), respectively. Notice that cudaMalloc() expects the size of the allocated memory to be provided in bytes (usually simply provide n x elemSize to allocate n elements, each of size elemSize bytes). Declare the cublasHandle\_t cuBLAS library handle. Initialize the handle using cublasCreate(). Also, release the handle once finished using cublasDestroy(). Add the handle as the first parameter to all the cuBLAS library function calls. Change the scalar parameters to be passed by reference, instead of by value (usually simply adding “&” symbol in C/C++ is enough, because the parameters are passed by reference on the host by default). However, note that if the routine is running asynchronously, then the variable holding the scalar parameter cannot be changed until the kernels that the routine dispatches are completed. See the CUDA C++ Programming Guide for a detailed discussion of how to use streams. Change the parameter characters N or n (non-transpose operation), T or t (transpose operation) and C or c (conjugate transpose operation) to CUBLAS\_OP\_N, CUBLAS\_OP\_T and CUBLAS\_OP\_C, respectively. Change the parameter characters L or l (lower part filled) and U or u (upper part filled) to CUBLAS\_FILL\_MODE\_LOWER and CUBLAS\_FILL\_MODE\_UPPER, respectively. Change the parameter characters N or n (non-unit diagonal) and U or u (unit diagonal) to CUBLAS\_DIAG\_NON\_UNIT and CUBLAS\_DIAG\_UNIT, respectively. Change the parameter characters L or l (left side) and R or r (right side) to CUBLAS\_SIDE\_LEFT and CUBLAS\_SIDE\_RIGHT, respectively. If the legacy API function returns a scalar value, add an extra scalar parameter of the same type passed by reference, as the last parameter to the same function. Instead of using cublasGetError(), use the return value of the function itself to check for errors. Finally, please use the function prototypes in the header files cublas.h and cublas\_v2.h to check the code for correctness. 6.9. Examples For sample code references that use the legacy cuBLAS API please see the two examples below. They show an application written in C using the legacy cuBLAS library API with two indexing styles (Example A.1. “Application Using C and cuBLAS: 1-based indexing” and Example A.2. “Application Using C and cuBLAS: 0-based Indexing”). This application is analogous to the one using the cuBLAS library API that is shown in the Introduction chapter. Example A.1. Application Using C and cuBLAS: 1-based indexing //----------------------------------------------------------- #include #include #include #include "cublas.h" #define M 6 #define N 5 #define IDX2F(i,j,ld) ((((j)-1)\*(ld))+((i)-1)) static \_\_inline\_\_ void modify (float \*m, int ldm, int n, int p, int q, float alpha, float beta){ cublasSscal (n-q+1, alpha, &m\[IDX2F(p,q,ldm)\], ldm); cublasSscal (ldm-p+1, beta, &m\[IDX2F(p,q,ldm)\], 1); } int main (void){ int i, j; cublasStatus stat; float\* devPtrA; float\* a = 0; a = (float \*)malloc (M \* N \* sizeof (\*a)); if (!a) { printf ("host memory allocation failed"); return EXIT\_FAILURE; } for (j = 1; j <= N; j++) { for (i = 1; i <= M; i++) { a\[IDX2F(i,j,M)\] = (float)((i-1) \* M + j); } } cublasInit(); stat = cublasAlloc (M\*N, sizeof(\*a), (void\*\*)&devPtrA); if (stat!= CUBLAS\_STATUS\_SUCCESS) { printf ("device memory allocation failed"); cublasShutdown(); return EXIT\_FAILURE; } stat = cublasSetMatrix (M, N, sizeof(\*a), a, M, devPtrA, M); if (stat!= CUBLAS\_STATUS\_SUCCESS) { printf ("data download failed"); cublasFree (devPtrA); cublasShutdown(); return EXIT\_FAILURE; } modify (devPtrA, M, N, 2, 3, 16.0f, 12.0f); stat = cublasGetMatrix (M, N, sizeof(\*a), devPtrA, M, a, M); if (stat!= CUBLAS\_STATUS\_SUCCESS) { printf ("data upload failed"); cublasFree (devPtrA); cublasShutdown(); return EXIT\_FAILURE; } cublasFree (devPtrA); cublasShutdown(); for (j = 1; j <= N; j++) { for (i = 1; i <= M; i++) { printf ("%7.0f", a\[IDX2F(i,j,M)\]); } printf ("\\n"); } free(a); return EXIT\_SUCCESS; } Example A.2. Application Using C and cuBLAS: 0-based indexing //----------------------------------------------------------- #include #include #include #include "cublas.h" #define M 6 #define N 5 #define IDX2C(i,j,ld) (((j)\*(ld))+(i)) static \_\_inline\_\_ void modify (float \*m, int ldm, int n, int p, int q, float alpha, float beta){ cublasSscal (n-q, alpha, &m\[IDX2C(p,q,ldm)\], ldm); cublasSscal (ldm-p, beta, &m\[IDX2C(p,q,ldm)\], 1); } int main (void){ int i, j; cublasStatus stat; float\* devPtrA; float\* a = 0; a = (float \*)malloc (M \* N \* sizeof (\*a)); if (!a) { printf ("host memory allocation failed"); return EXIT\_FAILURE; } for (j = 0; j < N; j++) { for (i = 0; i < M; i++) { a\[IDX2C(i,j,M)\] = (float)(i \* M + j + 1); } } cublasInit(); stat = cublasAlloc (M\*N, sizeof(\*a), (void\*\*)&devPtrA); if (stat!= CUBLAS\_STATUS\_SUCCESS) { printf ("device memory allocation failed"); cublasShutdown(); return EXIT\_FAILURE; } stat = cublasSetMatrix (M, N, sizeof(\*a), a, M, devPtrA, M); if (stat!= CUBLAS\_STATUS\_SUCCESS) { printf ("data download failed"); cublasFree (devPtrA); cublasShutdown(); return EXIT\_FAILURE; } modify (devPtrA, M, N, 1, 2, 16.0f, 12.0f); stat = cublasGetMatrix (M, N, sizeof(\*a), devPtrA, M, a, M); if (stat!= CUBLAS\_STATUS\_SUCCESS) { printf ("data upload failed"); cublasFree (devPtrA); cublasShutdown(); return EXIT\_FAILURE; } cublasFree (devPtrA); cublasShutdown(); for (j = 0; j < N; j++) { for (i = 0; i < M; i++) { printf ("%7.0f", a\[IDX2C(i,j,M)\]); } printf ("\\n"); } free(a); return EXIT\_SUCCESS; } 7. cuBLAS Fortran Bindings The cuBLAS library is implemented using the C-based CUDA toolchain. Thus, it provides a C-style API. This makes interfacing to applications written in C and C++ trivial, but the library can also be used by applications written in Fortran. In particular, the cuBLAS library uses 1-based indexing and Fortran-style column-major storage for multidimensional data to simplify interfacing to Fortran applications. Unfortunately, Fortran-to-C calling conventions are not standardized and differ by platform and toolchain. In particular, differences may exist in the following areas: symbol names (capitalization, name decoration) argument passing (by value or reference) passing of string arguments (length information) passing of pointer arguments (size of the pointer) returning floating-point or compound data types (for example single-precision or complex data types) To provide maximum flexibility in addressing those differences, the cuBLAS Fortran interface is provided in the form of wrapper functions and is part of the Toolkit delivery. The C source code of those wrapper functions is located in the src directory and provided in two different forms: the thunking wrapper interface located in the file fortran\_thunking.c the direct wrapper interface located in the file fortran.c The code of one of those two files needs to be compiled into an application for it to call the cuBLAS API functions. Providing source code allows users to make any changes necessary for a particular platform and toolchain. The code in those two C files has been used to demonstrate interoperability with the compilers g77 3.2.3 and g95 0.91 on 32-bit Linux, g77 3.4.5 and g95 0.91 on 64-bit Linux, Intel Fortran 9.0 and Intel Fortran 10.0 on 32-bit and 64-bit Microsoft Windows XP, and g77 3.4.0 and g95 0.92 on Mac OS X. Note that for g77, use of the compiler flag -fno-second-underscore is required to use these wrappers as provided. Also, the use of the default calling conventions with regard to argument and return value passing is expected. Using the flag -fno-f2c changes the default calling convention with respect to these two items. The thunking wrappers allow interfacing to existing Fortran applications without any changes to the application. During each call, the wrappers allocate GPU memory, copy source data from CPU memory space to GPU memory space, call cuBLAS, and finally copy back the results to CPU memory space and deallocate the GPU memory. As this process causes very significant call overhead, these wrappers are intended for light testing, not for production code. To use the thunking wrappers, the application needs to be compiled with the file fortran\_thunking.c. The direct wrappers, intended for production code, substitute device pointers for vector and matrix arguments in all BLAS functions. To use these interfaces, existing applications need to be modified slightly to allocate and deallocate data structures in GPU memory space (using cuBLAS\_ALLOC and cuBLAS\_FREE) and to copy data between GPU and CPU memory spaces (using cuBLAS\_SET\_VECTOR, cuBLAS\_GET\_VECTOR, cuBLAS\_SET\_MATRIX, and cuBLAS\_GET\_MATRIX). The sample wrappers provided in fortran.c map device pointers to the OS-dependent type size\_t, which is 32-bit wide on 32-bit platforms and 64-bit wide on a 64-bit platforms. One approach to deal with index arithmetic on device pointers in Fortran code is to use C-style macros, and use the C preprocessor to expand these, as shown in the example below. On Linux and Mac OS X, one way of pre-processing is to use the option -E -x f77-cpp-input when using g77 compiler, or simply the option -cpp when using g95 or gfortran. On Windows platforms with Microsoft Visual C/C++, using ’cl -EP’ achieves similar results.! Example B.1. Fortran 77 Application Executing on the Host! ---------------------------------------------------------- subroutine modify ( m, ldm, n, p, q, alpha, beta ) implicit none integer ldm, n, p, q real\*4 m (ldm, \*), alpha, beta external cublas\_sscal call cublas\_sscal (n-p+1, alpha, m(p,q), ldm) call cublas\_sscal (ldm-p+1, beta, m(p,q), 1) return end program matrixmod implicit none integer M,N parameter (M=6, N=5) real\*4 a(M,N) integer i, j external cublas\_init external cublas\_shutdown do j = 1, N do i = 1, M a(i, j) = (i-1)\*M + j enddo enddo call cublas\_init call modify ( a, M, N, 2, 3, 16.0, 12.0 ) call cublas\_shutdown do j = 1, N do i = 1, M write(\*,"(F7.0$)") a(i,j) enddo write (\*,\*) "" enddo stop end When traditional fixed-form Fortran 77 code is ported to use the cuBLAS library, line length often increases when the BLAS calls are exchanged for cuBLAS calls. Longer function names and possible macro expansion are contributing factors. Inadvertently exceeding the maximum line length can lead to run-time errors that are difficult to find, so care should be taken not to exceed the 72-column limit if fixed form is retained. The examples in this chapter show a small application implemented in Fortran 77 on the host and the same application with the non-thunking wrappers after it has been ported to use the cuBLAS library. The second example should be compiled with ARCH\_64 defined as 1 on 64-bit OS system and as 0 on 32-bit OS system. For example for g95 or gfortran, this can be done directly on the command line by using the option -cpp -DARCH\_64=1.! Example B.2. Same Application Using Non-thunking cuBLAS Calls!------------------------------------------------------------- #define IDX2F(i,j,ld) ((((j)-1)\*(ld))+((i)-1)) subroutine modify ( devPtrM, ldm, n, p, q, alpha, beta ) implicit none integer sizeof\_real parameter (sizeof\_real=4) integer ldm, n, p, q #if ARCH\_64 integer\*8 devPtrM #else integer\*4 devPtrM #endif real\*4 alpha, beta call cublas\_sscal ( n-p+1, alpha, 1 devPtrM+IDX2F(p, q, ldm)\*sizeof\_real, 2 ldm) call cublas\_sscal(ldm-p+1, beta, 1 devPtrM+IDX2F(p, q, ldm)\*sizeof\_real, 2 1) return end program matrixmod implicit none integer M,N,sizeof\_real #if ARCH\_64 integer\*8 devPtrA #else integer\*4 devPtrA #endif parameter(M=6,N=5,sizeof\_real=4) real\*4 a(M,N) integer i,j,stat external cublas\_init, cublas\_set\_matrix, cublas\_get\_matrix external cublas\_shutdown, cublas\_alloc integer cublas\_alloc, cublas\_set\_matrix, cublas\_get\_matrix do j=1,N do i=1,M a(i,j)=(i-1)\*M+j enddo enddo call cublas\_init stat= cublas\_alloc(M\*N, sizeof\_real, devPtrA) if (stat.NE.0) then write(\*,\*) "device memory allocation failed" call cublas\_shutdown stop endif stat = cublas\_set\_matrix(M,N,sizeof\_real,a,M,devPtrA,M) if (stat.NE.0) then call cublas\_free( devPtrA ) write(\*,\*) "data download failed" call cublas\_shutdown stop endif — — Code block continues below. Space added for formatting purposes. — — call modify(devPtrA, M, N, 2, 3, 16.0, 12.0) stat = cublas\_get\_matrix(M, N, sizeof\_real, devPtrA, M, a, M ) if (stat.NE.0) then call cublas\_free ( devPtrA ) write(\*,\*) "data upload failed" call cublas\_shutdown stop endif call cublas\_free ( devPtrA ) call cublas\_shutdown do j = 1, N do i = 1, M write (\*,"(F7.0$)") a(i,j) enddo write (\*,\*) "" enddo stop end 8. Interaction with Other Libraries and Tools This section describes important requirements and recommendations that ensure correct use of cuBLAS with other libraries and utilities. 8.1. nvprune nvprune enables pruning relocatable host objects and static libraries to only contain device code for the specific target architectures. In case of cuBLAS, particular care must be taken if using nvprune with compute capabilities, whose minor revision number is different than 0. To reduce binary size, cuBLAS may only store major revision equivalents of CUDA binary files for kernels reused between different minor revision versions. Therefore, to ensure that a pruned library does not fail for arbitrary problems, the user must keep binaries for a selected architecture and all prior minor architectures in its major architecture. For example, the following call prunes libcublas\_static.a to contain only sm\_75 (Turing) and sm\_70 (Volta) cubins: nvprune --generate-code code=sm\_70 --generate-code code=sm\_75 libcublasLt\_static.a -o libcublasLt\_static\_sm70\_sm75.a which should be used instead of: nvprune -arch=sm\_75 libcublasLt\_static.a -o libcublasLt\_static\_sm75.a 9. Acknowledgements NVIDIA would like to thank the following individuals and institutions for their contributions: Portions of the SGEMM, DGEMM, CGEMM and ZGEMM library routines were written by Vasily Volkov of the University of California. Portions of the SGEMM, DGEMM and ZGEMM library routines were written by Davide Barbieri of the University of Rome Tor Vergata. Portions of the DGEMM and SGEMM library routines optimized for Fermi architecture were developed by the University of Tennessee. Subsequently, several other routines that are optimized for the Fermi architecture have been derived from these initial DGEMM and SGEMM implementations. The substantial optimizations of the STRSV, DTRSV, CTRSV and ZTRSV library routines were developed by Jonathan Hogg of The Science and Technology Facilities Council (STFC). Subsequently, some optimizations of the STRSM, DTRSM, CTRSM and ZTRSM have been derived from these TRSV implementations. Substantial optimizations of the SYMV and HEMV library routines were developed by Ahmad Abdelfattah, David Keyes and Hatem Ltaief of King Abdullah University of Science and Technology (KAUST). Substantial optimizations of the TRMM and TRSM library routines were developed by Ali Charara, David Keyes and Hatem Ltaief of King Abdullah University of Science and Technology (KAUST). This product includes {fmt} - A modern formatting library https://fmt.devCopyright (c) 2012 - present, Victor Zverovich. This product includes spdlog - Fast C++ logging library. https://github.com/gabime/spdlog The MIT License (MIT). This product includes SIMD Library for Evaluating Elementary Functions, vectorized libm and DFT https://sleef.orgBoost Software License - Version 1.0 - August 17th, 2003. This product includes Frozen - a header-only, constexpr alternative to gperf for C++14 users. https://github.com/serge-sans-paille/frozen Apache License - Version 2.0, January 2004. This product includes Boost C++ Libraries - free peer-reviewed portable C++ source libraries https://www.boost.org/ Boost Software License - Version 1.0 - August 17th, 2003. This product includes Zstandard - a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios. https://github.com/facebook/zstd The BSD License. 10. Notices 10.1. Notice This document is provided for information purposes only and shall not be regarded as a warranty of a certain functionality, condition, or quality of a product. NVIDIA Corporation (“NVIDIA”) makes no representations or warranties, expressed or implied, as to the accuracy or completeness of the information contained in this document and assumes no responsibility for any errors contained herein. NVIDIA shall have no liability for the consequences or use of such information or for any infringement of patents or other rights of third parties that may result from its use. This document is not a commitment to develop, release, or deliver any Material (defined below), code, or functionality. NVIDIA reserves the right to make corrections, modifications, enhancements, improvements, and any other changes to this document, at any time without notice. Customer should obtain the latest relevant information before placing orders and should verify that such information is current and complete. NVIDIA products are sold subject to the NVIDIA standard terms and conditions of sale supplied at the time of order acknowledgement, unless otherwise agreed in an individual sales agreement signed by authorized representatives of NVIDIA and customer (“Terms of Sale”). NVIDIA hereby expressly objects to applying any customer general terms and conditions with regards to the purchase of the NVIDIA product referenced in this document. No contractual obligations are formed either directly or indirectly by this document. NVIDIA products are not designed, authorized, or warranted to be suitable for use in medical, military, aircraft, space, or life support equipment, nor in applications where failure or malfunction of the NVIDIA product can reasonably be expected to result in personal injury, death, or property or environmental damage. NVIDIA accepts no liability for inclusion and/or use of NVIDIA products in such equipment or applications and therefore such inclusion and/or use is at customer’s own risk. NVIDIA makes no representation or warranty that products based on this document will be suitable for any specified use. Testing of all parameters of each product is not necessarily performed by NVIDIA. It is customer’s sole responsibility to evaluate and determine the applicability of any information contained in this document, ensure the product is suitable and fit for the application planned by customer, and perform the necessary testing for the application in order to avoid a default of the application or the product. Weaknesses in customer’s product designs may affect the quality and reliability of the NVIDIA product and may result in additional or different conditions and/or requirements beyond those contained in this document. NVIDIA accepts no liability related to any default, damage, costs, or problem which may be based on or attributable to: (i) the use of the NVIDIA product in any manner that is contrary to this document or (ii) customer product designs. No license, either expressed or implied, is granted under any NVIDIA patent right, copyright, or other NVIDIA intellectual property right under this document. Information published by NVIDIA regarding third-party products or services does not constitute a license from NVIDIA to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property rights of the third party, or a license from NVIDIA under the patents or other intellectual property rights of NVIDIA. Reproduction of information in this document is permissible only if approved in advance by NVIDIA in writing, reproduced without alteration and in full compliance with all applicable export laws and regulations, and accompanied by all associated conditions, limitations, and notices. THIS DOCUMENT AND ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS, DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY, “MATERIALS”) ARE BEING PROVIDED “AS IS.” NVIDIA MAKES NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL NVIDIA BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF ANY USE OF THIS DOCUMENT, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Notwithstanding any damages that customer might incur for any reason whatsoever, NVIDIA’s aggregate and cumulative liability towards customer for the products described herein shall be limited in accordance with the Terms of Sale for the product. 10.2. OpenCL OpenCL is a trademark of Apple Inc. used under license to the Khronos Group Inc. 10.3. Trademarks NVIDIA and the NVIDIA logo are trademarks or registered trademarks of NVIDIA Corporation in the U.S. and other countries. Other company and product names may be trademarks of the respective companies with which they are associated. Privacy Policy | Manage My Privacy | Do Not Sell or Share My Data | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact Copyright © 2012-2025, NVIDIA Corporation & affiliates. All rights reserved. Last updated on Oct 02, 2025.