Exemplo n.º 1
0
        //public void SetGraphStructure(nvgraphCSRTopology32I topologyData)
        //{
        //	res = NVGraphNativeMathods.nvgraphSetGraphStructure(_context, _descr, ref topologyData, nvgraphTopologyType.CSR32);
        //	Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphSetGraphStructure", res));
        //	if (res != nvgraphStatus.Success) throw new NVGraphException(res);
        //}

        //public void SetGraphStructure(nvgraphCSCTopology32I topologyData)
        //{
        //	res = NVGraphNativeMathods.nvgraphSetGraphStructure(_context, _descr, ref topologyData, nvgraphTopologyType.CSC32);
        //	Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphSetGraphStructure", res));
        //	if (res != nvgraphStatus.Success) throw new NVGraphException(res);
        //      }

        public void SetGraphStructure(nvgraphTopologyBase topologyData)
        {
            nvgraphTopologyType type;

            if (topologyData is nvgraphCSRTopology32I)
            {
                type = nvgraphTopologyType.CSR32;
            }
            else
            {
                if (topologyData is nvgraphCSCTopology32I)
                {
                    type = nvgraphTopologyType.CSC32;
                }
                else
                {
                    type = nvgraphTopologyType.COO32;
                }
            }


            res = NVGraphNativeMathods.nvgraphSetGraphStructure(_context, _descr, topologyData, type);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphSetGraphStructure", res));
            if (res != nvgraphStatus.Success)
            {
                throw new NVGraphException(res);
            }
        }
Exemplo n.º 2
0
 public void WidestPath(SizeT weight_index, ref int source_vert, SizeT widest_path_index)
 {
     res = NVGraphNativeMathods.nvgraphWidestPath(_context, _descr, weight_index, ref source_vert, widest_path_index);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphWidestPath", res));
     if (res != nvgraphStatus.Success)
     {
         throw new NVGraphException(res);
     }
 }
Exemplo n.º 3
0
 public void GetEdgeData <Type>(CudaDeviceVariable <Type> edgeData, SizeT setnum) where Type : struct
 {
     res = NVGraphNativeMathods.nvgraphGetEdgeData(_context, _descr, edgeData.DevicePointer, setnum);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphGetEdgeData", res));
     if (res != nvgraphStatus.Success)
     {
         throw new NVGraphException(res);
     }
 }
Exemplo n.º 4
0
 public void AllocateEdgeData(cudaDataType[] settypes)
 {
     res = NVGraphNativeMathods.nvgraphAllocateEdgeData(_context, _descr, settypes.Length, settypes);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphAllocateEdgeData", res));
     if (res != nvgraphStatus.Success)
     {
         throw new NVGraphException(res);
     }
 }
Exemplo n.º 5
0
        //      public void GetGraphStructure(ref nvgraphCSRTopology32I topologyData)
        //{
        //          nvgraphTopologyType type = nvgraphTopologyType.CSR32;
        //          res = NVGraphNativeMathods.nvgraphGetGraphStructure(_context, _descr, ref topologyData, ref type);
        //	Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphGetGraphStructure", res));
        //	if (res != nvgraphStatus.Success) throw new NVGraphException(res);
        //}

        //public void GetGraphStructure(ref nvgraphCSCTopology32I topologyData)
        //      {
        //          nvgraphTopologyType type = nvgraphTopologyType.CSC32;
        //          res = NVGraphNativeMathods.nvgraphGetGraphStructure(_context, _descr, ref topologyData, ref type);
        //	Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphGetGraphStructure", res));
        //	if (res != nvgraphStatus.Success) throw new NVGraphException(res);
        //}

        public void GetGraphStructure(nvgraphTopologyBase topologyData, ref nvgraphTopologyType type)
        {
            res = NVGraphNativeMathods.nvgraphGetGraphStructure(_context, _descr, topologyData, ref type);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphGetGraphStructure", res));
            if (res != nvgraphStatus.Success)
            {
                throw new NVGraphException(res);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// </summary>
        public GraphContext()
        {
            _context = new nvgraphContext();

            res = NVGraphNativeMathods.nvgraphCreate(ref _context);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphCreate", res));
            if (res != nvgraphStatus.Success)
            {
                throw new NVGraphException(res);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// </summary>
        internal GraphDescriptor(nvgraphContext context)
        {
            _descr   = new nvgraphGraphDescr();
            _context = context;

            res = NVGraphNativeMathods.nvgraphCreateGraphDescr(_context, ref _descr);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphCreateGraphDescr", res));
            if (res != nvgraphStatus.Success)
            {
                throw new NVGraphException(res);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// For IDisposable
 /// </summary>
 /// <param name="fDisposing"></param>
 protected virtual void Dispose(bool fDisposing)
 {
     if (fDisposing && !disposed)
     {
         res = NVGraphNativeMathods.nvgraphDestroy(_context);
         Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphDestroy", res));
         disposed = true;
     }
     if (!fDisposing && !disposed)
     {
         Debug.WriteLine(String.Format("ManagedCUDA.NVGraph not-disposed warning: {0}", this.GetType()));
     }
 }
Exemplo n.º 9
0
        public GraphDescriptor ExtractSubgraphByEdge(int[] subedges)
        {
            GraphDescriptor subdescr = new GraphDescriptor(_context);

            res = NVGraphNativeMathods.nvgraphExtractSubgraphByEdge(_context, _descr, subdescr.GraphDescr, subedges, subedges.Length);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphExtractSubgraphByEdge", res));
            if (res != nvgraphStatus.Success)
            {
                throw new NVGraphException(res);
            }

            return(subdescr);
        }
Exemplo n.º 10
0
        public void Pagerank(SizeT weight_index, Array alpha, SizeT bookmark_index, int has_guess, SizeT pagerank_index, float tolerance, int max_iter)
        {
            GCHandle alphaHandle = GCHandle.Alloc(alpha, GCHandleType.Pinned);

            try
            {
                res = NVGraphNativeMathods.nvgraphPagerank(_context, _descr, weight_index, alphaHandle.AddrOfPinnedObject(), bookmark_index, has_guess, pagerank_index, tolerance, max_iter);
                Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphPagerank", res));
                if (res != nvgraphStatus.Success)
                {
                    throw new NVGraphException(res);
                }
            }
            finally
            {
                alphaHandle.Free();
            }
        }
Exemplo n.º 11
0
        public void GetEdgeData(Array edgeData, SizeT setnum)
        {
            GCHandle handle = GCHandle.Alloc(edgeData, GCHandleType.Pinned);

            try
            {
                res = NVGraphNativeMathods.nvgraphGetEdgeData(_context, _descr, handle.AddrOfPinnedObject(), setnum);
                Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphGetEdgeData", res));
                if (res != nvgraphStatus.Success)
                {
                    throw new NVGraphException(res);
                }
            }
            finally
            {
                handle.Free();
            }
        }
Exemplo n.º 12
0
        public void SrSpmv(SizeT weight_index, Array alpha, SizeT x_index, Array beta, SizeT y_index, nvgraphSemiring SR)
        {
            GCHandle alphaHandle = GCHandle.Alloc(alpha, GCHandleType.Pinned);
            GCHandle betaHandle  = GCHandle.Alloc(beta, GCHandleType.Pinned);

            try
            {
                res = NVGraphNativeMathods.nvgraphSrSpmv(_context, _descr, weight_index, alphaHandle.AddrOfPinnedObject(), x_index, betaHandle.AddrOfPinnedObject(), y_index, SR);
                Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvgraphSrSpmv", res));
                if (res != nvgraphStatus.Success)
                {
                    throw new NVGraphException(res);
                }
            }
            finally
            {
                alphaHandle.Free();
                betaHandle.Free();
            }
        }
Exemplo n.º 13
0
        private static string GetInternalNameFromNVgraphStatus(nvgraphStatus error)
        {
            string val = NVGraphNativeMathods.nvgraphStatusGetString(error);

            return(val);
        }