Ejemplo n.º 1
0
        internal static Kernels CreateInternal(CommandQueue commandQueue, Program program, Int32 kernelsCount, Int32 kernelInfoBufferSize)
        {
            Validate(commandQueue, program);

            Int32 numKernelsRet = 0;

            CLKernel[] openclKernels = new CLKernel[kernelsCount];

            OpenCLError.Validate(OpenCLDriver.clCreateKernelsInProgram(program.CLProgram, openclKernels.Length, openclKernels, ref numKernelsRet));

            Kernel[] result = new Kernel[numKernelsRet];

            for (int i = 0; i < numKernelsRet; i++)
            {
                result[i] = new Kernel(openclKernels[i], program, commandQueue, kernelInfoBufferSize);
            }

            return(new Kernels(result));
        }
Ejemplo n.º 2
0
 public DeviceMemoryStream(DeviceBuffer deviceBuffer, CommandQueue commandQueue)
 {
     this.DeviceBuffer = deviceBuffer;
     this.CommandQueue = commandQueue;
 }
Ejemplo n.º 3
0
 public Event Acquire(CommandQueue commandQueue)
 {
     return Acquire(commandQueue, Events.Empty);
 }
Ejemplo n.º 4
0
        public Event Acquire(CommandQueue commandQueue, Events eventWaitList)
        {
            CLEvent e = new CLEvent();

            OpenCLError.Validate(OpenCLGLDriver.clEnqueueAcquireGLObjects(commandQueue.CLCommandQueue, memObjects.Length, memObjects, eventWaitList.Count, eventWaitList.OpenCLEventArray, ref e));

            Acquired = true;

            return new Event(e);
        }
Ejemplo n.º 5
0
 public Event Release(CommandQueue commandQueue)
 {
     return Release(commandQueue, Events.Empty);
 }
Ejemplo n.º 6
0
 public Event Acquire(CommandQueue commandQueue)
 {
     return(Acquire(commandQueue, Events.Empty));
 }
Ejemplo n.º 7
0
        public void Write(Stream stream, Int64 bufferOffset, Int64 bytesToCopy, Byte[] buffer, CommandQueue commandQueue, Events eventWaitList)
        {
            while (bytesToCopy > buffer.Length)
            {
                stream.Read(buffer, 0, buffer.Length);

                Write(buffer, 0, bufferOffset, buffer.Length, commandQueue, eventWaitList);

                bufferOffset += buffer.Length;
                bytesToCopy  -= buffer.Length;
            }

            stream.Read(buffer, 0, (Int32)bytesToCopy);

            Write(buffer, 0, bufferOffset, bytesToCopy, commandQueue, eventWaitList);
        }
Ejemplo n.º 8
0
 public void Write(Stream stream, Int64 bufferOffset, Int64 bytesToCopy, Int32 bufferSize, CommandQueue commandQueue, Events eventWaitList)
 {
     Write(stream, bufferOffset, bytesToCopy, new Byte[bufferSize], commandQueue, eventWaitList);
 }
Ejemplo n.º 9
0
 public void Write(Stream stream, Int64 bufferOffset, Int64 bytesToCopy, Byte[] buffer, CommandQueue commandQueue)
 {
     Write(stream, bufferOffset, bytesToCopy, buffer, commandQueue, null);
 }
Ejemplo n.º 10
0
 public void Write(Stream stream, Int64 bufferOffset, Int64 bytesToCopy, Int32 bufferSize, CommandQueue commandQueue, Events eventWaitList)
 {
     Write(stream, bufferOffset, bytesToCopy, new Byte[bufferSize], commandQueue, eventWaitList);
 }
Ejemplo n.º 11
0
 public void Write(Stream stream, Int64 bufferOffset, Int64 bytesToCopy, Int32 bufferSize, CommandQueue commandQueue)
 {
     Write(stream, bufferOffset, bytesToCopy, new Byte[bufferSize], commandQueue, null);
 }
Ejemplo n.º 12
0
 public DeviceMemoryStream(DeviceBuffer deviceBuffer, CommandQueue commandQueue)
 {
     this.DeviceBuffer = deviceBuffer;
     this.CommandQueue = commandQueue;
 }
Ejemplo n.º 13
0
 public DeviceMemoryStream(DeviceBuffer deviceBuffer)
 {
     this.DeviceBuffer = deviceBuffer;
     this.CommandQueue = CommandQueue.Default;
 }
Ejemplo n.º 14
0
        internal Kernel(CLKernel openclKernel, Program program, CommandQueue commandQueue, Int32 kernelInfoBufferSize)
            : this(openclKernel, program, commandQueue, GetKernelInfoString(openclKernel, CLKernelInfo.FunctionName, kernelInfoBufferSize))

        {
        }
Ejemplo n.º 15
0
        public Event Write(Array array, Int64 arrayOffset, Int64 bufferOffset, Int64 bytesToCopy, CommandQueue commandQueue, Events eventWaitList)
        {
            Int64 arraySize = array.Length * Marshal.SizeOf(array.GetType().GetElementType());

            return(WriteBytesInternal(openCLMem, commandQueue, array, bytesToCopy, arrayOffset, arraySize, bufferOffset, (long)openCLMemSize, eventWaitList, OpenCLDriver.clEnqueueWriteBuffer));
        }
Ejemplo n.º 16
0
 public void Write(Stream stream, Int64 bufferOffset, Int64 bytesToCopy, Int32 bufferSize, CommandQueue commandQueue)
 {
     Write(stream, bufferOffset, bytesToCopy, new Byte[bufferSize], commandQueue, null);
 }
Ejemplo n.º 17
0
        public void Write(Stream stream, Int64 bufferOffset, Int64 bytesToCopy, Byte[] buffer, CommandQueue commandQueue, Events eventWaitList)
        {
            while (bytesToCopy > buffer.Length)
            {
                stream.Read(buffer, 0, buffer.Length);

                Write(buffer, 0, bufferOffset, buffer.Length, commandQueue, eventWaitList);

                bufferOffset += buffer.Length;
                bytesToCopy -= buffer.Length;
            }

            stream.Read(buffer, 0, (Int32)bytesToCopy);

            Write(buffer, 0, bufferOffset, bytesToCopy, commandQueue, eventWaitList);
        }
Ejemplo n.º 18
0
 public void Write(Stream stream, Int64 bufferOffset, Int64 bytesToCopy, Byte[] buffer, CommandQueue commandQueue)
 {
     Write(stream, bufferOffset, bytesToCopy, buffer, commandQueue, null);
 }
Ejemplo n.º 19
0
        private static Event WriteBytesInternal(CLMem openCLMem, CommandQueue commandQueue, Array array, Int64 bytesToCopy, Int64 arrayOffset, Int64 arraySize, Int64 bufferOffset, Int64 bufferSize, Events eventWaitList, WriteOperation writeDelegate)
        {
            if (bufferSize < bufferOffset + bytesToCopy) throw new ArgumentException(Resources.Buffer_out_of_bounds);
            if (arraySize < arrayOffset + bytesToCopy) throw new ArgumentException(Resources.Array_out_of_bounds);

            GCHandle valueHandle = GCHandle.Alloc(array, GCHandleType.Pinned);

            try
            {
                CLEvent e = new CLEvent();

                unsafe
                {
                    IntPtr valuePtr = new IntPtr((Byte*)(valueHandle.AddrOfPinnedObject().ToPointer()) + arrayOffset);

                    OpenCLError.Validate
                    (
                        writeDelegate
                        (
                            commandQueue.CLCommandQueue,
                            openCLMem,
                            CLBool.True,
                            new SizeT(bufferOffset),
                            new SizeT(bytesToCopy),
                            valuePtr,
                            eventWaitList == null ? 0 : eventWaitList.Count,
                            eventWaitList == null ? null : eventWaitList.OpenCLEventArray,
                            ref e
                        )
                    );
                }

                return new Event(e);
            }
            finally
            {
                valueHandle.Free();
            }
        }
Ejemplo n.º 20
0
        public Event Read(Array array, Int64 arrayOffset, Int64 bufferOffset, Int64 bytesToCopy, CommandQueue commandQueue, Events eventWaitList)
        {
            Int64 arraySize = array.Length * Marshal.SizeOf(array.GetType().GetElementType());

            return WriteBytesInternal(openCLMem, commandQueue, array, bytesToCopy, arrayOffset, arraySize, bufferOffset, (long)openCLMemSize, eventWaitList, OpenCLDriver.clEnqueueReadBuffer);
        }
Ejemplo n.º 21
0
 public Event Release(CommandQueue commandQueue)
 {
     return(Release(commandQueue, Events.Empty));
 }