generate_automake_test_programs.py 7.28 KB
Newer Older
1
2
3
4
#!/usr/bin/env python
from __future__ import print_function
from itertools import product

Andreas Marek's avatar
Andreas Marek committed
5
6
7
8
9
language_flag = { 
        "Fortran" : "Fortran",
        "C" : "C",
}

10
11
12
13
14
15
16
17
18
19
20
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
21
        "scalapack_all" : "-DTEST_SCALAPACK_ALL",
22
        "scalapack_part" : "-DTEST_SCALAPACK_PART",
23
24
25
26
27
}
gpu_flag = {
        0 : "-DTEST_GPU=0",
        1 : "-DTEST_GPU=1",
}
Pavel Kus's avatar
Pavel Kus committed
28
29
30
matrix_flag = {
        "random" : "-DTEST_MATRIX_RANDOM",
        "analytic" : "-DTEST_MATRIX_ANALYTIC",
Andreas Marek's avatar
Andreas Marek committed
31
32
33
34
35
36
37
        "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
38
}
39

40
test_type_flag = {
41
42
43
        "eigenvectors" : "-DTEST_EIGENVECTORS",
        "eigenvalues"  : "-DTEST_EIGENVALUES",
        "solve_tridiagonal"  : "-DTEST_SOLVE_TRIDIAGONAL",
44
        "cholesky"  : "-DTEST_CHOLESKY",
45
        "hermitian_multiply"  : "-DTEST_HERMITIAN_MULTIPLY",
46
47
}

48
49
50
51
52
layout_flag = {
        "all_layouts" : "-DTEST_ALL_LAYOUTS",
        "square" : ""
}

53
for lang, m, g, q, t, p, d, s, l in product(
Andreas Marek's avatar
Andreas Marek committed
54
                             sorted(language_flag.keys()),
55
                             sorted(matrix_flag.keys()),
Pavel Kus's avatar
Pavel Kus committed
56
                             sorted(gpu_flag.keys()),
Andreas Marek's avatar
Andreas Marek committed
57
                             sorted(qr_flag.keys()),
58
59
60
                             sorted(test_type_flag.keys()),
                             sorted(prec_flag.keys()),
                             sorted(domain_flag.keys()),
61
62
                             sorted(solver_flag.keys()),
                             sorted(layout_flag.keys())):
63

Andreas Marek's avatar
Andreas Marek committed
64
65
66
67
68
    if (lang == "C"):
        continue
    if (lang == "C" and ( m == "analytic" or l == "all_layouts")):
        continue

Andreas Marek's avatar
Andreas Marek committed
69
70
71
    # exclude some test combinations

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

Andreas Marek's avatar
Andreas Marek committed
75
76
77
78
    # 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

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

Andreas Marek's avatar
Andreas Marek committed
82
83
    # solve tridiagonal only for real toeplitz matrix in 1stage
    if (t == "solve_tridiagonal" and (s != "1stage" or d !="real" or m != "toeplitz")):
84
85
        continue

Andreas Marek's avatar
Andreas Marek committed
86
87
88
89
90
91

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

    if (t == "eigenvalues" and (m == "random")):
92
93
        continue

94
95
96
    if (t == "hermitian_multiply" and (s == "2stage")):
        continue

Andreas Marek's avatar
Andreas Marek committed
97
98
99
100
101
    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")):
102
103
        continue

104
105
106
    for kernel in ["all_kernels", "default_kernel"] if s == "2stage" else ["nokernel"]:
        endifs = 0
        extra_flags = []
107
108
109
110

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

111
112
113
        if (g == 1):
            print("if WITH_GPU_VERSION")
            endifs += 1
114

115
116
117
118
        if (l == "all_layouts"):
            print("if WITH_MPI")
            endifs += 1

119
        if (s in ["scalapack_all", "scalapack_part"]):
120
121
122
            print("if WITH_SCALAPACK_TESTS")
            endifs += 1

123
124
125
126
        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")
127

128
129
130
        if layout_flag[l]:
            extra_flags.append(layout_flag[l])

131
132
133
134
135
136
137
138
139
        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
140
141
        if (lang == "Fortran"):

142
            name = "test_{0}_{1}_{2}_{3}{4}_{5}{6}{7}{8}".format(
Andreas Marek's avatar
Andreas Marek committed
143
144
                        d, p, t, s,
                        "" if kernel == "nokernel" else "_" + kernel,
145
146
147
                        "gpu_" if g else "",
                        "qr_" if q else "",
                        m,
Andreas Marek's avatar
Andreas Marek committed
148
                        "_all_layouts" if l == "all_layouts" else "")
149
150
151
            print("if BUILD_KCOMPUTER")
            print("bin_PROGRAMS += " + name)
            print("else")
Andreas Marek's avatar
Andreas Marek committed
152
            print("noinst_PROGRAMS += " + name)
153
            print("endif")
Andreas Marek's avatar
Andreas Marek committed
154
155
156
157
158
159
160
161
162
163
164
            print("check_SCRIPTS += " + name + ".sh")
            print(name + "_SOURCES = test/Fortran/test.F90")
            print(name + "_LDADD = $(test_program_ldadd)")
            print(name + "_FCFLAGS = $(test_program_fcflags) \\")
            print("  -DTEST_CASE=\\\"{0}\\\" \\".format(name))
            print("  " + " \\\n  ".join([
                domain_flag[d],
                prec_flag[p],
                test_type_flag[t],
                solver_flag[s],
                gpu_flag[g],
165
                qr_flag[q],
Andreas Marek's avatar
Andreas Marek committed
166
167
168
169
170
171
                matrix_flag[m]] + extra_flags))

            print("endif\n" * endifs)

        if (lang == "C"):

172
            name = "test_c_version_{0}_{1}_{2}_{3}{4}_{5}{6}{7}{8}".format(
Andreas Marek's avatar
Andreas Marek committed
173
174
                        d, p, t, s,
                        "" if kernel == "nokernel" else "_" + kernel,
175
176
177
                        "gpu_" if g else "",
                        "qr_" if q else "",
                        m,
Andreas Marek's avatar
Andreas Marek committed
178
                        "_all_layouts" if l == "all_layouts" else "")
179
180
181
            print("if BUILD_KCOMPUTER")
            print("bin_PROGRAMS += " + name)
            print("else")
Andreas Marek's avatar
Andreas Marek committed
182
            print("noinst_PROGRAMS += " + name)
183
            print("endif")
Andreas Marek's avatar
Andreas Marek committed
184
185
186
187
188
189
190
191
192
193
194
            print("check_SCRIPTS += " + name + ".sh")
            print(name + "_SOURCES = test/C/test.c")
            print(name + "_LDADD = $(test_program_ldadd) $(FCLIBS)")
            print(name + "_CFLAGS = $(test_program_fcflags) \\")
            print("  -DTEST_CASE=\\\"{0}\\\" \\".format(name))
            print("  " + " \\\n  ".join([
                domain_flag[d],
                prec_flag[p],
                test_type_flag[t],
                solver_flag[s],
                gpu_flag[g],
195
                qr_flag[q],
Andreas Marek's avatar
Andreas Marek committed
196
197
198
                matrix_flag[m]] + extra_flags))

            print("endif\n" * endifs)
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213

for p, d in product(sorted(prec_flag.keys()), sorted(domain_flag.keys())):
    endifs = 0
    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

    name = "test_autotune_{0}_{1}".format(d, p)

    print("noinst_PROGRAMS += " + name)
214
215
    #if (p != "single"):
    #    print("check_SCRIPTS += " + name + ".sh")
216
217
218
219
220
221
222
    print(name + "_SOURCES = test/Fortran/test_autotune.F90")
    print(name + "_LDADD = $(test_program_ldadd)")
    print(name + "_FCFLAGS = $(test_program_fcflags) \\")
    print("  " + " \\\n  ".join([
            domain_flag[d],
            prec_flag[p]]))
    print("endif\n" * endifs)