当前位置: 首页>>代码示例>>C#>>正文


C# CUResult类代码示例

本文整理汇总了C#中CUResult的典型用法代码示例。如果您正苦于以下问题:C# CUResult类的具体用法?C# CUResult怎么用?C# CUResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CUResult类属于命名空间,在下文中一共展示了CUResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CudaException

		/// <summary>
		/// 
		/// </summary>
		/// <param name="error"></param>
		public CudaException(CUResult error)
			: base(GetErrorMessageFromCUResult(error))
		{
			this._cudaError = error;
			this._internalDescripton = GetInternalDescriptionFromCUResult(error);
			this._internalName = GetInternalNameFromCUResult(error);
		}
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:11,代码来源:CudaException.cs

示例2: CudaSurface

		/// <summary>
		/// Creates a new surface from array memory. Allocates new array.
		/// </summary>
		/// <param name="kernel"></param>
		/// <param name="surfName"></param>
		/// <param name="flags"></param>
		/// <param name="format"></param>
		/// <param name="width">In elements</param>
		/// <param name="height">In elements</param>
		/// <param name="depth">In elements</param>
		/// <param name="numChannels"></param>
		/// <param name="arrayFlags"></param>
		public CudaSurface(CudaKernel kernel, string surfName, CUSurfRefSetFlags flags, CUArrayFormat format, SizeT width, SizeT height, SizeT depth, CudaArray3DNumChannels numChannels, CUDAArray3DFlags arrayFlags)
		{
			_surfref = new CUsurfref();
			res = DriverAPINativeMethods.ModuleManagement.cuModuleGetSurfRef(ref _surfref, kernel.CUModule, surfName);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}, Surface name: {3}", DateTime.Now, "cuModuleGetSurfRef", res, surfName));
			if (res != CUResult.Success) throw new CudaException(res);

			_flags = flags;
			_format = format;
			_height = height;
			_width = width;
			_depth = depth;
			_numChannels = (int)numChannels;
			_name = surfName;
			_module = kernel.CUModule;
			_cufunction = kernel.CUFunction;

			_channelSize = CudaHelperMethods.GetChannelSize(format);
			_dataSize = height * width * depth * _numChannels * _channelSize;
			_array = new CudaArray3D(format, width, height, depth, numChannels, arrayFlags);

			res = DriverAPINativeMethods.SurfaceReferenceManagement.cuSurfRefSetArray(_surfref, _array.CUArray, flags);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuSurfRefSetArray", res));
			if (res != CUResult.Success) throw new CudaException(res);
		}
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:37,代码来源:CudaSurface.cs

示例3: CudaEvent

        /// <summary>
        /// Creates a new Event
        /// </summary>
        /// <param name="flags">Parameters for event creation</param>
        public CudaEvent(CUEventFlags flags)
        {
            _event = new CUevent();

            res = DriverAPINativeMethods.Events.cuEventCreate(ref _event, flags);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuEventCreate", res));
            if (res != CUResult.Success) throw new CudaException(res);
        }
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:12,代码来源:CudaEvent.cs

示例4: CudaStream

        /// <summary>
        /// Creates a new Stream
        /// </summary>
        /// <param name="flags">Parameters for stream creation (must be <see cref="CUStreamFlags.None"/>)</param>
        public CudaStream(CUStreamFlags flags)
        {
            _stream = new CUstream();

            res = DriverAPINativeMethods.Streams.cuStreamCreate(ref _stream, flags);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuStreamCreate", res));
            if (res != CUResult.Success) throw new CudaException(res);
			_isOwner = true;
        }
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:13,代码来源:CudaStream.cs

示例5: CudaSurfObject

		/// <summary>
		/// Creates a surface object. <c>ResDesc</c> describes
		/// the data to perform surface load/stores on. <c>ResDesc.resType</c> must be 
		/// <see cref="CUResourceType.Array"/> and  <c>ResDesc.hArray</c>
		/// must be set to a valid CUDA array handle.
		/// </summary>
		/// <param name="array">CudaArray1D</param>
		public CudaSurfObject(CudaArray1D array)
		{
			_resDesc = new CudaResourceDesc(array);

			_surfObject = new CUsurfObject();
			res = DriverAPINativeMethods.SurfaceObjects.cuSurfObjectCreate(ref _surfObject, ref _resDesc);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuSurfObjectCreate", res));
			if (res != CUResult.Success) throw new CudaException(res);
		}
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:16,代码来源:CudaSurfObject.cs

示例6: CudaTexObject

		/// <summary>
		/// Creates a texture object and returns it in pTexObject. pResDesc describes the data to texture from. pTexDesc
		/// describes how the data should be sampled.
		/// </summary>
		/// <param name="resDesc">CudaResourceDesc</param>
		/// <param name="texDesc">CudaTextureDescriptor</param>
		public CudaTexObject(CudaResourceDesc resDesc, CudaTextureDescriptor texDesc)
		{
			_resDesc = resDesc;
			_texDesc = texDesc;

			_texObject = new CUtexObject();
			res = DriverAPINativeMethods.TextureObjects.cuTexObjectCreate(ref _texObject, ref _resDesc, ref _texDesc, IntPtr.Zero);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexObjectCreate", res));
			if (res != CUResult.Success) throw new CudaException(res);


		}
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:18,代码来源:CudaTexObject.cs

示例7: CudaLinker

		/// <summary>
		/// Creates a pending JIT linker invocation.
		/// </summary>
		/// <param name="options">Collection of linker and compiler options</param>
		public CudaLinker(CudaJitOptionCollection options)
		{
			
			_state = new CUlinkState();

			if (options == null) 
				res = DriverAPINativeMethods.ModuleManagement.cuLinkCreate(0, null, null, ref _state);
			else
				res = DriverAPINativeMethods.ModuleManagement.cuLinkCreate((uint)options.Count, options.Options, options.Values, ref _state);

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

		}
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:20,代码来源:CudaLinker.cs

示例8: CudaTextureArray1D

        /// <summary>
        /// Creates a new 1D texture from array memory. Allocates new array.
        /// </summary>
        /// <param name="kernel"></param>
        /// <param name="texName"></param>
        /// <param name="addressMode"></param>
        /// <param name="filterMode"></param>
        /// <param name="flags"></param>
        /// <param name="format"></param>
        /// <param name="size">In elements</param>
        /// <param name="numChannels"></param>
        public CudaTextureArray1D(CudaKernel kernel, string texName, CUAddressMode addressMode, CUFilterMode filterMode, CUTexRefSetFlags flags, CUArrayFormat format, SizeT size, CudaArray1DNumChannels numChannels)
        {
            _texref = new CUtexref();
            res = DriverAPINativeMethods.ModuleManagement.cuModuleGetTexRef(ref _texref, kernel.CUModule, texName);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}, Texture name: {3}", DateTime.Now, "cuModuleGetTexRef", res, texName));
            if (res != CUResult.Success) throw new CudaException(res);

            res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetAddressMode(_texref, 0, addressMode);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetAddressMode", res));
            if (res != CUResult.Success) throw new CudaException(res);
            res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetFilterMode(_texref, filterMode);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetFilterMode", res));
            if (res != CUResult.Success) throw new CudaException(res);
            res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetFlags(_texref, flags);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetFlags", res));
            if (res != CUResult.Success) throw new CudaException(res);
            res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetFormat(_texref, format, (int)numChannels);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetFormat", res));
            if (res != CUResult.Success) throw new CudaException(res);

            _filtermode = filterMode;
            _flags = flags;
            _addressMode = addressMode;
            _format = format;
            _size = size;
            _numChannels = (int)numChannels;
            _name = texName;
            _module = kernel.CUModule;
            _cufunction = kernel.CUFunction;

            _channelSize = CudaHelperMethods.GetChannelSize(format);
            _dataSize = size * _numChannels * _channelSize;
            _array = new CudaArray1D(format, size, numChannels);

            res = DriverAPINativeMethods.TextureReferenceManagement.cuTexRefSetArray(_texref, _array.CUArray, CUTexRefSetArrayFlags.OverrideFormat);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuTexRefSetArray", res));
            if (res != CUResult.Success) throw new CudaException(res);
            //res = DriverAPINativeMethods.ParameterManagement.cuParamSetTexRef(_cufunction, CUParameterTexRef.Default, _texref);
            //Debug.WriteLine("{0:G}, {1}: {2}", DateTime.Now, "cuParamSetTexRef", res);
            //if (res != CUResult.Success) throw new CudaException(res);
        }
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:52,代码来源:CudaTextureArray1D.cs

示例9: AddCallback

		/// <summary> 
		/// Adds a callback to be called on the host after all currently enqueued
		/// items in the stream have completed.  For each 
		/// cuStreamAddCallback call, the callback will be executed exactly once.
		/// The callback will block later work in the stream until it is finished.
		/// <para/>
		/// The callback may be passed <see cref="CUResult.Success"/> or an error code.  In the event
		/// of a device error, all subsequently executed callbacks will receive an
		/// appropriate <see cref="CUResult"/>.
		/// <para/>
		/// Callbacks must not make any CUDA API calls.  Attempting to use a CUDA API
		/// will result in <see cref="CUResult.ErrorNotPermitted"/>.  Callbacks must not perform any
		/// synchronization that may depend on outstanding device work or other callbacks
		/// that are not mandated to run earlier.  Callbacks without a mandated order
		/// (in independent streams) execute in undefined order and may be serialized.
		/// <para/>
		/// This API requires compute capability 1.1 or greater.  See
		/// cuDeviceGetAttribute or ::cuDeviceGetProperties to query compute
		/// capability.  Attempting to use this API with earlier compute versions will
		/// return <see cref="CUResult.ErrorNotSupported"/>.
		/// </summary>
		/// <param name="callback">The function to call once preceding stream operations are complete</param>
		/// <param name="userData">User specified data to be passed to the callback function. Use GCAlloc to pin a managed object</param>
		/// <param name="flags">Callback flags (must be CUStreamAddCallbackFlags.None)</param>
		public void AddCallback(CUstreamCallback callback, IntPtr userData, CUStreamAddCallbackFlags flags)
		{
			if (disposed) throw new ObjectDisposedException(this.ToString());
			
			res = DriverAPINativeMethods.Streams.cuStreamAddCallback(_stream, callback, userData, flags);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuStreamAddCallback", res));
			if (res != CUResult.Success) throw new CudaException(res);
			
		}
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:33,代码来源:CudaStream.cs

示例10: WaitEvent

        /// <summary>
        /// Make a compute stream wait on an event<para/>
        /// Makes all future work submitted to the Stream wait until <c>hEvent</c>
        /// reports completion before beginning execution. This synchronization
        /// will be performed efficiently on the device.
        /// <para/>
        /// The stream will wait only for the completion of the most recent
        /// host call to <see cref="CudaEvent.Record()"/> on <c>hEvent</c>. Once this call has returned,
        /// any functions (including <see cref="CudaEvent.Record()"/> and <see cref="Dispose()"/> may be
        /// called on <c>hEvent</c> again, and the subsequent calls will not have any
        /// effect on this stream.
        /// <para/>
        /// If <c>hStream</c> is 0 (the NULL stream) any future work submitted in any stream
        /// will wait for <c>hEvent</c> to complete before beginning execution. This
        /// effectively creates a barrier for all future work submitted to the context.
        /// <para/>
        /// If <see cref="CudaEvent.Record()"/> has not been called on <c>hEvent</c>, this call acts as if
        /// the record has already completed, and so is a functional no-op.
        /// </summary>
        /// <returns></returns>
        public void WaitEvent(CUevent cuevent)
        {
            if (disposed) throw new ObjectDisposedException(this.ToString());
            res = DriverAPINativeMethods.Streams.cuStreamWaitEvent(_stream, cuevent, 0);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuStreamWaitEvent", res));
            if (res != CUResult.Success) throw new CudaException(res);

        }
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:28,代码来源:CudaStream.cs

示例11: Query

        /// <summary>
        /// Returns true if all operations in the stream have completed, or
        /// false if not.
        /// </summary>
        /// <returns></returns>
        public bool Query()
        {
            if (disposed) throw new ObjectDisposedException(this.ToString());
            res = DriverAPINativeMethods.Streams.cuStreamQuery(_stream);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuStreamQuery", res));
            if (res != CUResult.Success && res != CUResult.ErrorNotReady) throw new CudaException(res);

            if (res == CUResult.Success) return true;
            return false; // --> ErrorNotReady
        }
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:15,代码来源:CudaStream.cs

示例12: Synchronize

 /// <summary>
 /// Waits until the device has completed all operations in the stream. If the context was created
 /// with the <see cref="CUCtxFlags.BlockingSync"/> flag, the CPU thread will block until the stream is finished with all of its
 /// tasks.
 /// </summary>
 public void Synchronize()
 {
     if (disposed) throw new ObjectDisposedException(this.ToString());
     res = DriverAPINativeMethods.Streams.cuStreamSynchronize(_stream);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuStreamSynchronize", res));
     if (res != CUResult.Success) throw new CudaException(res);
 }
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:12,代码来源:CudaStream.cs

示例13: GetInternalNameFromCUResult

		private static string GetInternalNameFromCUResult(CUResult error)
		{
			IntPtr name = new IntPtr();

			DriverAPINativeMethods.ErrorHandling.cuGetErrorName(error, ref name);
			string val = Marshal.PtrToStringAnsi(name);			
			return val;
		}
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:8,代码来源:CudaException.cs

示例14: BindArray

		/// <summary>
		/// Bind a CudaArray3D to a surface reference.
		/// </summary>
		/// <param name="kernel"></param>
		/// <param name="surfName"></param>
		/// <param name="flags"></param>
		/// <param name="array"></param>
		public static void BindArray(CudaKernel kernel, string surfName, CUSurfRefSetFlags flags, CudaArray3D array)
		{
			CUsurfref surfref = new CUsurfref();
			CUResult res = DriverAPINativeMethods.ModuleManagement.cuModuleGetSurfRef(ref surfref, kernel.CUModule, surfName);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}, Surface name: {3}", DateTime.Now, "cuModuleGetSurfRef", res, surfName));
			if (res != CUResult.Success) throw new CudaException(res);
			
			res = DriverAPINativeMethods.SurfaceReferenceManagement.cuSurfRefSetArray(surfref, array.CUArray, flags);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuSurfRefSetArray", res));
			if (res != CUResult.Success) throw new CudaException(res);
		}
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:18,代码来源:CudaSurface.cs

示例15: GetLevelAsCUArray

		/// <summary>
		/// Returns a CUDA array that represents a single mipmap level
		/// of the CUDA mipmapped array.
		/// </summary>
		/// <param name="level">Mipmap level</param>
		public CUarray GetLevelAsCUArray(uint level)
		{
			CUarray array = new CUarray();

			res = DriverAPINativeMethods.ArrayManagement.cuMipmappedArrayGetLevel(ref array, _mipmappedArray, level);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuMipmappedArrayGetLevel", res));
			if (res != CUResult.Success)
				throw new CudaException(res);

			return array;
		}
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:16,代码来源:CudaMipmappedArray.cs


注:本文中的CUResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。