generate_automake_test_programs.py 4.93 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env python
from __future__ import print_function
from itertools import product

domain_flag = {
        "real"   : "-DTEST_REAL",
        "complex": "-DTEST_COMPLEX",
}
prec_flag = {
        "double" : "-DTEST_DOUBLE",
        "single" : "-DTEST_SINGLE",
}
solver_flag = {
        "1stage" : "-DTEST_SOLVER_1STAGE",
        "2stage" : "-DTEST_SOLVER_2STAGE",
Pavel Kus's avatar
Pavel Kus committed
16
        "scalapack_all" : "-DTEST_SCALAPACK_ALL",
17
        "scalapack_part" : "-DTEST_SCALAPACK_PART",
18
19
20
21
22
}
gpu_flag = {
        0 : "-DTEST_GPU=0",
        1 : "-DTEST_GPU=1",
}
Pavel Kus's avatar
Pavel Kus committed
23
24
25
matrix_flag = {
        "random" : "-DTEST_MATRIX_RANDOM",
        "analytic" : "-DTEST_MATRIX_ANALYTIC",
Andreas Marek's avatar
Andreas Marek committed
26
27
28
29
30
31
32
        "toeplitz" : "-DTEST_MATRIX_TOEPLITZ",
        "frank" : "-DTEST_MATRIX_FRANK",
}

qr_flag = {
        0 : "-DTEST_QR_DECOMPOSITION=0",
        1 : "-DTEST_QR_DECOMPOSITION=1",
Pavel Kus's avatar
Pavel Kus committed
33
}
34

35
test_type_flag = {
36
37
38
        "eigenvectors" : "-DTEST_EIGENVECTORS",
        "eigenvalues"  : "-DTEST_EIGENVALUES",
        "solve_tridiagonal"  : "-DTEST_SOLVE_TRIDIAGONAL",
39
        "cholesky"  : "-DTEST_CHOLESKY",
40
        "hermitian_multiply"  : "-DTEST_HERMITIAN_MULTIPLY",
41
42
}

43
44
45
46
47
layout_flag = {
        "all_layouts" : "-DTEST_ALL_LAYOUTS",
        "square" : ""
}

Andreas Marek's avatar
Andreas Marek committed
48
for m, g, q, t, p, d, s, l in product(
49
                             sorted(matrix_flag.keys()),
Pavel Kus's avatar
Pavel Kus committed
50
                             sorted(gpu_flag.keys()),
Andreas Marek's avatar
Andreas Marek committed
51
                             sorted(qr_flag.keys()),
52
53
54
                             sorted(test_type_flag.keys()),
                             sorted(prec_flag.keys()),
                             sorted(domain_flag.keys()),
55
56
                             sorted(solver_flag.keys()),
                             sorted(layout_flag.keys())):
57

Andreas Marek's avatar
Andreas Marek committed
58
59
60
    # exclude some test combinations

    # analytic tests only for "eigenvectors" and not on GPU
Pavel Kus's avatar
Pavel Kus committed
61
    if(m == "analytic" and (g == 1 or t != "eigenvectors")):
Pavel Kus's avatar
Pavel Kus committed
62
63
        continue

Andreas Marek's avatar
Andreas Marek committed
64
65
66
67
    # Frank tests only for "eigenvectors" and eigenvalues and real double precision case
    if(m == "frank" and ((t != "eigenvectors"  or t != "eigenvalues") and (d !="real" or p !="double"))):
        continue

68
    if(s in ["scalapack_all", "scalapack_part"]  and (g == 1 or t != "eigenvectors" or m != "analytic")):
Pavel Kus's avatar
Pavel Kus committed
69
70
        continue

Andreas Marek's avatar
Andreas Marek committed
71
72
    # solve tridiagonal only for real toeplitz matrix in 1stage
    if (t == "solve_tridiagonal" and (s != "1stage" or d !="real" or m != "toeplitz")):
73
74
        continue

Andreas Marek's avatar
Andreas Marek committed
75
76
77
78
79
80

    # cholesky tests only 1stage and teoplitz matrix
    if (t == "cholesky" and (m != "toeplitz" or s == "2stage")):
        continue

    if (t == "eigenvalues" and (m == "random")):
81
82
        continue

83
84
85
    if (t == "hermitian_multiply" and (s == "2stage")):
        continue

Andreas Marek's avatar
Andreas Marek committed
86
87
88
89
90
    if (t == "hermitian_multiply" and (m == "toeplitz")):
        continue

    # qr only for 2stage real
    if (q == 1 and (s != "2stage" or d != "real" or t != "eigenvectors" or g == 1 or m != "random")):
91
92
        continue

93
94
95
    for kernel in ["all_kernels", "default_kernel"] if s == "2stage" else ["nokernel"]:
        endifs = 0
        extra_flags = []
96
97
98
99

        if (t == "eigenvalues" and kernel == "all_kernels"):
           continue

100
101
102
        if (g == 1):
            print("if WITH_GPU_VERSION")
            endifs += 1
103

104
105
106
107
        if (l == "all_layouts"):
            print("if WITH_MPI")
            endifs += 1

108
        if (s in ["scalapack_all", "scalapack_part"]):
109
110
111
            print("if WITH_SCALAPACK_TESTS")
            endifs += 1

112
113
114
115
        if kernel == "default_kernel":
            extra_flags.append("-DTEST_KERNEL=ELPA_2STAGE_{0}_DEFAULT".format(d.upper()))
        elif kernel == "all_kernels":
            extra_flags.append("-DTEST_ALL_KERNELS")
116

117
118
119
        if layout_flag[l]:
            extra_flags.append(layout_flag[l])

120
121
122
123
124
125
126
127
128
        if (p == "single"):
            if (d == "real"):
                print("if WANT_SINGLE_PRECISION_REAL")
            elif (d == "complex"):
                print("if WANT_SINGLE_PRECISION_COMPLEX")
            else:
                raise Exception("Oh no!")
            endifs += 1

Andreas Marek's avatar
Andreas Marek committed
129
        name = "test_{0}_{1}_{2}_{3}{4}_{5}{6}{7}{8}".format(
130
131
                    d, p, t, s,
                    "" if kernel == "nokernel" else "_" + kernel,
Andreas Marek's avatar
Andreas Marek committed
132
133
134
                    "gpu_" if g else "",
                    "qr_" if q else "",
                    m,
135
                    "_all_layouts" if l == "all_layouts" else "")
Andreas Marek's avatar
Andreas Marek committed
136
137
138
        print("if BUILD_KCOMPUTER")
        print("bin_PROGRAMS += " + name)
        print("else")
139
        print("noinst_PROGRAMS += " + name)
Andreas Marek's avatar
Andreas Marek committed
140
        print("endif")
141
142
        print("check_SCRIPTS += " + name + ".sh")
        print(name + "_SOURCES = test/Fortran/test.F90")
143
144
        print(name + "_LDADD = $(test_program_ldadd)")
        print(name + "_FCFLAGS = $(test_program_fcflags) \\")
145
        print("  -DTEST_CASE=\\\"{0}\\\" \\".format(name))
146
147
148
        print("  " + " \\\n  ".join([
            domain_flag[d],
            prec_flag[p],
149
            test_type_flag[t],
150
            solver_flag[s],
Pavel Kus's avatar
Pavel Kus committed
151
            gpu_flag[g],
Andreas Marek's avatar
Andreas Marek committed
152
            qr_flag[q],
Pavel Kus's avatar
Pavel Kus committed
153
            matrix_flag[m]] + extra_flags))
154
155

        print("endif\n" * endifs)