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

check for existing data before radiation_map_setup #532

Conversation

electronsandstuff
Copy link
Contributor

This is related to the performance issue in #523. I think I was able to solve it by putting a check before where the radiation_map_setup subroutine is called.

Here is the performance on the example in the issue before the change.

Benchmark 1: tao -noplot -command exit
  Time (mean ± σ):      2.359 s ±  0.019 s    [User: 2.332 s, System: 0.024 s]
  Range (min … max):    2.336 s …  2.395 s    10 runs

Here is the performance with the checks.

Benchmark 1: tao -noplot -command exit
  Time (mean ± σ):      1.746 s ±  0.008 s    [User: 1.720 s, System: 0.023 s]
  Range (min … max):    1.736 s …  1.758 s    10 runs

It gives about a 25% reduction in running time for this example. Profiling it after the change confirms that the radiation_map_setup code takes an insignificant amount of time.
image

@ChristopherMayes
Copy link
Contributor

track1_radiation is called by track1. With OpenMP, this is within a parallelized loop:

!$OMP parallel do if (thread_safe)

@DavidSagan won't this cause a problem, modifying ele_struct by separate threads?

@DavidSagan
Copy link
Member

@ChristopherMayes Yes it looks like there is an OpenMP problem here. I will take a look. Also the new test as constructed is invalid since Fortran does not have short-circuiting so testing associated(ele%rad_map) and ele%rad_map%stale in the same if statement is illegal.

@DavidSagan
Copy link
Member

I modified the code to avoid the OpenMP problem and added code so that the radiation integral values would be reused if possible. This decreased the run time for the test program by about 15%. (Devel/step17 #534)

@DavidSagan
Copy link
Member

With the Bmad code change mentioned above the difference with and without the PR code is about 5%. The next PR from me will contain this PR code modified to be valid.

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

Successfully merging this pull request may close these issues.

3 participants