Beispiel #1
0
        //CSR
        public static SparseMatrix <indexT1, dataT1> CreateCSC <indexT1, dataT1>(
            long rows,
            long cols,
            long nnz,
            CudaDeviceVariable <indexT1> cscColOffsets,
            CudaDeviceVariable <indexT1> cscRowInd,
            CudaDeviceVariable <dataT1> cscValues,
            IndexBase idxBase) where indexT1 : struct where dataT1 : struct
        {
            cusparseSpMatDescr descr       = new cusparseSpMatDescr();
            IndexType          typeIndices = IndexTypeTranslator.GetType(typeof(indexT1));
            cudaDataType       typeData    = CudaDataTypeTranslator.GetType(typeof(dataT1));
            cusparseStatus     res         = CudaSparseNativeMethods.cusparseCreateCsc(ref descr, rows, cols, nnz, cscColOffsets.DevicePointer,
                                                                                       cscRowInd.DevicePointer, cscValues.DevicePointer, typeIndices, typeIndices, idxBase, typeData);

            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cusparseCreateCsc", res));
            if (res != cusparseStatus.Success)
            {
                throw new CudaSparseException(res);
            }

            return(new SparseMatrix <indexT1, dataT1>(descr, rows, cols, nnz, idxBase, typeIndices, typeData));
        }