Skip to content

Support tuple dims in mapreduce_nd using CartesianIndices#83

Open
shreyas-omkar wants to merge 1 commit into
JuliaGPU:mainfrom
shreyas-omkar:sh/mapreduce_nd_dims
Open

Support tuple dims in mapreduce_nd using CartesianIndices#83
shreyas-omkar wants to merge 1 commit into
JuliaGPU:mainfrom
shreyas-omkar:sh/mapreduce_nd_dims

Conversation

@shreyas-omkar
Copy link
Copy Markdown
Member

Support tuple dims in mapreduce_nd

Extends mapreduce/reduce to accept dims as a Tuple{Vararg{Int}} in addition to a single Int, matching the semantics of Base.mapreduce.

What changed

  • mapreduce_nd signature updated to dims::Union{Int, Tuple{Vararg{Int}}}
  • Replaced stride-arithmetic-based kernels with a CartesianIndices-based approach, splitting iteration into Rother (kept dims) and Rreduce (reduced dims), mirroring the approach in GPUArrays.jl's vc/ka_mapreducedim branch
  • Single kernel pass, no intermediate allocations, works for any combination of dims

Testing

  • All existing tests pass
  • New tests added for dims=(1,2), (1,3), (2,3), (1,2,3) on 3D arrays
  • Verified on CPU, Intel GPU (oneAPI/Iris XE), NVIDIA GPU (CUDA/RTX 3060)

@shreyas-omkar
Copy link
Copy Markdown
Member Author

@maleadt and @christiangnrd, Please take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant