Skip to content

Commit fcfb23e

Browse files
committed
bug fix due to new behaviour of threadid() in 1.12
1 parent 05550ad commit fcfb23e

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

src/byrow/hp_row_functions.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ function _hp_row_generic_vec!(res, ds, f, colsidx, ::Val{T}) where T
9595
Threads.@threads :static for i in 1:loopsize
9696
t_st = i*1000 + 1
9797
i == loopsize ? t_en = length(res) : t_en = (i+1)*1000
98-
_fill_matrix!(inmat_all[Threads.threadid()], all_data, t_st:t_en, colsidx)
98+
_fill_matrix!(inmat_all[tid(Threads.nthreads())], all_data, t_st:t_en, colsidx)
9999
for k in t_st:t_en
100-
res[k] = f(view(inmat_all[Threads.threadid()], :, k - t_st + 1))
100+
res[k] = f(view(inmat_all[tid(Threads.nthreads())], :, k - t_st + 1))
101101
end
102102
end
103103
end

src/other/utils.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,3 +952,8 @@ Base.IndexStyle(::Type{<:Cat2Vec}) = Base.IndexLinear()
952952
Base.size(v::Cat2Vec) = (length(v),)
953953
Base.length(v::Cat2Vec) = v.len1 + v.len2
954954
Base.eltype(v::Cat2Vec{F1, F2, CT, T, S, A, B}) where {F1, F2, CT, T, S, A, B} = CT
955+
956+
957+
function tid(nt)
958+
Threads.threadid() % nt + 1
959+
end

src/sort/int.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ function _sort_chunks_int_right!(x, idx::Vector{<:Integer}, idx_cpy, where, numb
9999
cz = div(length(x), number_of_chunks)
100100
en = length(x)
101101
Threads.@threads :static for i in 1:number_of_chunks
102-
ds_sort_int_missatright!(x, idx, idx_cpy, where[Threads.threadid()], (i-1)*cz+1,i*cz, rangelen, minval)
102+
ds_sort_int_missatright!(x, idx, idx_cpy, where[tid(Threads.nthreads())], (i-1)*cz+1,i*cz, rangelen, minval)
103103
end
104104
# take care of the last few observations
105105
if number_of_chunks*div(length(x), number_of_chunks) < en
106-
ds_sort_int_missatright!(x, idx, idx_cpy, where[Threads.threadid()], number_of_chunks*div(length(x), number_of_chunks)+1, en, rangelen, minval)
106+
ds_sort_int_missatright!(x, idx, idx_cpy, where[tid(1)], number_of_chunks*div(length(x), number_of_chunks)+1, en, rangelen, minval)
107107
end
108108
end
109109

@@ -112,11 +112,11 @@ function _sort_chunks_int_left!(x, idx::Vector{<:Integer}, idx_cpy, where, numbe
112112
cz = div(length(x), number_of_chunks)
113113
en = length(x)
114114
Threads.@threads :static for i in 1:number_of_chunks
115-
ds_sort_int_missatleft!(x, idx, idx_cpy, where[Threads.threadid()], (i-1)*cz+1,i*cz, rangelen, minval)
115+
ds_sort_int_missatleft!(x, idx, idx_cpy, where[tid(Threads.nthreads())], (i-1)*cz+1,i*cz, rangelen, minval)
116116
end
117117
# take care of the last few observations
118118
if number_of_chunks*div(length(x), number_of_chunks) < en
119-
ds_sort_int_missatleft!(x, idx, idx_cpy, where[Threads.threadid()], number_of_chunks*div(length(x), number_of_chunks)+1, en, rangelen, minval)
119+
ds_sort_int_missatleft!(x, idx, idx_cpy, where[tid(1)], number_of_chunks*div(length(x), number_of_chunks)+1, en, rangelen, minval)
120120
end
121121
end
122122

@@ -263,7 +263,7 @@ function _ds_sort_int_missatright_nopermx_threaded!(x, original_P, copy_P, lo, h
263263
where[i][2] = 1
264264
end
265265
Threads.@threads :static for i = lo:hi
266-
@inbounds ismissing(x[i]) ? where[Threads.threadid()][rangelen+3] += 1 : where[Threads.threadid()][Int(x[i]) + offs + 2] += 1
266+
@inbounds ismissing(x[i]) ? where[tid(Threads.nthreads())][rangelen+3] += 1 : where[tid(Threads.nthreads())][Int(x[i]) + offs + 2] += 1
267267
end
268268
for j in 3:length(where[1])
269269
for i in 2:nt
@@ -307,7 +307,7 @@ function _ds_sort_int_missatright_nopermx_threaded!(x, original_P, rangelen, min
307307
where[i][2] = 1
308308
end
309309
Threads.@threads :static for i = 1:length(x)
310-
@inbounds ismissing(x[i]) ? where[Threads.threadid()][rangelen+3] += 1 : where[Threads.threadid()][Int(x[i]) + offs + 2] += 1
310+
@inbounds ismissing(x[i]) ? where[tid(Threads.nthreads())][rangelen+3] += 1 : where[tid(Threads.nthreads())][Int(x[i]) + offs + 2] += 1
311311
end
312312
for j in 3:length(where[1])
313313
for i in 2:nt
@@ -349,7 +349,7 @@ function _ds_sort_int_missatleft_nopermx_threaded!(x, original_P, copy_P, lo, hi
349349
where[i][2] = 1
350350
end
351351
Threads.@threads :static for i = lo:hi
352-
@inbounds ismissing(x[i]) ? where[Threads.threadid()][3] += 1 : where[Threads.threadid()][Int(x[i]) + offs + 3] += 1
352+
@inbounds ismissing(x[i]) ? where[tid(Threads.nthreads())][3] += 1 : where[tid(Threads.nthreads())][Int(x[i]) + offs + 3] += 1
353353
end
354354
for j in 3:length(where[1])
355355
for i in 2:nt
@@ -393,7 +393,7 @@ function _ds_sort_int_missatleft_nopermx_threaded!(x, original_P, rangelen, minv
393393
where[i][2] = 1
394394
end
395395
Threads.@threads :static for i = 1:length(x)
396-
@inbounds ismissing(x[i]) ? where[Threads.threadid()][3] += 1 : where[Threads.threadid()][Int(x[i]) + offs + 3] += 1
396+
@inbounds ismissing(x[i]) ? where[tid(Threads.nthreads())][3] += 1 : where[tid(Threads.nthreads())][Int(x[i]) + offs + 3] += 1
397397
end
398398
for j in 3:length(where[1])
399399
for i in 2:nt

src/sort/sort.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,15 @@ function _issorted_check_for_each_range(v, starts, lastvalid, _ord, nrows; threa
218218
Threads.@threads :static for rng in 1:lastvalid
219219
lo = starts[rng]
220220
rng == lastvalid ? hi = nrows : hi = starts[rng+1] - 1
221-
part_res[Threads.threadid()] = _issorted_barrier(v, _ord, lo, hi)
222-
!part_res[Threads.threadid()] && break
221+
part_res[tid(Threads.nthreads())] = _issorted_barrier(v, _ord, lo, hi)
222+
!part_res[tid(Threads.nthreads())] && break
223223
end
224224
else
225225
for rng in 1:lastvalid
226226
lo = starts[rng]
227227
rng == lastvalid ? hi = nrows : hi = starts[rng+1] - 1
228-
part_res[Threads.threadid()] = _issorted_barrier(v, _ord, lo, hi)
229-
!part_res[Threads.threadid()] && break
228+
part_res[tid(1)] = _issorted_barrier(v, _ord, lo, hi)
229+
!part_res[tid(1)] && break
230230
end
231231
end
232232
all(part_res)

src/sort/sortperm.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function fast_sortperm_int_threaded!(x, original_P, copy_P, ranges, rangelen, mi
4141
_start_vals = _ds_sort_int_missatright_nopermx!(x, original_P, copy_P, rangestart, rangeend, rangelen, minval, Val(T))
4242
end
4343
_cleanup_starts!(_start_vals, rangeend - rangestart + 1)
44-
append!(starts[Threads.threadid()], _start_vals .+ rangestart .- 1)
44+
append!(starts[tid(Threads.nthreads())], _start_vals .+ rangestart .- 1)
4545
end
4646
cnt = 1
4747
flag = false
@@ -123,9 +123,9 @@ function _sortperm_int!(idx, idx_cpy, x, ranges, where, last_valid_range, missin
123123
rangelen = maxval - minval + 1
124124
if rangelen < div(rangeend - rangestart + 1, 2)
125125
if missingatleft
126-
ds_sort_int_missatleft!(x, idx, idx_cpy, where[Threads.threadid()], rangestart, rangeend, rangelen, minval)
126+
ds_sort_int_missatleft!(x, idx, idx_cpy, where[tid(Threads.nthreads())], rangestart, rangeend, rangelen, minval)
127127
else
128-
ds_sort_int_missatright!(x, idx, idx_cpy, where[Threads.threadid()], rangestart, rangeend, rangelen, minval)
128+
ds_sort_int_missatright!(x, idx, idx_cpy, where[tid(Threads.nthreads())], rangestart, rangeend, rangelen, minval)
129129
end
130130
else
131131
ds_sort!(x, idx, rangestart, rangeend, a, ord)
@@ -149,9 +149,9 @@ function _sortperm_int!(idx, idx_cpy, x, ranges, where, last_valid_range, missin
149149
rangelen = maxval - minval + 1
150150
if rangelen < div(rangeend - rangestart + 1, 2)
151151
if missingatleft
152-
ds_sort_int_missatleft!(x, idx, idx_cpy, where[Threads.threadid()], rangestart, rangeend, rangelen, minval)
152+
ds_sort_int_missatleft!(x, idx, idx_cpy, where[tid(1)], rangestart, rangeend, rangelen, minval)
153153
else
154-
ds_sort_int_missatright!(x, idx, idx_cpy, where[Threads.threadid()], rangestart, rangeend, rangelen, minval)
154+
ds_sort_int_missatright!(x, idx, idx_cpy, where[tid(1)], rangestart, rangeend, rangelen, minval)
155155
end
156156
else
157157
ds_sort!(x, idx, rangestart, rangeend, a, ord)

0 commit comments

Comments
 (0)