Skip to content

Commit

Permalink
Bugfix non-abelian add_transform!
Browse files Browse the repository at this point in the history
Original version had a typo only affecting non-abelian groups with more than 1 threads
Threads were not being used anyways so disabled them and added TODO to fix this
  • Loading branch information
lkdvos committed Aug 14, 2023
1 parent 29d4ef7 commit 7703e4b
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions src/tensors/indexmanipulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,18 +326,32 @@ function _add_general_kernel!(tdst, tsrc, p, fusiontreetransform, α, β, backen
elseif β != 1
tdst = scale!(tdst, β)
end
if Threads.nthreads() > 1
Threads.@sync for s₁ in sectors(codomain(tsrc)), s₂ in sectors(domain(tsrc))
_add_sector!(tdst, tsrc, fusiontreemap, s₁, s₂, α, β, backend...)
end
else
for (f₁, f₂) in fusiontrees(tsrc)
for ((f₁′, f₂′), coeff) in fusiontreetransform(f₁, f₂)
TO.tensoradd!(tdst[f₁′, f₂′], p, tsrc[f₁, f₂], :N, α * coeff, true,
backend...)
end

# TODO: implement multithreading for general symmetries
# Currently disable multithreading for general symmetries, requires more testing and
# possibly a different approach. Ideally, we'd loop over output blocks in parallel, to
# avoid parallel writing, but this requires the inverse of the fusiontreetransform.

for (f₁, f₂) in fusiontrees(tsrc)
for ((f₁′, f₂′), coeff) in fusiontreetransform(f₁, f₂)
TO.tensoradd!(tdst[f₁′, f₂′], p, tsrc[f₁, f₂], :N, α * coeff, true,
backend...)
end
end

# if Threads.nthreads() > 1
# Threads.@sync for s₁ in sectors(codomain(tsrc)), s₂ in sectors(domain(tsrc))
# _add_sectors!(tdst, tsrc, fusiontreemap, s₁, s₂, α, β, backend...)
# end
# else
# for (f₁, f₂) in fusiontrees(tsrc)
# for ((f₁′, f₂′), coeff) in fusiontreetransform(f₁, f₂)
# TO.tensoradd!(tdst[f₁′, f₂′], p, tsrc[f₁, f₂], :N, α * coeff, true,
# backend...)
# end
# end
# end

return nothing
end

Expand Down

0 comments on commit 7703e4b

Please sign in to comment.