예제 #1
0
        /// <summary>
        /// Gets all devices of the given type.
        /// </summary>
        /// <typeparam name="TDevice">The device class type.</typeparam>
        /// <returns>All device instances.</returns>
        public DeviceCollection <TDevice> GetDevices <TDevice>()
            where TDevice : Device
        {
            var type = DeviceTypeAttribute.GetAcceleratorType(typeof(TDevice));

            return(deviceMapping.TryGetValue(type, out var devices)
                ? new DeviceCollection <TDevice>(devices)
                : new DeviceCollection <TDevice>(new List <Device>()));
        }
예제 #2
0
파일: Context.cs 프로젝트: rpfeuti/ILGPU
        /// <summary>
        /// Gets all devices of the given type.
        /// </summary>
        /// <typeparam name="TDevice">The device class type.</typeparam>
        /// <returns>All device instances.</returns>
        public DeviceCollection <TDevice> GetDevices <TDevice>()
            where TDevice : Device
        {
            var type = DeviceTypeAttribute.GetAcceleratorType(typeof(TDevice));

            return(deviceMapping.TryGetValue(type, out var devices)
                ? new DeviceCollection <TDevice>(devices)
                : throw new NotSupportedException(
                       RuntimeErrorMessages.NotSupportedTargetAccelerator));
        }