generate_automake_test_programs.py 1.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#!/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",
}
gpu_flag = {
        0 : "-DTEST_GPU=0",
        1 : "-DTEST_GPU=1",
}

for g, p, d, s in product(sorted(gpu_flag.keys()),
                          sorted(prec_flag.keys()),
                          sorted(domain_flag.keys()),
                          sorted(solver_flag.keys())):
    endifs = 0
    extra_flags = []
    if (g == 1):
29
        print("if WITH_GPU_VERSION")
30 31 32
        endifs += 1
        if s == "2stage":
            extra_flags.append("-DTEST_KERNEL=ELPA_2STAGE_{0}_GPU".format(d.upper()))
33 34
    elif s == "2stage":
        extra_flags.append("-DTEST_ALL_KERNELS")
35 36 37

    if (p == "single"):
        if (d == "real"):
38
            print("if WANT_SINGLE_PRECISION_REAL")
39
        elif (d == "complex"):
40
            print("if WANT_SINGLE_PRECISION_COMPLEX")
41 42 43 44 45
        else:
            raise Exception("Oh no!")
        endifs += 1

    name = "test_{0}_{1}_{2}{3}".format(d, p, s, "_gpu" if g else "")
46 47 48
    print("noinst_PROGRAMS += " + name)
    print("check_SCRIPTS += " + name + ".sh")
    print(name + "_SOURCES = test/Fortran/test.F90")
49
    print(name + "_LDADD = $(build_lib)")
50
    print(name + "_FCFLAGS = $(AM_FCFLAGS) $(FC_MODINC)test_modules $(FC_MODINC)modules \\")
51 52 53 54
    print("  " + " \\\n  ".join([
        domain_flag[d],
        prec_flag[p],
        solver_flag[s],
55
        gpu_flag[g]] + extra_flags))
56

57
    print("endif\n" * endifs)