Exemplo n.º 1
0
        /// <summary>
        ///     Retrieves the specified information about the OpenCL kernel.
        /// </summary>
        /// <typeparam name="T">
        ///     The type of the data that is to be returned.</param>
        ///     <param name="kernelInformation">The kind of information that is to be retrieved.</param>
        ///     <exception cref="OpenClException">
        ///         If the information could not be retrieved, then an <see cref="OpenClException" />
        ///         is thrown.
        ///     </exception>
        ///     <returns>Returns the specified information.</returns>
        private T GetKernelInformation <T>(KernelInformation kernelInformation)
        {
            // Retrieves the size of the return value in bytes, this is used to later get the full information
            Result result =
                KernelsNativeApi.GetKernelInformation(
                    Handle,
                    kernelInformation,
                    UIntPtr.Zero,
                    null,
                    out UIntPtr returnValueSize
                    );

            if (result != Result.Success)
            {
                throw new OpenClException("The kernel information could not be retrieved.", result);
            }

            // Allocates enough memory for the return value and retrieves it
            byte[] output = new byte[returnValueSize.ToUInt32()];
            result = KernelsNativeApi.GetKernelInformation(
                Handle,
                kernelInformation,
                new UIntPtr((uint)output.Length),
                output,
                out returnValueSize
                );
            if (result != Result.Success)
            {
                throw new OpenClException("The kernel information could not be retrieved.", result);
            }

            // Returns the output
            return(InteropConverter.To <T>(output));
        }
Exemplo n.º 2
0
 public static extern Result GetKernelInformation(
     [In] IntPtr kernel,
     [In][MarshalAs(UnmanagedType.U4)] KernelInformation parameterName,
     [In] UIntPtr parameterValueSize,
     [Out] byte[] parameterValue,
     [Out] out UIntPtr parameterValueSizeReturned
     );