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)); }
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(); } }
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); }
public static extern CLError clGetKernelInfo( CLKernel kernel, CLKernelInfo param_name, SizeT param_value_size, IntPtr param_value, ref SizeT param_value_size_ret);
internal static extern CLError clGetKernelInfo(CLKernel kernel, CLKernelInfo param_name, SizeT param_value_size, IntPtr param_value, ref SizeT param_value_size_ret);