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

decompose get_nse_state into two separate functions #1276

Merged
merged 97 commits into from
Jul 17, 2023

Conversation

zhichen3
Copy link
Collaborator

Here I separated get_nse_state into two separate functions, one that calculates the exponent part of the nse mass fraction (depends on chemical potentials) and the other calculates components that do not depend on chemical potentials.

This way we don't have to compute unnecessary parts when we solve for chemical potentials, mu_p and mu_n during hybrid solver, which includes getting the partition function.

Heres the new profile, it brings down # of calls for get_partition_functions from 900,000,000+ (from pr1274) to 200,000,000+

Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls   s/call   s/call  name    
 18.17     11.93    11.93 17968009     0.00     0.00  void fcn<burn_t>(amrex::Array1D<double, 1, 2>&, amrex::Array1D<double, 1, 2>&, burn_t const&, int&) [clone .constprop.0]
 12.44     20.10     8.17    58352     0.00     0.00  Castro::valid_zones_to_burn(amrex::MultiFab&)
  8.03     25.37     5.27 53037636     0.00     0.00  void apply_electrons<burn_t>(burn_t&)
  7.02     29.98     4.61  5332400     0.00     0.00  in_nse(burn_t&, bool)
  6.06     33.96     3.98 258295193     0.00     0.00  std::_Function_handler<amrex::GpuTuple<amrex::ValLocPair<double, amrex::IntVect> > (), amrex::ReduceData<amrex::ValLocPair<double, amrex::IntVect> >::ReduceData<amrex::ReduceOpMin>(amrex::ReduceOps<amrex::ReduceOpMin>&)::{lambda()#1}>::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation)
  6.00     37.90     3.94 190665624     0.00     0.00  std::_Function_handler<amrex::GpuTuple<int, int> (), amrex::ReduceData<int, int>::ReduceData<amrex::ReduceOpMax, amrex::ReduceOpMax>(amrex::ReduceOps<amrex::ReduceOpMax, amrex::ReduceOpMax>&)::{lambda()#1}>::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation)
  5.50     41.51     3.61  5249180     0.00     0.00  void nse_hybrid_solver<burn_t>(burn_t&, double)
  5.44     45.08     3.57  5381927     0.00     0.00  amrex::Vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::~Vector()
  4.28     47.89     2.81 13877485     0.00     0.00  void actual_eos<eos_input_t, burn_t>(eos_input_t, burn_t&)
  3.24     50.02     2.13  5257685     0.00     0.00  void hybrj<2, burn_t>(hybrj_t<2>&, burn_t const&)
  2.85     51.89     1.87  8988526     0.00     0.00  sneut5(double, double, double, double, double&, double&, double&, double&, double&)
  2.07     53.25     1.36  8609836     0.00     0.00  void fill_reaclib_rates<0, rate_t>(tf_t const&, rate_t&)
  2.03     54.58     1.33  8609836     0.00     0.00  void evaluate_rates<0, rate_t>(burn_t const&, rate_t&)
  1.55     55.60     1.02 56453976     0.00     0.00  fill_merge_indices(amrex::Array1D<int, 1, 2>&, double&, int, amrex::Array1D<double, 1, 22> const&, burn_t const&, amrex::Array1D<double, 1, 93> const&, amrex::Array1D<int, 1, 22> const&, double const&)
  1.53     56.61     1.01 236019664     0.00     0.00  get_partition_function(int, tf_t const&, double&, double&)
  1.29     57.46     0.85  8988526     0.00     0.00  rhs_nuc(burn_t const&, amrex::Array1D<double, 1, 23>&, amrex::Array1D<double, 1, 22> const&, amrex::Array1D<double, 1, 93> const&)
  0.87     58.03     0.57  8609836     0.00     0.00  void rate_ne20_to_he4_o16_derived<0>(tf_t const&, double&, double&)
  0.75     58.52     0.49  8609836     0.00     0.00  void rate_he4_ne20_to_p_na23_derived<0>(tf_t const&, double&, double&)
  0.73     59.00     0.48  8609836     0.00     0.00  void rate_si28_to_p_al27_derived<0>(tf_t const&, double&, double&)
  0.69     59.45     0.45  8609836     0.00     0.00  void rate_mg24_to_he4_ne20_derived<0>(tf_t const&, double&, double&)
  0.69     59.90     0.45  8609836     0.00     0.00  void rate_ar36_to_p_cl35_derived_removed<0>(tf_t const&, double&, double&)

nse_solver/nse_solver.H Outdated Show resolved Hide resolved
@zingale
Copy link
Member

zingale commented Jul 16, 2023

this has conflicts now

@zingale zingale merged commit 6af7154 into AMReX-Astro:development Jul 17, 2023
21 checks passed
maxpkatz pushed a commit to maxpkatz/Microphysics that referenced this pull request Jul 19, 2023
Here I separated get_nse_state into two separate functions, one that calculates the exponent part of the nse mass fraction (depends on chemical potentials) and the other calculates components that do not depend on chemical potentials.

This way we don't have to compute unnecessary parts when we solve for chemical potentials, mu_p and mu_n during hybrid solver, which includes getting the partition function.

Heres the new profile, it brings down # of calls for get_partition_functions from 900,000,000+ (from pr1274) to 200,000,000+
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