etmc/tmLQCD — Issue #9: Schroedinger Functional cleanup
Author: kostrzewa
Created: 2012-01-13 10:10:01+00:00
State: open

The Schroedinger functional code that currently exists inside the tmLQCD package has several issues.
- It is not included in existing code very well
a) For example, sf_get_staples.c replicates the code for get_staples.c 8 times, with only very minor changes (copy the same 13 lines over and over again, modifying only a single line). This is really bad, because the code becomes hard to read (if clause is far separated from its actual effect), and very hard to maintain. What if a bug is found in one of these if clauses, it needs to be fixed everywhere, but where is everywhere?
b) sf_get_rectangle_staples.c does the same to get_rectangle_staples.c, but then on a whole different scale, one that is SO bad that the compilation time of the ENTIRE tmLQCD package noticeably increases due to this single file. Also here a proper if construction would solve everything in a clean way, and the same story about bug fixing.
c) Inside hmc_tm, there are a few places where the SF code gets called. Also here a lot of replication of code is present, particularly for the output. Similar things are true for update_tm.c.

- Debug output appears to be still present.
a) There are instances of #if 1 or #if 0 preprocessor directives (sf_gauge_monomial.c, sf_observables.c)
b) printf ("hola"); in sf_gauge_monomial.c

- Many functions in the same file, mainly in sf_calc_action.c
- Output not prepared for parallel running, so no preparation for many cores repeating the same statement

- Inefficiencies in recomputing the same value
For example, inside hmc_tm.c
if(g_proc_id==0){
fprintf(parameterfile,"# First plaquette value for SF: %14.12f \n", plaquette_energy/(6.*VOLUME*g_nproc));
printf("# First plaquette value for SF: %14.12f \n", plaquette_energy/(6.*VOLUME*g_nproc));
fprintf(parameterfile,"# First rectangle value for SF: %14.12f \n", rectangle_energy/(12.*VOLUME*g_nproc));
printf("# First rectangle value for SF: %14.12f \n", rectangle_energy/(12.*VOLUME*g_nproc));
}
calls both functions twice without first storing intermediate result. Other examples exist.

- No tests are supplied, and the sample input file currently does not work. And even when fixed (online measurement error) it is hard to see if the code is working, as all trajectories from the test get rejected (tested the first 250, not going to wait more).

Unless someone steps up claiming to currently use the SF code, and provides usable test cases, applying fixes for these issues is likely to introduce undetected bugs, and unlikely to lead to any clear benefit.
Since the code will exist in the repository anyway, I'd propose to just remove it for now, especially since that does have at least some benefits: faster compilation, smaller files, and cleaner code.