Skip to content

Commit

Permalink
ins
Browse files Browse the repository at this point in the history
  • Loading branch information
Bittens authored and Bittens committed Oct 9, 2024
1 parent 29bece9 commit a1f614b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function Base.iterate(iter::InterpolationIterator{HCP},state::Int) where {HCP<:A
if basis_fun(cpt, coords(iter), 1) > 0.0 && isrefined(cpt) && level(cpt) < stoplevel(iter)
next_interpolation_descendants!(iter.nextlevel,cpt,coords(iter))
end
return cpt,1
return cpt, 1

end

Expand Down
27 changes: 27 additions & 0 deletions src/DistributedSparseGrids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,33 @@ function interp_below(asg::SG, cpt::HCP) where {N,HCP<:AbstractHierarchicalCollo
#return interpolate_recursive(asg,coords(cpt),level(cpt)-1)
end


function interpolate_chunk!(res::RT, tmp::RT, x::VCT, chunk::Vector{HCP}) where {N,RT,CT,VCT<:AbstractVector{CT},CP<:AbstractCollocationPoint{N,CT}, HCP<:AbstractHierarchicalCollocationPoint{N,CP,RT}}
fill!(res,0.0)
fill!(tmp,0.0)
for hcpt in chunk
mul!(tmp,scaling_weight(hcpt),basis_fun(hcpt, x, 1))
add!(res,tmp)
end
return nothing
end

function interpolate!(res::RT, tres::Vector{RT}, ttmp::Vector{RT}, asg::SG, x::VCT, stplvl::Int=numlevels(asg)) where {N,RT,CT,VCT<:AbstractVector{CT},CP<:AbstractCollocationPoint{N,CT}, HCP<:AbstractHierarchicalCollocationPoint{N,CP,RT}, SG<:AbstractHierarchicalSparseGrid{N,HCP}}
fill!(res,0.0)
use_n_threads = length(tres)
in_it = InterpolationIterator(asg,x,stplvl)
chunks = Iterators.partition(in_it, length(in_it) ÷ use_n_threads+1)
tasks = map(enumerate(chunks)) do (i,chunk)
Threads.@spawn interpolate_chunk!(tres[i], ttmp[i], x, chunk)
end
fetch.(tasks)
for chunkres in tres
add!(res,chunkres)
end
return nothing
end


"""
init_weights!(asg::SG, cpts::AbstractVector{HCP}, fun::F)
Expand Down

0 comments on commit a1f614b

Please sign in to comment.