Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
OhMyThreads.jl Changelog
=========================

Version 0.8.9
------------
- ![Enhancement][badge-enhancement] `tforeach` no longer compiles a scheduler's implementation for every output type: its output type (`Nothing`) is now passed on as a constant, instead of a `DataType` in the keyword arguments. With schedulers that compile a reduction only when there is a result, this saves the compilation of the reduction for every loop body [#177][gh-pr-177].

Version 0.8.8
------------
- ![Enhancement][badge-enhancement] `tforeach`, `treduce`, `treducemap`, `tmap`, `tmap!`, and `tmapreduce` now always specialize on the function arguments. Before, a call could run through an instance compiled for `f::Function`, and dispatch every call of `f` dynamically, e.g. `tforeach(_ -> work(n), xs)` with a non-inlined `work` and a run-time `n` [#176][gh-pr-176].
Expand Down Expand Up @@ -196,3 +200,4 @@ Version 0.2.0
[gh-pr-173]: https://github.com/JuliaFolds2/OhMyThreads.jl/pull/173
[gh-pr-174]: https://github.com/JuliaFolds2/OhMyThreads.jl/pull/174
[gh-pr-176]: https://github.com/JuliaFolds2/OhMyThreads.jl/pull/176
[gh-pr-177]: https://github.com/JuliaFolds2/OhMyThreads.jl/pull/177
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "OhMyThreads"
uuid = "67456a42-1dca-4109-a031-0a68de7e3ad5"
authors = ["Carsten Bauer <mail@carstenbauer.eu>", "Mason Protter <mason.protter@icloud.com>"]
version = "0.8.8"
version = "0.8.9"

[deps]
BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"
Expand Down
16 changes: 14 additions & 2 deletions src/implementation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ end
outputtype::Type = Any,
init = NotGiven(),
kwargs...) where {F, OP}
return tmapreduce_positional(f, op, Arrs, outputtype, scheduler, init, kwargs)
end

# `tmapreduce` with the output type as a positional argument: passed through keyword
# arguments, a type is stored as a `DataType`, and the parallel implementation is then
# compiled for every output type at once (for `tforeach`, also the reduction it never does).
# No type parameter: an output type only known at run time would then be dispatched on
# before the serial fallback; `_tmapreduce` specializes on it instead.
@inline function tmapreduce_positional(f::F, op::OP, Arrs, outputtype::Type,
scheduler, init, kwargs) where {F, OP}
mapreduce_kwargs = isgiven(init) ? (; init) : (;)
_scheduler = _scheduler_from_userinput(scheduler; kwargs...)

Expand Down Expand Up @@ -462,8 +472,10 @@ end

#-------------------------------------------------------------

function tforeach(f::F, A...; kwargs...)::Nothing where {F}
tmapreduce(f, (l, r) -> l, A...; kwargs..., init = nothing, outputtype = Nothing)
function tforeach(f::F, A...; scheduler::MaybeScheduler = NotGiven(),
init = nothing, outputtype::Type = Nothing, kwargs...)::Nothing where {F}
tmapreduce_positional(f, (l, r) -> l, A, Nothing, scheduler, nothing, kwargs)
return nothing
end

#-------------------------------------------------------------
Expand Down
Loading