Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of calculating the initial field distribution #3

Open
DanielKotik opened this issue Feb 23, 2020 · 1 comment
Open
Assignees

Comments

@DanielKotik
Copy link
Owner

There is a huge Python bottleneck due to the high number of necessary function calls of the integrand function in psi_spherical. We use Cython to tackle this problem. According to a527d2d we start our journey from an average execution time of roughly one second:

In [1]: import beamprofile                                                        

In [2]: psi = beamprofile.main()                                                  
Using MPI version 3.1, 1 processes

In [3]: %timeit psi()                                                             
Calculating inital field configuration. This will take some time...
1 s ± 58.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
@DanielKotik
Copy link
Owner Author

At 2436587 we have now (same parameters as in #3 (comment)):

Pure Python implementation:

In [1]: import optbeam

Please consider compiling `optbeam.py` via Cython: `$ cythonize -3 -i optbeam.py`


In [2]: beamLGspherical, beamLGcartesian, r = optbeam.main()

In [3]: psi = beamLGspherical.profile

In [4]: %timeit psi(r)
Calculating inital field configuration. This will take some time...
79.9 ms ± 408 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

Cython implementation (without disabled checks):

In [1]: import optbeam

In [2]: beamLGspherical, beamLGcartesian, r = optbeam.main()

In [3]: psi = beamLGspherical.profile

In [4]: %timeit psi(r)
Calculating inital field configuration. This will take some time...
9.25 ms ± 74.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant