public static void ThrowIfFailed(CudaError cudaStatus) { if (cudaStatus != CudaError.CUDA_SUCCESS) { throw new CudaException(cudaStatus); } }
internal static void VerifyDisposed(bool disposing, CudaError cudaStatus) { if (disposing) { ThrowIfFailed(cudaStatus); } }
/// <summary> /// Resolves the error string for the given error status. /// </summary> /// <param name="error">The error to resolve.</param> /// <returns>The resolved error string.</returns> public string GetErrorString(CudaError error) { if (GetErrorString(error, out IntPtr ptr) != CudaError.CUDA_SUCCESS) { return(RuntimeErrorMessages.CannotResolveErrorString); } return(Marshal.PtrToStringAnsi(ptr)); }
public CudaError EnsureCapacity(SizeT lastSizeInBytes, SizeT newSizeInBytes) { if (newSizeInBytes <= lastSizeInBytes && Handle != IntPtr.Zero) { return(CudaError.Success); } if (Handle != IntPtr.Zero) { CudaError error = Deallocate(this); if (error != CudaError.Success) { return(error); } } return(Allocate(newSizeInBytes, ref this)); }
/// <summary> /// Constructs a new Cuda exception. /// </summary> /// <param name="error">The Cuda runtime error.</param> public CudaException(CudaError error) : base(CurrentAPI.GetErrorString(error)) { Error = error.ToString(); }
/// <summary> /// Constructs a new Cuda exception. /// </summary> /// <param name="error">The Cuda runtime error.</param> private CudaException(CudaError error) : base(CudaAPI.Current.GetErrorString(error)) { Error = error.ToString(); }
public CudaException(CudaError error, Exception innerException) : this(error, null, innerException) { }
public CudaException(CudaError error, String message, Exception innerException) : base(innerException) { Error = error.AssertThat(ec => ec != CudaError.Success); _message = message; }
/// <summary cref="CudaAPI.GetErrorString(CudaError, out IntPtr)"/> internal override CudaError GetErrorString(CudaError error, out IntPtr pStr) { return(cuGetErrorString(error, out pStr)); }
private static extern CudaError cuGetErrorString( [In] CudaError error, [Out] out IntPtr pStr);
/// <summary cref="CudaAPI.GetErrorString(CudaError, out IntPtr)"/> internal override CudaError GetErrorString(CudaError error, out IntPtr pStr) => cuGetErrorString(error, out pStr);
public CudaException(CudaError error, String message) : this(error, message, null) { }
public CudaResult(CudaError error, T result) { Error = error; Result = result; }
public CudaException(CudaError error) : this(error, null, null) { }
/// <summary> /// Resolves the error string for the given error status. /// </summary> /// <param name="error">The error to resolve.</param> /// <param name="pStr">The resolved error string.</param> /// <returns>The error status.</returns> internal abstract CudaError GetErrorString( CudaError error, out IntPtr pStr);
/// <summary cref="CudaAPI.GetErrorString(CudaError, out IntPtr)"/> internal override CudaError GetErrorString(CudaError error, out IntPtr pStr) { pStr = IntPtr.Zero; return(CudaError.CUDA_ERROR_NOT_INITIALIZED); }
/// <summary> /// Resolves the error string for the given error status. /// </summary> /// <param name="error">The error to resolve.</param> /// <returns>The resolved error string.</returns> public string GetErrorString(CudaError error) => cuGetErrorString(error, out IntPtr ptr) != CudaError.CUDA_SUCCESS ? RuntimeErrorMessages.CannotResolveErrorString : Marshal.PtrToStringAnsi(ptr);