Skip to content

Commit

Permalink
use static thread scheduling (#260)
Browse files Browse the repository at this point in the history
* use static thread scheduling

* Test Multithreading

* test with single and multiple threads

---------

Co-authored-by: Fabian Gans <fgans@bgc-jena.mpg.de>
  • Loading branch information
felixcremer and meggart authored Jun 7, 2023
1 parent ee6ba19 commit 922731b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
env:
JULIA_NUM_THREADS: '4'
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion src/DAT/DAT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ using Base.Cartesian
)
end
else
Threads.@threads for cI in CartesianIndices(map(i -> 1:length(i), loopRanges))
Threads.@threads :static for cI in CartesianIndices(map(i -> 1:length(i), loopRanges))
innercode(
f,
cI,
Expand Down
14 changes: 14 additions & 0 deletions test/DAT/DAT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,18 @@
xout .= sum(skipmissing(xin))
end
@test any(ismissing.(nofilter.data)) == false
end

@testset "Threaded input caches" begin
a = rand(1000,5)
b = YAXArray(a)
mapslices(b,dims="Dim_2") do x
xc = copy(x)
for i in 1:100
xc[1] = xc[1]
yield()
x == xc || error("Multithreaded buffer is not correct")
end
1.0
end
end
4 changes: 4 additions & 0 deletions test/DAT/mapcube.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
xout .= x1 .+ x2
end
@test r.data == a2.data .+ reshape(a3.data,(4,1,5))
r = mapCube((a2, a3), indims=(indims, indims), outdims=outdims,nthreads = [1]) do xout, x1, x2
xout .= x1 .+ x2
end
@test r.data == a2.data .+ reshape(a3.data,(4,1,5))
end

@testset "Reduction to empty outputs" begin
Expand Down

0 comments on commit 922731b

Please sign in to comment.