|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 | import test_framework |
| 3 | +import json |
| 4 | + |
| 5 | +stencil_input = [{"operator": {"stencil": {"name": "7pt", "size": 100}}, |
| 6 | + "preconditioner": {"type": "matrix::Identity"}, |
| 7 | + "format": "csr"}] |
3 | 8 |
|
4 | 9 | # check that all input modes work: |
5 | 10 | # parameter |
6 | 11 | test_framework.compare_output( |
7 | | - ["-input", '[{"size": 100, "stencil": "7pt"}]'], |
| 12 | + ["-input", json.dumps(stencil_input)], |
8 | 13 | expected_stdout="preconditioner.simple.stdout", |
9 | 14 | expected_stderr="preconditioner.simple.stderr", |
10 | 15 | ) |
|
14 | 19 | [], |
15 | 20 | expected_stdout="preconditioner.simple.stdout", |
16 | 21 | expected_stderr="preconditioner.simple.stderr", |
17 | | - stdin='[{"size": 100, "stencil": "7pt"}]', |
| 22 | + stdin=json.dumps(stencil_input), |
18 | 23 | ) |
19 | 24 |
|
20 | 25 | # input file |
21 | 26 | test_framework.compare_output( |
22 | | - ["-input", str(test_framework.sourcepath / "input.mtx.json")], |
| 27 | + ["-input", str(test_framework.sourcepath / "input.preconditioner.json")], |
23 | 28 | expected_stdout="preconditioner.simple.stdout", |
24 | 29 | expected_stderr="preconditioner.simple.stderr", |
25 | 30 | ) |
26 | 31 |
|
27 | | -# input matrix file |
28 | | -test_framework.compare_output( |
29 | | - ["-input_matrix", str(test_framework.matrixpath)], |
30 | | - expected_stdout="preconditioner.matrix.stdout", |
31 | | - expected_stderr="preconditioner.matrix.stderr", |
32 | | -) |
33 | | - |
34 | 32 | # set preconditioner works |
| 33 | +precond_config = [stencil_input[0] | { |
| 34 | + "preconditioner": {"type": "preconditioner::Jacobi", "max_block_size": 32, "storage_optimization": [0, 0]}}] |
35 | 35 | test_framework.compare_output( |
36 | 36 | [ |
37 | | - "-preconditioners", |
38 | | - "jacobi", |
39 | | - "-jacobi_max_block_size", |
40 | | - "32", |
41 | | - "-jacobi_storage", |
42 | | - "0,0", |
43 | 37 | "-input", |
44 | | - '[{"size": 100, "stencil": "7pt"}]'], |
| 38 | + json.dumps(precond_config)], |
45 | 39 | expected_stdout="preconditioner.precond.stdout", |
46 | 40 | expected_stderr="preconditioner.precond.stderr", |
47 | 41 | ) |
|
50 | 44 | test_framework.compare_output( |
51 | 45 | [ |
52 | 46 | "-input", |
53 | | - '[{"size": 100, "stencil": "7pt"}]', |
| 47 | + json.dumps(stencil_input), |
54 | 48 | "-profile", |
55 | 49 | "-profiler_hook", |
56 | 50 | "debug", |
|
61 | 55 |
|
62 | 56 | # stdin |
63 | 57 | test_framework.compare_output( |
64 | | - ["-reorder", "amd"], |
| 58 | + [], |
65 | 59 | expected_stdout="preconditioner.reordered.stdout", |
66 | 60 | expected_stderr="preconditioner.reordered.stderr", |
67 | | - stdin='[{"size": 100, "stencil": "7pt"}]', |
| 61 | + stdin=json.dumps([stencil_input[0] | {"reorder": "amd"}]), |
68 | 62 | ) |
69 | 63 |
|
70 | 64 | # complex |
71 | 65 | test_framework.compare_output( |
72 | | - ["-input", '[{"size": 100, "stencil": "7pt"}]'], |
| 66 | + ["-input", json.dumps(stencil_input)], |
73 | 67 | expected_stdout="preconditioner_dcomplex.simple.stdout", |
74 | 68 | expected_stderr="preconditioner_dcomplex.simple.stderr", |
75 | 69 | use_complex=True |
|
0 commit comments