Example #1
0
 public abstract void CreateSolveAnalysisInfo(ref cusparseSolveAnalysisInfo info);
Example #2
0
 public abstract void DestroySolveAnalysisInfo(cusparseSolveAnalysisInfo info);
Example #3
0
 private static extern CUSPARSEStatus cusparseCreateSolveAnalysisInfo(ref cusparseSolveAnalysisInfo info);
Example #4
0
 private static extern CUSPARSEStatus cusparseDcsrsv_analysis_v2(cusparseHandle handle, cusparseOperation transA, int m, int nnz, cusparseMatDescr descrA, IntPtr csrValA, IntPtr csrRowPtrA, IntPtr csrColIndA, cusparseSolveAnalysisInfo info);
Example #5
0
 public CUSPARSEStatus CusparseCreateSolveAnalysisInfo(ref cusparseSolveAnalysisInfo info)
 {
     return(cusparseCreateSolveAnalysisInfo(ref info));
 }
Example #6
0
 public CUSPARSEStatus CusparseDcsrsv_analysis(cusparseHandle handle, cusparseOperation transA, int m, int nnz, cusparseMatDescr descrA, IntPtr csrValA, IntPtr csrRowPtrA, IntPtr csrColIndA, cusparseSolveAnalysisInfo info)
 {
     return(cusparseDcsrsv_analysis_v2(handle, transA, m, nnz, descrA, csrValA, csrRowPtrA, csrColIndA, info));;
 }
Example #7
0
 private static extern CUSPARSEStatus cusparseCreateSolveAnalysisInfo(ref cusparseSolveAnalysisInfo info);
Example #8
0
 private static extern CUSPARSEStatus cusparseDcsrsv_analysis_v2(cusparseHandle handle, cusparseOperation transA, int m, int nnz, cusparseMatDescr descrA, IntPtr csrValA, IntPtr csrRowPtrA, IntPtr csrColIndA, cusparseSolveAnalysisInfo info);
Example #9
0
 public CUSPARSEStatus CusparseDcsrsv_analysis(cusparseHandle handle, cusparseOperation transA, int m, int nnz, cusparseMatDescr descrA, IntPtr csrValA, IntPtr csrRowPtrA, IntPtr csrColIndA, cusparseSolveAnalysisInfo info)
 {
     return cusparseDcsrsv_analysis_v2(handle, transA, m, nnz, descrA, csrValA, csrRowPtrA, csrColIndA, info); ;
 }
Example #10
0
 public CUSPARSEStatus CusparseDcsrsv_solve(cusparseHandle handle, cusparseOperation transA, int m, ref double alpha, cusparseMatDescr descrA, IntPtr csrValA, IntPtr csrRowPtrA, IntPtr csrColIndA, cusparseSolveAnalysisInfo info, IntPtr x, IntPtr y)
 {
     return cusparseDcsrsv_solve_v2(handle, transA, m, ref alpha, descrA, csrValA, csrRowPtrA, csrColIndA, info, x, y);
 }
Example #11
0
 public CUSPARSEStatus CusparseDestroySolveAnalysisInfo(cusparseSolveAnalysisInfo info)
 {
     return cusparseDestroySolveAnalysisInfo(info);
 }
Example #12
0
 public CUSPARSEStatus CusparseCreateSolveAnalysisInfo(ref cusparseSolveAnalysisInfo info)
 {
     return cusparseCreateSolveAnalysisInfo(ref info);
 }
Example #13
0
 private static extern CUSPARSEStatus cusparseDcsrsv_solve_v2(cusparseHandle handle, cusparseOperation transA, int m, ref double alpha, cusparseMatDescr descrA, IntPtr csrValA, IntPtr csrRowPtrA, IntPtr csrColIndA, cusparseSolveAnalysisInfo info, IntPtr x, IntPtr y);
Example #14
0
 /// <summary>
 /// Performs the analysis phase of the solution of a sparse triangular linear system.
 /// op(A) * y = alpha * x
 /// </summary>
 /// <param name="m">specifies the number of rows and columns of matrix A; m must be at least zero.</param>
 /// <param name="nnz">number of non-zero elements of matrix A.</param>
 /// <param name="csrValA">array of nnz elements, where nnz is the number of non-zero elements and can be obtained from csrRow[m] - csrRow[0].</param>
 /// <param name="csrRowA">array of m+1 index elements.</param>
 /// <param name="csrColA">array of nnz column indices.</param>
 /// <param name="op">specifies op(A).</param>
 /// <param name="info">structure that stores the information collected during the analysis phase. It should be passed to the solve phase unchanged.</param>
 /// <param name="descrA">descriptor of matrix A.</param>
 public abstract void CSRSV_ANALYSIS(int m, int nnz, double[] csrValA, int[] csrRowA, int[] csrColA, cusparseOperation op, cusparseSolveAnalysisInfo info, cusparseMatDescr descrA);
Example #15
0
 private static extern CUSPARSEStatus cusparseDestroySolveAnalysisInfo(cusparseSolveAnalysisInfo info);
Example #16
0
 /// <summary>
 /// Performs the solve phase of the solution of a sparse triangular linear system.
 /// op(A) * y = alpha * x
 /// </summary>
 /// <param name="m">specifies the number of rows and columns of matrix A; m must be at least zero.</param>
 /// <param name="alpha">scalar multiplier applied to x.</param>
 /// <param name="csrValA">array of nnz elements, where nnz is the number of non-zero elements and can be obtained from csrRow[m] - csrRow[0].</param>
 /// <param name="csrRowA">array of m+1 index elements.</param>
 /// <param name="csrColA">array of nnz column indices.</param>
 /// <param name="x">vector of m elements.</param>
 /// <param name="y">vector of m elements. updated according to op(A) * y = alpha * x</param>
 /// <param name="op">specifies op(A).</param>
 /// <param name="info">structure that stores the information collected during the analysis phase. It should be passed to the solve phase unchanged.</param>
 /// <param name="descrA">descriptor of matrix A.</param>
 public abstract void CSRSV_SOLVE(int m, ref double alpha, double[] csrValA, int[] csrRowA, int[] csrColA, double[] x, double[] y, cusparseOperation op, cusparseSolveAnalysisInfo info, cusparseMatDescr descrA);
Example #17
0
 public override void CreateSolveAnalysisInfo(ref cusparseSolveAnalysisInfo info)
 {
     LastStatus = _driver.CusparseCreateSolveAnalysisInfo(ref info);
 }
Example #18
0
 private static extern CUSPARSEStatus cusparseDcsrsv_solve_v2(cusparseHandle handle, cusparseOperation transA, int m, ref double alpha, cusparseMatDescr descrA, IntPtr csrValA, IntPtr csrRowPtrA, IntPtr csrColIndA, cusparseSolveAnalysisInfo info, IntPtr x, IntPtr y);
Example #19
0
 public override void DestroySolveAnalysisInfo(cusparseSolveAnalysisInfo info)
 {
     LastStatus = _driver.CusparseDestroySolveAnalysisInfo(info);
 }
Example #20
0
 public CUSPARSEStatus CusparseDestroySolveAnalysisInfo(cusparseSolveAnalysisInfo info)
 {
     return(cusparseDestroySolveAnalysisInfo(info));
 }
Example #21
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);
        }
Example #22
0
 public CUSPARSEStatus CusparseDcsrsv_solve(cusparseHandle handle, cusparseOperation transA, int m, ref double alpha, cusparseMatDescr descrA, IntPtr csrValA, IntPtr csrRowPtrA, IntPtr csrColIndA, cusparseSolveAnalysisInfo info, IntPtr x, IntPtr y)
 {
     return(cusparseDcsrsv_solve_v2(handle, transA, m, ref alpha, descrA, csrValA, csrRowPtrA, csrColIndA, info, x, y));
 }
Example #23
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);
        }
Example #24
0
 private static extern CUSPARSEStatus cusparseDestroySolveAnalysisInfo(cusparseSolveAnalysisInfo info);
Example #25
0
        public SolveResult CGPreconditioned(
            int n, int nnz, float[] csrValA, int[] csrRowA, int[] csrColA, float[] dx, float[] db,
            float[] csrValICP, int[] csrRowICP, int[] csrColICP,
            float[] dy, float[] dp, float[] domega, float[] zm1, float[] zm2, float[] rm2, float tolerence = 0.0001f, int maxIterate = 300)
        {
            SolveResult result = new SolveResult();

            // Make Incomplete Cholesky Preconditioner.
            gpu.Launch().DefineLower(n, csrRowICP, csrColICP);
            gpu.Launch(n, 1).CopyAIntoH(n, csrValA, csrRowA, csrValICP, csrRowICP);
            gpu.Launch(n, 1).ConstructH(n, csrValICP, csrRowICP);

            cusparseMatDescr descrM = new cusparseMatDescr();
            descrM.MatrixType = cusparseMatrixType.Triangular;
            descrM.FillMode = cusparseFillMode.Lower;
            descrM.IndexBase = cusparseIndexBase.Zero;
            descrM.DiagType = cusparseDiagType.NonUnit;

            cusparseSolveAnalysisInfo info = new cusparseSolveAnalysisInfo();
            sparse.CreateSolveAnalysisInfo(ref info);
            cusparseSolveAnalysisInfo infoTrans = new cusparseSolveAnalysisInfo();
            sparse.CreateSolveAnalysisInfo(ref infoTrans);

            sparse.CSRSV_ANALYSIS(n, nnz, csrValICP, csrRowICP, csrColICP, cusparseOperation.NonTranspose, info, descrM);
            sparse.CSRSV_ANALYSIS(n, nnz, csrValICP, csrRowICP, csrColICP, cusparseOperation.Transpose, infoTrans, descrM);

            int k = 0;
            float r1 = blas.DOT(db, db);
            float alpha, beta;

            float identityFloat = 1.0f;
            float zeroFloat = 0.0f;

            while (true)
            {
                sparse.CSRSV_SOLVE(n, ref identityFloat, csrValICP, csrRowICP, csrColICP, db, dy, cusparseOperation.NonTranspose, info, descrM);
                sparse.CSRSV_SOLVE(n, ref identityFloat, csrValICP, csrRowICP, csrColICP, dy, zm1, cusparseOperation.Transpose, infoTrans, descrM);

                k++;

                if (k == 1)
                {
                    blas.COPY(zm1, dp);
                }
                else
                {
                    beta = blas.DOT(db, zm1) / blas.DOT(rm2, zm2);
                    blas.SCAL(beta, dp);
                    blas.AXPY(1.0f, zm1, dp);
                }

                sparse.CSRMV(n, n, nnz, ref identityFloat, csrValA, csrRowA, csrColA, dp, ref zeroFloat, domega);
                alpha = blas.DOT(db, zm1) / blas.DOT(dp, domega);

                blas.AXPY(alpha, dp, dx);
                blas.COPY(db, rm2);
                blas.COPY(zm1, zm2);
                blas.AXPY(-alpha, domega, db);

                r1 = blas.DOT(db, db);

                if (r1 <= tolerence * tolerence)
                {
                    result.IsSuccess = true;
                    result.IterateCount = k;
                    result.LastError = r1;
                    break;
                }
                if (k > maxIterate)
                {
                    result.IsSuccess = false;
                    result.IterateCount = k;
                    result.LastError = r1;
                    break;
                }
            }

            return result;
        }