Skip to content

Commit

Permalink
Fix GPU tests (JuliaMolSim#867)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael F. Herbst <[email protected]>
  • Loading branch information
vchuravy and mfherbst authored Jul 20, 2023
1 parent ffe078f commit bfbe7af
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ julia/1.8-n2:
- module load lang/JuliaHPC/1.9.0-foss-2022a-CUDA-11.7.0
- julia --project=. -e '
using Pkg; Pkg.instantiate();
using DFTK;
DFTK.disable_libxc_cuda!();
using CUDA;
CUDA.set_runtime_version!(v"11.7")
'
- julia --color=yes --project=. -e '
using Pkg;
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"
wannier90_jll = "c5400fa0-8d08-52c2-913f-1e3f656c1ce9"

[targets]
test = ["Test", "ASEconvert", "Aqua", "AtomsIO", "AtomsIOPython", "CUDA", "ComponentArrays", "DoubleFloats", "FiniteDiff", "FiniteDifferences", "GenericLinearAlgebra", "IntervalArithmetic", "JLD2", "Logging", "Plots", "QuadGK", "Random", "KrylovKit", "WriteVTK", "wannier90_jll"]
test = ["Test", "ASEconvert", "Aqua", "AtomsIO", "AtomsIOPython", "CUDA", "CUDA_Runtime_jll", "ComponentArrays", "DoubleFloats", "FiniteDiff", "FiniteDifferences", "GenericLinearAlgebra", "IntervalArithmetic", "JLD2", "Logging", "Plots", "QuadGK", "Random", "KrylovKit", "WriteVTK", "wannier90_jll"]
12 changes: 5 additions & 7 deletions src/workarounds/cuda_arrays.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
synchronize_device(::GPU{<:CUDA.CuArray}) = CUDA.synchronize()

@static if @load_preference("use_libxc_cuda", "true") == "true"
for fun in (:potential_terms, :kernel_terms)
@eval function DftFunctionals.$fun(fun::DispatchFunctional,
ρ::CUDA.CuMatrix{Float64}, args...)
@assert Libxc.has_cuda()
$fun(fun.inner, ρ, args...)
end
for fun in (:potential_terms, :kernel_terms)
@eval function DftFunctionals.$fun(fun::DispatchFunctional,
ρ::CUDA.CuMatrix{Float64}, args...)
@assert Libxc.has_cuda()
$fun(fun.inner, ρ, args...)
end
end
7 changes: 0 additions & 7 deletions src/workarounds/gpu_arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,3 @@ for fun in (:potential_terms, :kernel_terms)
$fun(fun, Array(ρ), cpuify.(args)...)
end
end

# Note: This preference is temporary for now and can disappear at any time.
# This is needed because for some reason I cannot arrive at the tests
# to use CUDA version 11.8 instead of 12 (where Libxc is not supported)
function disable_libxc_cuda!()
@set_preferences!("use_libxc_cuda" => "false")
end
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Work around JuliaLang/Pkg.jl#2500
# Must be before loading anything
if VERSION < v"1.8-"
test_project = first(Base.load_path())
preferences_file = "../LocalPreferences.toml"
test_preferences_file = joinpath(dirname(test_project), "LocalPreferences.toml")
if isfile(preferences_file) && !isfile(test_preferences_file)
cp(preferences_file, test_preferences_file)
@info "copied LocalPreferences.toml to $test_preferences_file"
end
end

using Test
using DFTK
using Random
Expand Down

0 comments on commit bfbe7af

Please sign in to comment.