コード例 #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);
            }
        }
コード例 #2
0
        /// <summary/>
        public static string nvgraphStatusGetString(nvgraphStatus status)
        {
            IntPtr ptr = nvgraphStatusGetStringInternal(status);
            string result;

            result = Marshal.PtrToStringAnsi(ptr);
            return(result);
        }
コード例 #3
0
ファイル: GraphContext.cs プロジェクト: kunzmi/managedCuda
        /// <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);
        }
コード例 #4
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);
     }
 }
コード例 #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);
            }
        }
コード例 #6
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);
     }
 }
コード例 #7
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);
     }
 }
コード例 #8
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);
            }
        }
コード例 #9
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);
            }
        }
コード例 #10
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()));
     }
 }
コード例 #11
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);
        }
コード例 #12
0
        private static string GetErrorMessageFromNVgraphStatus(nvgraphStatus error)
        {
            string message = string.Empty;

            switch (error)
            {
            case nvgraphStatus.Success:
                message = "No error.";
                break;

            case nvgraphStatus.NotInitialized:
                message = "NotInitialized";
                break;

            case nvgraphStatus.AllocFailed:
                message = "AllocFailed";
                break;

            case nvgraphStatus.InvalidValue:
                message = "InvalidValue";
                break;

            case nvgraphStatus.ArchMismatch:
                message = "ArchMismatch";
                break;

            case nvgraphStatus.MappingError:
                message = "MappingError";
                break;

            case nvgraphStatus.ExecutionFailed:
                message = "ExecutionFailed";
                break;

            case nvgraphStatus.InternalError:
                message = "InternalError";
                break;

            case nvgraphStatus.TypeNotSupported:
                message = "TypeNotSupported";
                break;

            case nvgraphStatus.NotConverged:
                message = "NotConverged";
                break;

            default:
                break;
            }
            return(error.ToString() + ": " + message);
        }
コード例 #13
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();
            }
        }
コード例 #14
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();
            }
        }
コード例 #15
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();
            }
        }
コード例 #16
0
 private static extern IntPtr nvgraphStatusGetStringInternal(nvgraphStatus status);
コード例 #17
0
 /// <summary/>
 public static string nvgraphStatusGetString(nvgraphStatus status)
 {
     IntPtr ptr = nvgraphStatusGetStringInternal(status);
     string result;
     result = Marshal.PtrToStringAnsi(ptr);
     return result;
 }
コード例 #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="error"></param>
 /// <param name="message"></param>
 /// <param name="exception"></param>
 public NVGraphException(nvgraphStatus error, string message, Exception exception)
     : base(message, exception)
 {
     this._nvgraphError = error;
     this._internalName = GetInternalNameFromNVgraphStatus(error);
 }
コード例 #19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="error"></param>
 public NVGraphException(nvgraphStatus error)
     : base(GetErrorMessageFromNVgraphStatus(error))
 {
     this._nvgraphError = error;
     this._internalName = GetInternalNameFromNVgraphStatus(error);
 }
コード例 #20
0
        private static string GetInternalNameFromNVgraphStatus(nvgraphStatus error)
        {
            string val = NVGraphNativeMathods.nvgraphStatusGetString(error);

            return(val);
        }
コード例 #21
0
 private static extern IntPtr nvgraphStatusGetStringInternal(nvgraphStatus status);
コード例 #22
0
        private static string GetErrorMessageFromNVgraphStatus(nvgraphStatus error)
        {
            string message = string.Empty;

            switch (error)
            {
                case nvgraphStatus.Success:
                    message = "No error.";
                    break;
                case nvgraphStatus.NotInitialized:
                    message = "NotInitialized";
                    break;
                case nvgraphStatus.AllocFailed:
                    message = "AllocFailed";
                    break;
                case nvgraphStatus.InvalidValue:
                    message = "InvalidValue";
                    break;
                case nvgraphStatus.ArchMismatch:
                    message = "ArchMismatch";
                    break;
                case nvgraphStatus.MappingError:
                    message = "MappingError";
                    break;
                case nvgraphStatus.ExecutionFailed:
                    message = "ExecutionFailed";
                    break;
                case nvgraphStatus.InternalError:
                    message = "InternalError";
                    break;
                case nvgraphStatus.TypeNotSupported:
                    message = "TypeNotSupported";
                    break;
                case nvgraphStatus.NotConverged:
                    message = "NotConverged";
                    break;
                default:
                    break;
            }
            return error.ToString() + ": " + message;
        }
コード例 #23
0
ファイル: GraphContext.cs プロジェクト: kunzmi/managedCuda
 /// <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()));
 }
コード例 #24
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="error"></param>
 /// <param name="message"></param>
 /// <param name="exception"></param>
 public NVGraphException(nvgraphStatus error, string message, Exception exception)
     : base(message, exception)
 {
     this._nvgraphError = error;
     this._internalName = GetInternalNameFromNVgraphStatus(error);
 }
コード例 #25
0
 private static string GetInternalNameFromNVgraphStatus(nvgraphStatus error)
 {
     string val = NVGraphNativeMathods.nvgraphStatusGetString(error);
     return val;
 }
コード例 #26
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="error"></param>
 public NVGraphException(nvgraphStatus error)
     : base(GetErrorMessageFromNVgraphStatus(error))
 {
     this._nvgraphError = error;
     this._internalName = GetInternalNameFromNVgraphStatus(error);
 }