/// <summary> /// Gets an array of all OpenCL Devices with the specified flags. /// </summary> /// <param name="deviceTypeFlags">A bitfield that identifies the type of OpenCL device.</param> /// <returns>An array of OpenCL devices with the specified flags.</returns> public Device[] GetDevices(DeviceTypeFlags deviceTypeFlags) { Device[] devices = null; uint count = 0; unsafe { ErrorCode errorCode = (ErrorCode)Native.GetDeviceIDs(this.Handle, deviceTypeFlags, 0, null, &count); if (errorCode == ErrorCode.DeviceNotFound) { return(new Device[0]); } else if (errorCode != ErrorCode.Success) { throw new OpenCLCallFailedException(errorCode); } IntPtr[] devHandles = new IntPtr[count]; devices = new Device[count]; fixed(IntPtr *p_devHandles = devHandles) { Native.Call(Native.GetDeviceIDs(this.Handle, deviceTypeFlags, count, p_devHandles, null)); } devices = Device.CreateFromHandles(devHandles); } return(devices); }
public static Context CreateFromType(Platform platform, DeviceTypeFlags deviceTypeFlags) { ContextProperties[] properties = new ContextProperties[3]; properties[0] = ContextProperties.Platform; properties[1] = (ContextProperties)(platform.Handle); properties[2] = (ContextProperties)0; return(CreateFromType(properties, deviceTypeFlags)); }
public static IntPtr[] GetDeviceIds(IntPtr platformId, DeviceTypeFlags deviceType) { //get numOfPlatforms uint num; CheckError(CL.GetDeviceIDs(platformId, deviceType, 0, (IntPtr*)NullPtr, &num)); //get platforms IntPtr[] ids = new IntPtr[num]; fixed (IntPtr* idsPtr = ids) { CheckError(CL.GetDeviceIDs(platformId, deviceType, num, idsPtr, (uint*)NullPtr)); } return ids; }
public static IntPtr[] GetDeviceIds(IntPtr platformId, DeviceTypeFlags deviceType) { //get numOfPlatforms uint num; CheckError(CL.GetDeviceIDs(platformId, deviceType, 0, (IntPtr *)NullPtr, &num)); //get platforms IntPtr[] ids = new IntPtr[num]; fixed(IntPtr *idsPtr = ids) { CheckError(CL.GetDeviceIDs(platformId, deviceType, num, idsPtr, (uint *)NullPtr)); } return(ids); }
public static Context CreateFromType(ContextProperties[] properties, DeviceTypeFlags deviceTypeFlags) { Context result = null; ErrorCode errorCode = ErrorCode.Success; IntPtr ctxHandle = IntPtr.Zero; unsafe { fixed(ContextProperties *p_properties = properties) { ctxHandle = Native.CreateContextFromType(p_properties, deviceTypeFlags, IntPtr.Zero, IntPtr.Zero, &errorCode); } } if (errorCode != ErrorCode.Success) { throw new OpenCLCallFailedException(errorCode); } result = new Context(ctxHandle); return(result); }
public static Device[] GetDevices(Platform platform, DeviceTypeFlags deviceTypeFlags) { return(platform.GetDevices(deviceTypeFlags)); }
public static unsafe IntPtr CreateContextFromType <T4>(ref ContextProperties properties, DeviceTypeFlags device_type, IntPtr pfn_notify, ref T4 user_data, out OpenTK.Compute.CL10.ErrorCode errcode_ret) where T4 : struct { IntPtr properties_correct = new IntPtr((int)properties); return(CreateContextFromType(ref properties_correct, device_type, pfn_notify, ref user_data, out errcode_ret)); }
public static unsafe IntPtr CreateContextFromType <T4>(ContextProperties[] properties, DeviceTypeFlags device_type, IntPtr pfn_notify, ref T4 user_data, OpenTK.Compute.CL10.ErrorCode[] errcode_ret) where T4 : struct { IntPtr[] properties_correct = properties != null ? new IntPtr[properties.Length] : null; for (int i = 0; i < properties_correct.Length; i++) { properties_correct[i] = new IntPtr((int)properties[i]); } return(CreateContextFromType(properties_correct, device_type, pfn_notify, ref user_data, errcode_ret)); }
public static unsafe IntPtr CreateContextFromType <T4>(ContextProperties *properties, DeviceTypeFlags device_type, IntPtr pfn_notify, ref T4 user_data, OpenTK.Compute.CL10.ErrorCode *errcode_ret) where T4 : struct { return(CreateContextFromType((IntPtr *)properties, device_type, pfn_notify, ref user_data, errcode_ret)); }
internal extern static unsafe IntPtr CreateContextFromType(ContextProperties *properties, DeviceTypeFlags device_type, IntPtr pfn_notify, IntPtr user_data, [Out] ErrorCode *errcode_ret);
internal extern static unsafe ErrorCode GetDeviceIDs(IntPtr platform, DeviceTypeFlags device_type, uint num_entries, IntPtr *devices, uint *num_devices);
internal extern static unsafe IntPtr CreateContextFromType(IntPtr *properties, DeviceTypeFlags device_type, IntPtr pfn_notify, IntPtr user_data, [OutAttribute] OpenTK.Compute.CL10.ErrorCode *errcode_ret);
internal extern static unsafe IntPtr CreateContextFromType(ContextProperties* properties, DeviceTypeFlags device_type, IntPtr pfn_notify, IntPtr user_data, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret);
internal extern static unsafe int GetDeviceIDs(IntPtr platform, DeviceTypeFlags device_type, uint num_entries, IntPtr* devices, uint* num_devices);
public static unsafe IntPtr CreateContextFromType(ContextProperties *properties, DeviceTypeFlags device_type, IntPtr pfn_notify, IntPtr user_data, osuTK.Compute.CL10.ErrorCode *errcode_ret) { return(CreateContextFromType((IntPtr *)properties, device_type, pfn_notify, user_data, errcode_ret)); }