Changes in / [259b116:aee8dfb] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/model_test.py
r00afc15 r00afc15 45 45 from __future__ import print_function 46 46 47 import argparse 47 48 import sys 48 49 import unittest … … 474 475 475 476 476 def main( *models):477 def main(): 477 478 # type: (*str) -> int 478 479 """ … … 488 489 test_args = {} 489 490 490 if models and models[0] == '-v': 491 verbosity = 2 492 models = models[1:] 493 else: 494 verbosity = 1 495 if models and models[0] == 'opencl': 491 parser = argparse.ArgumentParser(description="Test SasModels Models") 492 parser.add_argument("-v", "--verbose", action="store_const", 493 default=1, const=2, help="Use verbose output") 494 parser.add_argument("engine", metavar="[engine]", 495 help="Engines on which to run the test. " 496 "Valid values are opencl, dll, and opencl_and_dll. " 497 "Defaults to opencl_and_dll if no value is given") 498 parser.add_argument("models", nargs="*", 499 help='The names of the models to be tested. ' 500 'If the first model is "all", then all except the ' 501 'remaining models will be tested.') 502 args, models = parser.parse_known_args() 503 504 if args.engine == "opencl": 496 505 if not use_opencl(): 497 506 print("opencl is not available") 498 507 return 1 499 508 loaders = ['opencl'] 500 models = models[1:] 501 elif models and models[0] == 'cuda': 509 elif args.engine == "dll": 510 loaders = ["dll"] 511 elif args.engine == "cuda": 502 512 if not use_cuda(): 503 513 print("cuda is not available") 504 514 return 1 505 515 loaders = ['cuda'] 506 models = models[1:]507 elif models and models[0] == 'dll':508 # TODO: test if compiler is available?509 loaders = ['dll']510 models = models[1:]511 516 else: 517 # Default to running both engines 512 518 loaders = ['dll'] 513 519 if use_opencl(): … … 515 521 if use_cuda(): 516 522 loaders.append('cuda') 517 if not models: 518 print("""\ 519 usage: 520 python -m sasmodels.model_test [-v] [opencl|cuda|dll] model1 model2 ... 521 522 If -v is included on the command line, then use verbose output. 523 524 If no platform is specified, then models will be tested with dll, and 525 if available, OpenCL and CUDA; the compute target is ignored for pure python models. 526 527 If model1 is 'all', then all except the remaining models will be tested. 528 529 """) 530 531 return 1 532 533 runner = TestRunner(verbosity=verbosity, **test_args) 534 result = runner.run(make_suite(loaders, models)) 523 args.models.insert(0, args.engine) 524 525 runner = TestRunner(verbosity=args.verbose, **test_args) 526 result = runner.run(make_suite(loaders, args.models)) 535 527 return 1 if result.failures or result.errors else 0 536 528 … … 571 563 572 564 if __name__ == "__main__": 573 sys.exit(main( *sys.argv[1:]))565 sys.exit(main())
Note: See TracChangeset
for help on using the changeset viewer.