Example #1
0
        private static String GetKernelInfoString(CLKernel openclKernel, CLKernelInfo kernelInfo, Int32 kernelInfoBufferSize)
        {
            byte[] buffer = GetKernelInfoBuffer(openclKernel, kernelInfo, kernelInfoBufferSize);

            Int32 count = Array.IndexOf <Byte>(buffer, 0, 0);

            return(System.Text.ASCIIEncoding.ASCII.GetString(buffer, 0, count < 0 ? buffer.Length : count));
        }
Example #2
0
        private static T GetKernelInfo <T>(CLKernel openclKernel, CLKernelInfo kernelInfo)
        {
            Byte[] buffer = GetKernelInfoBuffer(openclKernel, kernelInfo, Marshal.SizeOf(typeof(T)));

            GCHandle bufferHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);

            try
            {
                return((T)Marshal.PtrToStructure(bufferHandle.AddrOfPinnedObject(), typeof(T)));
            }
            finally
            {
                bufferHandle.Free();
            }
        }
Example #3
0
        private static Byte[] GetKernelInfoBuffer(CLKernel openclKernel, CLKernelInfo kernelInfo, Int32 kernelInfoBufferSize)
        {
            SizeT bufferSize = SizeT.Zero;

            Byte[] buffer = new Byte[kernelInfoBufferSize];

            GCHandle bufferHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);

            IntPtr bufferPtr = bufferHandle.AddrOfPinnedObject();

            try
            {
                OpenCLError.Validate(OpenCLDriver.clGetKernelInfo(openclKernel, kernelInfo, new SizeT(buffer.Length), bufferPtr, ref bufferSize));
            }
            finally
            {
                bufferHandle.Free();
            }

            Array.Resize(ref buffer, (int)bufferSize);

            return(buffer);
        }
Example #4
0
 public static extern CLError clGetKernelInfo(
     CLKernel kernel,
     CLKernelInfo param_name,
     SizeT param_value_size,
     IntPtr param_value,
     ref SizeT param_value_size_ret);
Example #5
0
 internal static extern CLError clGetKernelInfo(CLKernel kernel, CLKernelInfo param_name, SizeT param_value_size, IntPtr param_value, ref SizeT param_value_size_ret);