static ComputePlatform() { if (Platforms != null) { return; } lock (lockObj) { try { CL10.GetPlatformIDsWrapper(0, null, out int handlesLength); CLPlatformHandle[] handles = new CLPlatformHandle[handlesLength]; CL10.GetPlatformIDsWrapper(handlesLength, handles, out handlesLength); var platformList = new List <ComputePlatform>(handlesLength); foreach (CLPlatformHandle handle in handles) { platformList.Add(new ComputePlatform(handle)); } Platforms = platformList.AsReadOnly(); } catch (DllNotFoundException) { Platforms = new List <ComputePlatform>().AsReadOnly(); } } }
static ComputePlatform() { lock (typeof(ComputePlatform)) { try { if (Platforms != null) { return; } CLPlatformHandle[] handles; var error = CL10.GetPlatformIDs(0, null, out int handlesLength); ComputeException.ThrowOnError(error); handles = new CLPlatformHandle[handlesLength]; error = CL10.GetPlatformIDs(handlesLength, handles, out handlesLength); ComputeException.ThrowOnError(error); var platformList = new List <ComputePlatform>(handlesLength); foreach (CLPlatformHandle handle in handles) { platformList.Add(new ComputePlatform(handle)); } Platforms = platformList.AsReadOnly(); } catch (DllNotFoundException) { Platforms = new List <ComputePlatform>().AsReadOnly(); } } }
private ComputePlatform(CLPlatformHandle handle) { Handle = handle; SetID(Handle.Value); string extensionString = GetStringInfo(Handle, ComputePlatformInfo.Extensions, CL10.GetPlatformInfoWrapper); Extensions = new ReadOnlyCollection <string>(extensionString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); Name = GetStringInfo(Handle, ComputePlatformInfo.Name, CL10.GetPlatformInfoWrapper); Profile = GetStringInfo(Handle, ComputePlatformInfo.Profile, CL10.GetPlatformInfoWrapper); Vendor = GetStringInfo(Handle, ComputePlatformInfo.Vendor, CL10.GetPlatformInfoWrapper); Version = GetStringInfo(Handle, ComputePlatformInfo.Version, CL10.GetPlatformInfoWrapper); QueryDevices(); }