/// <summary>
        /// Builds (compiles and links) a program executable from the program source or binary for all or some of the <see cref="ComputeProgram.Devices"/>.
        /// </summary>
        /// <param name="devices"> A subset or all of <see cref="ComputeProgram.Devices"/>. If <paramref name="devices"/> is <c>null</c>, the executable is built for every item of <see cref="ComputeProgram.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="ComputeProgram.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="ComputeProgram.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(ICollection <ComputeDevice> devices, string options, ComputeProgramBuildNotifier notify, IntPtr notifyDataPtr)
        {
            int handleCount;

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

            ComputeErrorCode error = CL12.BuildProgram(Handle, handleCount, deviceHandles, options, buildNotify, notifyDataPtr);

#if DEBUG
            if (error != ComputeErrorCode.Success)
            {
                string str  = String.Empty;
                var    ptr  = Marshal.StringToHGlobalAnsi(str);
                IntPtr size = IntPtr.Zero;

                var errorCode = CL12.GetProgramBuildInfo(Handle, deviceHandles[0], ComputeProgramBuildInfo.BuildLog,
                                                         new IntPtr(4096), ptr,
                                                         out size);
                if (errorCode == ComputeErrorCode.Success)
                {
                    Debug.WriteLine($"Build Error:{Marshal.PtrToStringAnsi(ptr, (int) size)}");
                }
            }
#endif

            ComputeException.ThrowOnError(error);
        }
예제 #2
0
        /// <summary>
        /// Builds (compiles and links) a program executable from the program source or binary for all or some of the <see cref="ComputeProgram.Devices"/>.
        /// </summary>
        /// <param name="devices"> A subset or all of <see cref="ComputeProgram.Devices"/>. If <paramref name="devices"/> is <c>null</c>, the executable is built for every item of <see cref="ComputeProgram.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="ComputeProgram.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="ComputeProgram.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(ICollection <ComputeDevice> devices, string options, ComputeProgramBuildNotifier notify, IntPtr notifyDataPtr)
        {
            int handleCount;

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

            ComputeErrorCode error = CL12.BuildProgram(Handle, handleCount, deviceHandles, options, buildNotify, notifyDataPtr);

            ComputeException.ThrowOnError(error);
        }
예제 #3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Builds (compiles and links) a program executable from the program source or binary for all or
        /// some of the <see cref="ComputeProgram.Devices"/>.
        /// </summary>
        ///
        /// <param name="devices">          A subset or all of <see cref="ComputeProgram.Devices"/>. If
        ///                                 <paramref name="devices"/> is <c>null</c>, the executable is
        ///                                 built for every item of <see cref="ComputeProgram.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="ComputeProgram.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="ComputeProgram.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(ICollection <ComputeDevice> devices, string options, ComputeProgramBuildNotifier notify, IntPtr notifyDataPtr)
        {
            Ensure.Argument(devices).NotNull("devices is null");

            CLDeviceHandle[] deviceHandles = ComputeTools.ExtractHandles(devices, out var handleCount);
            buildOptions = options ?? "";
            buildNotify  = notify;

            ComputeErrorCode error = CL12.BuildProgram(Handle, handleCount, deviceHandles, options, buildNotify, notifyDataPtr);

            ComputeException.ThrowOnError(error);
        }