diff --git a/src/tensors/indexmanipulations.jl b/src/tensors/indexmanipulations.jl index 19208fdd..7e80f938 100644 --- a/src/tensors/indexmanipulations.jl +++ b/src/tensors/indexmanipulations.jl @@ -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