ENH: unroll correlate loops

Unrolling the inner loop ensures the kernel is placed into registers and
reused, this almost doubles performance.
Also move the function to arraytypes.c.src where also our dot product is
placed.
The templ_common.h might still be useful in future so its kept.
BUG: ImportError: No module named thread

Fixes #5136. Import dummy_threading if importing threading fails.
Merge pull request #5140 from pyhits/5136

BUG: ImportError: No module named thread
Merge pull request #5135 from juliantaylor/correlate-improve

ENH: unroll correlate loops