示例#1
0
        /// <summary>
        ///     Retrieves the specified information about the OpenCL memory object.
        /// </summary>
        /// <typeparam name="T">
        ///     The type of the data that is to be returned.</param>
        ///     <param name="memoryObjectInformation">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 GetMemoryObjectInformation <T>(MemoryObjectInformation memoryObjectInformation)
        {
            // Retrieves the size of the return value in bytes, this is used to later get the full information
            Result result = MemoryNativeApi.GetMemoryObjectInformation(
                Handle,
                memoryObjectInformation,
                UIntPtr.Zero,
                null,
                out UIntPtr returnValueSize
                );

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

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

            // Returns the output
            return(InteropConverter.To <T>(output));
        }
示例#2
0
 public static extern Result GetMemoryObjectInformation(
     [In] IntPtr memoryObject,
     [In][MarshalAs(UnmanagedType.U4)] MemoryObjectInformation parameterName,
     [In] UIntPtr parameterValueSize,
     [Out] byte[] parameterValue,
     [Out] out UIntPtr parameterValueSizeReturned
     );