Changeset ced1bff in sasview for src/sas/qtgui/Perspectives/Fitting/GPUOptions.py
- 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
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.