Monday, June 9, 2014

Fully Rewrote Monte Carlo Routines in C

Recently I have finally rewritten all the TARDIS Monte Carlo routines in C. The code can be found here. I have also performed a speed comparison between a fully Cython and fully C versions. The results of that comparison in seconds, using this TARDIS configuration can be found here. To wrap up - a naive, almost line to line, rewrite buys a reduction for this configuration of computation time to 75% of what it was before. This is quite a bit less than what I expected but still substantial, especially when run multiple times on clusters. To further optimize TARDIS Monte Carlo routines we will need to restructure the algorithms and see if the algorithms themselves can be improved. Profiling was done for this version using Callgrind but all the most expensive lines are so simple I can see no easy improvements without restructuring the code first. To restructure the code we will need to implement better, more logical structures for storage and packet data and break up long functions in to their logical parts. Also an interface for interacting with those structures is a good idea and will not induce any extra cost if using inlining. Simply accessing the fields directly as done now is very bad style that hampers the ability to make changes to the code.

No comments:

Post a Comment