Esempio n. 1
0
        private ReadOnlyCollection <byte[]> GetBinaries()
        {
            IntPtr[] binaryLengths = GetArrayInfo <CLProgramHandle, OpenCLProgramInfo, IntPtr>(Handle, OpenCLProgramInfo.BinarySizes, CL10.GetProgramInfo);

            GCHandle[]     binariesGCHandles    = new GCHandle[binaryLengths.Length];
            IntPtr[]       binariesPtrs         = new IntPtr[binaryLengths.Length];
            IList <byte[]> binaries             = new List <byte[]>();
            GCHandle       binariesPtrsGCHandle = GCHandle.Alloc(binariesPtrs, GCHandleType.Pinned);

            try
            {
                for (int i = 0; i < binaryLengths.Length; i++)
                {
                    byte[] binary = new byte[binaryLengths[i].ToInt64()];
                    binariesGCHandles[i] = GCHandle.Alloc(binary, GCHandleType.Pinned);
                    binariesPtrs[i]      = binariesGCHandles[i].AddrOfPinnedObject();
                    binaries.Add(binary);
                }

                IntPtr          sizeRet;
                OpenCLErrorCode error = CL10.GetProgramInfo(Handle, OpenCLProgramInfo.Binaries, new IntPtr(binariesPtrs.Length * IntPtr.Size), binariesPtrsGCHandle.AddrOfPinnedObject(), out sizeRet);
                OpenCLException.ThrowOnError(error);
            }
            finally
            {
                for (int i = 0; i < binaryLengths.Length; i++)
                {
                    binariesGCHandles[i].Free();
                }
                binariesPtrsGCHandle.Free();
            }

            return(new ReadOnlyCollection <byte[]>(binaries));
        }
Esempio n. 2
0
 public extern static CLContextHandle CreateContext(
     [MarshalAs(UnmanagedType.LPArray)] IntPtr[] properties,
     Int32 num_devices,
     [MarshalAs(UnmanagedType.LPArray)] CLDeviceHandle[] devices,
     OpenCLContextNotifier pfn_notify,
     IntPtr user_data,
     out OpenCLErrorCode errcode_ret);
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        protected void HookNotifier()
        {
            statusNotify = new OpenCLEventCallback(StatusNotify);
            OpenCLErrorCode error = CL11.SetEventCallback(Handle, (int)OpenCLCommandExecutionStatus.Complete, statusNotify, IntPtr.Zero);

            OpenCLException.ThrowOnError(error);
        }
Esempio n. 4
0
        /// <summary>
        /// Enqueues a command to copy a 2D or 3D region of elements between two buffers.
        /// </summary>
        /// <typeparam name="T"> The type of data in the buffers. </typeparam>
        /// <param name="source"> The buffer to copy from. </param>
        /// <param name="destination"> The buffer to copy to. </param>
        /// <param name="sourceOffset"> The <paramref name="source"/> element position where reading starts. </param>
        /// <param name="destinationOffset"> The <paramref name="destination"/> element position where writing starts. </param>
        /// <param name="region"> The region of elements to copy. </param>
        /// <param name="sourceRowPitch"> The size of the source buffer row in bytes. If set to zero then <paramref name="sourceRowPitch"/> equals <c>region.X * sizeof(T)</c>. </param>
        /// <param name="sourceSlicePitch"> The size of the source buffer 2D slice in bytes. If set to zero then <paramref name="sourceSlicePitch"/> equals <c>region.Y * sizeof(T) * sourceRowPitch</c>. </param>
        /// <param name="destinationRowPitch"> The size of the destination buffer row in bytes. If set to zero then <paramref name="destinationRowPitch"/> equals <c>region.X * sizeof(T)</c>. </param>
        /// <param name="destinationSlicePitch"> The size of the destination buffer 2D slice in bytes. If set to zero then <paramref name="destinationSlicePitch"/> equals <c>region.Y * sizeof(T) * destinationRowPitch</c>. </param>
        /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param>
        /// <remarks> Requires OpenCL 1.1. </remarks>
        public void Copy(OpenCLBufferBase source, OpenCLBufferBase destination, SysIntX3 sourceOffset, SysIntX3 destinationOffset, SysIntX3 region, long sourceRowPitch, long sourceSlicePitch, long destinationRowPitch, long destinationSlicePitch, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null)
        {
            int sizeofT = Marshal.SizeOf(source.ElementType);

            sourceOffset.X      = new IntPtr(sizeofT * sourceOffset.X.ToInt64());
            destinationOffset.X = new IntPtr(sizeofT * destinationOffset.X.ToInt64());
            region.X            = new IntPtr(sizeofT * region.X.ToInt64());

            int eventWaitListSize;

            CLEventHandle[] eventHandles = OpenCLTools.ExtractHandles(events, out eventWaitListSize);

            CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null;

            OpenCLErrorCode error = CL11.EnqueueCopyBufferRect(this.Handle, source.Handle, destination.Handle, ref sourceOffset, ref destinationOffset, ref region, new IntPtr(sourceRowPitch), new IntPtr(sourceSlicePitch), new IntPtr(destinationRowPitch), new IntPtr(destinationSlicePitch), eventWaitListSize, eventHandles, newEventHandle);

            OpenCLException.ThrowOnError(error);

            if (newEvents != null)
            {
                lock (newEvents)
                {
                    newEvents.Add(new OpenCLEvent(newEventHandle[0], this));
                }
            }
        }
Esempio n. 5
0
 public extern static CLMemoryHandle CreateFromGLTexture3D(
     CLContextHandle context,
     OpenCLMemoryFlags flags,
     Int32 target,
     Int32 miplevel,
     Int32 texture,
     out OpenCLErrorCode errcode_ret);
Esempio n. 6
0
        static OpenCLPlatform()
        {
            try
            {
                if (platforms != null)
                {
                    return;
                }
                CLPlatformHandle[] handles;
                int             handlesLength;
                OpenCLErrorCode error = CL10.GetPlatformIDs(0, null, out handlesLength);
                OpenCLException.ThrowOnError(error);
                handles = new CLPlatformHandle[handlesLength];

                error = CL10.GetPlatformIDs(handlesLength, handles, out handlesLength);
                OpenCLException.ThrowOnError(error);

                List <OpenCLPlatform> platformList = new List <OpenCLPlatform>(handlesLength);
                foreach (CLPlatformHandle handle in handles)
                {
                    platformList.Add(new OpenCLPlatform(handle));
                }

                platforms = platformList.AsReadOnly();
            }
            catch (DllNotFoundException)
            {
                platforms = new List <OpenCLPlatform>().AsReadOnly();
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Enqueues a command to map a part of a buffer into the host address space.
        /// </summary>
        /// <param name="buffer"> The buffer to map. </param>
        /// <param name="blocking">  The mode of operation of this call. </param>
        /// <param name="flags"> A list of properties for the mapping mode. </param>
        /// <param name="offset"> The <paramref name="buffer"/> element position where mapping starts. </param>
        /// <param name="region"> The region of elements to map. </param>
        /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param>
        /// <remarks> If <paramref name="blocking"/> is <c>true</c> this method will not return until the command completes. If <paramref name="blocking"/> is <c>false</c> this method will return immediately after the command is enqueued. </remarks>
        public IntPtr Map(OpenCLBufferBase buffer, bool blocking, OpenCLMemoryMappingFlags flags, long offset, long region, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null)
        {
            int sizeofT = Marshal.SizeOf(buffer.ElementType);

            int eventWaitListSize;

            CLEventHandle[] eventHandles   = OpenCLTools.ExtractHandles(events, out eventWaitListSize);
            CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null;

            IntPtr mappedPtr = IntPtr.Zero;

            OpenCLErrorCode error = OpenCLErrorCode.Success;

            mappedPtr = CL10.EnqueueMapBuffer(Handle, buffer.Handle, blocking, flags, new IntPtr(offset * sizeofT), new IntPtr(region * sizeofT), eventWaitListSize, eventHandles, newEventHandle, out error);
            OpenCLException.ThrowOnError(error);

            if (newEvents != null)
            {
                lock (newEvents)
                {
                    newEvents.Add(new OpenCLEvent(newEventHandle[0], this));
                }
            }

            return(mappedPtr);
        }
Esempio n. 8
0
        /// <summary>
        /// Enqueues a command to map a part of a <see cref="OpenCLImage"/> into the host address space.
        /// </summary>
        /// <param name="image"> The <see cref="OpenCLImage"/> to map. </param>
        /// <param name="blocking"> The mode of operation of this command. If <c>true</c> this call will not return until the command has finished execution. </param>
        /// <param name="flags"> A list of properties for the mapping mode. </param>
        /// <param name="offset"> The <paramref name="image"/> element position where mapping starts. </param>
        /// <param name="region"> The region of elements to map. </param>
        /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param>
        /// <remarks> If <paramref name="blocking"/> is <c>true</c> this method will not return until the command completes. If <paramref name="blocking"/> is <c>false</c> this method will return immediately after the command is enqueued. </remarks>
        public IntPtr Map(OpenCLImage image, bool blocking, OpenCLMemoryMappingFlags flags, SysIntX3 offset, SysIntX3 region, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null)
        {
            int eventWaitListSize;

            CLEventHandle[] eventHandles = OpenCLTools.ExtractHandles(events, out eventWaitListSize);

            CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null;

            IntPtr mappedPtr, rowPitch, slicePitch;

            OpenCLErrorCode error = OpenCLErrorCode.Success;

            mappedPtr = CL10.EnqueueMapImage(Handle, image.Handle, blocking, flags, ref offset, ref region, out rowPitch, out slicePitch, eventWaitListSize, eventHandles, newEventHandle, out error);
            OpenCLException.ThrowOnError(error);

            if (newEvents != null)
            {
                lock (newEvents)
                {
                    newEvents.Add(new OpenCLEvent(newEventHandle[0], this));
                }
            }

            return(mappedPtr);
        }
Esempio n. 9
0
 public extern static CLProgramHandle CreateProgramWithBinary(
     CLContextHandle context,
     Int32 num_devices,
     [MarshalAs(UnmanagedType.LPArray)] CLDeviceHandle[] device_list,
     [MarshalAs(UnmanagedType.LPArray)] IntPtr[] lengths,
     [MarshalAs(UnmanagedType.LPArray)] IntPtr[] binaries,
     [MarshalAs(UnmanagedType.LPArray)] Int32[] binary_status,
     out OpenCLErrorCode errcode_ret);
 public static ContextHandle CreateContextFromType(ContextProperty[] properties,
                                             DeviceType deviceType,
                                             ContextNotify pfnNotify,
                                             IntPtr userData,
                                             out OpenCLErrorCode errcodeRet)
 {
     return new ContextHandle(clCreateContextFromType(properties, deviceType, pfnNotify, userData, out errcodeRet));
 }
Esempio n. 11
0
        /// <summary>
        /// Enqueues a marker.
        /// </summary>
        public OpenCLEvent AddMarker()
        {
            CLEventHandle   newEventHandle;
            OpenCLErrorCode error = CL10.EnqueueMarker(Handle, out newEventHandle);

            OpenCLException.ThrowOnError(error);
            return(new OpenCLEvent(newEventHandle, this));
        }
Esempio n. 12
0
 public extern static CLMemoryHandle CreateImage2D(
     CLContextHandle context,
     OpenCLMemoryFlags flags,
     ref OpenCLImageFormat image_format,
     IntPtr image_width,
     IntPtr image_height,
     IntPtr image_row_pitch,
     IntPtr host_ptr,
     out OpenCLErrorCode errcode_ret);
Esempio n. 13
0
        /// <summary>
        /// Creates a new <see cref="OpenCLImage2D"/> from an OpenGL 2D texture object.
        /// </summary>
        /// <param name="context"> A <see cref="OpenCLContext"/> with enabled CL/GL sharing. </param>
        /// <param name="flags"> A bit-field that is used to specify usage information about the <see cref="OpenCLImage2D"/>. Only <c>OpenCLMemoryFlags.ReadOnly</c>, <c>OpenCLMemoryFlags.WriteOnly</c> and <c>OpenCLMemoryFlags.ReadWrite</c> are allowed. </param>
        /// <param name="textureTarget"> One of the following values: GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, or GL_TEXTURE_RECTANGLE. Using GL_TEXTURE_RECTANGLE for texture_target requires OpenGL 3.1. Alternatively, GL_TEXTURE_RECTANGLE_ARB may be specified if the OpenGL extension GL_ARB_texture_rectangle is supported. </param>
        /// <param name="mipLevel"> The mipmap level of the OpenGL 2D texture object to be used. </param>
        /// <param name="textureId"> The OpenGL 2D texture object id to use. </param>
        /// <returns> The created <see cref="OpenCLImage2D"/>. </returns>
        public static OpenCLImage2D CreateFromGLTexture2D(OpenCLContext context, OpenCLMemoryFlags flags, int textureTarget, int mipLevel, int textureId)
        {
            OpenCLErrorCode error = OpenCLErrorCode.Success;
            CLMemoryHandle  image = CL10.CreateFromGLTexture2D(context.Handle, flags, textureTarget, mipLevel, textureId, out error);

            OpenCLException.ThrowOnError(error);

            return(new OpenCLImage2D(image, context, flags));
        }
Esempio n. 14
0
        /// <summary>
        /// Creates a new <see cref="OpenCLImage2D"/> from an OpenGL renderbuffer object.
        /// </summary>
        /// <param name="context"> A <see cref="OpenCLContext"/> with enabled CL/GL sharing. </param>
        /// <param name="flags"> A bit-field that is used to specify usage information about the <see cref="OpenCLImage2D"/>. Only <c>OpenCLMemoryFlags.ReadOnly</c>, <c>OpenCLMemoryFlags.WriteOnly</c> and <c>OpenCLMemoryFlags.ReadWrite</c> are allowed. </param>
        /// <param name="renderbufferId"> The OpenGL renderbuffer object id to use. </param>
        /// <returns> The created <see cref="OpenCLImage2D"/>. </returns>
        public static OpenCLImage2D CreateFromGLRenderbuffer(OpenCLContext context, OpenCLMemoryFlags flags, int renderbufferId)
        {
            OpenCLErrorCode error = OpenCLErrorCode.Success;
            CLMemoryHandle  image = CL10.CreateFromGLRenderbuffer(context.Handle, flags, renderbufferId, out error);

            OpenCLException.ThrowOnError(error);

            return(new OpenCLImage2D(image, context, flags));
        }
Esempio n. 15
0
        /// <summary>
        /// Waits on the host thread for the specified events to complete.
        /// </summary>
        /// <param name="events"> The events to be waited for completition. </param>
        public static void Wait(List <OpenCLEventBase> events)
        {
            int eventWaitListSize;

            CLEventHandle[] eventHandles = OpenCLTools.ExtractHandles(events, out eventWaitListSize);
            OpenCLErrorCode error        = CL10.WaitForEvents(eventWaitListSize, eventHandles);

            OpenCLException.ThrowOnError(error);
        }
 public static ContextHandle CreateContext(ContextProperty[] properties,
                                     uint numDevices,
                                     DeviceHandle[] devices,
                                     ContextNotify pfnNotify,
                                     IntPtr userData,
                                     out OpenCLErrorCode errcodeRet)
 {
     return new ContextHandle(clCreateContext(properties, numDevices, devices, pfnNotify, userData, out errcodeRet));
 }
Esempio n. 17
0
        /// <summary>
        /// Creates a new <see cref="OpenCLImage3D"/>.
        /// </summary>
        /// <param name="context"> A valid <see cref="OpenCLContext"/> in which the <see cref="OpenCLImage3D"/> is created. </param>
        /// <param name="flags"> A bit-field that is used to specify allocation and usage information about the <see cref="OpenCLImage3D"/>. </param>
        /// <param name="format"> A structure that describes the format properties of the <see cref="OpenCLImage3D"/>. </param>
        /// <param name="width"> The width of the <see cref="OpenCLImage3D"/> in pixels. </param>
        /// <param name="height"> The height of the <see cref="OpenCLImage3D"/> in pixels. </param>
        /// <param name="depth"> The depth of the <see cref="OpenCLImage3D"/> in pixels. </param>
        /// <param name="rowPitch"> The size in bytes of each row of elements of the <see cref="OpenCLImage3D"/>. If <paramref name="rowPitch"/> is zero, OpenCL will compute the proper value based on <see cref="OpenCLImage.Width"/> and <see cref="OpenCLImage.ElementSize"/>. </param>
        /// <param name="slicePitch"> The size in bytes of each 2D slice in the <see cref="OpenCLImage3D"/>. If <paramref name="slicePitch"/> is zero, OpenCL will compute the proper value based on <see cref="OpenCLImage.RowPitch"/> and <see cref="OpenCLImage.Height"/>. </param>
        /// <param name="data"> The data to initialize the <see cref="OpenCLImage3D"/>. Can be <c>IntPtr.Zero</c>. </param>
        public OpenCLImage3D(OpenCLContext context, OpenCLMemoryFlags flags, OpenCLImageFormat format, int width, int height, int depth, long rowPitch, long slicePitch, IntPtr data)
            : base(context, flags)
        {
            OpenCLErrorCode error = OpenCLErrorCode.Success;

            Handle = CL10.CreateImage3D(context.Handle, flags, ref format, new IntPtr(width), new IntPtr(height), new IntPtr(depth), new IntPtr(rowPitch), new IntPtr(slicePitch), data, out error);
            OpenCLException.ThrowOnError(error);

            Init();
        }
Esempio n. 18
0
 public extern static IntPtr EnqueueMapBuffer(
     CLCommandQueueHandle command_queue,
     CLMemoryHandle buffer,
     [MarshalAs(UnmanagedType.Bool)] bool blocking_map,
     OpenCLMemoryMappingFlags map_flags,
     IntPtr offset,
     IntPtr cb,
     Int32 num_events_in_wait_list,
     [MarshalAs(UnmanagedType.LPArray)] CLEventHandle[] event_wait_list,
     [Out, MarshalAs(UnmanagedType.LPArray, SizeConst = 1)] CLEventHandle[] new_event,
     out OpenCLErrorCode errcode_ret);
Esempio n. 19
0
        /// <summary>
        /// Builds (compiles and links) a program executable from the program source or binary for all or some of the <see cref="OpenCLProgram.Devices"/>.
        /// </summary>
        /// <param name="devices"> A subset or all of <see cref="OpenCLProgram.Devices"/>. If <paramref name="devices"/> is <c>null</c>, the executable is built for every item of <see cref="OpenCLProgram.Devices"/> for which a source or a binary has been loaded. </param>
        /// <param name="options"> A set of options for the OpenCL compiler. </param>
        /// <param name="notify"> A delegate instance that represents a reference to a notification routine. This routine is a callback function that an application can register and which will be called when the program executable has been built (successfully or unsuccessfully). If <paramref name="notify"/> is not <c>null</c>, <see cref="OpenCLProgram.Build"/> does not need to wait for the build to complete and can return immediately. If <paramref name="notify"/> is <c>null</c>, <see cref="OpenCLProgram.Build"/> does not return until the build has completed. The callback function may be called asynchronously by the OpenCL implementation. It is the application's responsibility to ensure that the callback function is thread-safe and that the delegate instance doesn't get collected by the Garbage Collector until the build operation triggers the callback. </param>
        /// <param name="notifyDataPtr"> Optional user data that will be passed to <paramref name="notify"/>. </param>
        public void Build(IList <OpenCLDevice> devices, string options, OpenCLProgramBuildNotifier notify, IntPtr notifyDataPtr)
        {
            int handleCount;

            CLDeviceHandle[] deviceHandles = OpenCLTools.ExtractHandles(devices, out handleCount);
            buildOptions = (options != null) ? options : "";
            buildNotify  = notify;

            OpenCLErrorCode error = CL10.BuildProgram(Handle, handleCount, deviceHandles, options, buildNotify, notifyDataPtr);

            OpenCLException.ThrowOnError(error);
        }
Esempio n. 20
0
 public static IMemoryObject CreateImage2D(ContextHandle context,
                                 MemFlags flags,
                                 ImageFormat imageFormat,
                                 IntPtr imageWidth,
                                 IntPtr imageHeight,
                                 IntPtr imageRowPitch,
                                 IntPtr hostPtr,
                                 out OpenCLErrorCode errorcodeRet)
 {
     using (var imageFormatPtr = imageFormat.Pin())
         return new MemoryObject(clCreateImage2D((context as IHandleData).Handle, flags, imageFormatPtr, imageWidth, imageHeight, imageRowPitch, hostPtr, out errorcodeRet));
 }
Esempio n. 21
0
 public extern static IntPtr EnqueueMapImage(
     CLCommandQueueHandle command_queue,
     CLMemoryHandle image,
     [MarshalAs(UnmanagedType.Bool)] bool blocking_map,
     OpenCLMemoryMappingFlags map_flags,
     ref SysIntX3 origin,
     ref SysIntX3 region,
     out IntPtr image_row_pitch,
     out IntPtr image_slice_pitch,
     Int32 num_events_in_wait_list,
     [MarshalAs(UnmanagedType.LPArray)] CLEventHandle[] event_wait_list,
     [Out, MarshalAs(UnmanagedType.LPArray, SizeConst = 1)] CLEventHandle[] new_event,
     out OpenCLErrorCode errcode_ret);
Esempio n. 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="flags"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        protected static ICollection <OpenCLImageFormat> GetSupportedFormats(OpenCLContext context, OpenCLMemoryFlags flags, OpenCLMemoryType type)
        {
            int             formatCountRet = 0;
            OpenCLErrorCode error          = CL10.GetSupportedImageFormats(context.Handle, flags, type, 0, null, out formatCountRet);

            OpenCLException.ThrowOnError(error);

            OpenCLImageFormat[] formats = new OpenCLImageFormat[formatCountRet];
            error = CL10.GetSupportedImageFormats(context.Handle, flags, type, formatCountRet, formats, out formatCountRet);
            OpenCLException.ThrowOnError(error);

            return(new Collection <OpenCLImageFormat>(formats));
        }
Esempio n. 23
0
        /// <summary>
        /// Creates a new <see cref="OpenCLProgram"/> from a specified list of binaries.
        /// </summary>
        /// <param name="context"> A <see cref="OpenCLContext"/>. </param>
        /// <param name="binaries"> A list of binaries, one for each item in <paramref name="devices"/>. </param>
        /// <param name="devices"> A subset of the <see cref="OpenCLContext.Devices"/>. If <paramref name="devices"/> is <c>null</c>, OpenCL will associate every binary from <see cref="OpenCLProgram.Binaries"/> with a corresponding <see cref="OpenCLDevice"/> from <see cref="OpenCLContext.Devices"/>. </param>
        public OpenCLProgram(OpenCLContext context, IList <byte[]> binaries, IList <OpenCLDevice> devices)
        {
            int count;

            CLDeviceHandle[] deviceHandles = (devices != null) ?
                                             OpenCLTools.ExtractHandles(devices, out count) :
                                             OpenCLTools.ExtractHandles(context.Devices, out count);

            IntPtr[]        binariesPtrs    = new IntPtr[count];
            IntPtr[]        binariesLengths = new IntPtr[count];
            int[]           binariesStats   = new int[count];
            OpenCLErrorCode error           = OpenCLErrorCode.Success;

            GCHandle[] binariesGCHandles = new GCHandle[count];

            try
            {
                for (int i = 0; i < count; i++)
                {
                    binariesGCHandles[i] = GCHandle.Alloc(binaries[i], GCHandleType.Pinned);
                    binariesPtrs[i]      = binariesGCHandles[i].AddrOfPinnedObject();
                    binariesLengths[i]   = new IntPtr(binaries[i].Length);
                }

                Handle = CL10.CreateProgramWithBinary(
                    context.Handle,
                    count,
                    deviceHandles,
                    binariesLengths,
                    binariesPtrs,
                    binariesStats,
                    out error);
                OpenCLException.ThrowOnError(error);
            }
            finally
            {
                for (int i = 0; i < count; i++)
                {
                    binariesGCHandles[i].Free();
                }
            }


            this.binaries = new ReadOnlyCollection <byte[]>(binaries);
            this.context  = context;
            this.devices  = new ReadOnlyCollection <OpenCLDevice>(
                (devices != null) ? devices : context.Devices);

            //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
Esempio n. 24
0
        /// <summary>
        /// Creates a new <see cref="OpenCLProgram"/> from a source code string.
        /// </summary>
        /// <param name="context"> A <see cref="OpenCLContext"/>. </param>
        /// <param name="source"> The source code for the <see cref="OpenCLProgram"/>. </param>
        /// <remarks> The created <see cref="OpenCLProgram"/> is associated with the <see cref="OpenCLContext.Devices"/>. </remarks>
        public OpenCLProgram(OpenCLContext context, string source)
        {
            OpenCLErrorCode error = OpenCLErrorCode.Success;

            Handle = CL10.CreateProgramWithSource(context.Handle, 1, new string[] { source }, null, out error);
            OpenCLException.ThrowOnError(error);

            SetID(Handle.Value);

            this.context = context;
            this.devices = context.Devices;
            this.source  = new ReadOnlyCollection <string>(new string[] { source });

            //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
Esempio n. 25
0
        internal OpenCLKernel(string functionName, OpenCLProgram program)
        {
            OpenCLErrorCode error = OpenCLErrorCode.Success;

            Handle = CL10.CreateKernel(program.Handle, functionName, out error);
            OpenCLException.ThrowOnError(error);

            SetID(Handle.Value);

            context           = program.Context;
            this.functionName = functionName;
            this.program      = program;

            //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
Esempio n. 26
0
        /// <summary>
        /// Creates a new <see cref="OpenCLSampler"/>.
        /// </summary>
        /// <param name="context"> A <see cref="OpenCLContext"/>. </param>
        /// <param name="normalizedCoords"> The usage state of normalized coordinates when accessing a <see cref="OpenCLImage"/> in a <see cref="OpenCLKernel"/>. </param>
        /// <param name="addressing"> The <see cref="OpenCLImageAddressing"/> mode of the <see cref="OpenCLSampler"/>. Specifies how out-of-range image coordinates are handled while reading. </param>
        /// <param name="filtering"> The <see cref="OpenCLImageFiltering"/> mode of the <see cref="OpenCLSampler"/>. Specifies the type of filter that must be applied when reading data from an image. </param>
        public OpenCLSampler(OpenCLContext context, bool normalizedCoords, OpenCLImageAddressing addressing, OpenCLImageFiltering filtering)
        {
            OpenCLErrorCode error = OpenCLErrorCode.Success;

            Handle = CL10.CreateSampler(context.Handle, normalizedCoords, addressing, filtering, out error);
            OpenCLException.ThrowOnError(error);

            SetID(Handle.Value);

            this.addressing       = addressing;
            this.context          = context;
            this.filtering        = filtering;
            this.normalizedCoords = normalizedCoords;

            //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
Esempio n. 27
0
        /// <summary>
        /// Enqueues a command to execute a single <see cref="OpenCLKernel"/>.
        /// </summary>
        /// <param name="kernel"> The <see cref="OpenCLKernel"/> to execute. </param>
        /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param>
        public void ExecuteTask(OpenCLKernel kernel, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null)
        {
            int eventWaitListSize;

            CLEventHandle[] eventHandles   = OpenCLTools.ExtractHandles(events, out eventWaitListSize);
            CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null;
            OpenCLErrorCode error          = CL10.EnqueueTask(Handle, kernel.Handle, eventWaitListSize, eventHandles, newEventHandle);

            OpenCLException.ThrowOnError(error);

            if (newEvents != null)
            {
                lock (newEvents)
                {
                    newEvents.Add(new OpenCLEvent(newEventHandle[0], this));
                }
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Enqueues a command to read data from a <see cref="OpenCLImage"/>.
        /// </summary>
        /// <param name="source"> The <see cref="OpenCLImage"/> to read from. </param>
        /// <param name="blocking"> The mode of operation of this command. If <c>true</c> this call will not return until the command has finished execution. </param>
        /// <param name="offset"> The <paramref name="source"/> element position where reading starts. </param>
        /// <param name="region"> The region of elements to read. </param>
        /// <param name="rowPitch"> The <see cref="OpenCLImage.RowPitch"/> of <paramref name="source"/> or 0. </param>
        /// <param name="slicePitch"> The <see cref="OpenCLImage.SlicePitch"/> of <paramref name="source"/> or 0. </param>
        /// <param name="destination"> A pointer to a preallocated memory area to read the data into. </param>
        /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param>
        /// <remarks> If <paramref name="blocking"/> is <c>true</c> this method will not return until the command completes. If <paramref name="blocking"/> is <c>false</c> this method will return immediately after the command is enqueued. </remarks>
        public void Read(OpenCLImage source, bool blocking, SysIntX3 offset, SysIntX3 region, long rowPitch, long slicePitch, IntPtr destination, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null)
        {
            int eventWaitListSize;

            CLEventHandle[] eventHandles   = OpenCLTools.ExtractHandles(events, out eventWaitListSize);
            CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null;
            OpenCLErrorCode error          = CL10.EnqueueReadImage(Handle, source.Handle, blocking, ref offset, ref region, new IntPtr(rowPitch), new IntPtr(slicePitch), destination, eventWaitListSize, eventHandles, newEventHandle);

            OpenCLException.ThrowOnError(error);

            if (newEvents != null)
            {
                lock (newEvents)
                {
                    newEvents.Add(new OpenCLEvent(newEventHandle[0], this));
                }
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Creates a new <see cref="OpenCLCommandQueue"/>.
        /// </summary>
        /// <param name="context"> A <see cref="OpenCLContext"/>. </param>
        /// <param name="device"> A <see cref="OpenCLDevice"/> associated with the <paramref name="context"/>. It can either be one of <see cref="OpenCLContext.Devices"/> or have the same <see cref="OpenCLDeviceTypes"/> as the <paramref name="device"/> specified when the <paramref name="context"/> is created. </param>
        /// <param name="properties"> The properties for the <see cref="OpenCLCommandQueue"/>. </param>
        public OpenCLCommandQueue(OpenCLContext context, OpenCLDevice device, OpenCLCommandQueueProperties properties)
        {
            OpenCLErrorCode error = OpenCLErrorCode.Success;

            Handle = CL10.CreateCommandQueue(context.Handle, device.Handle, properties, out error);
            OpenCLException.ThrowOnError(error);

            SetID(Handle.Value);

            this.device  = device;
            this.context = context;

            outOfOrderExec = ((properties & OpenCLCommandQueueProperties.OutOfOrderExecution) == OpenCLCommandQueueProperties.OutOfOrderExecution);
            profiling      = ((properties & OpenCLCommandQueueProperties.Profiling) == OpenCLCommandQueueProperties.Profiling);

            Events = new List <OpenCLEventBase>();

            //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
Esempio n. 30
0
        /// <summary>
        /// Enqueues a command to write data to a buffer.
        /// </summary>
        /// <param name="destination"> The buffer to write to. </param>
        /// <param name="blocking"> The mode of operation of this command. If <c>true</c> this call will not return until the command has finished execution. </param>
        /// <param name="destinationOffset"> The <paramref name="destination"/> element position where writing starts. </param>
        /// <param name="region"> The region of elements to write. </param>
        /// <param name="source"> The data written to the buffer. </param>
        /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param>
        /// <remarks> If <paramref name="blocking"/> is <c>true</c> this method will not return until the command completes. If <paramref name="blocking"/> is <c>false</c> this method will return immediately after the command is enqueued. </remarks>
        public void Write(OpenCLBufferBase destination, bool blocking, long destinationOffset, long region, IntPtr source, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null)
        {
            int sizeofT = Marshal.SizeOf(destination.ElementType);

            int eventWaitListSize;

            CLEventHandle[] eventHandles   = OpenCLTools.ExtractHandles(events, out eventWaitListSize);
            CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null;
            OpenCLErrorCode error          = CL10.EnqueueWriteBuffer(Handle, destination.Handle, blocking, new IntPtr(destinationOffset * sizeofT), new IntPtr(region * sizeofT), source, eventWaitListSize, eventHandles, newEventHandle);

            OpenCLException.ThrowOnError(error);

            if (newEvents != null)
            {
                lock (newEvents)
                {
                    newEvents.Add(new OpenCLEvent(newEventHandle[0], this));
                }
            }
        }
Esempio n. 31
0
        /// <summary>
        /// Enqueues a command to unmap a buffer or a <see cref="OpenCLImage"/> from the host address space.
        /// </summary>
        /// <param name="memory"> The <see cref="OpenCLMemory"/>. </param>
        /// <param name="mappedPtr"> The host address returned by a previous call to <see cref="OpenCLCommandQueue.Map"/>. This pointer is <c>IntPtr.Zero</c> after this method returns. </param>
        /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param>
        public void Unmap(OpenCLMemory memory, ref IntPtr mappedPtr, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null)
        {
            int eventWaitListSize;

            CLEventHandle[] eventHandles   = OpenCLTools.ExtractHandles(events, out eventWaitListSize);
            CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null;
            OpenCLErrorCode error          = CL10.EnqueueUnmapMemObject(Handle, memory.Handle, mappedPtr, eventWaitListSize, eventHandles, newEventHandle);

            OpenCLException.ThrowOnError(error);

            mappedPtr = IntPtr.Zero;

            if (newEvents != null)
            {
                lock (newEvents)
                {
                    newEvents.Add(new OpenCLEvent(newEventHandle[0], this));
                }
            }
        }
Esempio n. 32
0
        /// <summary>
        /// Enqueues a command to execute a range of <see cref="OpenCLKernel"/>s in parallel.
        /// </summary>
        /// <param name="kernel"> The <see cref="OpenCLKernel"/> to execute. </param>
        /// <param name="globalWorkOffset"> An array of values that describe the offset used to calculate the global ID of a work-item instead of having the global IDs always start at offset (0, 0,... 0). </param>
        /// <param name="globalWorkSize"> An array of values that describe the number of global work-items in dimensions that will execute the kernel function. The total number of global work-items is computed as global_work_size[0] *...* global_work_size[work_dim - 1]. </param>
        /// <param name="localWorkSize"> An array of values that describe the number of work-items that make up a work-group (also referred to as the size of the work-group) that will execute the <paramref name="kernel"/>. The total number of work-items in a work-group is computed as local_work_size[0] *... * local_work_size[work_dim - 1]. </param>
        /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param>
        public void Execute(OpenCLKernel kernel, long[] globalWorkOffset, long[] globalWorkSize, long[] localWorkSize, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null)
        {
            int eventWaitListSize;

            CLEventHandle[] eventHandles = OpenCLTools.ExtractHandles(events, out eventWaitListSize);

            CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null;

            OpenCLErrorCode error = CL10.EnqueueNDRangeKernel(Handle, kernel.Handle, globalWorkSize.Length, OpenCLTools.ConvertArray(globalWorkOffset), OpenCLTools.ConvertArray(globalWorkSize), OpenCLTools.ConvertArray(localWorkSize), eventWaitListSize, eventHandles, newEventHandle);

            OpenCLException.ThrowOnError(error);

            if (newEvents != null)
            {
                lock (newEvents)
                {
                    newEvents.Add(new OpenCLEvent(newEventHandle[0], this));
                }
            }
        }
Esempio n. 33
0
        /// <summary>
        /// Enqueues a command to copy data between <see cref="OpenCLImage"/>s.
        /// </summary>
        /// <param name="source"> The <see cref="OpenCLImage"/> to copy from. </param>
        /// <param name="destination"> The <see cref="OpenCLImage"/> to copy to. </param>
        /// <param name="sourceOffset"> The <paramref name="source"/> element position where reading starts. </param>
        /// <param name="destinationOffset"> The <paramref name="destination"/> element position where writing starts. </param>
        /// <param name="region"> The region of elements to copy. </param>
        /// <param name="events"> A collection of events that need to complete before this particular command can be executed. If <paramref name="events"/> is not <c>null</c> or read-only a new <see cref="OpenCLEvent"/> identifying this command is created and attached to the end of the collection. </param>
        public void Copy(OpenCLImage source, OpenCLImage destination, SysIntX3 sourceOffset, SysIntX3 destinationOffset, SysIntX3 region, IReadOnlyList <OpenCLEventBase> events = null, IList <OpenCLEventBase> newEvents = null)
        {
            int eventWaitListSize;

            CLEventHandle[] eventHandles = OpenCLTools.ExtractHandles(events, out eventWaitListSize);

            CLEventHandle[] newEventHandle = (newEvents != null) ? new CLEventHandle[1] : null;

            OpenCLErrorCode error = CL10.EnqueueCopyImage(Handle, source.Handle, destination.Handle, ref sourceOffset, ref destinationOffset, ref region, eventWaitListSize, eventHandles, newEventHandle);

            OpenCLException.ThrowOnError(error);

            if (newEvents != null)
            {
                lock (newEvents)
                {
                    newEvents.Add(new OpenCLEvent(newEventHandle[0], this));
                }
            }
        }
 private static extern IntPtr clCreateContext([In] [MarshalAs(UnmanagedType.LPArray)] ContextProperty[] properties,
                                              uint numDevices,
                                              [In] [MarshalAs(UnmanagedType.LPArray)] DeviceHandle[] devices,
                                              ContextNotify pfnNotify,
                                              IntPtr userData,
                                              out OpenCLErrorCode errcodeRet);
Esempio n. 35
0
 public static IMemoryObject CreateBuffer(ContextHandle context, MemFlags flags, IntPtr size, object hostData, out OpenCLErrorCode errcodeRet)
 {
     using (var hostPtr = hostData.Pin())
         return CreateBuffer(context, flags, size, hostPtr, out errcodeRet);
 }
Esempio n. 36
0
 /// <summary>
 /// Creates a new <see cref="OpenCLException"/> with a specified <see cref="OpenCLErrorCode"/>.
 /// </summary>
 /// <param name="code"> A <see cref="OpenCLErrorCode"/>. </param>
 public OpenCLException(OpenCLErrorCode code)
     : base("OpenCL error code detected: " + code.ToString() + ".")
 {
     this.code = code;
 }
Esempio n. 37
0
        /// <summary>
        /// Checks for an OpenCL error code and throws a <see cref="OpenCLException"/> if such is encountered.
        /// </summary>
        /// <param name="errorCode"> The OpenCL error code. </param>
        public static void ThrowOnError(OpenCLErrorCode errorCode)
        {
            switch (errorCode)
            {
                case OpenCLErrorCode.Success:
                    return;

                case OpenCLErrorCode.DeviceNotFound:
                    throw new DeviceNotFoundOpenCLException();

                case OpenCLErrorCode.DeviceNotAvailable:
                    throw new DeviceNotAvailableOpenCLException();

                case OpenCLErrorCode.CompilerNotAvailable:
                    throw new CompilerNotAvailableOpenCLException();

                case OpenCLErrorCode.MemoryObjectAllocationFailure:
                    throw new MemoryObjectAllocationFailureOpenCLException();

                case OpenCLErrorCode.OutOfResources:
                    throw new OutOfResourcesOpenCLException();

                case OpenCLErrorCode.OutOfHostMemory:
                    throw new OutOfHostMemoryOpenCLException();

                case OpenCLErrorCode.ProfilingInfoNotAvailable:
                    throw new ProfilingInfoNotAvailableOpenCLException();

                case OpenCLErrorCode.MemoryCopyOverlap:
                    throw new MemoryCopyOverlapOpenCLException();

                case OpenCLErrorCode.ImageFormatMismatch:
                    throw new ImageFormatMismatchOpenCLException();

                case OpenCLErrorCode.ImageFormatNotSupported:
                    throw new ImageFormatNotSupportedOpenCLException();

                case OpenCLErrorCode.BuildProgramFailure:
                    throw new BuildProgramFailureOpenCLException();

                case OpenCLErrorCode.MapFailure:
                    throw new MapFailureOpenCLException();

                case OpenCLErrorCode.InvalidValue:
                    throw new InvalidValueOpenCLException();

                case OpenCLErrorCode.InvalidDeviceType:
                    throw new InvalidDeviceTypeOpenCLException();

                case OpenCLErrorCode.InvalidPlatform:
                    throw new InvalidPlatformOpenCLException();

                case OpenCLErrorCode.InvalidDevice:
                    throw new InvalidDeviceOpenCLException();

                case OpenCLErrorCode.InvalidContext:
                    throw new InvalidContextOpenCLException();

                case OpenCLErrorCode.InvalidCommandQueueFlags:
                    throw new InvalidCommandQueueFlagsOpenCLException();

                case OpenCLErrorCode.InvalidCommandQueue:
                    throw new InvalidCommandQueueOpenCLException();

                case OpenCLErrorCode.InvalidHostPointer:
                    throw new InvalidHostPointerOpenCLException();

                case OpenCLErrorCode.InvalidMemoryObject:
                    throw new InvalidMemoryObjectOpenCLException();

                case OpenCLErrorCode.InvalidImageFormatDescriptor:
                    throw new InvalidImageFormatDescriptorOpenCLException();

                case OpenCLErrorCode.InvalidImageSize:
                    throw new InvalidImageSizeOpenCLException();

                case OpenCLErrorCode.InvalidSampler:
                    throw new InvalidSamplerOpenCLException();

                case OpenCLErrorCode.InvalidBinary:
                    throw new InvalidBinaryOpenCLException();

                case OpenCLErrorCode.InvalidBuildOptions:
                    throw new InvalidBuildOptionsOpenCLException();

                case OpenCLErrorCode.InvalidProgram:
                    throw new InvalidProgramOpenCLException();

                case OpenCLErrorCode.InvalidProgramExecutable:
                    throw new InvalidProgramExecutableOpenCLException();

                case OpenCLErrorCode.InvalidKernelName:
                    throw new InvalidKernelNameOpenCLException();

                case OpenCLErrorCode.InvalidKernelDefinition:
                    throw new InvalidKernelDefinitionOpenCLException();

                case OpenCLErrorCode.InvalidKernel:
                    throw new InvalidKernelOpenCLException();

                case OpenCLErrorCode.InvalidArgumentIndex:
                    throw new InvalidArgumentIndexOpenCLException();

                case OpenCLErrorCode.InvalidArgumentValue:
                    throw new InvalidArgumentValueOpenCLException();

                case OpenCLErrorCode.InvalidArgumentSize:
                    throw new InvalidArgumentSizeOpenCLException();

                case OpenCLErrorCode.InvalidKernelArguments:
                    throw new InvalidKernelArgumentsOpenCLException();

                case OpenCLErrorCode.InvalidWorkDimension:
                    throw new InvalidWorkDimensionsOpenCLException();

                case OpenCLErrorCode.InvalidWorkGroupSize:
                    throw new InvalidWorkGroupSizeOpenCLException();

                case OpenCLErrorCode.InvalidWorkItemSize:
                    throw new InvalidWorkItemSizeOpenCLException();

                case OpenCLErrorCode.InvalidGlobalOffset:
                    throw new InvalidGlobalOffsetOpenCLException();

                case OpenCLErrorCode.InvalidEventWaitList:
                    throw new InvalidEventWaitListOpenCLException();

                case OpenCLErrorCode.InvalidEvent:
                    throw new InvalidEventOpenCLException();

                case OpenCLErrorCode.InvalidOperation:
                    throw new InvalidOperationOpenCLException();

                case OpenCLErrorCode.InvalidGLObject:
                    throw new InvalidGLObjectOpenCLException();

                case OpenCLErrorCode.InvalidBufferSize:
                    throw new InvalidBufferSizeOpenCLException();

                case OpenCLErrorCode.InvalidMipLevel:
                    throw new InvalidMipLevelOpenCLException();

                default:
                    throw new OpenCLException(errorCode);
            }
        }
Esempio n. 38
0
 public extern static CLCommandQueueHandle CreateCommandQueue(
     CLContextHandle context,
     CLDeviceHandle device,
     OpenCLCommandQueueProperties properties,
     out OpenCLErrorCode errcode_ret);
Esempio n. 39
0
 public extern static CLProgramHandle CreateProgramWithBinary(
     CLContextHandle context,
     Int32 num_devices,
     [MarshalAs(UnmanagedType.LPArray)] CLDeviceHandle[] device_list,
     [MarshalAs(UnmanagedType.LPArray)] IntPtr[] lengths,
     [MarshalAs(UnmanagedType.LPArray)] IntPtr[] binaries,
     [MarshalAs(UnmanagedType.LPArray)] Int32[] binary_status,
     out OpenCLErrorCode errcode_ret);
Esempio n. 40
0
 public static IMemoryObject CreateBuffer(ContextHandle context, MemFlags flags, IntPtr size, IntPtr hostPtr, out OpenCLErrorCode errcodeRet)
 {
     return new MemoryObject(clCreateBuffer((context as IHandleData).Handle, flags, size, hostPtr, out errcodeRet));
 }
Esempio n. 41
0
 public extern static CLMemoryHandle CreateImage3D(
     CLContextHandle context,
     OpenCLMemoryFlags flags,
     ref OpenCLImageFormat image_format,
     IntPtr image_width,
     IntPtr image_height,
     IntPtr image_depth,
     IntPtr image_row_pitch,
     IntPtr image_slice_pitch,
     IntPtr host_ptr,
     out OpenCLErrorCode errcode_ret);
Esempio n. 42
0
 public extern static CLContextHandle CreateContext(
     [MarshalAs(UnmanagedType.LPArray)] IntPtr[] properties,
     Int32 num_devices,
     [MarshalAs(UnmanagedType.LPArray)] CLDeviceHandle[] devices,
     OpenCLContextNotifier pfn_notify,
     IntPtr user_data,
     out OpenCLErrorCode errcode_ret);
Esempio n. 43
0
 public extern static CLMemoryHandle CreateFromGLRenderbuffer(
     CLContextHandle context,
     OpenCLMemoryFlags flags,
     Int32 renderbuffer,
     out OpenCLErrorCode errcode_ret);
Esempio n. 44
0
 public extern static CLSamplerHandle CreateSampler(
     CLContextHandle context,
     [MarshalAs(UnmanagedType.Bool)] bool normalized_coords,
     OpenCLImageAddressing addressing_mode,
     OpenCLImageFiltering filter_mode,
     out OpenCLErrorCode errcode_ret);
Esempio n. 45
0
 public extern static IntPtr EnqueueMapImage(
     CLCommandQueueHandle command_queue,
     CLMemoryHandle image,
     [MarshalAs(UnmanagedType.Bool)] bool blocking_map,
     OpenCLMemoryMappingFlags map_flags,
     ref SysIntX3 origin,
     ref SysIntX3 region,
     out IntPtr image_row_pitch,
     out IntPtr image_slice_pitch,
     Int32 num_events_in_wait_list,
     [MarshalAs(UnmanagedType.LPArray)] CLEventHandle[] event_wait_list,
     [Out, MarshalAs(UnmanagedType.LPArray, SizeConst = 1)] CLEventHandle[] new_event,
     out OpenCLErrorCode errcode_ret);
Esempio n. 46
0
 public extern static IntPtr EnqueueMapBuffer(
     CLCommandQueueHandle command_queue,
     CLMemoryHandle buffer,
     [MarshalAs(UnmanagedType.Bool)] bool blocking_map,
     OpenCLMemoryMappingFlags map_flags,
     IntPtr offset,
     IntPtr cb,
     Int32 num_events_in_wait_list,
     [MarshalAs(UnmanagedType.LPArray)] CLEventHandle[] event_wait_list,
     [Out, MarshalAs(UnmanagedType.LPArray, SizeConst = 1)] CLEventHandle[] new_event,
     out OpenCLErrorCode errcode_ret);
Esempio n. 47
0
 public extern static CLKernelHandle CreateKernel(
     CLProgramHandle program,
     String kernel_name,
     out OpenCLErrorCode errcode_ret);
Esempio n. 48
0
 public extern static CLMemoryHandle CreateSubBuffer(
     CLMemoryHandle buffer,
     OpenCLMemoryFlags flags,
     OpenCLBufferCreateType buffer_create_type,
     ref SysIntX2 buffer_create_info,
     out OpenCLErrorCode errcode_ret);
Esempio n. 49
0
 public extern static CLEventHandle CreateUserEvent(
     CLContextHandle context,
     out OpenCLErrorCode errcode_ret);
Esempio n. 50
0
 public extern static CLMemoryHandle CreateBuffer(
     CLContextHandle context,
     OpenCLMemoryFlags flags,
     IntPtr size,
     IntPtr host_ptr,
     out OpenCLErrorCode errcode_ret);
Esempio n. 51
0
 public extern static CLMemoryHandle CreateFromGLTexture3D(
     CLContextHandle context,
     OpenCLMemoryFlags flags,
     Int32 target,
     Int32 miplevel,
     Int32 texture,
     out OpenCLErrorCode errcode_ret);
Esempio n. 52
0
 public extern static CLProgramHandle CreateProgramWithSource(
     CLContextHandle context,
     Int32 count,
     String[] strings,
     [MarshalAs(UnmanagedType.LPArray)] IntPtr[] lengths,
     out OpenCLErrorCode errcode_ret);
Esempio n. 53
0
 public extern static CLContextHandle CreateContextFromType(
     [MarshalAs(UnmanagedType.LPArray)] IntPtr[] properties,
     OpenCLDeviceType device_type,
     OpenCLContextNotifier pfn_notify,
     IntPtr user_data,
     out OpenCLErrorCode errcode_ret);
Esempio n. 54
0
 private static extern IntPtr clCreateImage3D(IntPtr context,
                                              MemFlags flags,
                                              IntPtr imageFormat,
                                              IntPtr imageWidth,
                                              IntPtr imageHeight,
                                              IntPtr imageDepth,
                                              IntPtr imageRowPitch,
                                              IntPtr imageSlicePitch,
                                              IntPtr hostPtr,
                                              out OpenCLErrorCode errcodeRet);