Improve Performance: findmin/findmax
- Dominant language
- Julia
- Stars
- 1.4k
- Forks
- 281
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 30
Description
The current `findmin` and `findmax` functions are slow due to the current algorithm working in two phases ([here](https://github.com/JuliaGPU/CUDA.jl/blob/afaec8e0b2a89e09e65f8977c1312b8846c561ed/src/indexing.jl#L128-L150)). It first computes the `minimum` (computed via mapreduce) and subsequently calls `findfirstval` to find it's index. This also affects other functions which internally use `findmin` such as `argmin`.
It may be possible to have a `mapreduce` call which returns both the minimum value and the corresponding index but I was unable to come up with such an abstraction.
Alternatively, we could have a function `findminmax!(A, dims)` similar to base ([here](https://github.com/JuliaLang/julia/blob/e119c24c770b29bc0e1870f42e487f17f0ed004c/base/reducedim.jl#L901)) but with the intention of returning both the minimum and maximum so even `extrema` can be implemented which has not been implemented in CUDA yet.
And yes, I would be happy to work on this.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.