Skip to content

Commit

Permalink
Check both backends for eigen allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgardner1421 committed Nov 6, 2023
1 parent 02e9421 commit b028f32
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/Core/calculators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ using NQCDynamics
using NQCDynamics.Calculators
using LinearAlgebra: tr, Diagonal, eigvecs, eigvals
using RingPolymerArrays: RingPolymerArrays
using MKL # A dependency added MKL so all our tests run with MKL anyway
# For the allocation tests it's important the BLAS/LAPACK backend doesn't change

# For the allocation tests check against both backends as we can't be sure which is in use
const MKL_EIGEN_ALLOCATIONS = 54912
const OPENBLAS_EIGEN_ALLOCATIONS = 56896

@testset "General constructors" begin
model = NQCModels.DoubleWell()
Expand Down Expand Up @@ -269,7 +269,8 @@ end

@test @allocated(Calculators.evaluate_potential!(calc, r)) == 0
@test @allocated(Calculators.evaluate_derivative!(calc, r)) == 0
@test @allocated(Calculators.evaluate_eigen!(calc, r)) == MKL_EIGEN_ALLOCATIONS # nonzero due to eigenroutines
eigen_allocations = @allocated(Calculators.evaluate_eigen!(calc, r))
@test (eigen_allocations == MKL_EIGEN_ALLOCATIONS) || (eigen_allocations == OPENBLAS_EIGEN_ALLOCATIONS)
@test @allocated(Calculators.evaluate_adiabatic_derivative!(calc, r)) == 0
@test @allocated(Calculators.evaluate_nonadiabatic_coupling!(calc, r)) == 0
end
Expand All @@ -291,7 +292,8 @@ end

@test @allocated(Calculators.evaluate_potential!(calc, r)) == 0
@test @allocated(Calculators.evaluate_derivative!(calc, r)) == 0
@test @allocated(Calculators.evaluate_eigen!(calc, r)) == 10*MKL_EIGEN_ALLOCATIONS # nonzero due to eigenroutines
eigen_allocations = @allocated(Calculators.evaluate_eigen!(calc, r)) / 10
@test (eigen_allocations == MKL_EIGEN_ALLOCATIONS) || (eigen_allocations == OPENBLAS_EIGEN_ALLOCATIONS)
@test @allocated(Calculators.evaluate_adiabatic_derivative!(calc, r)) == 0
@test @allocated(Calculators.evaluate_nonadiabatic_coupling!(calc, r)) == 0
end
Expand Down

0 comments on commit b028f32

Please sign in to comment.