-
Notifications
You must be signed in to change notification settings - Fork 93
Bringing GPU programming to DFTK #697
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
Changes from all commits
e17fb59
e80f5b6
ed15b32
19bfa69
f4748ac
94f1d2a
60d8041
fb6484a
cf1dc3c
11b85f0
abb99f4
a89171a
44bcb61
646b44c
76c697d
bd684d7
f02c954
15d1324
62d9f79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using DFTK | ||
using CUDA | ||
using MKL | ||
setup_threading(n_blas=1) | ||
|
||
a = 10.263141334305942 # Lattice constant in Bohr | ||
lattice = a / 2 .* [[0 1 1.]; [1 0 1.]; [1 1 0.]] | ||
Si = ElementPsp(:Si, psp=load_psp("hgh/lda/Si-q4")) | ||
atoms = [Si, Si] | ||
positions = [ones(3)/8, -ones(3)/8]; | ||
terms_LDA = [Kinetic(), AtomicLocal(), AtomicNonlocal()] | ||
|
||
# Setup an LDA model and discretize using | ||
# a single k-point and a small `Ecut` of 5 Hartree. | ||
mod = Model(lattice, atoms, positions; terms=terms_LDA,symmetries=false) | ||
basis = PlaneWaveBasis(mod; Ecut=30, kgrid=(1, 1, 1)) | ||
basis_gpu = PlaneWaveBasis(mod; Ecut=30, kgrid=(1, 1, 1), array_type = CuArray) | ||
|
||
|
||
DFTK.reset_timer!(DFTK.timer) | ||
scfres = self_consistent_field(basis; solver=scf_damping_solver(1.0), is_converged=DFTK.ScfConvergenceDensity(1e-3)) | ||
println(DFTK.timer) | ||
|
||
DFTK.reset_timer!(DFTK.timer) | ||
scfres_gpu = self_consistent_field(basis_gpu; solver=scf_damping_solver(1.0), is_converged=DFTK.ScfConvergenceDensity(1e-3)) | ||
println(DFTK.timer) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Orthonormalize | ||
ortho_qr(φk) = Matrix(qr(φk).Q) | ||
ortho_qr(φk::AbstractArray) = Matrix(qr(φk).Q) #LinearAlgebra.QRCompactWYQ -> Matrix | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't we simply do this?
Another way to do it would be to have only one function and to get the the "base type" of |
||
ortho_qr(φk::CuArray) = CuArray(qr(φk).Q) #CUDA.CUSOLVER.CuQRPackedQ -> CuArray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure they should be here (and a hard dependency of DFTK) long-term.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we will need to discuss dependencies (especially if we want to move LOBPCG out of DFTK, that can take some work): I also didn't really know where to put my imports and how they were managed in a big package, so there is room for improvement.