private static String GetDeviceInfoString(Device device, CLDeviceInfo deviceInfo) { byte[] buffer = GetDeviceInfoBuffer(device, deviceInfo); Int32 count = Array.IndexOf <byte>(buffer, 0); return(System.Text.ASCIIEncoding.ASCII.GetString(buffer, 0, count < 0 ? buffer.Length : count).Trim()); }
private static Byte[] GetDeviceInfoBuffer(Device device, CLDeviceInfo deviceInfo) { SizeT bufferSize = SizeT.Zero; OpenCLError.Validate(OpenCLDriver.clGetDeviceInfo(device.CLDeviceID, deviceInfo, SizeT.Zero, IntPtr.Zero, ref bufferSize)); Byte[] buffer = new Byte[(Int64)bufferSize]; OpenCLError.Validate(OpenCLDriver.clGetDeviceInfo(device.CLDeviceID, deviceInfo, bufferSize, buffer, ref bufferSize)); return(buffer); }
private static T GetDeviceInfo <T>(Device device, CLDeviceInfo deviceInfo) where T : struct { Byte[] buffer = GetDeviceInfoBuffer(device, deviceInfo); GCHandle bufferHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned); try { return((T)Marshal.PtrToStructure(bufferHandle.AddrOfPinnedObject(), typeof(T))); } finally { bufferHandle.Free(); } }
public static extern CLError clGetDeviceInfo( CLDeviceID device, CLDeviceInfo param_name, SizeT param_value_size, IntPtr param_value, ref SizeT param_value_size_ret);
internal static extern CLError clGetDeviceInfo(CLDeviceID device, CLDeviceInfo param_name, SizeT param_value_size, IntPtr param_value, ref SizeT param_value_size_ret);
internal static extern CLError clGetDeviceInfo(CLDeviceID device, CLDeviceInfo param_name, SizeT param_value_size, [Out] CLPlatformID[] param_value, ref SizeT param_value_size_ret);
internal static extern CLError clGetDeviceInfo(CLDeviceID device, CLDeviceInfo param_name, SizeT param_value_size, [Out] byte[] param_value, ref SizeT param_value_size_ret);