/* Illustration of dense matrix inversion using CUDA cuBLAS library Sergey Voronin, 01.22 */ #include #include #include #include #include "cublas_v2.h" int main (void){ cublasStatus_t stat; cublasHandle_t handle; int i, j, n, lda, batchsize = 1; if (cudaStat != cudaSuccess) { printf ("device memory allocation failed"); return EXIT_FAILURE; } stat = cublasCreate(&handle); if (stat != CUBLAS_STATUS_SUCCESS) { printf ("CUBLAS initialization failed\n"); return EXIT_FAILURE; } /* define matrix */ n = 3; lda = 3; float a_mat[] = { 1, 0, 3, 4, 6, 5, 1, 5, 9 }; /* single array to hold matrix, device version, and device version of double array */ float *am = (float *)malloc(n*n*sizeof(float)); float *am_d; cudaMalloc(&am_d, n*n*sizeof(float)); float **am_dd; cudaMalloc(&am_dd, sizeof(float *)); /* initialize mat */ for(i=0; i