Skip to content

Commit dee352a

Browse files
authored
Fix type instability (#32)
* fix type instability for large array ranks * update ci and version * change convert for less invalidations?
1 parent 39bc28c commit dee352a

File tree

6 files changed

+51
-46
lines changed

6 files changed

+51
-46
lines changed

.github/workflows/CI-nightly.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ name: CI (Julia nightly)
22
on:
33
push:
44
branches:
5-
- main
6-
- workflow_dispatch
7-
tags: ['*']
5+
- 'master'
6+
- 'main'
7+
- 'release-'
8+
tags: '*'
89
pull_request:
10+
workflow_dispatch:
911
concurrency:
1012
# Skip intermediate builds: always.
1113
# Cancel intermediate builds: only if it is a pull request build.
@@ -28,7 +30,7 @@ jobs:
2830
- x64
2931
steps:
3032
- uses: actions/checkout@v4
31-
- uses: julia-actions/setup-julia@v1
33+
- uses: julia-actions/setup-julia@v2
3234
with:
3335
version: ${{ matrix.version }}
3436
arch: ${{ matrix.arch }}
@@ -38,7 +40,7 @@ jobs:
3840
env:
3941
JULIA_NUM_THREADS: 4
4042
- uses: julia-actions/julia-processcoverage@v1
41-
- uses: codecov/codecov-action@v3
43+
- uses: codecov/codecov-action@v4
4244
with:
4345
file: lcov.info
4446

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,33 @@
11
name: Invalidations
2-
3-
on:
4-
pull_request:
5-
6-
concurrency:
7-
# Skip intermediate builds: always.
8-
# Cancel intermediate builds: always.
9-
group: ${{ github.workflow }}-${{ github.ref }}
10-
cancel-in-progress: true
2+
on: pull_request
113

124
jobs:
135
evaluate:
14-
# Only run on PRs to the default branch.
15-
# In the PR trigger above branches can be specified only explicitly whereas this check should work for master, main, or any other default branch
16-
if: github.base_ref == github.event.repository.default_branch
176
runs-on: ubuntu-latest
187
steps:
19-
- uses: julia-actions/setup-julia@v1
8+
- uses: julia-actions/setup-julia@v2
209
with:
21-
version: '1'
10+
version: 'lts'
2211
- uses: actions/checkout@v4
23-
- uses: julia-actions/julia-buildpkg@v1
12+
- uses: julia-actions/julia-buildpkg@latest
2413
- uses: julia-actions/julia-invalidations@v1
2514
id: invs_pr
2615

2716
- uses: actions/checkout@v4
2817
with:
29-
ref: ${{ github.event.repository.default_branch }}
30-
- uses: julia-actions/julia-buildpkg@v1
18+
ref: 'main'
19+
- uses: julia-actions/julia-buildpkg@latest
3120
- uses: julia-actions/julia-invalidations@v1
32-
id: invs_default
21+
id: invs_main
3322

3423
- name: Report invalidation counts
3524
run: |
36-
echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY
37-
echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY
38-
- name: Check if the PR does increase number of invalidations
39-
if: steps.invs_pr.outputs.total > steps.invs_default.outputs.total
40-
run: exit 1
25+
echo "Invalidations on main: ${{ steps.invs_main.outputs.total }} (${{ steps.invs_main.outputs.deps }} via deps)"
26+
echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)"
27+
shell: bash
28+
- name: PR doesn't increase number of invalidations
29+
run: |
30+
if (( ${{ steps.invs_pr.outputs.total }} > ${{ steps.invs_main.outputs.total }} )); then
31+
exit 1
32+
fi
33+
shell: bash

.github/workflows/ci.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ name: CI
22
on:
33
push:
44
branches:
5-
- main
6-
- workflow_dispatch
7-
tags: ['*']
5+
- 'master'
6+
- 'main'
7+
- 'release-'
8+
tags: '*'
89
pull_request:
10+
workflow_dispatch:
911
concurrency:
1012
# Skip intermediate builds: always.
1113
# Cancel intermediate builds: only if it is a pull request build.
@@ -19,8 +21,9 @@ jobs:
1921
fail-fast: false
2022
matrix:
2123
version:
22-
- '1.6'
23-
- '1'
24+
- '1.6' # previous LTS release
25+
- 'lts' # current LTS release
26+
- '1' # current stable release
2427
os:
2528
- ubuntu-latest
2629
- macOS-latest
@@ -29,7 +32,7 @@ jobs:
2932
- x64
3033
steps:
3134
- uses: actions/checkout@v4
32-
- uses: julia-actions/setup-julia@v1
35+
- uses: julia-actions/setup-julia@v2
3336
with:
3437
version: ${{ matrix.version }}
3538
arch: ${{ matrix.arch }}
@@ -39,7 +42,7 @@ jobs:
3942
env:
4043
JULIA_NUM_THREADS: 4
4144
- uses: julia-actions/julia-processcoverage@v1
42-
- uses: codecov/codecov-action@v3
45+
- uses: codecov/codecov-action@v4
4346
with:
4447
file: lcov.info
4548

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Strided"
22
uuid = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
33
authors = ["Lukas Devos <[email protected]>", "Maarten Van Damme <[email protected]>", "Jutho Haegeman <[email protected]>"]
4-
version = "2.1.1"
4+
version = "2.2"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -12,9 +12,9 @@ TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"
1212
Aqua = "0.8"
1313
LinearAlgebra = "1.6"
1414
Random = "1.6"
15-
StridedViews = "0.1,0.2,0.3"
15+
StridedViews = "0.3.2"
1616
Test = "1.6"
17-
TupleTools = "1.1"
17+
TupleTools = "1.6"
1818
julia = "1.6"
1919

2020
[extras]

src/convert.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
function Base.convert(::Type{T}, a::StridedView) where {T<:Array}
2-
b = T(undef, size(a))
1+
function Base.Array(a::StridedView)
2+
b = Array{eltype(a)}(undef, size(a))
33
copyto!(StridedView(b), a)
44
return b
55
end
6-
function Base.convert(::Type{Array}, a::StridedView{T}) where {T}
6+
7+
function (Base.Array{T})(a::StridedView{S,N}) where {T,S,N}
8+
b = Array{T}(undef, size(a))
9+
copyto!(StridedView(b), a)
10+
return b
11+
end
12+
13+
function (Base.Array{T,N})(a::StridedView{S,N}) where {T,S,N}
714
b = Array{T}(undef, size(a))
815
copyto!(StridedView(b), a)
916
return b

src/mapreduce.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ function _mapreduce(f, op, A::StridedView{T}, nt=nothing) where {T}
7171
return out[ParentIndex(1)]
7272
end
7373

74-
@inline function Base.mapreducedim!(f, op, b::StridedView{<:Any,N},
75-
a1::StridedView{<:Any,N},
76-
A::Vararg{StridedView{<:Any,N}}) where {N}
74+
function Base.mapreducedim!(f, op, b::StridedView{<:Any,N},
75+
a1::StridedView{<:Any,N},
76+
A::Vararg{StridedView{<:Any,N}}) where {N}
7777
outdims = size(b)
7878
dims = map(max, outdims, map(max, map(size, (a1, A...))...))
7979

@@ -176,7 +176,7 @@ function _mapreduce_block!((f), (op), (initop),
176176
_mapreduce_threaded!(f, op, initop, dims, blocks, strides, offsets, costs, arrays,
177177
get_num_threads(), 0, 1)
178178
end
179-
return
179+
return nothing
180180
end
181181

182182
_init_reduction!(out, f, op::Union{typeof(+),typeof(Base.add_sum)}, a) = fill!(out, zero(a))
@@ -483,7 +483,7 @@ function _computeblocks(dims::NTuple{N,Int}, costs::NTuple{N,Int},
483483
end
484484

485485
if minimum(minimum.(bytestrides)) > blocksize
486-
return ntuple(n -> 1, N)
486+
return ntuple(n -> 1, Val(N))
487487
end
488488

489489
# reduce dims to find appropriate blocks

0 commit comments

Comments
 (0)