/// <summary> /// Resolves the number of available platforms. /// </summary> /// <returns>The error code.</returns> public static CLError GetNumDevices(IntPtr platform, CLDeviceType deviceType, out int numDevices) => NativeMethods.GetDeviceIDs( platform, deviceType, short.MaxValue, null, out numDevices);
public static CLError GetDevices( IntPtr platform, CLDeviceType deviceType, IntPtr *devices, ref int numDevices) => NativeMethods.GetDeviceIDs( platform, deviceType, numDevices, devices, out numDevices);
public static IntPtr CreateContextFromType(CLDeviceType deviceType, ref int error) { uint numPlatforms; IntPtr platform = IntPtr.Zero; IntPtr[] platforms = null; int ciErrNum = CL.GetPlatformIDs(0, ref platforms, out numPlatforms); if (ciErrNum != 0) { error = ciErrNum; return(IntPtr.Zero); } if (CLStuff.deviceType == CLDeviceType.Cpu) { platformVendor = "MiniCL, SCEA"; } if (numPlatforms > 0) { platforms = new IntPtr[numPlatforms]; ciErrNum = CL.GetPlatformIDs(numPlatforms, ref platforms, out numPlatforms); if (ciErrNum != 0) { error = ciErrNum; return(IntPtr.Zero); } for (int i = 0; i < numPlatforms; ++i) { string vendor; ciErrNum = CL.GetPlatformInfo(platforms[i], CLPlatform.Vendor, out vendor); if (ciErrNum != 0) { error = ciErrNum; return(IntPtr.Zero); } platform = platforms[i]; if (vendor == platformVendor) { break; } } } List <KeyValuePair <CLContext, IntPtr> > properties = new List <KeyValuePair <CLContext, IntPtr> >(); properties.Add(new KeyValuePair <CLContext, IntPtr>(CLContext.Platform, platform)); return(CL.CreateContextFromType(properties, deviceType, out error)); }
/// <summary> /// Resolves the number of available devices. /// </summary> /// <param name="platform">The target platform.</param> /// <param name="deviceType">The device type.</param> /// <param name="devices">The device ids to fill.</param> /// <param name="numDevices">The number of devices.</param> /// <returns>The error code.</returns> public static CLError GetDevices( IntPtr platform, CLDeviceType deviceType, IntPtr[] devices, out int numDevices) { Debug.Assert(devices != null, "Invalid devices"); fixed(IntPtr *ptr = &devices[0]) { numDevices = devices.Length; return(GetDevices(platform, deviceType, ptr, ref numDevices)); } }
public static Devices Create(CLDeviceType deviceType, Platform platform) { Int32 deviceCount = 0; CLPlatformID pfm = platform == null ? new CLPlatformID() : platform.CLPlatformID; OpenCLError.Validate(OpenCLDriver.clGetDeviceIDs(pfm, (ManOCL.Internal.OpenCL.CLDeviceType)deviceType, 0, null, ref deviceCount)); CLDeviceID[] deviceIds = new CLDeviceID[deviceCount]; OpenCLError.Validate(OpenCLDriver.clGetDeviceIDs(pfm, (ManOCL.Internal.OpenCL.CLDeviceType)deviceType, deviceCount, deviceIds, ref deviceCount)); return(new Devices(deviceIds)); }
public static IntPtr CreateContextFromType(CLDeviceType deviceType, ref int error) { uint numPlatforms; IntPtr platform = IntPtr.Zero; IntPtr[] platforms = null; int ciErrNum = CL.GetPlatformIDs(0, ref platforms, out numPlatforms); if (ciErrNum != 0) { error = ciErrNum; return IntPtr.Zero; } if (CLStuff.deviceType == CLDeviceType.Cpu) { platformVendor = "MiniCL, SCEA"; } if (numPlatforms > 0) { platforms = new IntPtr[numPlatforms]; ciErrNum = CL.GetPlatformIDs(numPlatforms, ref platforms, out numPlatforms); if (ciErrNum != 0) { error = ciErrNum; return IntPtr.Zero; } for (int i = 0; i < numPlatforms; ++i) { string vendor; ciErrNum = CL.GetPlatformInfo(platforms[i], CLPlatform.Vendor, out vendor); if (ciErrNum != 0) { error = ciErrNum; return IntPtr.Zero; } platform = platforms[i]; if (vendor == platformVendor) break; } } List<KeyValuePair<CLContext, IntPtr>> properties = new List<KeyValuePair<CLContext, IntPtr>>(); properties.Add(new KeyValuePair<CLContext, IntPtr>(CLContext.Platform, platform)); return CL.CreateContextFromType(properties, deviceType, out error); }
public static Devices Create(CLDeviceType deviceType, Platforms platforms) { List <Device> rd = new List <Device>(); foreach (Platform platform in platforms) { Devices devices = Devices.Create(deviceType, platform); foreach (Device device in devices) { rd.Add(device); } } Device[] resultingDevices = rd.ToArray(); CLDeviceID[] resultingOpenCLDevices = GetOpenCLDeviceArray(resultingDevices); return(new Devices(resultingOpenCLDevices, resultingDevices)); }
public static extern CLError GetDeviceIDs( [In] IntPtr platform, [In] CLDeviceType deviceType, [In] int maxNumDevices, [Out] IntPtr *devices, [Out] out int numDevices);
public static extern CLError clGetDeviceIDs( CLPlatformID platform_id, CLDeviceType device_type, uint num_entries, IntPtr devices, ref uint num_devices);
public static extern CLContext clCreateContextFromType( [In] IntPtr[] properties, CLDeviceType device_type, LoggingFunction pfn_notify, IntPtr user_data, ref CLError errcode_ret);
internal static extern CLContext clCreateContextFromType([In] IntPtr[] properties, CLDeviceType device_type, LoggingFunction pfn_notify, IntPtr user_data, ref CLError errcode_ret);
internal static extern CLError clGetDeviceIDs(CLPlatformID platform_id, CLDeviceType device_type, int num_entries, IntPtr devices, ref int num_devices);
internal static extern CLError clGetDeviceIDs(CLPlatformID platform_id, CLDeviceType device_type, int num_entries, [Out] CLDeviceID[] devices, ref int num_devices);
public static Devices Create(CLDeviceType deviceType) { return(Create(deviceType, Context.Default.Platforms)); }