/// <summary> /// Loads the binary representation of the given OpenCL kernel. /// </summary> /// <param name="program">The program pointer.</param> /// <returns>The binary representation of the underlying kernel.</returns> public static unsafe byte[] LoadBinaryRepresentation(IntPtr program) { IntPtr kernelSize; CLException.ThrowIfFailed( CurrentAPI.GetProgramInfo( program, CLProgramInfo.CL_PROGRAM_BINARY_SIZES, new IntPtr(IntPtr.Size), &kernelSize, out var _)); var programBinary = new byte[kernelSize.ToInt32()]; fixed(byte *binPtr = &programBinary[0]) { CLException.ThrowIfFailed( CurrentAPI.GetProgramInfo( program, CLProgramInfo.CL_PROGRAM_BINARIES, new IntPtr(IntPtr.Size), &binPtr, out var _)); } return(programBinary); }