/// <summary> /// Here the Stream is the NULL stream<para/> /// 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 static void AddCallbackToNullStream(CUstreamCallback callback, IntPtr userData, CUStreamAddCallbackFlags flags) { CUResult res = DriverAPINativeMethods.Streams.cuStreamAddCallback(new CUstream(), callback, userData, flags); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuStreamAddCallback", res)); if (res != CUResult.Success) { throw new CudaException(res); } }
/// <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); } }
/// <summary> /// Here the Stream is the NULL stream<para/> /// 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 static void AddCallbackToNullStream(CUstreamCallback callback, IntPtr userData, CUStreamAddCallbackFlags flags) { CUResult res = DriverAPINativeMethods.Streams.cuStreamAddCallback(new CUstream(), callback, userData, flags); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuStreamAddCallback", res)); if (res != CUResult.Success) throw new CudaException(res); }
public static extern CUResult cuStreamAddCallback(CUstream hStream, CUstreamCallback callback, IntPtr userData, CUStreamAddCallbackFlags flags);
/// <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); }