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(); } } }