Skip to content

Commit

Permalink
Breaking: Broadcast performance and correctness (#777)
Browse files Browse the repository at this point in the history
* Improve GPU functionality and fix performnce combined commit

* fix broadcast type stability

* Improve GPU functionality

* Add missing weakdeps

* Update src/array/broadcast.jl

Co-authored-by: Rafael Schouten <[email protected]>

* Update src/array/broadcast.jl

Co-authored-by: Rafael Schouten <[email protected]>

* Push materialize fix

* Clean up mapreduce and add a bunch of tests for JLArray broadcast

* Add some more JLArray tests

* Just return dest in broadcast

* Update src/array/methods.jl

Co-authored-by: Rafael Schouten <[email protected]>

* Format

---------

Co-authored-by: Rafael Schouten <[email protected]>

* bugfixes

* more bugfix

* skip broken plot

* use GPUArrays.allowscalar(false) in tests

* add GPUArrays to test targets

* use generated function for comparedims and promotedims

* fix _remove

* fix promotedims

* test and bugfix promotedims

* bugfix

* remove @d

---------

Co-authored-by: Paul Tiede <[email protected]>
  • Loading branch information
rafaqz and ptiede authored Sep 1, 2024
1 parent 1210df6 commit 8330424
Show file tree
Hide file tree
Showing 23 changed files with 876 additions and 298 deletions.
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ Dates = "1"
Distributions = "0.25"
Documenter = "1"
Extents = "0.1"
GPUArrays = "10"
ImageFiltering = "0.7"
ImageTransformations = "0.10"
Interfaces = "0.3"
IntervalSets = "0.5, 0.6, 0.7"
InvertedIndices = "1"
IteratorInterfaceExtensions = "1"
JLArrays = "0.1"
LinearAlgebra = "1"
Makie = "0.19, 0.20, 0.21"
OffsetArrays = "1"
Expand Down Expand Up @@ -83,8 +85,10 @@ CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
ImageFiltering = "6a3955dd-da59-5b1f-98d4-e7296123deb5"
ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795"
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Expand All @@ -95,4 +99,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["Aqua", "ArrayInterface", "BenchmarkTools", "CategoricalArrays", "ColorTypes", "Combinatorics", "CoordinateTransformations", "DataFrames", "Distributions", "Documenter", "ImageFiltering", "ImageTransformations", "CairoMakie", "OffsetArrays", "Plots", "Random", "SafeTestsets", "StatsPlots", "Test", "Unitful"]
test = ["Aqua", "ArrayInterface", "BenchmarkTools", "CategoricalArrays", "ColorTypes", "Combinatorics", "CoordinateTransformations", "DataFrames", "Distributions", "Documenter", "GPUArrays", "ImageFiltering", "ImageTransformations", "JLArrays", "CairoMakie", "OffsetArrays", "Plots", "Random", "SafeTestsets", "StatsPlots", "Test", "Unitful"]
3 changes: 2 additions & 1 deletion src/Dimensions/Dimensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const LookupArrays = Lookups

import .Lookups: rebuild, order, span, sampling, locus, val, index, set, _set,
metadata, bounds, intervalbounds, units, basetypeof, unwrap, selectindices, hasselection,
shiftlocus, maybeshiftlocus
shiftlocus, maybeshiftlocus, ordered_first, ordered_last, ordered_firstindex, ordered_lastindex,
promote_first, _remove
using .Lookups: StandardIndices, SelTuple, CategoricalEltypes,
LookupTrait, AllMetadata, LookupSetters, AbstractBeginEndRange,
SelectorOrInterval, Interval
Expand Down
5 changes: 5 additions & 0 deletions src/Dimensions/dimension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ function Base.:(==)(d1::Dimension, d2::Dimension)
basetypeof(d1) == basetypeof(d2) && val(d1) == val(d2)
end

LookupArrays.ordered_first(d::Dimension{<:AbstractArray}) = ordered_first(lookup(d))
LookupArrays.ordered_last(d::Dimension{<:AbstractArray}) = ordered_last(lookup(d))
LookupArrays.ordered_firstindex(d::Dimension{<:AbstractArray}) = ordered_firstindex(lookup(d))
LookupArrays.ordered_lastindex(d::Dimension{<:AbstractArray}) = ordered_lastindex(lookup(d))

Base.size(dims::DimTuple) = map(length, dims)
Base.CartesianIndices(dims::DimTuple) = CartesianIndices(map(d -> axes(d, 1), dims))

Expand Down
2 changes: 2 additions & 0 deletions src/Dimensions/format.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ format(dims::Tuple{Vararg{Any,N}}, A::AbstractArray{<:Any,N}) where N = format(d
format(dims::Tuple{Vararg{Any,N}}, axes::Tuple{Vararg{Any,N}}) where N = map(_format, dims, axes)
format(d::Dimension{<:AbstractArray}) = _format(d, axes(val(d), 1))
format(d::Dimension, axis::AbstractRange) = _format(d, axis)
format(l::Lookup) = parent(format(AnonDim(l)))

_format(dimname::Symbol, axis::AbstractRange) = Dim{dimname}(NoLookup(axes(axis, 1)))
_format(::Type{D}, axis::AbstractRange) where D<:Dimension = D(NoLookup(axes(axis, 1)))
Expand All @@ -55,6 +56,7 @@ format(v, D::Type, axis::AbstractRange) = _valformaterror(v, D)

# Format Lookups
# No more identification required for NoLookup
format(m::Lookups.Length1NoLookup, D::Type, values, axis::AbstractRange) = m
format(m::NoLookup, D::Type, values, axis::AbstractRange) = m
format(m::NoLookup, D::Type, values::AutoValues, axis::AbstractRange) = NoLookup(axis)
# # AutoLookup
Expand Down
Loading

0 comments on commit 8330424

Please sign in to comment.