Changes in / [b2964ef:fa307dd] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/gpu_options.py
r4688acf r895703d 16 16 import wx 17 17 18 # TODO: move device query functions to sasmodels19 18 try: 20 19 import pyopencl as cl … … 25 24 import sasmodels.model_test 26 25 import sasmodels.sasview_model 27 from sasmodels.generate import F32, F6428 26 29 27 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 30 28 31 29 logger = logging.getLogger(__name__) 30 31 32 32 33 33 class CustomMessageBox(wx.Dialog): … … 76 76 77 77 self.SetAutoLayout(True) 78 self.ShowModal() 79 self.Destroy() 78 80 79 81 … … 142 144 test_btn = wx.Button(self, test_id, 'Test') 143 145 test_btn.SetToolTipString("Test if models compile on the given infrastructure") 144 self.test_btn = test_btn145 146 146 147 self.Bind(wx.EVT_BUTTON, self.on_OK, accept_btn) … … 178 179 :return: 179 180 """ 180 # TODO: Include cuda platforms if available.181 181 clinfo = [] 182 182 platforms = [] … … 257 257 #The same block of code as for OK but it is needed if we want to have 258 258 #active response to Test button 259 260 259 no_opencl_msg = False 261 260 if self.sas_opencl: … … 266 265 if "SAS_OPENCL" in os.environ: 267 266 del os.environ["SAS_OPENCL"] 268 # CRUFT: next version of reset_environment() will return env 269 env = sasmodels.sasview_model.reset_environment() 267 sasmodels.sasview_model.reset_environment() 270 268 271 269 try: 272 270 env = sasmodels.kernelcl.environment() 273 clinfo = {} 274 if env.context[F64] is None: 275 clinfo['double'] = "None" 276 else: 277 ctx64 = env.context[F64].devices[0] 278 clinfo['double'] = ", ".join(( 279 ctx64.platform.vendor, 280 ctx64.platform.version, 281 ctx64.vendor, 282 ctx64.name, 283 ctx64.version)) 284 if env.context[F32] is None: 285 clinfo['single'] = "None" 286 else: 287 ctx32 = env.context[F32].devices[0] 288 clinfo['single'] = ", ".join(( 289 ctx32.platform.vendor, 290 ctx32.platform.version, 291 ctx32.vendor, 292 ctx32.name, 293 ctx32.version)) 294 # If the same device is used for single and double precision, then 295 # say so. Whether double is the same as single or single is the 296 # same as double depends on the order they are listed below. 297 if env.context[F32] == env.context[F64]: 298 clinfo['double'] = "same as single precision" 299 except Exception as exc: 300 logger.debug("exc %s", str(exc)) 301 clinfo = {'double': "None", 'single': "None"} 302 303 msg = "\nPlatform Details:\n\n" 304 msg += "Sasmodels version: " 305 msg += sasmodels.__version__ + "\n" 306 msg += "\nPlatform used: " 307 msg += json.dumps(platform.uname()) + "\n" 308 if no_opencl_msg: 309 msg += "\nOpenCL driver: None\n" 310 else: 311 msg += "\nOpenCL driver:\n" 312 msg += " single precision: " + clinfo['single'] + "\n" 313 msg += " double precision: " + clinfo['double'] + "\n" 314 315 msg_title = 'OpenCL tests results' 316 running = msg + "\nRunning tests. This may take several minutes.\n\n" 317 msg_dialog = CustomMessageBox(self.panel1, running, msg_title) 318 msg_dialog.Show() 271 clinfo = [(ctx.devices[0].platform.vendor, 272 ctx.devices[0].platform.version, 273 ctx.devices[0].vendor, 274 ctx.devices[0].name, 275 ctx.devices[0].version) 276 for ctx in env.context] 277 except Exception: 278 clinfo = None 319 279 320 280 failures = [] 321 281 tests_completed = 0 322 self.test_btn.Disable() 323 tests = sasmodels.model_test.make_suite('opencl', ['all']) 324 for test in tests: 282 for test in sasmodels.model_test.model_tests(): 325 283 try: 326 wx.Yield() 327 test.run_all() 328 msg_dialog.text.AppendText('.') 329 except Exception as exc: 330 logger.debug("%s failed with %s", test.test_name, str(exc)) 331 msg_dialog.text.AppendText('\nFail: ' + test.test_name) 332 failures.append(test.test_name) 284 test() 285 except Exception: 286 failures.append(test.description) 287 333 288 tests_completed += 1 334 # TODO: Put a stop button in CustomDialog and test it here. 335 #if tests_completed > 5: break 336 337 status = 'Failed %d of %d' % (len(failures), tests_completed) 338 msg_dialog.text.AppendText('\n\n' + status + '\n') 339 self.test_btn.Enable() 340 msg_dialog.ShowModal() 341 msg_dialog.Destroy() 289 290 info = { 291 'version': sasmodels.__version__, 292 'platform': platform.uname(), 293 'opencl': clinfo, 294 'failing tests': failures, 295 } 296 297 msg_info = 'OpenCL tests results' 298 299 msg = str(tests_completed)+' tests completed.\n' 300 if len(failures) > 0: 301 msg += str(len(failures))+' tests failed.\n' 302 msg += 'Failing tests: ' 303 msg += json.dumps(info['failing tests']) 304 msg += "\n" 305 else: 306 msg += "All tests passed!\n" 307 308 msg += "\nPlatform Details:\n\n" 309 msg += "Sasmodels version: " 310 msg += info['version']+"\n" 311 msg += "\nPlatform used: " 312 msg += json.dumps(info['platform'])+"\n" 313 if no_opencl_msg: 314 msg += "\nOpenCL driver: None" 315 else: 316 msg += "\nOpenCL driver: " 317 msg += json.dumps(info['opencl'])+"\n" 318 319 CustomMessageBox(self.panel1, msg, msg_info) 342 320 343 321 def on_help(self, event):
Note: See TracChangeset
for help on using the changeset viewer.