bmad-sim / bmad-ecosystem

Bmad simulation ecosystem for simulating high energy storage rings.
https://www.classe.cornell.edu/bmad/
12 stars 15 forks source link

Beam Tracking - multipole_ele_to_ab Caching #543

Closed electronsandstuff closed 11 months ago

electronsandstuff commented 1 year ago

For beam tracking with CSR, it looks like a ton of time (about 40% of the total runtime of the program for my application) is being spent calling multipole_ele_to_ab. I'm pretty sure it's getting run for every particle in the bunch. There is some caching code in there (in the image) to protect against this, but for whatever reason it doesn't seem to be working on my setup.

image

Here is the profiling on my input file. I can still see it on the minimal example I put at /nfs/acc/temp/electronsandstuff/csr-radiation-profiling on the CLASSE system (doing tests with 5mil particles now), but with fewer elements in the lattice it's more like 27% of runtime.

image
DavidSagan commented 11 months ago

I modified the code to better cache multipole values.

DavidSagan commented 11 months ago

Chris reports a 20-30% speedup