JuliaDecisionFocusedLearning / InferOpt.jl

Combinatorial optimization layers for machine learning pipelines
https://juliadecisionfocusedlearning.github.io/InferOpt.jl/
MIT License
114 stars 4 forks source link

Get rid of ThreadsX? #67

Open gdalle opened 1 year ago

gdalle commented 1 year ago

We can speed up loading of InferOpt by replacing ThreadsX with built-in threads:

res = ThreadsX.map(f(i) for i in 1:n)

would become

f1 = f(1)
res = Vector{typeof(f1)}(undef, n)
res[1] = f1
@threads for i in 2:n
    res[i] = f(i)
end

Downsides:

Upsides:

gdalle commented 1 year ago

Also beware that @threads sometimes introduces type instabilities due to boxing

https://github.com/JuliaLang/julia/issues/41731