Skip to content

Commit f6668a6

Browse files
committed
add oop test
1 parent 0bc138c commit f6668a6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/build_function.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,13 @@ function set_array(s::MultithreadedForm, out, outputidxs, rhss, checkbounds, ski
277277
end
278278
ntasks = 2 * nthreads() # oversubscribe a little bit
279279
per_task = ceil(Int, length(rhss) / ntasks)
280+
# TODO: do better partitioning when skipzeros is present
280281
slices = collect(Iterators.partition(zip(outputidxs, rhss), per_task))
281282
arrays = map(slices) do slice
282283
idxs, vals = first.(slice), last.(slice)
283284
_set_array(out, idxs, vals, checkbounds, skipzeros)
284285
end
285-
SpawnFetch{Multithreaded}(arrays, @inline f(args...) = nothing)
286+
SpawnFetch{Multithreaded}(arrays, @inline noop(args...) = nothing)
286287
end
287288

288289
function _set_array(out, outputidxs, rhss::AbstractArray, checkbounds, skipzeros)

test/build_function.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ end
1414

1515
h_str = ModelingToolkit.build_function(h, [a], [b], [c1, c2, c3], [d], [e], [g])
1616
h_oop = eval(h_str[1])
17+
h_str_par = ModelingToolkit.build_function(h, [a], [b], [c1, c2, c3], [d], [e], [g], parallel=ModelingToolkit.MultithreadedForm())
18+
h_oop_par = eval(h_str_par[1])
1719
h_ip! = eval(h_str[2])
1820
h_ip_skip! = eval(ModelingToolkit.build_function(h, [a], [b], [c1, c2, c3], [d], [e], [g], skipzeros=true, fillzeros=false)[2])
1921
h_ip_skip_par! = eval(ModelingToolkit.build_function(h, [a], [b], [c1, c2, c3], [d], [e], [g], skipzeros=true, parallel=ModelingToolkit.MultithreadedForm(), fillzeros=false)[2])
2022
inputs = ([1], [2], [3, 4, 5], [6], [7], [8])
2123

2224
@test h_oop(inputs...) == h_julia(inputs...)
25+
@test h_oop_par(inputs...) == h_julia(inputs...)
2326
out_1 = similar(h, Int)
2427
out_2 = similar(out_1)
2528
h_ip!(out_1, inputs...)

0 commit comments

Comments
 (0)