public static List<Platform> GetAllPlatforms() { var tmpPlatformList = new List<Platform>(); uint platformCount; OpenCLErrorCode tmpErrorCode = OpenCL_PlatformInformation.GetPlatformIDs(0, null, out platformCount); if (tmpErrorCode != OpenCLErrorCode.Success) { Log.Add(LogType.Error, $"No Platrofm Cound available: {tmpErrorCode}"); return tmpPlatformList; } Log.Add(LogType.Info, $"{platformCount} platforms found"); var platformIds = new PlatformHandle[platformCount]; tmpErrorCode = OpenCL_PlatformInformation.GetPlatformIDs(platformCount, platformIds, out platformCount); if (tmpErrorCode != OpenCLErrorCode.Success) { Log.Add(LogType.Error, $"Coudl not Get PlatformId's: {tmpErrorCode}"); return tmpPlatformList; } foreach (PlatformHandle platformId in platformIds) { Log.Add(LogType.Info, $"PlatformId: {(platformId as IHandleData).Handle}"); tmpPlatformList.Add(new Platform { Handle = platformId, }); } return tmpPlatformList; }
/// <summary> /// Get ID's of the Devices /// </summary> /// <returns></returns> public static OpenCLErrorCode GetDeviceIDs(PlatformHandle platform, DeviceType deviceType, uint numEntries, DeviceHandle[] devices, out uint numDevices) { return clGetDeviceIDs((platform as IHandleData).Handle, deviceType, numEntries, devices, out numDevices); }
/// <summary> /// Returns Information about a specific Platform /// </summary> /// <returns></returns> public static OpenCLErrorCode GetPlatformInfo(PlatformHandle platformId, PlatformInfo paramName, IntPtr paramValueBufferSize, InfoBuffer paramValue, out IntPtr paramValueSize) { return clGetPlatformInfo((platformId as IHandleData).Handle, paramName, paramValueBufferSize, paramValue.Address, out paramValueSize); }
/// <summary> /// Returns the ID's of the Different Platforms (CPU, iGPU, GPU1, GPU2,...) /// </summary> /// <param name="numEntries"></param> /// <param name="platforms"></param> /// <param name="numPlatforms"></param> /// <returns></returns> public static OpenCLErrorCode GetPlatformIDs(uint numEntries, PlatformHandle[] platforms, out uint numPlatforms) { return clGetPlatformIDs(numEntries, platforms, out numPlatforms); }