Changeset ced1bff in sasview
- Timestamp:
- Oct 25, 2017 4:57:22 AM (7 years ago)
- 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:
- 0bb1397
- Parents:
- c82fd8f
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
rc82fd8f rced1bff 3 3 import sys 4 4 import sasmodels 5 import json 6 import platform 5 7 6 8 from PyQt4 import QtGui, QtCore, QtWebKit 7 9 from sas.qtgui.Perspectives.Fitting.UI.GPUOptionsUI import Ui_GPUOptions 10 from sas.qtgui.Perspectives.Fitting.UI.GPUTestResultsUI import Ui_GPUTestResults 8 11 9 12 try: … … 57 60 # Expand group and shift items down as more are added 58 61 self.openCLCheckBoxGroup.resize(391, 60 + i) 59 self.okButton.setGeometry(QtCore.QRect(20, 90 + i, 93, 28)) 60 self.resetButton.setGeometry(QtCore.QRect(120, 90 + i, 93, 28)) 61 self.testButton.setGeometry(QtCore.QRect(220, 90 + i, 93, 28)) 62 self.helpButton.setGeometry(QtCore.QRect(320, 90 + i, 93, 28)) 63 self.resize(440, 130 + i) 62 self.label.setGeometry(QtCore.QRect(20, 90 + i, 391, 37)) 63 self.okButton.setGeometry(QtCore.QRect(20, 127 + i, 93, 28)) 64 self.resetButton.setGeometry(QtCore.QRect(120, 127 + i, 93, 28)) 65 self.testButton.setGeometry(QtCore.QRect(220, 127 + i, 93, 28)) 66 self.helpButton.setGeometry(QtCore.QRect(320, 127 + i, 93, 28)) 67 self.resize(440, 167 + i) 64 68 i += 30 65 69 … … 91 95 self.sas_open_cl = None 92 96 97 def set_open_cl(self): 98 """ 99 Set openCL value when tests run or OK button clicked 100 """ 101 no_opencl_msg = False 102 if self.sas_open_cl: 103 os.environ["SAS_OPENCL"] = self.sas_open_cl 104 if self.sas_open_cl.lower() == "none": 105 no_opencl_msg = True 106 else: 107 if "SAS_OPENCL" in os.environ: 108 del os.environ["SAS_OPENCL"] 109 # Sasmodels kernelcl doesn't exist when initiated with None 110 if 'sasmodels.kernelcl' in sys.modules: 111 sasmodels.kernelcl.ENV = None 112 reload(sasmodels.core) 113 return no_opencl_msg 114 93 115 def testButtonClicked(self): 94 116 """ 95 Run the model tests when the test button is clicked 96 """ 97 # TODO: Do something 98 pass 117 Run sasmodels check from here and report results from 118 """ 119 120 no_opencl_msg = self.set_open_cl() 121 122 # Only import when tests are run 123 from sasmodels.model_test import model_tests 124 125 try: 126 from sasmodels.kernelcl import environment 127 env = environment() 128 clinfo = [(ctx.devices[0].platform.vendor, 129 ctx.devices[0].platform.version, 130 ctx.devices[0].vendor, 131 ctx.devices[0].name, 132 ctx.devices[0].version) 133 for ctx in env.context] 134 except ImportError: 135 clinfo = None 136 137 failures = [] 138 tests_completed = 0 139 for test in model_tests(): 140 try: 141 test() 142 except Exception: 143 failures.append(test.description) 144 145 tests_completed += 1 146 147 info = { 148 'version': sasmodels.__version__, 149 'platform': platform.uname(), 150 'opencl': clinfo, 151 'failing tests': failures, 152 } 153 154 msg_info = 'OpenCL tests results' 155 156 msg = str(tests_completed) + ' tests completed.\n' 157 if len(failures) > 0: 158 msg += str(len(failures)) + ' tests failed.\n' 159 msg += 'Failing tests: ' 160 msg += json.dumps(info['failing tests']) 161 msg += "\n" 162 else: 163 msg += "All tests passed!\n" 164 165 msg += "\nPlatform Details:\n\n" 166 msg += "Sasmodels version: " 167 msg += info['version'] + "\n" 168 msg += "\nPlatform used: " 169 msg += json.dumps(info['platform']) + "\n" 170 if no_opencl_msg: 171 msg += "\nOpenCL driver: None" 172 else: 173 msg += "\nOpenCL driver: " 174 msg += json.dumps(info['opencl']) + "\n" 175 GPUTestResults(self, msg, msg_info) 99 176 100 177 def helpButtonClicked(self): … … 120 197 Close the window after modifying the SAS_OPENCL value 121 198 """ 122 # If statement added to handle Reset 123 if self.sas_open_cl: 124 os.environ["SAS_OPENCL"] = self.sas_open_cl 125 else: 126 if "SAS_OPENCL" in os.environ: 127 del os.environ["SAS_OPENCL"] 128 129 # Sasmodels kernelcl doesn't exist when initiated with None 130 if 'sasmodels.kernelcl' in sys.modules: 131 sasmodels.kernelcl.ENV = None 132 133 reload(sasmodels.core) 199 self.set_open_cl() 134 200 super(GPUOptions, self).reject() 135 201 … … 140 206 self.close() 141 207 self.parent.gpu_options_widget = GPUOptions(self) 208 209 210 class GPUTestResults(QtGui.QDialog, Ui_GPUTestResults): 211 """ 212 OpenCL Dialog to modify the OpenCL options 213 """ 214 def __init__(self, parent, msg, title): 215 super(GPUTestResults, self).__init__(parent) 216 self.setupUi(self) 217 self.resultsText.setText(_translate("GPUTestResults", msg, None)) 218 self.open() 142 219 143 220 -
src/sas/qtgui/Perspectives/Fitting/UI/GPUOptionsUI.ui
ra6cd8d1 rced1bff 8 8 <y>0</y> 9 9 <width>440</width> 10 <height> 178</height>10 <height>211</height> 11 11 </rect> 12 12 </property> … … 17 17 <property name="geometry"> 18 18 <rect> 19 <x> 220</x>20 <y>1 40</y>19 <x>120</x> 20 <y>170</y> 21 21 <width>93</width> 22 22 <height>28</height> … … 31 31 <rect> 32 32 <x>320</x> 33 <y>1 40</y>33 <y>170</y> 34 34 <width>93</width> 35 35 <height>28</height> … … 59 59 <property name="geometry"> 60 60 <rect> 61 <x> 120</x>62 <y>1 40</y>61 <x>220</x> 62 <y>170</y> 63 63 <width>93</width> 64 64 <height>28</height> … … 73 73 <rect> 74 74 <x>20</x> 75 <y>1 40</y>75 <y>170</y> 76 76 <width>93</width> 77 77 <height>28</height> … … 80 80 <property name="text"> 81 81 <string>OK</string> 82 </property> 83 </widget> 84 <widget class="QLabel" name="label"> 85 <property name="geometry"> 86 <rect> 87 <x>20</x> 88 <y>132</y> 89 <width>391</width> 90 <height>37</height> 91 </rect> 92 </property> 93 <property name="font"> 94 <font> 95 <pointsize>8</pointsize> 96 </font> 97 </property> 98 <property name="text"> 99 <string>WARNING: Running tests can take a few minutes!</string> 100 </property> 101 <property name="alignment"> 102 <set>Qt::AlignCenter</set> 82 103 </property> 83 104 </widget>
Note: See TracChangeset
for help on using the changeset viewer.