public static int GetAmdDevicePciBusID(OpenCl.DotNetCore.Devices.Device device) { var deviceHandle = GetDeviceHandle(device); var deviceInformation = (OpenCl.DotNetCore.Interop.Devices.DeviceInformation)DeviceInformation.CL_DEVICE_TOPOLOGY_AMD; var temp = new byte[256]; var res = DevicesNativeApi.GetDeviceInformation(deviceHandle, (OpenCl.DotNetCore.Interop.Devices.DeviceInformation)DeviceInformation.CL_DEVICE_BOARD_NAME_AMD, new UIntPtr(256), temp, out UIntPtr rVal); var name = System.Text.Encoding.ASCII.GetString(temp).TrimEnd(char.MinValue); var result = DevicesNativeApi.GetDeviceInformation(deviceHandle, deviceInformation, UIntPtr.Zero, null, out UIntPtr returnValueSize); if (result != Result.Success) { throw new Exception($"The device information could not be retrieved. Error code: {result}."); } var output = new byte[returnValueSize.ToUInt32()]; result = DevicesNativeApi.GetDeviceInformation(deviceHandle, deviceInformation, new UIntPtr((uint)output.Length), output, out returnValueSize); if (result != Result.Success) { throw new Exception($"The device information could not be retrieved. Error code: {result}."); } var topology = ByteArrayToStructure <CL_device_topology_amd>(output); return((topology.type == CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD) ? topology.bus : -1); }
public static string GetAmdDeviceName(OpenCl.DotNetCore.Devices.Device device) { var deviceHandle = GetDeviceHandle(device); var deviceInformation = (OpenCl.DotNetCore.Interop.Devices.DeviceInformation)DeviceInformation.CL_DEVICE_BOARD_NAME_AMD; var nameBin = new byte[256]; var result = DevicesNativeApi.GetDeviceInformation(deviceHandle, deviceInformation, new UIntPtr(256), nameBin, out UIntPtr rVal); if (result != Result.Success) { throw new Exception($"The device information could not be retrieved. Error code: {result}."); } return(System.Text.Encoding.ASCII.GetString(nameBin).TrimEnd(char.MinValue)); }
public static ulong GetAvailableMemory(OpenCl.DotNetCore.Devices.Device device) { var deviceHandle = GetDeviceHandle(device); var deviceInformation = (OpenCl.DotNetCore.Interop.Devices.DeviceInformation)DeviceInformation.CL_DEVICE_GLOBAL_FREE_MEMORY_AMD; var output = new byte[8]; var result = DevicesNativeApi.GetDeviceInformation(deviceHandle, deviceInformation, new UIntPtr(8), output, out UIntPtr rVal); if (result != Result.Success) { throw new Exception($"The device information could not be retrieved. Error code: {result}."); } var memory = new ulong[1]; Buffer.BlockCopy(output, 0, memory, 0, 8); return(memory[0] * (ulong)Math.Pow(2, 10)); }