Ejemplo n.º 1
0
        public void Build(ICollection <ComputeDevice> devices, string options, ComputeProgramBuildNotifier notify, IntPtr notifyDataPtr)
        {
            IntPtr[] deviceHandles = ComputeTools.ExtractHandles(devices, out var handleCount);
            buildNotify = notify;

            CL10.BuildProgram(handle, handleCount, deviceHandles, options, buildNotify, notifyDataPtr);
        }
Ejemplo n.º 2
0
        public ComputeContext(ICollection <ComputeDevice> devices, ComputeContextPropertyList properties, ComputeContextNotifier notify, IntPtr notifyDataPtr)
        {
            IntPtr[] deviceHandles = ComputeTools.ExtractHandles(devices, out var handleCount);
            IntPtr[] propertyArray = properties?.ToIntPtrArray();

            handle = CL10.CreateContext(propertyArray, handleCount, deviceHandles, notify, notifyDataPtr, out _);

#if DEBUG
            Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
#endif
        }
Ejemplo n.º 3
0
        internal ComputeEvent(IntPtr handle, ComputeCommandQueue queue)
        {
            CommandQueue = queue;
            Type         = (ComputeCommandType)GetInfo <IntPtr, ComputeEventInfo, int>(handle, ComputeEventInfo.CommandType, CL10.GetEventInfo);
            Context      = queue.Context;

            if (ComputeTools.ParseVersionString(CommandQueue.Device.Platform.Version, 1) > new Version(1, 0))
            {
                HookNotifier();
            }

#if DEBUG
            Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
#endif
        }
        public void Read <T>(ComputeBuffer <T> source, bool blocking, long offset, long region, IntPtr destination, ICollection <ComputeEvent> events) where T : unmanaged
        {
            int eventWaitListSize;

            IntPtr[] eventHandles   = ComputeTools.ExtractHandles(events, out eventWaitListSize);
            bool     eventsWritable = events != null && !events.IsReadOnly;

            IntPtr[] newEventHandle = eventsWritable ? new IntPtr[1] : null;
            CL10.EnqueueReadBuffer(handle, source.handle, blocking, new IntPtr(offset * Unsafe.SizeOf <T>()), new IntPtr(region * Unsafe.SizeOf <T>()), destination, eventWaitListSize, eventHandles, newEventHandle);


            if (eventsWritable)
            {
                events.Add(new ComputeEvent(newEventHandle[0], this));
            }
        }
        public void Execute(ComputeKernel kernel, long[] globalWorkOffset, long[] globalWorkSize, long[] localWorkSize, ICollection <ComputeEvent> events)
        {
            int eventWaitListSize;

            IntPtr[] eventHandles   = ComputeTools.ExtractHandles(events, out eventWaitListSize);
            bool     eventsWritable = events != null && !events.IsReadOnly;

            IntPtr[] newEventHandle = eventsWritable ? new IntPtr[1] : null;

            CL10.EnqueueNDRangeKernel(handle, kernel.handle, globalWorkSize.Length, ComputeTools.ConvertArray(globalWorkOffset), ComputeTools.ConvertArray(globalWorkSize), ComputeTools.ConvertArray(localWorkSize), eventWaitListSize, eventHandles, newEventHandle);

            if (eventsWritable)
            {
                events.Add(new ComputeEvent(newEventHandle[0], this));
            }
        }