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

Make LOBPCG GPU-compatible #711

Merged
merged 19 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DftFunctionals = "6bd331d2-b28d-4fd3-880e-1a1c7f37947f"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
InteratomicPotentials = "a9efe35a-c65d-452d-b8a8-82646cd5cb04"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
Expand Down
4 changes: 1 addition & 3 deletions src/eigen/lobpcg_hyper_impl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,7 @@ end
# cP[Xn_indices,:] .= 0

lenXn = length(Xn_indices)
# TODO: two allocations needed for zero(similar(...)). Create a zero_like
# function which only does one allocation.
e = zero(similar(X, size(cX, 1), M - prev_nlocked))
e = zeros_like(X, size(cX, 1), M - prev_nlocked)
lower_diag = one(similar(X, lenXn, lenXn))
# e has zeros everywhere except on one of its lower diagonal
e[Xn_indices[1]:last(Xn_indices), 1:lenXn] = lower_diag
Expand Down
10 changes: 9 additions & 1 deletion src/workarounds/gpu_arrays.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TODO: remove this when it is implemented in GPUArrays and CUDA
import LinearAlgebra.dot, LinearAlgebra.eigen
using LinearAlgebra
using GPUArrays
using GPUArraysCore
using CUDA

mfherbst marked this conversation as resolved.
Show resolved Hide resolved
# https://github.com/JuliaGPU/CUDA.jl/issues/1565
Expand All @@ -17,3 +17,11 @@ function LinearAlgebra.eigen(A::Hermitian{T,AT}) where {T <: Real,AT <: CuArray}
vals, vects = CUDA.CUSOLVER.syevd!('V','U', A.data)
(vectors = vects, values = vals)
end

# Create an array of same type as X filled with zeros, minimizing the number
# of allocations.
function zeros_like(X, n, m)
Z = similar(X, n, m)
Z .= 0
Z
end
mfherbst marked this conversation as resolved.
Show resolved Hide resolved