Skip to content

Commit bd5ede4

Browse files
committed
Fix GPU kernel
1 parent a837827 commit bd5ede4

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/density_methods.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ function atomic_density_superposition(basis::PlaneWaveBasis{T},
163163

164164
# Pre-allocation of large arrays for GPU efficiency
165165
Gs = G_vectors(basis)
166-
ρ = to_device(basis.architecture, zeros(Complex{T}, length(Gs)))
167-
ρ_tmp = similar(ρ)
168166
indices = to_device(basis.architecture, collect(1:length(Gs)))
167+
ρ = zeros_like(indices, Complex{T})
168+
ρ_tmp = similar(ρ)
169169

170170
for (igroup, group) in enumerate(basis.model.atom_groups)
171171
for iatom in group
@@ -235,8 +235,11 @@ end
235235

236236
"""Gaussian valence charge density using Abinit's coefficient table, in Fourier space."""
237237
function atomic_density(element::Element, Gnorms::AbstractVector, ::ValenceDensityGaussian)
238+
charge = charge_ionic(element)
239+
decay_length = atom_decay_length(element)
238240
map(Gnorms) do Gnorm
239-
charge_ionic(element) * exp(-(Gnorm * atom_decay_length(element))^2)
241+
# Note: cannot pass element to GPU kernel, because not isbit
242+
charge * exp(-(Gnorm * decay_length)^2)
240243
end
241244
end
242245
function atomic_density(element::Element, Gnorms::AbstractVector, ::ValenceDensityAuto)

0 commit comments

Comments
 (0)