Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor mapreduce improvements #303

Merged
merged 2 commits into from
Mar 5, 2024
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
6 changes: 3 additions & 3 deletions src/device/intrinsics/simd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ Returns `a * b + c`.

## SIMD Shuffle Up/Down

simd_shuffle_map = ((Float32, "f16"),
(Float16, "f32"),
simd_shuffle_map = ((Float32, "f32"),
(Float16, "f16"),
(Int32, "s.i32"),
(UInt32, "u.i32"),
(Int16, "s.i16"),
Expand Down Expand Up @@ -133,4 +133,4 @@ modify the lower delta lanes of data because it doesn’t wrap values around the

T must be one of the following: Float32, Float16, Int32, UInt32, Int16, UInt16, Int8, or UInt8
"""
simd_shuffle_up
simd_shuffle_up
8 changes: 4 additions & 4 deletions src/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ function GPUArrays.mapreducedim!(f::F, op::OP, R::WrappedMtlArray{T},
Base.check_reducedims(R, A)
length(A) == 0 && return R # isempty(::Broadcasted) iterates

# be conservative about using shuffle instructions
shuffle = T <: Union{Float32, Float16, Int32, UInt32, Int16, UInt16, Int8, UInt8}
# be conservative about using shuffle instructions
shuffle = T <: Union{Float32, Float16, Int32, UInt32, Int16, UInt16, Int8, UInt8}

# add singleton dimensions to the output container, if needed
if ndims(R) < ndims(A)
Expand Down Expand Up @@ -184,8 +184,8 @@ function GPUArrays.mapreducedim!(f::F, op::OP, R::WrappedMtlArray{T},
Int(dev.maxThreadgroupMemoryLength) ÷ sizeof(T))

# also want to make sure the grain size is not too high as to starve threads of work.
# as a simple heuristic, assume we can launch the maximum number of threads.
grain = min(grain, prevpow(2, cld(length(Rreduce), maxthreads)))
# as a simple heuristic, ensure we can launch the maximum number of threads.
grain = min(grain, nextpow(2, cld(length(Rreduce), maxthreads)))

# how many threads can we launch?
#
Expand Down