Esempio n. 1
0
 /// <summary>
 /// </summary>
 public void SetSolverLowestPrecision(cudaDataType solver_main_precision)
 {
     res = CudaSolveNativeMethods.Dense.cusolverDnIRSParamsSetSolverLowestPrecision(_params, solver_main_precision);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cusolverDnIRSParamsSetSolverLowestPrecision", res));
     if (res != cusolverStatus.Success)
     {
         throw new CudaSolveException(res);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// </summary>
 public void SetTolInner(cudaDataType data_type, double val)
 {
     res = CudaSolveNativeMethods.Dense.cusolverDnIRSParamsSetTolInner(_params, data_type, val);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cusolverDnIRSParamsSetTolInner", res));
     if (res != cusolverStatus.Success)
     {
         throw new CudaSolveException(res);
     }
 }
 public static extern CublasStatus cublasAxpyEx(CudaBlasHandle handle,
                                               int n,
                                               CUdeviceptr alpha, /* host or device pointer */
                                               cudaDataType alphaType,
                                               CUdeviceptr x,
                                               cudaDataType xType,
                                               int incx,
                                               CUdeviceptr y,
                                               cudaDataType yType,
                                               int incy,
                                               cudaDataType executiontype);
Esempio n. 4
0
 /// <summary>
 /// </summary>
 public DenseVector(long aSize, CudaDeviceVariable <dataT> values)
 {
     size     = aSize;
     descr    = new cusparseDnVecDescr();
     typeData = CudaDataTypeTranslator.GetType(typeof(dataT));
     res      = CudaSparseNativeMethods.cusparseCreateDnVec(ref descr, size, values.DevicePointer, typeData);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cusparseCreateDnVec", res));
     if (res != cusparseStatus.Success)
     {
         throw new CudaSparseException(res);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// </summary>
 public SparseVector(long aSize, long aNnz, CudaDeviceVariable <indexT> indices, CudaDeviceVariable <dataT> values, IndexBase aIdxBase)
 {
     size        = aSize;
     nnz         = aNnz;
     idxBase     = aIdxBase;
     descr       = new cusparseSpVecDescr();
     typeIndices = IndexTypeTranslator.GetType(typeof(indexT));
     typeData    = CudaDataTypeTranslator.GetType(typeof(dataT));
     res         = CudaSparseNativeMethods.cusparseCreateSpVec(ref descr, size, nnz, indices.DevicePointer, values.DevicePointer, typeIndices, idxBase, typeData);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cusparseCreateSpVec", res));
     if (res != cusparseStatus.Success)
     {
         throw new CudaSparseException(res);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// </summary>
 public DenseMatrix(long aRows, long aCols, long aLd, Order aOrder, CudaDeviceVariable <dataT> values)
 {
     rows     = aRows;
     cols     = aCols;
     ld       = aLd;
     order    = aOrder;
     descr    = new cusparseDnMatDescr();
     typeData = CudaDataTypeTranslator.GetType(typeof(dataT));
     res      = CudaSparseNativeMethods.cusparseCreateDnMat(ref descr, rows, cols, ld, values.DevicePointer, typeData, order);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cusparseCreateDnMat", res));
     if (res != cusparseStatus.Success)
     {
         throw new CudaSparseException(res);
     }
 }
Esempio n. 7
0
 /// <summary>
 /// </summary>
 private SparseMatrix(cusparseSpMatDescr aDescr, long aRows, long aCols, long aNnz, IndexBase aIdxBase, IndexType aTypeIndices, cudaDataType aTypeData)
 {
     rows        = aRows;
     cols        = aCols;
     nnz         = aNnz;
     idxBase     = aIdxBase;
     descr       = aDescr;
     typeIndices = aTypeIndices;
     typeData    = aTypeData;
     format      = Format.COO;
     res         = CudaSparseNativeMethods.cusparseSpMatGetFormat(descr, ref format);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cusparseSpMatGetFormat", res));
     if (res != cusparseStatus.Success)
     {
         throw new CudaSparseException(res);
     }
 }
Esempio n. 8
0
        public static SparseMatrix <indexT1, dataT1> CreateCooAoS <indexT1, dataT1>(
            long rows,
            long cols,
            long nnz,
            CudaDeviceVariable <indexT1> cooInd,
            CudaDeviceVariable <dataT1> cooValues,
            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.cusparseCreateCooAoS(ref descr, rows, cols, nnz, cooInd.DevicePointer,
                                                                                          cooValues.DevicePointer, typeIndices, idxBase, typeData);

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

            return(new SparseMatrix <indexT1, dataT1>(descr, rows, cols, nnz, idxBase, typeIndices, typeData));
        }
 public static extern CublasStatus cublasCgemmEx(CudaBlasHandle handle, 
                                              Operation transa, Operation transb,  
                                              int m, int n, int k, 
                                              CUdeviceptr alpha, 
                                              CUdeviceptr A, 
                                              cudaDataType Atype, 
                                              int lda, 
                                              CUdeviceptr B, 
                                              cudaDataType Btype, 
                                              int ldb,
                                              CUdeviceptr beta, 
                                              CUdeviceptr C, 
                                              cudaDataType Ctype, 
                                              int ldc);
Esempio n. 10
0
 public static extern CublasStatus cublasScalEx(CudaBlasHandle handle, 
                                              int n, 
                                              IntPtr alpha,  /* host or device pointer */
                                              cudaDataType alphaType,
                                              CUdeviceptr x, 
                                              cudaDataType xType,
                                              int incx,
                                              cudaDataType executionType);
Esempio n. 11
0
        public static extern CublasStatus cublasNrm2Ex(CudaBlasHandle handle,
													 int n,
													 CUdeviceptr x,
													 cudaDataType xType,
													 int incx,
													 CUdeviceptr result,
													 cudaDataType resultType,
													 cudaDataType executionType);
Esempio n. 12
0
 public static extern CublasStatus cublasGemmEx(CudaBlasHandle handle, 
                                               Operation transa,
                                               Operation transb, 
                                               int m,
                                               int n,
                                               int k,
                                               CUdeviceptr alpha, /* host or device pointer */  
                                               CUdeviceptr A, 
                                               cudaDataType Atype,
                                               int lda,
                                               CUdeviceptr B,
                                               cudaDataType Btype,
                                               int ldb, 
                                               CUdeviceptr beta, /* host or device pointer */  
                                               CUdeviceptr C,
                                               cudaDataType Ctype,
                                               int ldc,
                                               cudaDataType computeType,
                                               GemmAlgo algo);
        /// <summary>
        ///
        /// </summary>
        /// <param name="cudaType"></param>
        /// <returns></returns>
        public static Type GetType(cudaDataType cudaType)
        {
            switch (cudaType)
            {
            case cudaDataType.CUDA_R_16F:
                return(typeof(half));

            case cudaDataType.CUDA_C_16F:
                return(typeof(half2));

            case cudaDataType.CUDA_R_32F:
                return(typeof(float));

            case cudaDataType.CUDA_C_32F:
                return(typeof(cuFloatComplex));

            case cudaDataType.CUDA_R_64F:
                return(typeof(double));

            case cudaDataType.CUDA_C_64F:
                return(typeof(cuDoubleComplex));

            case cudaDataType.CUDA_R_8I:
                return(typeof(sbyte));

            case cudaDataType.CUDA_C_8I:
                return(typeof(char2));

            case cudaDataType.CUDA_R_8U:
                return(typeof(byte));

            case cudaDataType.CUDA_C_8U:
                return(typeof(uchar2));

            case cudaDataType.CUDA_R_16BF:
                return(typeof(bfloat16));

            case cudaDataType.CUDA_C_16BF:
                return(typeof(bfloat162));

            //case cudaDataType.CUDA_R_4I:
            //    return typeof(int);
            //case cudaDataType.CUDA_C_4I:
            //    return typeof(int2);
            //case cudaDataType.CUDA_R_4U:
            //    return typeof(uint);
            //case cudaDataType.CUDA_C_4U:
            //    return typeof(uint2);
            case cudaDataType.CUDA_R_16I:
                return(typeof(short));

            case cudaDataType.CUDA_C_16I:
                return(typeof(short2));

            case cudaDataType.CUDA_R_16U:
                return(typeof(ushort));

            case cudaDataType.CUDA_C_16U:
                return(typeof(ushort2));

            case cudaDataType.CUDA_R_32I:
                return(typeof(int));

            case cudaDataType.CUDA_C_32I:
                return(typeof(int2));

            case cudaDataType.CUDA_R_32U:
                return(typeof(uint));

            case cudaDataType.CUDA_C_32U:
                return(typeof(uint2));

            case cudaDataType.CUDA_R_64I:
                return(typeof(long));

            case cudaDataType.CUDA_C_64I:
                return(typeof(long2));

            case cudaDataType.CUDA_R_64U:
                return(typeof(ulong));

            case cudaDataType.CUDA_C_64U:
                return(typeof(ulong2));

            default:
                throw new ArgumentException("Unsupported cuda type: " + cudaType.ToString());
            }
        }
Esempio n. 14
0
 public static extern nvgraphStatus nvgraphAllocateVertexData(nvgraphContext handle, nvgraphGraphDescr descrG, SizeT numsets, cudaDataType[] settypes);
Esempio n. 15
0
        public static extern CublasStatus cublasCherk3mEx(CudaBlasHandle handle,
															   FillMode uplo,
															   Operation trans, 
															   int n, 
															   int k,
															   ref float alpha,
															   CUdeviceptr A, cudaDataType Atype, 
															   int lda,
															   ref float beta,
															   CUdeviceptr C, 
															   cudaDataType Ctype, 
															   int ldc);
Esempio n. 16
0
        /* PageRank
         *  Find PageRank for a graph with a given transition probabilities, a bookmark vector of dangling vertices, and the damping factor.
         *  This is equivalent to an eigenvalue problem where we want the eigenvector corresponding to the maximum eigenvalue.
         *  By construction, the maximum eigenvalue is 1.
         *  The eigenvalue problem is solved with the power method.
         *
         * Initially :
         * V = 6
         * E = 10
         *
         * Edges       W
         * 0 -> 1    0.50
         * 0 -> 2    0.50
         * 2 -> 0    0.33
         * 2 -> 1    0.33
         * 2 -> 4    0.33
         * 3 -> 4    0.50
         * 3 -> 5    0.50
         * 4 -> 3    0.50
         * 4 -> 5    0.50
         * 5 -> 3    1.00
         *
         * bookmark (0.0, 1.0, 0.0, 0.0, 0.0, 0.0)^T note: 1.0 if i is a dangling node, 0.0 otherwise
         *
         * Source oriented representation (CSC):
         * destination_offsets {0, 1, 3, 4, 6, 8, 10}
         * source_indices {2, 0, 2, 0, 4, 5, 2, 3, 3, 4}
         * W0 = {0.33, 0.50, 0.33, 0.50, 0.50, 1.00, 0.33, 0.50, 0.50, 1.00}
         *
         * ----------------------------------
         *
         * Operation : Pagerank with various damping factor
         * ----------------------------------
         *
         * Expected output for alpha= 0.9 (result stored in pr_2) : (0.037210, 0.053960, 0.041510, 0.37510, 0.206000, 0.28620)^T
         * From "Google's PageRank and Beyond: The Science of Search Engine Rankings" Amy N. Langville & Carl D. Meyer
         */

        static void Main(string[] args)
        {
            SizeT n = 6, nnz = 10, vertex_numsets = 3, edge_numsets = 1;

            float[] alpha1 = new float[] { 0.85f }, alpha2 = new float[] { 0.90f };

            int i;

            int[]   destination_offsets_h, source_indices_h;
            float[] weights_h, bookmark_h, pr_1, pr_2;
            //void** vertex_dim;

            // nvgraph variables
            GraphContext          handle;
            GraphDescriptor       graph;
            nvgraphCSCTopology32I CSC_input;

            cudaDataType[] edge_dimT = new cudaDataType[] { cudaDataType.CUDA_R_32F };
            cudaDataType[] vertex_dimT;

            // use command-line specified CUDA device, otherwise use device with highest Gflops/s
            int cuda_device = 0;

            CudaDeviceProperties deviceProp = CudaContext.GetDeviceInfo(cuda_device);

            Console.WriteLine("> Detected Compute SM {0}.{1} hardware with {2} multi-processors",
                              deviceProp.ComputeCapability.Major, deviceProp.ComputeCapability.Minor, deviceProp.MultiProcessorCount);

            if (deviceProp.ComputeCapability.Major < 3)
            {
                Console.WriteLine("> nvGraph requires device SM 3.0+");
                Console.WriteLine("> Waiving.");
                return;
            }


            // Allocate host data
            destination_offsets_h = new int[n + 1];
            source_indices_h      = new int[nnz];
            weights_h             = new float[nnz];
            bookmark_h            = new float[n];
            pr_1 = new float[n];
            pr_2 = new float[n];
            //vertex_dim = (void**)malloc(vertex_numsets * sizeof(void*));
            vertex_dimT = new cudaDataType[vertex_numsets];
            CSC_input   = new nvgraphCSCTopology32I();

            // Initialize host data
            //vertex_dim[0] = (void*)bookmark_h; vertex_dim[1]= (void*)pr_1, vertex_dim[2]= (void*)pr_2;
            vertex_dimT[0] = cudaDataType.CUDA_R_32F; vertex_dimT[1] = cudaDataType.CUDA_R_32F; vertex_dimT[2] = cudaDataType.CUDA_R_32F;

            weights_h[0] = 0.333333f;
            weights_h[1] = 0.500000f;
            weights_h[2] = 0.333333f;
            weights_h[3] = 0.500000f;
            weights_h[4] = 0.500000f;
            weights_h[5] = 1.000000f;
            weights_h[6] = 0.333333f;
            weights_h[7] = 0.500000f;
            weights_h[8] = 0.500000f;
            weights_h[9] = 0.500000f;

            destination_offsets_h[0] = 0;
            destination_offsets_h[1] = 1;
            destination_offsets_h[2] = 3;
            destination_offsets_h[3] = 4;
            destination_offsets_h[4] = 6;
            destination_offsets_h[5] = 8;
            destination_offsets_h[6] = 10;

            source_indices_h[0] = 2;
            source_indices_h[1] = 0;
            source_indices_h[2] = 2;
            source_indices_h[3] = 0;
            source_indices_h[4] = 4;
            source_indices_h[5] = 5;
            source_indices_h[6] = 2;
            source_indices_h[7] = 3;
            source_indices_h[8] = 3;
            source_indices_h[9] = 4;

            bookmark_h[0] = 0.0f;
            bookmark_h[1] = 1.0f;
            bookmark_h[2] = 0.0f;
            bookmark_h[3] = 0.0f;
            bookmark_h[4] = 0.0f;
            bookmark_h[5] = 0.0f;

            // Starting nvgraph
            handle = new GraphContext();
            graph  = handle.CreateGraphDecriptor();

            GCHandle destination_offsets_handle = GCHandle.Alloc(destination_offsets_h, GCHandleType.Pinned);
            GCHandle source_indices_handle      = GCHandle.Alloc(source_indices_h, GCHandleType.Pinned);

            CSC_input.nvertices           = n;
            CSC_input.nedges              = nnz;
            CSC_input.destination_offsets = destination_offsets_handle.AddrOfPinnedObject();
            CSC_input.source_indices      = source_indices_handle.AddrOfPinnedObject();

            // Set graph connectivity and properties (tranfers)
            graph.SetGraphStructure(CSC_input);
            graph.AllocateVertexData(vertex_dimT);
            graph.AllocateEdgeData(edge_dimT);

            graph.SetVertexData(bookmark_h, 0);
            graph.SetVertexData(pr_1, 1);
            graph.SetVertexData(pr_2, 2);

            graph.SetEdgeData(weights_h, 0);

            // First run with default values
            graph.Pagerank(0, alpha1, 0, 0, 1, 0.0f, 0);

            // Get and print result
            graph.GetVertexData(pr_1, 1);
            Console.WriteLine("pr_1, alpha = 0.85");
            for (i = 0; i < n; i++)
            {
                Console.WriteLine(pr_1[i]);
            }
            Console.WriteLine();

            // Second run with different damping factor and an initial guess
            for (i = 0; i < n; i++)
            {
                pr_2[i] = pr_1[i];
            }

            graph.SetVertexData(pr_2, 2);
            graph.Pagerank(0, alpha2, 0, 1, 2, 0.0f, 0);

            // Get and print result
            graph.GetVertexData(pr_2, 2);
            Console.WriteLine("pr_2, alpha = 0.90");
            for (i = 0; i < n; i++)
            {
                Console.WriteLine(pr_2[i]);
            }
            Console.WriteLine();

            //Clean
            graph.Dispose();
            handle.Dispose();


            Console.WriteLine("\nDone!");
        }
Esempio n. 17
0
        /* PageRank
         *  Find PageRank for a graph with a given transition probabilities, a bookmark vector of dangling vertices, and the damping factor.
         *  This is equivalent to an eigenvalue problem where we want the eigenvector corresponding to the maximum eigenvalue.
         *  By construction, the maximum eigenvalue is 1.
         *  The eigenvalue problem is solved with the power method.

        Initially :
        V = 6
        E = 10

        Edges       W
        0 -> 1    0.50
        0 -> 2    0.50
        2 -> 0    0.33
        2 -> 1    0.33
        2 -> 4    0.33
        3 -> 4    0.50
        3 -> 5    0.50
        4 -> 3    0.50
        4 -> 5    0.50
        5 -> 3    1.00

        bookmark (0.0, 1.0, 0.0, 0.0, 0.0, 0.0)^T note: 1.0 if i is a dangling node, 0.0 otherwise

        Source oriented representation (CSC):
        destination_offsets {0, 1, 3, 4, 6, 8, 10}
        source_indices {2, 0, 2, 0, 4, 5, 2, 3, 3, 4}
        W0 = {0.33, 0.50, 0.33, 0.50, 0.50, 1.00, 0.33, 0.50, 0.50, 1.00}

        ----------------------------------

        Operation : Pagerank with various damping factor
        ----------------------------------

        Expected output for alpha= 0.9 (result stored in pr_2) : (0.037210, 0.053960, 0.041510, 0.37510, 0.206000, 0.28620)^T
        From "Google's PageRank and Beyond: The Science of Search Engine Rankings" Amy N. Langville & Carl D. Meyer
        */
        static void Main(string[] args)
        {
            SizeT n = 6, nnz = 10, vertex_numsets = 3, edge_numsets = 1;
            float[] alpha1 = new float[] { 0.85f }, alpha2 = new float[] { 0.90f };

            int i;
            int[] destination_offsets_h, source_indices_h;
            float[] weights_h, bookmark_h, pr_1, pr_2;
            //void** vertex_dim;

            // nvgraph variables
            GraphContext handle;
            GraphDescriptor graph;
            nvgraphCSCTopology32I CSC_input;
            cudaDataType[] edge_dimT = new cudaDataType[] { cudaDataType.CUDA_R_32F };
            cudaDataType[] vertex_dimT;

            // use command-line specified CUDA device, otherwise use device with highest Gflops/s
            int cuda_device = 0;

            CudaDeviceProperties deviceProp = CudaContext.GetDeviceInfo(cuda_device);

            Console.WriteLine("> Detected Compute SM {0}.{1} hardware with {2} multi-processors",
                   deviceProp.ComputeCapability.Major, deviceProp.ComputeCapability.Minor, deviceProp.MultiProcessorCount);

            if (deviceProp.ComputeCapability.Major < 3)
            {
                Console.WriteLine("> nvGraph requires device SM 3.0+");
                Console.WriteLine("> Waiving.");
                return;
            }

            // Allocate host data
            destination_offsets_h = new int[n + 1];
            source_indices_h = new int[nnz];
            weights_h = new float[nnz];
            bookmark_h = new float[n];
            pr_1 = new float[n];
            pr_2 = new float[n];
            //vertex_dim = (void**)malloc(vertex_numsets * sizeof(void*));
            vertex_dimT = new cudaDataType[vertex_numsets];
            CSC_input = new nvgraphCSCTopology32I();

            // Initialize host data
            //vertex_dim[0] = (void*)bookmark_h; vertex_dim[1]= (void*)pr_1, vertex_dim[2]= (void*)pr_2;
            vertex_dimT[0] = cudaDataType.CUDA_R_32F; vertex_dimT[1] = cudaDataType.CUDA_R_32F; vertex_dimT[2]= cudaDataType.CUDA_R_32F;

            weights_h[0] = 0.333333f;
            weights_h[1] = 0.500000f;
            weights_h[2] = 0.333333f;
            weights_h[3] = 0.500000f;
            weights_h[4] = 0.500000f;
            weights_h[5] = 1.000000f;
            weights_h[6] = 0.333333f;
            weights_h[7] = 0.500000f;
            weights_h[8] = 0.500000f;
            weights_h[9] = 0.500000f;

            destination_offsets_h[0] = 0;
            destination_offsets_h[1] = 1;
            destination_offsets_h[2] = 3;
            destination_offsets_h[3] = 4;
            destination_offsets_h[4] = 6;
            destination_offsets_h[5] = 8;
            destination_offsets_h[6] = 10;

            source_indices_h[0] = 2;
            source_indices_h[1] = 0;
            source_indices_h[2] = 2;
            source_indices_h[3] = 0;
            source_indices_h[4] = 4;
            source_indices_h[5] = 5;
            source_indices_h[6] = 2;
            source_indices_h[7] = 3;
            source_indices_h[8] = 3;
            source_indices_h[9] = 4;

            bookmark_h[0] = 0.0f;
            bookmark_h[1] = 1.0f;
            bookmark_h[2] = 0.0f;
            bookmark_h[3] = 0.0f;
            bookmark_h[4] = 0.0f;
            bookmark_h[5] = 0.0f;

            // Starting nvgraph
            handle = new GraphContext();
            graph = handle.CreateGraphDecriptor();

            GCHandle destination_offsets_handle = GCHandle.Alloc(destination_offsets_h, GCHandleType.Pinned);
            GCHandle source_indices_handle = GCHandle.Alloc(source_indices_h, GCHandleType.Pinned);

            CSC_input.nvertices = n;
            CSC_input.nedges = nnz;
            CSC_input.destination_offsets = destination_offsets_handle.AddrOfPinnedObject();
            CSC_input.source_indices = source_indices_handle.AddrOfPinnedObject();

            // Set graph connectivity and properties (tranfers)
            graph.SetGraphStructure(CSC_input);
            graph.AllocateVertexData(vertex_dimT);
            graph.AllocateEdgeData(edge_dimT);

            graph.SetVertexData(bookmark_h, 0);
            graph.SetVertexData(pr_1, 1);
            graph.SetVertexData(pr_2, 2);

            graph.SetEdgeData(weights_h, 0);

            // First run with default values
            graph.Pagerank(0, alpha1, 0, 0, 1, 0.0f, 0);

            // Get and print result
            graph.GetVertexData(pr_1, 1);
            Console.WriteLine("pr_1, alpha = 0.85");
            for (i = 0; i<n; i++)
                Console.WriteLine(pr_1[i]);
            Console.WriteLine();

            // Second run with different damping factor and an initial guess
            for (i = 0; i<n; i++)
                pr_2[i] =pr_1[i];

            graph.SetVertexData(pr_2, 2);
            graph.Pagerank(0, alpha2, 0, 1, 2, 0.0f, 0);

            // Get and print result
            graph.GetVertexData(pr_2, 2);
            Console.WriteLine("pr_2, alpha = 0.90");
            for (i = 0; i < n; i++)
                Console.WriteLine(pr_2[i]);
            Console.WriteLine();

            //Clean
            graph.Dispose();
            handle.Dispose();

            Console.WriteLine("\nDone!");
        }
        public static extern cusparseStatus cusparseCsrsv_solveEx(cusparseContext handle, 
                                                   cusparseOperation transA, 
                                                   int m,
												   CUdeviceptr alpha, 
                                                   cudaDataType alphatype,
                                                   cusparseMatDescr descrA,
												   CUdeviceptr csrSortedValA, 
                                                   cudaDataType csrSortedValAtype,
												   CUdeviceptr csrSortedRowPtrA,
												   CUdeviceptr csrSortedColIndA, 
                                                   cusparseSolveAnalysisInfo info,
												   CUdeviceptr f, 
                                                   cudaDataType ftype,
												   CUdeviceptr x,
                                                   cudaDataType xtype,
                                                   cudaDataType executiontype);
        public static extern cusparseStatus cusparseCsrmvEx_bufferSize(cusparseContext handle,
														cusparseAlgMode alg,
														cusparseOperation transA,
														int m,
														int n,
														int nnz,
														CUdeviceptr alpha,
														cudaDataType alphatype,
														cusparseMatDescr descrA,
														CUdeviceptr csrValA,
														cudaDataType csrValAtype,
														CUdeviceptr csrRowPtrA,
														CUdeviceptr csrColIndA,
														CUdeviceptr x,
														cudaDataType xtype,
														CUdeviceptr beta,
														cudaDataType betatype,
														CUdeviceptr y,
														cudaDataType ytype,
														cudaDataType executiontype,
														ref SizeT bufferSizeInBytes);
 public static extern cusparseStatus cusparseCsrilu0Ex(cusparseContext handle, 
                                       cusparseOperation trans, 
                                       int m, 
                                       cusparseMatDescr descrA, 
                                       CUdeviceptr csrSortedValA_ValM, 
                                       cudaDataType csrSortedValA_ValMtype,
                                       /* matrix A values are updated inplace 
                                          to be the preconditioner M values */
                                       CUdeviceptr csrSortedRowPtrA, 
                                       CUdeviceptr csrSortedColIndA,
                                       cusparseSolveAnalysisInfo info,
                                       cudaDataType executiontype);
 public static extern cusparseStatus cusparseCsr2cscEx(cusparseContext handle,
                                       int m, 
                                       int n, 
                                       int nnz,
                                       CUdeviceptr csrSortedVal, 
                                       cudaDataType csrSortedValtype,
                                       CUdeviceptr csrSortedRowPtr, 
                                       CUdeviceptr csrSortedColInd, 
                                       CUdeviceptr cscSortedVal, 
                                       cudaDataType cscSortedValtype,
                                       CUdeviceptr cscSortedRowInd, 
                                       CUdeviceptr cscSortedColPtr, 
                                       cusparseAction copyValues, 
                                       cusparseIndexBase idxBase,
                                       cudaDataType executiontype);
Esempio n. 22
0
        public static extern CublasStatus cublasCherkEx(CudaBlasHandle handle,
															  FillMode uplo,
															  Operation trans,
															  int n,
															  int k,
															  CUdeviceptr alpha,  /* host or device pointer */
															  CUdeviceptr A,
															  cudaDataType Atype,
															  int lda,
															  CUdeviceptr beta,   /* host or device pointer */
															  CUdeviceptr C,
															  cudaDataType Ctype,
															  int ldc);
Esempio n. 23
0
 public static extern nvgraphStatus nvgraphConvertTopology(nvgraphContext handle,
                                 nvgraphTopologyType srcTType, nvgraphTopologyBase srcTopology, CUdeviceptr srcEdgeData, ref cudaDataType dataType,
                                 nvgraphTopologyType dstTType, nvgraphTopologyBase dstTopology, CUdeviceptr dstEdgeData);
Esempio n. 24
0
 public static extern nvgraphStatus nvgraphConvertTopology(nvgraphContext handle,
                                                           nvgraphTopologyType srcTType, nvgraphTopologyBase srcTopology, CUdeviceptr srcEdgeData, ref cudaDataType dataType,
                                                           nvgraphTopologyType dstTType, nvgraphTopologyBase dstTopology, CUdeviceptr dstEdgeData);
        /// <summary>
        ///
        /// </summary>
        /// <param name="cudaType"></param>
        /// <returns></returns>
        public static int GetSize(cudaDataType cudaType)
        {
            switch (cudaType)
            {
            case cudaDataType.CUDA_R_16F:
                return(2);

            case cudaDataType.CUDA_C_16F:
                return(4);

            case cudaDataType.CUDA_R_32F:
                return(4);

            case cudaDataType.CUDA_C_32F:
                return(8);

            case cudaDataType.CUDA_R_64F:
                return(8);

            case cudaDataType.CUDA_C_64F:
                return(16);

            case cudaDataType.CUDA_R_8I:
                return(1);

            case cudaDataType.CUDA_C_8I:
                return(2);

            case cudaDataType.CUDA_R_8U:
                return(1);

            case cudaDataType.CUDA_C_8U:
                return(2);

            case cudaDataType.CUDA_R_16BF:
                return(2);

            case cudaDataType.CUDA_C_16BF:
                return(4);

            //case cudaDataType.CUDA_R_4I:
            //    return typeof(int);
            //case cudaDataType.CUDA_C_4I:
            //    return typeof(int2);
            //case cudaDataType.CUDA_R_4U:
            //    return typeof(uint);
            //case cudaDataType.CUDA_C_4U:
            //    return typeof(uint2);
            case cudaDataType.CUDA_R_16I:
                return(2);

            case cudaDataType.CUDA_C_16I:
                return(4);

            case cudaDataType.CUDA_R_16U:
                return(2);

            case cudaDataType.CUDA_C_16U:
                return(4);

            case cudaDataType.CUDA_R_32I:
                return(4);

            case cudaDataType.CUDA_C_32I:
                return(8);

            case cudaDataType.CUDA_R_32U:
                return(4);

            case cudaDataType.CUDA_C_32U:
                return(8);

            case cudaDataType.CUDA_R_64I:
                return(8);

            case cudaDataType.CUDA_C_64I:
                return(16);

            case cudaDataType.CUDA_R_64U:
                return(8);

            case cudaDataType.CUDA_C_64U:
                return(16);

            default:
                throw new ArgumentException("Unsupported cuda type: " + cudaType.ToString());
            }
        }