Beispiel #1
0
        public override void CSR2COO(int nnz, int m, int[] csrRow, int[] cooRow, cusparseIndexBase idxBase = cusparseIndexBase.Zero)
        {
            CUdeviceptr ptrcsr = GetDeviceMemory(csrRow);
            CUdeviceptr ptrcoo = GetDeviceMemory(cooRow);

            LastStatus = _driver.CusparseXcsr2coo(_sparse, ptrcsr.Pointer, nnz, m, ptrcoo.Pointer, idxBase);
        }
Beispiel #2
0
        public override void CSRSV_ANALYSIS(int m, int nnz, double[] csrValA, int[] csrRowA, int[] csrColA, cusparseOperation op, cusparseSolveAnalysisInfo info, cusparseMatDescr descrA)
        {
            CUdeviceptr ptrcsrv = GetDeviceMemory(csrValA);
            CUdeviceptr ptrcsrr = GetDeviceMemory(csrRowA);
            CUdeviceptr ptrcsrc = GetDeviceMemory(csrColA);

            LastStatus = _driver.CusparseDcsrsv_analysis(_sparse, op, m, nnz, descrA, ptrcsrv.Pointer, ptrcsrr.Pointer, ptrcsrc.Pointer, info);
        }
Beispiel #3
0
        public override void SCTR(double[] vectorx, int[] indexx, double[] vectory, int n = 0, cusparseIndexBase ibase = cusparseIndexBase.Zero)
        {
            CUdeviceptr ptrx  = GetDeviceMemory(vectorx, ref n);
            CUdeviceptr ptry  = GetDeviceMemory(vectory);
            CUdeviceptr ptrix = GetDeviceMemory(indexx);

            LastStatus = _driver.CusparseDsctr(_sparse, n, ptrx.Pointer, ptrix.Pointer, ptry.Pointer, ibase);
        }
Beispiel #4
0
        public override void ROT(float[] vectorx, int[] indexx, float[] vectory, ref float c, ref float s, int n = 0, cusparseIndexBase ibase = cusparseIndexBase.Zero)
        {
            CUdeviceptr ptrx  = GetDeviceMemory(vectorx, ref n);
            CUdeviceptr ptry  = GetDeviceMemory(vectory);
            CUdeviceptr ptrix = GetDeviceMemory(indexx);

            LastStatus = _driver.CusparseSroti(_sparse, n, ptrx.Pointer, ptrix.Pointer, ptry.Pointer, ref c, ref s, ibase);
        }
Beispiel #5
0
        public override void AXPY(ref float alpha, float[] vectorx, int[] indexx, float[] vectory, int n = 0, cusparseIndexBase ibase = cusparseIndexBase.Zero)
        {
            CUdeviceptr ptrx  = GetDeviceMemory(vectorx, ref n);
            CUdeviceptr ptry  = GetDeviceMemory(vectory);
            CUdeviceptr ptrix = GetDeviceMemory(indexx);

            LastStatus = _driver.CusparseSaxpyi(_sparse, n, ref alpha, ptrx.Pointer, ptrix.Pointer, ptry.Pointer, ibase);
        }
Beispiel #6
0
        public override void CSRMV(int m, int n, int nnz, ref double alpha, double[] csrValA, int[] csrRowA, int[] csrColA, double[] x, ref double beta, double[] y, cusparseMatDescr descrA, cusparseOperation op = cusparseOperation.NonTranspose)
        {
            CUdeviceptr ptrcsrv = GetDeviceMemory(csrValA);
            CUdeviceptr ptrcsrr = GetDeviceMemory(csrRowA);
            CUdeviceptr ptrcsrc = GetDeviceMemory(csrColA);
            CUdeviceptr ptrx    = GetDeviceMemory(x);
            CUdeviceptr ptry    = GetDeviceMemory(y);

            LastStatus = _driver.CusparseDcsrmv(_sparse, op, m, n, nnz, ref alpha, descrA, ptrcsrv.Pointer, ptrcsrr.Pointer, ptrcsrc.Pointer, ptrx.Pointer, ref beta, ptry.Pointer);
        }
Beispiel #7
0
        public override void CSRSV_SOLVE(int m, ref double alpha, double[] csrValA, int[] csrRowA, int[] csrColA, double[] x, double[] y, cusparseOperation op, cusparseSolveAnalysisInfo info, cusparseMatDescr descrA)
        {
            CUdeviceptr ptrcsrv = GetDeviceMemory(csrValA);
            CUdeviceptr ptrcsrr = GetDeviceMemory(csrRowA);
            CUdeviceptr ptrcsrc = GetDeviceMemory(csrColA);
            CUdeviceptr ptrx    = GetDeviceMemory(x);
            CUdeviceptr ptry    = GetDeviceMemory(y);

            LastStatus = _driver.CusparseDcsrsv_solve(_sparse, op, m, ref alpha, descrA, ptrcsrv.Pointer, ptrcsrr.Pointer, ptrcsrc.Pointer, info, ptrx.Pointer, ptry.Pointer);
        }
Beispiel #8
0
        public override double DOT(double[] vectorx, int[] indexx, double[] vectory, int n = 0, cusparseIndexBase ibase = cusparseIndexBase.Zero)
        {
            CUdeviceptr ptrx  = GetDeviceMemory(vectorx, ref n);
            CUdeviceptr ptry  = GetDeviceMemory(vectory);
            CUdeviceptr ptrix = GetDeviceMemory(indexx);

            double result = 0;

            LastStatus = _driver.CusparseDdoti(_sparse, n, ptrx.Pointer, ptrix.Pointer, ptry.Pointer, ref result, ibase);
            return(result);
        }
Beispiel #9
0
        public override void CSC2Dense(int m, int n, double[] cscValA, int[] cscRowA, int[] cscColA, double[] A, cusparseMatDescr descrA, int lda = 0)
        {
            lda = (lda == 0 ? m : lda);

            CUdeviceptr ptra   = GetDeviceMemory(A);
            CUdeviceptr ptrval = GetDeviceMemory(cscValA);
            CUdeviceptr ptrrow = GetDeviceMemory(cscRowA);
            CUdeviceptr ptrcol = GetDeviceMemory(cscColA);

            LastStatus = _driver.CusparseDcsc2dense(_sparse, m, n, descrA, ptrval.Pointer, ptrrow.Pointer, ptrcol.Pointer, ptra.Pointer, lda);
        }
Beispiel #10
0
 protected override void Shutdown()
 {
     try
     {
         LastStatus = _driver.CusparseDestroy(_sparse);
     }
     catch (DllNotFoundException ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
Beispiel #11
0
        public override void CSR2CSC(int m, int n, int nnz, double[] csrVal, int[] csrRow, int[] csrCol, double[] cscVal, int[] cscRow, int[] cscCol, cusparseAction copyValues = cusparseAction.Numeric, cusparseIndexBase bs = cusparseIndexBase.Zero)
        {
            CUdeviceptr ptrcsrv = GetDeviceMemory(csrVal);
            CUdeviceptr ptrcsrr = GetDeviceMemory(csrRow);
            CUdeviceptr ptrcsrc = GetDeviceMemory(csrCol);

            CUdeviceptr ptrcscv = GetDeviceMemory(cscVal);
            CUdeviceptr ptrcscr = GetDeviceMemory(cscRow);
            CUdeviceptr ptrcscc = GetDeviceMemory(cscCol);

            LastStatus = _driver.CusparseDcsr2csc(_sparse, m, n, nnz, ptrcsrv.Pointer, ptrcsrr.Pointer, ptrcsrc.Pointer, ptrcscv.Pointer, ptrcscr.Pointer, ptrcscc.Pointer, copyValues, bs);
        }
Beispiel #12
0
        public override void Dense2CSC(int m, int n, double[] A, int[] nnzPerCol, double[] cscValA, int[] cscRowIndA, int[] cscColA, cusparseMatDescr descrA, int lda = 0)
        {
            lda = (lda == 0 ? m : lda);

            CUdeviceptr ptra   = GetDeviceMemory(A);
            CUdeviceptr ptrn   = GetDeviceMemory(nnzPerCol);
            CUdeviceptr ptrval = GetDeviceMemory(cscValA);
            CUdeviceptr ptrrow = GetDeviceMemory(cscRowIndA);
            CUdeviceptr ptrcol = GetDeviceMemory(cscColA);

            LastStatus = _driver.CusparseDdense2csc(_sparse, m, n, descrA, ptra.Pointer, lda, ptrn.Pointer, ptrval.Pointer, ptrrow.Pointer, ptrcol.Pointer);
        }
Beispiel #13
0
        public override void Dense2CSR(int m, int n, float[] A, int[] nnzPerRow, float[] csrValA, int[] csrRow, int[] csrColIndA, cusparseMatDescr descrA, int lda = 0)
        {
            lda = (lda == 0 ? m : lda);

            CUdeviceptr ptra   = GetDeviceMemory(A);
            CUdeviceptr ptrn   = GetDeviceMemory(nnzPerRow);
            CUdeviceptr ptrval = GetDeviceMemory(csrValA);
            CUdeviceptr ptrrow = GetDeviceMemory(csrRow);
            CUdeviceptr ptrcol = GetDeviceMemory(csrColIndA);

            LastStatus = _driver.CusparseSdense2csr(_sparse, m, n, descrA, ptra.Pointer, lda, ptrn.Pointer, ptrval.Pointer, ptrrow.Pointer, ptrcol.Pointer);
        }
Beispiel #14
0
        public override int NNZ(int m, int n, double[] A, int[] vector, cusparseMatDescr descrA, cusparseDirection dirA = cusparseDirection.Row, int lda = 0)
        {
            lda = (lda == 0 ? m : lda);

            CUdeviceptr ptra = GetDeviceMemory(A);
            CUdeviceptr ptrv = GetDeviceMemory(vector);

            int nzz = 0;

            LastStatus = _driver.CusparseDnnz(_sparse, dirA, m, n, descrA, ptra.Pointer, lda, ptrv.Pointer, ref nzz);

            return(nzz);
        }
Beispiel #15
0
        internal CudaSPARSE(GPGPU gpu)
            : base()
        {
            if (IntPtr.Size == 8)
            {
                _driver = new CUSPARSEDriver64();
            }
            else
            {
                throw new NotSupportedException();
            }

            LastStatus = _driver.CusparseCreate(ref _sparse);
            _gpu       = gpu;
        }
Beispiel #16
0
        public override void CSRMM(int m, int k, int n, int nnz, ref double alpha, double[] csrValA, int[] csrRowA, int[] csrColA, double[] B, ref double beta, double[] C, cusparseMatDescr descrA, cusparseOperation op = cusparseOperation.NonTranspose, int ldb = 0, int ldc = 0)
        {
            if (op == cusparseOperation.NonTranspose)
            {
                ldb = (ldb == 0 ? k : ldb);
                ldc = (ldc == 0 ? m : ldc);
            }
            else
            {
                ldb = (ldb == 0 ? m : ldb);
                ldc = (ldc == 0 ? k : ldc);
            }

            CUdeviceptr ptrcsrv = GetDeviceMemory(csrValA);
            CUdeviceptr ptrcsrr = GetDeviceMemory(csrRowA);
            CUdeviceptr ptrcsrc = GetDeviceMemory(csrColA);

            CUdeviceptr ptrb = GetDeviceMemory(B);
            CUdeviceptr ptrc = GetDeviceMemory(C);

            LastStatus = _driver.CusparseDcsrmm(_sparse, op, m, n, k, nnz, ref alpha, descrA, ptrcsrv.Pointer, ptrcsrr.Pointer, ptrcsrc.Pointer, ptrb.Pointer, ldb, ref beta, ptrc.Pointer, ldc);
        }
Beispiel #17
0
 public override void CreateSolveAnalysisInfo(ref cusparseSolveAnalysisInfo info)
 {
     LastStatus = _driver.CusparseCreateSolveAnalysisInfo(ref info);
 }
Beispiel #18
0
 public override void DestroySolveAnalysisInfo(cusparseSolveAnalysisInfo info)
 {
     LastStatus = _driver.CusparseDestroySolveAnalysisInfo(info);
 }