Exemplo n.º 1
0
 def test_result_image(self):
     dir_path = tempfile.mkdtemp()
     try:
         image_path = os.path.join(dir_path, 'kmeans.png')
         example_test.run_example('kmeans/kmeans.py', '-m', '1', '--num',
                                  '10', '-o', image_path)
         self.assertTrue(os.path.exists(image_path))
     finally:
         shutil.rmtree(dir_path, ignore_errors=True)
Exemplo n.º 2
0
 def test_output_image(self):
     dir_path = tempfile.mkdtemp()
     try:
         image_path = os.path.join(dir_path, 'gmm.png')
         example_test.run_example('gmm/gmm.py', '--num', '10', '-o',
                                  image_path)
         assert os.path.exists(image_path)
     finally:
         shutil.rmtree(dir_path, ignore_errors=True)
Exemplo n.º 3
0
 def test_custom_kernel(self):
     output = example_test.run_example('kmeans/kmeans.py', '-m', '1',
                                       '--num', '10', '--use-custom-kernel')
     assert re.search(
         r' CPU :  [0-9\.]+ sec\s+GPU :  [0-9\.]+ sec',
         output.decode('utf-8'),
     )
Exemplo n.º 4
0
 def test_packed_matrix(self):
     output = example_test.run_example('custom_struct/packed_matrix.py')
     assert re.match(
         r"Kernel output matches expected value for type 'float'.\r?\n"
         r"Kernel output matches expected value for type 'double'.",
         output.decode('utf-8'),
     )
Exemplo n.º 5
0
 def test_default(self):
     output = example_test.run_example('kmeans/kmeans.py', '-m', '1',
                                       '--num', '10')
     assert re.search(
         r' CPU :  [0-9\.]+ sec\s+GPU :  [0-9\.]+ sec',
         output.decode('utf-8'),
     )
Exemplo n.º 6
0
 def test_custom_kernel(self):
     output = example_test.run_example(
         'kmeans/kmeans.py', '-m', '1', '--num', '10',
         '--use-custom-kernel')
     six.assertRegex(
         self, output.decode('utf-8'),
         r' CPU :  [0-9\.]+ sec\s+GPU :  [0-9\.]+ sec')
Exemplo n.º 7
0
 def test_gmm(self):
     output = example_test.run_example('gmm/gmm.py', '--num', '10')
     six.assertRegex(
         self, output.decode('utf-8'),
         r'Running CPU\.\.\.\s+train_accuracy : [0-9\.]+\s+' +
         r'test_accuracy : [0-9\.]+\s+CPU :  [0-9\.]+ sec\s+' +
         r'Running GPU\.\.\.\s+train_accuracy : [0-9\.]+\s+' +
         r'test_accuracy : [0-9\.]+\s+GPU :  [0-9\.]+ sec')
Exemplo n.º 8
0
 def test_black_scholes(self):
     output = example_test.run_example('finance/black_scholes.py',
                                       '--n-options', '10')
     six.assertRegex(
         self, output.decode('utf-8'),
         r'initializing...\n' + r'start computation\n' +
         r' CPU \(NumPy, Naive implementation\):\t[0-9\.]+ sec\n' +
         r' GPU \(CuPy, Naive implementation\):\t[0-9\.]+ sec\n' +
         r' GPU \(CuPy, Elementwise kernel\):\t[0-9\.]+ sec')
Exemplo n.º 9
0
 def test_black_scholes(self):
     output = example_test.run_example('finance/black_scholes.py',
                                       '--n-options', '10')
     pattern = _normalize_regexp_eol(
         r'initializing...\n' + r'start computation\n' +
         r' CPU \(NumPy, Naive implementation\):\t[0-9\.]+ sec\n' +
         r' GPU \(CuPy, Naive implementation\):\t[0-9\.]+ sec\n' +
         r' GPU \(CuPy, Elementwise kernel\):\t[0-9\.]+ sec')
     assert re.search(pattern, output.decode('utf-8'))
Exemplo n.º 10
0
 def test_monte_carlo_multigpu(self):
     output = example_test.run_example('finance/monte_carlo_multigpu.py',
                                       '--gpus', '0', '1', '--n-options',
                                       '10', '--n-samples-per-thread', '10',
                                       '--n-threads-per-option', '10')
     six.assertRegex(
         self, output.decode('utf-8'), r'initializing...\n' +
         r'start computation\n' + r'    # of gpus: 2\n' +
         r'    # of options: 10\n' + r'    # of samples per option: 200\n' +
         r'GPU \(CuPy, Monte Carlo method\):\t[0-9\.]+ sec\n' +
         r'Error: [0-9\.]+')
Exemplo n.º 11
0
 def test_monte_carlo(self):
     output = example_test.run_example('finance/monte_carlo.py',
                                       '--n-options', '10',
                                       '--n-samples-per-thread', '10',
                                       '--n-threads-per-option', '10')
     pattern = _normalize_regexp_eol(
         r'initializing...\n' + r'start computation\n' +
         r'    # of options: 10\n' + r'    # of samples per option: 100\n' +
         r'GPU \(CuPy, Monte Carlo method\):\t[0-9\.]+ sec\n' +
         r'Error: [0-9\.]+')
     self.assertRegex(output.decode('utf-8'), pattern)
Exemplo n.º 12
0
 def test_complex_struct(self):
     output = example_test.run_example('custom_struct/complex_struct.py')
     assert re.match(
         r"Overall structure itemsize: \d+ bytes\r?\n"
         r"Structure members itemsize: \[(\s*\d+){5}]\r?\n"
         r"Structure members offsets: \[(\s*\d+){5}]\r?\n"
         r"Complex structure value:\r?\n"
         r"\s+\[.*\]\r?\n"
         r"Kernel output matches expected value.",
         output.decode('utf-8'),
     )
Exemplo n.º 13
0
 def test_default(self):
     output = example_test.run_example('kmeans/kmeans.py', '-m', '1',
                                       '--num', '10')
     self.assertRegex(output.decode('utf-8'),
                      r' CPU :  [0-9\.]+ sec\s+GPU :  [0-9\.]+ sec')
Exemplo n.º 14
0
 def test_builtin_vectors(self):
     output = example_test.run_example('custom_struct/builtin_vectors.py')
     assert re.match(
         r"Kernel output matches expected value.",
         output.decode('utf-8'),
     )
Exemplo n.º 15
0
 def test_sgemm(self):
     example_test.run_example('gemm/sgemm.py')