示例#1
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);
        }