Skip to content

Commit

Permalink
more bug squashing
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Ortner committed Jun 24, 2023
1 parent 31cfd8f commit f4b3b04
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/assemble.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ function mt_assemble(data::AbstractVector{<:AbstractData}, basis)
_prog_ctr = 0
next = 1

failed = Int[]

Threads.@threads for _i = 1:nthreads()

while next <= length(packets)
Expand All @@ -69,25 +71,36 @@ function mt_assemble(data::AbstractVector{<:AbstractData}, basis)
break
end
lock(_lock)
p = packets[next]
cur = next
next += 1
unlock(_lock)
if cur > length(packets)
break
end
p = packets[cur]

# assemble the corresponding data
Ap = feature_matrix(p.data, basis)
Yp = target_vector(p.data)
Wp = weight_vector(p.data)
try
Ap = feature_matrix(p.data, basis)
Yp = target_vector(p.data)
Wp = weight_vector(p.data)

# write into global design matrix
lock(_lock)
A[p.rows, :] .= Ap
Y[p.rows] .= Yp
W[p.rows] .= Wp
_prog_ctr += length(p.rows)
ProgressMeter.update!(_prog, _prog_ctr)
unlock(_lock)
# write into global design matrix
lock(_lock)
A[p.rows, :] .= Ap
Y[p.rows] .= Yp
W[p.rows] .= Wp
_prog_ctr += length(p.rows)
ProgressMeter.update!(_prog, _prog_ctr)
unlock(_lock)
catch
@info("failed assembly: cur = $cur")
push!(failed, cur)
end
end
@info("thread $_i done")
end
@info " - Assembly completed."
@show failed
return Array(A), Array(Y), Array(W)
end

0 comments on commit f4b3b04

Please sign in to comment.