示例#1
0
文件: OpenCLError.cs 项目: lu4/ManOCL
        internal static void ValidateBuild(CLProgram openclProgram, Device device, CLError error)
        {
            if (CLError.None != error)
            {
                SizeT bufferSize = SizeT.Zero;

                OpenCLError.Validate(OpenCLDriver.clGetProgramBuildInfo(openclProgram, device.CLDeviceID, CLProgramBuildInfo.Log, SizeT.Zero, IntPtr.Zero, ref bufferSize));

                byte[] buffer = new byte[(Int64)bufferSize];

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

                try
                {
                    OpenCLError.Validate(OpenCLDriver.clGetProgramBuildInfo(openclProgram, device.CLDeviceID, CLProgramBuildInfo.Log, new SizeT(buffer.LongLength), bufferHandle.AddrOfPinnedObject(), ref bufferSize));

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

                    throw new OpenCLBuildError(error, System.Text.Encoding.ASCII.GetString(buffer, 0, count < 0 ? buffer.Length : count).Trim());
                }
                finally
                {
                    bufferHandle.Free();
                }
            }
        }