generate_automake_test_programs.py 6.07 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
31
matrix_flag = {
        "random" : "-DTEST_MATRIX_RANDOM",
        "analytic" : "-DTEST_MATRIX_ANALYTIC",
}
32

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

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

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

Andreas Marek's avatar
Andreas Marek committed
57
58
59
60
61
    if (lang == "C"):
        continue
    if (lang == "C" and ( m == "analytic" or l == "all_layouts")):
        continue

Pavel Kus's avatar
Pavel Kus committed
62
    if(m == "analytic" and (g == 1 or t != "eigenvectors")):
Pavel Kus's avatar
Pavel Kus committed
63
64
        continue

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

68
    if (t == "solve_tridiagonal" and (s == "2stage" or d == "complex")):
69
70
        continue

71
72
73
    if (t == "cholesky" and (s == "2stage")):
        continue

74
75
76
    if (t == "hermitian_multiply" and (s == "2stage")):
        continue

77
78
79
    if (t == "qr" and (s == "1stage" or d == "complex")):
        continue

80
81
82
    for kernel in ["all_kernels", "default_kernel"] if s == "2stage" else ["nokernel"]:
        endifs = 0
        extra_flags = []
83
84
85
86

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

87
88
89
        if (g == 1):
            print("if WITH_GPU_VERSION")
            endifs += 1
90

91
92
93
94
        if (l == "all_layouts"):
            print("if WITH_MPI")
            endifs += 1

95
        if (s in ["scalapack_all", "scalapack_part"]):
96
97
98
            print("if WITH_SCALAPACK_TESTS")
            endifs += 1

99
100
101
102
        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")
103

104
105
106
        if layout_flag[l]:
            extra_flags.append(layout_flag[l])

107
108
109
110
111
112
113
114
115
        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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
        if (lang == "Fortran"):

            name = "test_{0}_{1}_{2}_{3}{4}{5}{6}{7}".format(
                        d, p, t, s,
                        "" if kernel == "nokernel" else "_" + kernel,
                        "_gpu" if g else "",
                        "_analytic" if m == "analytic" else "",
                        "_all_layouts" if l == "all_layouts" else "")
            print("noinst_PROGRAMS += " + name)
            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],
                matrix_flag[m]] + extra_flags))

            print("endif\n" * endifs)

        if (lang == "C"):

            name = "test_c_version_{0}_{1}_{2}_{3}{4}{5}{6}{7}".format(
                        d, p, t, s,
                        "" if kernel == "nokernel" else "_" + kernel,
                        "_gpu" if g else "",
                        "_analytic" if m == "analytic" else "",
                        "_all_layouts" if l == "all_layouts" else "")
            print("noinst_PROGRAMS += " + name)
            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],
                matrix_flag[m]] + extra_flags))

            print("endif\n" * endifs)
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177

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)
178
179
    #if (p != "single"):
    #    print("check_SCRIPTS += " + name + ".sh")
180
181
182
183
184
185
186
187
    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)