generate_automake_test_programs.py 4.68 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 26
matrix_flag = {
        "random" : "-DTEST_MATRIX_RANDOM",
        "analytic" : "-DTEST_MATRIX_ANALYTIC",
}
27

28
test_type_flag = {
29 30 31
        "eigenvectors" : "-DTEST_EIGENVECTORS",
        "eigenvalues"  : "-DTEST_EIGENVALUES",
        "solve_tridiagonal"  : "-DTEST_SOLVE_TRIDIAGONAL",
32
        "cholesky"  : "-DTEST_CHOLESKY",
33
        "hermitian_multiply"  : "-DTEST_HERMITIAN_MULTIPLY",
34
        "qr"  : "-DTEST_QR_DECOMPOSITION",
35 36
}

37 38 39 40 41 42 43
layout_flag = {
        "all_layouts" : "-DTEST_ALL_LAYOUTS",
        "square" : ""
}

for m, g, t, p, d, s, l in product(
                             sorted(matrix_flag.keys()),
Pavel Kus's avatar
Pavel Kus committed
44
                             sorted(gpu_flag.keys()),
45 46 47
                             sorted(test_type_flag.keys()),
                             sorted(prec_flag.keys()),
                             sorted(domain_flag.keys()),
48 49
                             sorted(solver_flag.keys()),
                             sorted(layout_flag.keys())):
50

Pavel Kus's avatar
Pavel Kus committed
51
    if(m == "analytic" and (g == 1 or t != "eigenvectors")):
Pavel Kus's avatar
Pavel Kus committed
52 53
        continue

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

57
    if (t == "solve_tridiagonal" and (s == "2stage" or d == "complex")):
58 59
        continue

60 61 62
    if (t == "cholesky" and (s == "2stage")):
        continue

63 64 65
    if (t == "hermitian_multiply" and (s == "2stage")):
        continue

66 67 68
    if (t == "qr" and (s == "1stage" or d == "complex")):
        continue

69 70 71
    for kernel in ["all_kernels", "default_kernel"] if s == "2stage" else ["nokernel"]:
        endifs = 0
        extra_flags = []
72 73 74 75

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

76 77 78
        if (g == 1):
            print("if WITH_GPU_VERSION")
            endifs += 1
79

80 81 82 83
        if (l == "all_layouts"):
            print("if WITH_MPI")
            endifs += 1

84
        if (s in ["scalapack_all", "scalapack_part"]):
85 86 87
            print("if WITH_SCALAPACK_TESTS")
            endifs += 1

88 89 90 91
        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")
92

93 94 95
        if layout_flag[l]:
            extra_flags.append(layout_flag[l])

96 97 98 99 100 101 102 103 104
        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

105 106 107 108 109 110
        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 "")
111 112 113
        print("noinst_PROGRAMS += " + name)
        print("check_SCRIPTS += " + name + ".sh")
        print(name + "_SOURCES = test/Fortran/test.F90")
114 115
        print(name + "_LDADD = $(test_program_ldadd)")
        print(name + "_FCFLAGS = $(test_program_fcflags) \\")
116
        print("  -DTEST_CASE=\\\"{0}\\\" \\".format(name))
117 118 119
        print("  " + " \\\n  ".join([
            domain_flag[d],
            prec_flag[p],
120
            test_type_flag[t],
121
            solver_flag[s],
Pavel Kus's avatar
Pavel Kus committed
122 123
            gpu_flag[g],
            matrix_flag[m]] + extra_flags))
124 125

        print("endif\n" * endifs)
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


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)
    print("check_SCRIPTS += " + name + ".sh")
    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)