Changeset 14fa542 in sasview


Ignore:
Timestamp:
Oct 24, 2017 6:54:24 AM (6 years ago)
Author:
krzywon
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
a6cd8d1
Parents:
06ce180
Message:

Auto-populate OpenCL dialog with available options to finalize GUI.

Location:
src/sas/qtgui/Perspectives/Fitting
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py

    r06ce180 r14fa542  
    6363 
    6464        # GPU Options 
    65         self.gpu_options_widget = GPUOptions() 
     65        self.gpu_options_widget = GPUOptions(self) 
    6666 
    6767        self.menu_manager = ModelUtilities.ModelManager() 
  • src/sas/qtgui/Perspectives/Fitting/GPUOptions.py

    r06ce180 r14fa542  
    11# global 
    2 import sys 
    3 import os 
    4 import types 
    52 
    6 from PyQt4 import QtCore 
    7 from PyQt4 import QtGui 
    8 from PyQt4 import QtWebKit 
     3from PyQt4 import QtGui, QtCore 
    94from sas.qtgui.Perspectives.Fitting.UI.GPUOptionsUI import Ui_GPUOptions 
    105 
    11 from bumps import fitters 
    12 import bumps.options 
     6try: 
     7    _fromUtf8 = QtCore.QString.fromUtf8 
     8except AttributeError: 
     9    def _fromUtf8(s): 
     10        return s 
    1311 
    14 # Set the default optimizer 
    15 fitters.FIT_DEFAULT_ID = 'lm' 
     12try: 
     13    _encoding = QtGui.QApplication.UnicodeUTF8 
     14    def _translate(context, text, disambig): 
     15        return QtGui.QApplication.translate(context, text, disambig, _encoding) 
     16except AttributeError: 
     17    def _translate(context, text, disambig): 
     18        return QtGui.QApplication.translate(context, text, disambig) 
    1619 
    1720 
     
    2528        self.setupUi(self) 
    2629 
     30        # Get list of openCL options and add to GUI 
     31        cl_tuple = self._get_clinfo() 
     32        i = 0 
     33        for title, descr in cl_tuple: 
     34            button = QtGui.QRadioButton(self.openCLButtonGroup) 
     35            button.setGeometry(20, 20 + i, 351, 30) 
     36            button.setObjectName(_fromUtf8(title)) 
     37            button.setText(_translate("GPUOptions", descr, None)) 
     38            # Expand group and shift items down as more are added 
     39            self.openCLButtonGroup.resize(391, 60 + i) 
     40            self.pushButton.setGeometry(QtCore.QRect(220, 90 + i, 93, 28)) 
     41            self.TestButton.setGeometry(QtCore.QRect(20, 90 + i, 193, 28)) 
     42            self.pushButton_2.setGeometry(QtCore.QRect(320, 90 + i, 93, 28)) 
     43            self.resize(440, 130 + i) 
     44            i += 30 
    2745 
    28 def main(): 
    29     app = QtGui.QApplication(sys.argv) 
     46    def _get_clinfo(self): 
     47        """ 
     48        Reading in information about available OpenCL infrastructure 
     49        :return: 
     50        """ 
     51        clinfo = [] 
     52        platforms = [] 
     53        try: 
     54            import pyopencl as cl 
     55            platforms = cl.get_platforms() 
     56        except ImportError: 
     57            print("pyopencl import failed. Using only CPU computations") 
    3058 
    31     w = GPUOptions() 
    32     w.show() 
     59        p_index = 0 
     60        for platform in platforms: 
     61            d_index = 0 
     62            devices = platform.get_devices() 
     63            for device in devices: 
     64                if len(devices) > 1 and len(platforms) > 1: 
     65                    combined_index = ":".join([str(p_index), str(d_index)]) 
     66                elif len(platforms) > 1: 
     67                    combined_index = str(p_index) 
     68                else: 
     69                    combined_index = str(d_index) 
     70                clinfo.append((combined_index, ":".join([platform.name, device.name]))) 
     71                d_index += 1 
     72            p_index += 1 
    3373 
    34     sys.exit(app.exec_()) 
    35  
    36 if __name__ == '__main__': 
    37     main() 
     74        clinfo.append(("None", "No OpenCL")) 
     75        return clinfo 
  • src/sas/qtgui/Perspectives/Fitting/UI/GPUOptionsUI.ui

    r06ce180 r14fa542  
    88    <y>0</y> 
    99    <width>440</width> 
    10     <height>163</height> 
     10    <height>178</height> 
    1111   </rect> 
    1212  </property> 
     
    1818    <rect> 
    1919     <x>220</x> 
    20      <y>110</y> 
     20     <y>140</y> 
    2121     <width>93</width> 
    2222     <height>28</height> 
     
    3131    <rect> 
    3232     <x>20</x> 
    33      <y>110</y> 
     33     <y>140</y> 
    3434     <width>193</width> 
    3535     <height>28</height> 
     
    4444    <rect> 
    4545     <x>320</x> 
    46      <y>110</y> 
     46     <y>140</y> 
    4747     <width>93</width> 
    4848     <height>28</height> 
     
    5353   </property> 
    5454  </widget> 
    55   <widget class="QWidget" name="gridLayoutWidget"> 
     55  <widget class="QGroupBox" name="openCLButtonGroup"> 
    5656   <property name="geometry"> 
    5757    <rect> 
    5858     <x>20</x> 
    59      <y>10</y> 
     59     <y>20</y> 
    6060     <width>391</width> 
    61      <height>91</height> 
     61     <height>111</height> 
    6262    </rect> 
    6363   </property> 
    64    <layout class="QGridLayout" name="OpenCLDialogOptionsSection"> 
    65     <item row="0" column="0"> 
    66      <widget class="QRadioButton" name="AvailableOpenCLOptions"> 
    67       <property name="text"> 
    68        <string>None</string> 
    69       </property> 
    70       <property name="checked"> 
    71        <bool>true</bool> 
    72       </property> 
    73      </widget> 
    74     </item> 
    75    </layout> 
     64   <property name="title"> 
     65    <string>Available OpenCL Options</string> 
     66   </property> 
    7667  </widget> 
    7768 </widget> 
Note: See TracChangeset for help on using the changeset viewer.