def parse_args_all_schemes(feature_str): _parser = OptionParser() _parser.add_option( '--scheme', '-s', action='callback', type='choice', choices=('cpu', 'cuda'), default='cpu', dest='scheme', callback=_check_scheme_all, help='specifies processing scheme, can be cpu [default], cuda') _parser.add_option( '--device-num', '-d', action='store', type='int', dest='devicenum', default=0, help='specifies a GPU device to use for CUDA, 0 by default') (_opt_list, _args) = _parser.parse_args() # Changing the optvalues to a dict makes them easier to read _options = vars(_opt_list) _scheme = _options['scheme'] if _scheme == 'cpu': _context = CPUScheme() if _scheme == 'cuda': _context = CUDAScheme(device_num=_options['devicenum']) _scheme_dict = {'cpu': 'CPU', 'cuda': 'CUDA'} print(72 * '=') print("Running {0} unit tests for {1}:".format(_scheme_dict[_scheme], feature_str)) return [_scheme, _context]
print("MKL not supported on arm64, skipping") pass elif not 'mkl' in pycbc.fft.get_backend_names(): print("MKL does not seem to be available; why isn't it installed?") _exit(0) else: # Now set the number of threads to something nontrivial # Most of the work is now done in fft_base. FFTTestClasses = [] for num_threads in [2, 4, 6, 8]: kdict = { 'backends': ['mkl'], 'scheme': 'cpu', 'context': CPUScheme(num_threads=num_threads) } klass = type('FFTW_OpenMP_test', (_BaseTestFFTClass, ), kdict) klass.__test__ = True FFTTestClasses.append(klass) # Finally, we create suites and run them if __name__ == '__main__': suite = unittest.TestSuite() for klass in FFTTestClasses: suite.addTest(unittest.TestLoader().loadTestsFromTestCase(klass)) results = unittest.TextTestRunner(verbosity=2).run(suite) simple_exit(results)