public static Context Create(Device[] devices, params ContextParam[] ctxParams) { Context result = null; IntPtr ctxHandle = IntPtr.Zero; ErrorCode errorCode = ErrorCode.Success; IntPtr[] devHandles = CLObject.GetHandles(devices); IntPtr[] properties = new IntPtr[2 * ctxParams.Length + 1]; int i = 0; foreach (ContextParam cp in ctxParams) { properties[i] = (IntPtr)cp.Name; i++; properties[i] = cp.Value; i++; } properties[i] = (IntPtr)0; unsafe { ctxHandle = Native.CreateContext(properties, (uint)devices.Length, devHandles, IntPtr.Zero, IntPtr.Zero, &errorCode); } if (errorCode != ErrorCode.Success) { throw new OpenCLCallFailedException(errorCode); } result = new Context(ctxHandle); return(result); }
public unsafe void EnqueueUnmap(CommandQueue queue, ref IntPtr mappedPtr, Event[] waitList, out Event evt) { uint waitCount = (waitList == null ? 0 : (uint)waitList.Length); IntPtr[] wlh = CLObject.GetHandles(waitList); IntPtr evtHandle = IntPtr.Zero; Native.Call(Native.EnqueueUnmapMemObject(queue.Handle, this.Handle, mappedPtr, waitCount, wlh, &evtHandle)); mappedPtr = IntPtr.Zero; evt = new Event(evtHandle); }
public static void EnqueueReleaseGLObjects(CommandQueue queue, CLObject[] objects, Event[] waitList, out Event evt) { unsafe { uint waitCount = (waitList == null ? 0 : (uint)waitList.Length); IntPtr[] wlh = CLObject.GetHandles(waitList); IntPtr evtHandle = IntPtr.Zero; IntPtr[] objHandles = CLObject.GetHandles(objects); Native.Call(Native.GL.EnqueueReleaseGLObjects(queue.Handle, (uint)objHandles.Length, objHandles, waitCount, wlh, &evtHandle)); evt = new Event(evtHandle); } }
public void EnqueueAcquireGL(CommandQueue queue, Event[] waitList, out Event evt) { unsafe { uint waitCount = (waitList == null ? 0 : (uint)waitList.Length); IntPtr[] wlh = CLObject.GetHandles(waitList); IntPtr evtHandle = IntPtr.Zero; IntPtr[] memobjHandles = new IntPtr[] { this.Handle }; Native.Call(Native.GL.EnqueueAcquireGLObjects(queue.Handle, 1, memobjHandles, waitCount, wlh, &evtHandle)); evt = new Event(evtHandle); } }
public void EnqueueWaitForEvents(Event[] waitList) { unsafe { uint waitCount = (waitList == null ? 0 : (uint)waitList.Length); IntPtr[] wlh = CLObject.GetHandles(waitList); fixed(IntPtr *p_wlh = wlh) { Native.Call(Native.EnqueueWaitForEvents(this.Handle, waitCount, p_wlh)); } } }
public void Build(Device[] devices, string options) { ErrorCode errorCode; unsafe { IntPtr[] devHandles = CLObject.GetHandles(devices); errorCode = Native.BuildProgram(this.Handle, (uint)devices.Length, devHandles, options, IntPtr.Zero, IntPtr.Zero); } if (errorCode != ErrorCode.Success) { throw new OpenCLCallFailedException(errorCode); } }
/// <summary> /// Enqueue a one dimensional kernel for launch. /// </summary> public void EnqueueLaunch(CommandQueue queue, IntPtr globalWorkSize, IntPtr localWorkSize, Event[] waitList, out Event evt) { unsafe { uint waitCount = (waitList == null ? 0 : (uint)waitList.Length); IntPtr[] wlh = CLObject.GetHandles(waitList); IntPtr evtHandle = IntPtr.Zero; Native.Call(Native.EnqueueNDRangeKernel( queue.Handle, this.Handle, 1, null, (IntPtr *)(&globalWorkSize), (IntPtr *)(&localWorkSize), waitCount, wlh, &evtHandle) ); evt = new Event(evtHandle); } }
public IntPtr EnqueueMap(CommandQueue queue, MapFlags flags, Offset2D origin, Dim2D region, out IntPtr pitch, Event[] waitList, out Event evt) { Offset3D origin_buf = new Offset3D(origin.X, origin.Y, (IntPtr)0); Dim3D region_buf = new Dim3D(region.X, region.Y, (IntPtr)1); IntPtr tempPitch = IntPtr.Zero; uint waitCount = (waitList == null ? 0 : (uint)waitList.Length); IntPtr[] wlh = CLObject.GetHandles(waitList); IntPtr evtHandle = IntPtr.Zero; ErrorCode errorCode; IntPtr result = IntPtr.Zero; unsafe { result = Native.EnqueueMapImage(queue.Handle, this.Handle, true, flags, &origin_buf, ®ion_buf, &tempPitch, null, waitCount, wlh, &evtHandle, &errorCode); } if (errorCode != ErrorCode.Success) { throw new OpenCLCallFailedException(errorCode); } pitch = tempPitch; evt = new Event(evtHandle); return(result); }