internal Event(EventSafeHandle handle) { if (handle == null) { throw new ArgumentNullException(nameof(handle)); } _handle = handle; }
public static void SetUserEventStatus(EventSafeHandle @event, ExecutionStatus executionStatus) { if (@event == null) { throw new ArgumentNullException("event"); } ErrorHandler.ThrowOnFailure(clSetUserEventStatus(@event, executionStatus)); }
private static extern ErrorCode clEnqueueNDRangeKernel( CommandQueueSafeHandle commandQueue, KernelSafeHandle kernel, uint workDim, [In, MarshalAs(UnmanagedType.LPArray)] IntPtr[] globalWorkOffset, [In, MarshalAs(UnmanagedType.LPArray)] IntPtr[] globalWorkSize, [In, MarshalAs(UnmanagedType.LPArray)] IntPtr[] localWorkSize, uint numEventsInWaitList, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(SafeHandleArrayMarshaler))] EventSafeHandle[] eventWaitList, out EventSafeHandle @event);
private static extern ErrorCode clEnqueueNativeKernel( CommandQueueSafeHandle commandQueue, NativeKernelFunction userFunction, IntPtr args, IntPtr cbArgs, uint numMemObjects, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(SafeHandleArrayMarshaler))] MemObjectSafeHandle[] memList, [In, MarshalAs(UnmanagedType.LPArray)] IntPtr[] argsMemLoc, uint numEventsInWaitList, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(SafeHandleArrayMarshaler))] EventSafeHandle[] eventWaitList, out EventSafeHandle @event);
public Event EnqueueCopyImage(Image sourceImage, Image destinationImage, BufferCoordinates sourceOrigin, BufferCoordinates destinationOrigin, BufferSize region, params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueCopyImage(Handle, sourceImage.Handle, destinationImage.Handle, ref sourceOrigin, ref destinationOrigin, ref region, eventHandles); return(new Event(handle)); }
public Event EnqueueFillImage(Image image, uint[] fillColor, BufferCoordinates origin, BufferSize region, params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueFillImage(Handle, image.Handle, fillColor, ref origin, ref region, eventHandles); return(new Event(handle)); }
public Event EnqueueWriteImage(Image image, bool blocking, BufferCoordinates origin, BufferSize region, long inputRowPitch, long inputSlicePitch, IntPtr source, params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueWriteImage(Handle, image.Handle, blocking, ref origin, ref region, (IntPtr)inputRowPitch, (IntPtr)inputSlicePitch, source, eventHandles); return(new Event(handle)); }
public Event EnqueueMapBuffer(Buffer buffer, bool blocking, MapFlags mapFlags, long offset, long size, out IntPtr mappedPointer, params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueMapBuffer(Handle, buffer.Handle, blocking, mapFlags, (IntPtr)offset, (IntPtr)size, out mappedPointer, eventHandles); return(new Event(handle)); }
public Event EnqueueCopyBufferRect(Buffer source, Buffer destination, BufferCoordinates sourceOrigin, BufferCoordinates destinationOrigin, BufferSize region, long sourceRowPitch, long sourceSlicePitch, long destinationRowPitch, long destinationSlicePitch, params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueCopyBufferRect(Handle, source.Handle, destination.Handle, ref sourceOrigin, ref destinationOrigin, ref region, (IntPtr)sourceRowPitch, (IntPtr)sourceSlicePitch, (IntPtr)destinationRowPitch, (IntPtr)destinationSlicePitch, eventHandles); return(new Event(handle)); }
public Event EnqueueCopyBuffer(Buffer source, Buffer destination, long sourceOffset, long destinationOffset, long size, params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueCopyBuffer(Handle, source.Handle, destination.Handle, (IntPtr)sourceOffset, (IntPtr)destinationOffset, (IntPtr)size, eventHandles); return(new Event(handle)); }
public Event EnqueueUnmapMemObject(MemObject memObject, IntPtr mappedPointer, params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueUnmapMemObject(Handle, memObject.BaseHandle, mappedPointer, eventHandles); return(new Event(handle)); }
/// <summary> /// Enqueues a command to execute a <see cref="Kernel"/> on this command queue's <see cref="Device"/>. /// </summary> /// <remarks> /// The kernel is executed using a single work-item. /// /// <para><see cref="EnqueueTask"/> is equivalent to calling /// <see cref="EnqueueNDRangeKernel(Kernel, IntPtr, IntPtr, Event[])"/> with /// <em>globalWorkSize</em> set to 1, and <em>localWorkSize</em> set to 1.</para> /// </remarks> /// <param name="kernel">A valid <see cref="Kernel"/> object.</param> /// <param name="eventWaitList">The events that need to be complete before this /// command is executed. If the list is null or empty, this command does not /// wait on any event to complete.</param> /// <returns>Returns an event object that identifies this particular kernel execution instance.</returns> public Event EnqueueTask(Kernel kernel, params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueTask(Handle, kernel.Handle, eventHandles); return(new Event(handle)); }
public Event EnqueueWriteBuffer(Buffer buffer, bool blocking, long offset, long size, IntPtr source, params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueWriteBuffer(Handle, buffer.Handle, blocking, (IntPtr)offset, (IntPtr)size, source, eventHandles); return(new Event(handle)); }
/// <summary> /// A synchronization point that enqueues a barrier operation. /// </summary> /// <remarks> /// Enqueues a barrier command which waits for all events in /// <paramref name="eventWaitList"/> to complete, or if /// <paramref name="eventWaitList"/> is empty it waits for all previously enqueued /// commands to complete before it completes. This command blocks command execution, /// that is, any commands enqueued after it do not execute until it completes. This /// command returns an event which can be waited on, i.e. this event can be waited /// on to ensure that all events either in the <paramref name="eventWaitList"/> /// or all previously enqueued commands, queued before this command, have completed. /// </remarks> /// <param name="eventWaitList">The events that need to be complete before this /// command is executed. If the list is null or empty, this command waits until /// all previous enqueued commands have completed.</param> /// <returns>Returns an event object that identifies this particular command.</returns> public Event EnqueueBarrier(params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueBarrierWithWaitList(Handle, eventHandles); return(new Event(handle)); }
public Event EnqueueNDRangeKernel(Kernel kernel, IntPtr[] globalWorkOffset, IntPtr[] globalWorkSize, IntPtr[] localWorkSize, params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueNDRangeKernel(Handle, kernel.Handle, globalWorkOffset, globalWorkSize, localWorkSize, eventHandles); return(new Event(handle)); }
public Event EnqueueWriteBufferRect(Buffer buffer, bool blocking, BufferCoordinates bufferOrigin, BufferCoordinates hostOrigin, BufferSize region, long bufferRowPitch, long bufferSlicePitch, long hostRowPitch, long hostSlicePitch, IntPtr source, params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueWriteBufferRect(Handle, buffer.Handle, blocking, ref bufferOrigin, ref hostOrigin, ref region, (IntPtr)bufferRowPitch, (IntPtr)bufferSlicePitch, (IntPtr)hostRowPitch, (IntPtr)hostSlicePitch, source, eventHandles); return(new Event(handle)); }
public Event EnqueueCopyImageToBuffer <T>(Image sourceImage, Buffer <T> destinationBuffer, BufferCoordinates sourceOrigin, BufferSize region, long destinationOffset, params Event[] eventWaitList) where T : struct { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueCopyImageToBuffer(Handle, sourceImage.Handle, destinationBuffer.Handle, ref sourceOrigin, ref region, (IntPtr)destinationOffset, eventHandles); return(new Event(handle)); }
public Event EnqueueCopyBufferToImage <T>(Buffer <T> sourceBuffer, Image destinationImage, long sourceOffset, BufferCoordinates destinationOrigin, BufferSize region, params Event[] eventWaitList) where T : struct { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueCopyBufferToImage(Handle, sourceBuffer.Handle, destinationImage.Handle, (IntPtr)sourceOffset, ref destinationOrigin, ref region, eventHandles); return(new Event(handle)); }
public static EventSafeHandle CreateUserEvent(ContextSafeHandle context) { if (context == null) { throw new ArgumentNullException("context"); } ErrorCode errorCode; EventSafeHandle handle = clCreateUserEvent(context, out errorCode); ErrorHandler.ThrowOnFailure(errorCode); return(handle); }
public Event EnqueueReadBuffer <T>(Buffer <T> buffer, bool blocking, long offset, long size, IntPtr destination, params Event[] eventWaitList) where T : struct { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueReadBuffer(Handle, buffer.Handle, blocking, (IntPtr)offset, (IntPtr)size, destination, eventHandles); return(new Event(handle)); }
public Event EnqueueMapImage(Image image, bool blocking, MapFlags mapFlags, BufferCoordinates origin, BufferSize region, out long rowPitch, out long slicePitch, out IntPtr mappedPointer, params Event[] eventWaitList) { EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } IntPtr imageRowPitch; IntPtr imageSlicePitch; EventSafeHandle handle = UnsafeNativeMethods.EnqueueMapImage(Handle, image.Handle, blocking, mapFlags, ref origin, ref region, out imageRowPitch, out imageSlicePitch, out mappedPointer, eventHandles); rowPitch = imageRowPitch.ToInt64(); slicePitch = imageSlicePitch.ToInt64(); return(new Event(handle)); }
public Event EnqueueMigrateMemObjects(MemObject[] memObjects, MigrationFlags flags, params Event[] eventWaitList) { MemObjectSafeHandle[] memHandles = null; if (memObjects != null) { memHandles = Array.ConvertAll(memObjects, mem => mem.BaseHandle); } EventSafeHandle[] eventHandles = null; if (eventWaitList != null) { eventHandles = Array.ConvertAll(eventWaitList, @event => @event.Handle); } EventSafeHandle handle = UnsafeNativeMethods.EnqueueMigrateMemObjects(Handle, memHandles, flags, eventHandles); return(new Event(handle)); }
public static T GetEventInfo <T>(EventSafeHandle @event, EventParameterInfo <T> parameter) { int?fixedSize = parameter.ParameterInfo.FixedSize; #if DEBUG bool verifyFixedSize = true; #else bool verifyFixedSize = false; #endif UIntPtr requiredSize; if (fixedSize.HasValue && !verifyFixedSize) { requiredSize = (UIntPtr)fixedSize; } else { ErrorHandler.ThrowOnFailure(clGetEventInfo(@event, parameter.ParameterInfo.Name, UIntPtr.Zero, IntPtr.Zero, out requiredSize)); } if (verifyFixedSize && fixedSize.HasValue) { if (requiredSize.ToUInt64() != (ulong)fixedSize.Value) { throw new ArgumentException("The parameter definition includes a fixed size that does not match the required size according to the runtime."); } } IntPtr memory = IntPtr.Zero; try { memory = Marshal.AllocHGlobal((int)requiredSize.ToUInt32()); UIntPtr actualSize; ErrorHandler.ThrowOnFailure(clGetEventInfo(@event, parameter.ParameterInfo.Name, requiredSize, memory, out actualSize)); return(parameter.ParameterInfo.Deserialize(actualSize, memory)); } finally { Marshal.FreeHGlobal(memory); } }
private static extern ErrorCode clEnqueueTask( CommandQueueSafeHandle commandQueue, KernelSafeHandle kernel, uint numEventsInWaitList, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(SafeHandleArrayMarshaler))] EventSafeHandle[] eventWaitList, out EventSafeHandle @event);
private static extern ErrorCode clGetEventInfo( EventSafeHandle @event, int paramName, UIntPtr paramValueSize, IntPtr paramValue, out UIntPtr paramValueSizeRet);
private static extern ErrorCode clSetUserEventStatus(EventSafeHandle @event, ExecutionStatus executionStatus);
public static void SetEventCallback(EventSafeHandle @event, ExecutionStatus executionCallbackType, EventCallback eventNotify, IntPtr userData) { throw new NotImplementedException(); }
private static extern ErrorCode clSetEventCallback( EventSafeHandle @event, ExecutionStatus executionCallbackType, EventCallback eventNotify, IntPtr userData);
public Event CreateUserEvent() { EventSafeHandle handle = UnsafeNativeMethods.CreateUserEvent(Handle); return(new Event(handle)); }
private static extern ErrorCode clRetainEvent(EventSafeHandle @event);