public void Fill(Memory mem, int off, int len, float val) { HandleEvent(); Cl.EnqueueFillBuffer(env.CommandQueues[1], mem.buf, val, sizeof(float), (uint)off, (uint)len, 0, null, out Event eve); lastEventHandler = () => { Cl.WaitForEvents(1, new Event[] { eve }); eve.Release(); }; }
public Event EnqueueFillBuffer(Buffer buffer, IntPtr pattern, ulong patternSize, ulong offset, ulong size, Event[] events) { ClHelper.ThrowNullException(Handle); if (buffer == Buffer.Null) { throw new ArgumentNullException("buffer"); } if (pattern == IntPtr.Zero) { throw new ArgumentNullException("pattern"); } unsafe { int num_events_in_wait_list = events == null ? 0 : events.Length; IntPtr *wait_list = stackalloc IntPtr[num_events_in_wait_list]; for (int i = 0; i < num_events_in_wait_list; ++i) { wait_list[i] = events[i].Handle; } if (events == null) { wait_list = null; } IntPtr event_ptr = IntPtr.Zero; ClHelper.GetError(Cl.EnqueueFillBuffer(Handle, buffer.Handle, pattern.ToPointer(), new UIntPtr(patternSize), new UIntPtr(offset), new UIntPtr(size), (uint)num_events_in_wait_list, wait_list, &event_ptr)); return(new Event(event_ptr)); } }