Ignore:
Timestamp:
Dec 10, 2010, 4:32:19 PM (11 years ago)
Author:
Sven Rech
Message:

it should be possible now to use more opencl devices simultaneously (can't test it, because I only have one).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/KeySearcher/KeySearcherSettings.cs

    r2183 r2194  
    11using System;
     2using System.Collections.Generic;
    23using System.Windows;
    34using Cryptool.PluginBase;
     
    1718        private const string GroupOpenCL = "OpenCL";
    1819
     20        public class OpenCLDeviceSettings
     21        {
     22            public string name;
     23            public int index;
     24            public bool useDevice;
     25            public int mode;
     26        }
     27
     28        private List<OpenCLDeviceSettings> deviceSettings = new List<OpenCLDeviceSettings>();
     29        public List<OpenCLDeviceSettings> DeviceSettings
     30        {
     31            get
     32            {
     33                return deviceSettings;
     34            }
     35        }
     36
    1937        public event TaskPaneAttributeChangedHandler TaskPaneAttributeChanged;
    2038
     
    2442
    2543            devicesAvailable.Clear();
     44            int c = 0;
    2645            if (oclManager != null)
    2746                foreach (var device in oclManager.Context.Devices)
    28                     devicesAvailable.Add(device.Vendor + ":" + device.Name);
     47                {
     48                    string deviceName = device.Vendor + ":" + device.Name;
     49                    deviceSettings.Add(new OpenCLDeviceSettings() {name = deviceName, index = c, mode = 1, useDevice = false});
     50                    devicesAvailable.Add(deviceName);
     51                    c++;
     52                }
    2953
    3054            CoresAvailable.Clear();
     
    250274        }
    251275
    252         private bool useOpenCL;
    253         [TaskPane("Use OpenCL", "If checked, an OpenCL device is used for bruteforcing.",
    254             GroupOpenCL, 1, false, DisplayLevel.Experienced, ControlType.CheckBox)]
    255         public bool UseOpenCL
    256         {
    257             get { return useOpenCL; }
    258             set
    259             {
    260                 if (value != useOpenCL)
    261                 {
    262                     useOpenCL = value;
    263                     hasChanges = true;
    264                     OnPropertyChanged("UseOpenCL");
    265 
    266                     DeviceVisibility();
    267                 }
    268             }
    269         }
    270 
    271         private void DeviceVisibility()
    272         {
    273             if (TaskPaneAttributeChanged == null)
    274                 return;
    275 
    276             Visibility visibility = UseOpenCL ? Visibility.Visible : Visibility.Collapsed;
    277             TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("OpenCLDevice", visibility)));
    278             TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("OpenCLMode", visibility)));
    279         }
    280 
    281276        private void OpenCLGroupVisiblity()
    282277        {
     
    297292                TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("UseOpenCL", Visibility.Visible)));
    298293                TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("NoOpenCL", Visibility.Collapsed)));
    299                 DeviceVisibility();
    300294            }
    301295        }
    302296
    303297        private int openCLDevice;
    304         [TaskPane("OpenCL Device", "Choose the OpenCL device you want to use.", GroupOpenCL, 2, false, DisplayLevel.Experienced, ControlType.DynamicComboBox, new string[] { "DevicesAvailable" })]
     298        [TaskPane("OpenCL Device", "Choose the OpenCL device you want to use.", GroupOpenCL, 1, false, DisplayLevel.Experienced, ControlType.DynamicComboBox, new string[] { "DevicesAvailable" })]
    305299        public int OpenCLDevice
    306300        {
     
    311305                {
    312306                    this.openCLDevice = value;
     307                    UseOpenCL = deviceSettings[value].useDevice;
     308                    OpenCLMode = deviceSettings[value].mode;
    313309                    OnPropertyChanged("OpenCLDevice");
    314310                    HasChanges = true;
     
    317313        }
    318314
    319         private int openCLMode = 1;
     315        [TaskPane("Use selected device", "If checked, the selected OpenCL device is used for bruteforcing.",
     316            GroupOpenCL, 2, false, DisplayLevel.Experienced, ControlType.CheckBox)]
     317        public bool UseOpenCL
     318        {
     319            get { return deviceSettings[OpenCLDevice].useDevice; }
     320            set
     321            {
     322                if (value != deviceSettings[OpenCLDevice].useDevice)
     323                {
     324                    deviceSettings[OpenCLDevice].useDevice = value;
     325                    hasChanges = true;
     326                    OnPropertyChanged("UseOpenCL");
     327                    //DeviceVisibility();
     328                }
     329            }
     330        }
     331
    320332        [TaskPane("OpenCL Mode", "Choose the OpenCL mode you want to use.", GroupOpenCL, 3, false, DisplayLevel.Experienced, ControlType.RadioButton, new string[] { "Low Load", "Normal Load", "High Load (use with caution)" })]
    321333        public int OpenCLMode
    322334        {
    323             get { return this.openCLMode; }
    324             set
    325             {
    326                 if (value != this.openCLMode)
    327                 {
    328                     this.openCLMode = value;
     335            get { return deviceSettings[OpenCLDevice].mode; }
     336            set
     337            {
     338                if (value != deviceSettings[OpenCLDevice].mode)
     339                {
     340                    deviceSettings[OpenCLDevice].mode = value;
    329341                    OnPropertyChanged("OpenCLMode");
    330342                    HasChanges = true;
Note: See TracChangeset for help on using the changeset viewer.