From 267c6a1144520bafd5a23eb3ee4123a330c39bb5 Mon Sep 17 00:00:00 2001 From: Nuwan Yapa Date: Wed, 11 Dec 2024 23:28:54 -0500 Subject: [PATCH] Cache misses fixed --- ho_basis.jl | 9 +++++---- ho_basis_2body.jl | 2 +- ho_basis_3body.jl | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ho_basis.jl b/ho_basis.jl index 1085bea..b8d7f22 100644 --- a/ho_basis.jl +++ b/ho_basis.jl @@ -108,8 +108,9 @@ function get_sp_T_matrix(ns, ls, kron_deltas=[]; μω_gen=1.0, μ=1.0) end "PE matrix for a single DOF. Set kron_deltas=[other quantum numbers] for other DOFs which the operator does not act on. - E.g. get_sp_V_matrix(n1s, l1s, kron_deltas=[n2s l2s])" -function get_sp_V_matrix(V_l, ns, ls, kron_deltas=[]; dtype=Float64, cache=prealloc_V_cache(maximum(ls), dtype)) + E.g. get_sp_V_matrix(n1s, l1s, kron_deltas=[n2s l2s]) + Providing a preallocated cache is optional. Otherwise, provided E_max value is used to initialize one (defaults to 100)." +function get_sp_V_matrix(V_l, ns, ls, kron_deltas=[]; dtype=Float64, E_max=100, cache=prealloc_V_cache(E_max, dtype)) mat = zeros(dtype, length(ns), length(ns)) Threads.@threads for idx in CartesianIndices(mat) (i, j) = Tuple(idx) @@ -170,7 +171,7 @@ end function get_jacobi_V1_matrix(V_of_r, basis::ho_basis_2B, μ1ω1; atol=10^-6, maxevals=10^5) V1_elem(l, n1, n2) = V_numerical(V_of_r, l, n1, n2; μω_gen=μ1ω1, atol=atol, maxevals=maxevals) - V1 = get_sp_V_matrix(V1_elem, basis.n1s, basis.l1s, [basis.n2s, basis.l2s]; dtype=ComplexF64) + V1 = get_sp_V_matrix(V1_elem, basis.n1s, basis.l1s, [basis.n2s, basis.l2s]; dtype=ComplexF64, E_max=basis.E_max) return V1 end @@ -213,7 +214,7 @@ end function get_src_V12_matrix(V_of_r, basis::ho_basis_2B, μω_global; atol=10^-6, maxevals=10^5) V_relative_elem(l, n1, n2) = V_numerical(V_of_r, l, n1, n2; μω_gen=μω_global, atol=atol, maxevals=maxevals) - V_relative = get_sp_V_matrix(V_relative_elem, basis.n1s, basis.l1s, [basis.n2s, basis.l2s]; dtype=ComplexF64) + V_relative = get_sp_V_matrix(V_relative_elem, basis.n1s, basis.l1s, [basis.n2s, basis.l2s]; dtype=ComplexF64, E_max=basis.E_max) U = Moshinsky_transform(basis) V12 = U' * V_relative * U diff --git a/ho_basis_2body.jl b/ho_basis_2body.jl index 80b9d62..3287d3a 100644 --- a/ho_basis_2body.jl +++ b/ho_basis_2body.jl @@ -21,7 +21,7 @@ println("Constructing KE matrices") println("Constructing PE matrices") V1_elem(l, n1, n2) = Va * V_Gaussian(Ra, l, n1, n2; μω_gen=μω_gen) -@time "V1" V1 = get_sp_V_matrix(V1_elem, basis.ns, basis.ls) +@time "V1" V1 = get_sp_V_matrix(V1_elem, basis.ns, basis.ls; E_max=E_max) println("Calculating spectrum") @time "H" H = T1 + V1 diff --git a/ho_basis_3body.jl b/ho_basis_3body.jl index 7c9d9f1..c883e5e 100644 --- a/ho_basis_3body.jl +++ b/ho_basis_3body.jl @@ -27,9 +27,9 @@ println("Constructing KE matrices") println("Constructing PE matrices") V_elem(l, n1, n2) = Va * V_Gaussian(Ra, l, n1, n2; μω_gen=μω) V_relative_elem(l, n1, n2) = Va * V_Gaussian(Ra, l, n1, n2; μω_gen=μω_global) -@time "V1" V1 = get_sp_V_matrix(V_elem, basis.n1s, basis.l1s, [basis.n2s, basis.l2s]) -@time "V2" V2 = get_sp_V_matrix(V_elem, basis.n2s, basis.l2s, [basis.n1s, basis.l1s]) -@time "V relative" V_relative = get_sp_V_matrix(V_relative_elem, basis.n1s, basis.l1s, [basis.n2s, basis.l2s]) +@time "V1" V1 = get_sp_V_matrix(V_elem, basis.n1s, basis.l1s, [basis.n2s, basis.l2s]; E_max=E_max) +@time "V2" V2 = get_sp_V_matrix(V_elem, basis.n2s, basis.l2s, [basis.n1s, basis.l1s]; E_max=E_max) +@time "V relative" V_relative = get_sp_V_matrix(V_relative_elem, basis.n1s, basis.l1s, [basis.n2s, basis.l2s]; E_max=E_max) @time "Moshinsky brackets" U = Moshinsky_transform(basis) @time "V12" V12 = U' * V_relative * U