generate_automake_test_programs.py 2.22 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/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",
}

22 23 24 25 26 27 28 29 30 31 32
test_type_flag = {
        "eigenvectors" : "-D__EIGENVECTORS",
        "eigenvalues"  : "-D__EIGENVALUES",
        "solve_tridiagonal"  : "-D__SOLVE_TRIDIAGONAL",
}

for g, t, p, d, s in product(sorted(gpu_flag.keys()),
                             sorted(test_type_flag.keys()),
                             sorted(prec_flag.keys()),
                             sorted(domain_flag.keys()),
                             sorted(solver_flag.keys())):
33

34 35 36 37 38 39
    for kernel in ["all_kernels", "default_kernel"] if s == "2stage" else ["nokernel"]:
        endifs = 0
        extra_flags = []
        if (g == 1):
            print("if WITH_GPU_VERSION")
            endifs += 1
40

41 42 43 44
        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")
45

46 47 48 49 50 51 52 53 54
        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

55
        name = "test_{0}_{1}_{2}_{3}{4}{5}".format(d, p, t, s, "" if kernel == "nokernel" else "_" + kernel, "_gpu" if g else "")
56 57 58 59 60 61 62 63
        print("noinst_PROGRAMS += " + name)
        print("check_SCRIPTS += " + name + ".sh")
        print(name + "_SOURCES = test/Fortran/test.F90")
        print(name + "_LDADD = $(build_lib)")
        print(name + "_FCFLAGS = $(AM_FCFLAGS) $(FC_MODINC)test_modules $(FC_MODINC)modules \\")
        print("  " + " \\\n  ".join([
            domain_flag[d],
            prec_flag[p],
64
            test_type_flag[t],
65 66 67 68
            solver_flag[s],
            gpu_flag[g]] + extra_flags))

        print("endif\n" * endifs)