Skip to content

Commit 259d935

Browse files
authored
Merge pull request #340 from JuliaPhysics/multithreaded-tests
Run CI with four Julia threads active
2 parents 17e46fd + 8a33d53 commit 259d935

File tree

6 files changed

+42
-23
lines changed

6 files changed

+42
-23
lines changed

.github/workflows/Downgrade.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: Downgrade
2+
env:
3+
JULIA_NUM_THREADS: 4
24
on:
35
pull_request:
46
branches:
@@ -31,3 +33,5 @@ jobs:
3133
skip: Pkg,TOML
3234
- uses: julia-actions/julia-buildpkg@v1
3335
- uses: julia-actions/julia-runtest@v1
36+
with:
37+
coverage: false

.github/workflows/ci.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ on:
1010
pull_request:
1111
release:
1212

13+
# needed to allow julia-actions/cache to delete old caches that it has created
14+
permissions:
15+
actions: write
16+
contents: read
17+
1318
concurrency:
1419
# Skip intermediate builds: always.
1520
# Cancel intermediate builds: only if it is a pull request build.
@@ -20,28 +25,35 @@ jobs:
2025
test:
2126
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
2227
runs-on: ${{ matrix.os }}
28+
env:
29+
JULIA_NUM_THREADS: ${{ matrix.threads }}
2330
continue-on-error: ${{ matrix.version == 'pre' }}
2431
strategy:
2532
fail-fast: false
2633
matrix:
2734
version:
28-
- '1.10'
2935
- '1'
30-
- 'pre'
3136
os:
3237
- ubuntu-latest
38+
- macOS-latest
39+
- windows-latest
3340
arch:
3441
- x64
42+
threads:
43+
- 4
3544
include:
36-
- version: 1
45+
- version: '1.10'
3746
os: ubuntu-latest
38-
arch: x86
39-
- version: 1
40-
os: macOS-latest
4147
arch: x64
42-
- version: 1
43-
os: windows-latest
48+
threads: '1'
49+
- version: pre
50+
os: ubuntu-latest
4451
arch: x64
52+
threads: 4
53+
- version: '1'
54+
os: ubuntu-latest
55+
arch: x86
56+
threads: 4
4557
steps:
4658
- uses: actions/checkout@v4
4759
- uses: julia-actions/setup-julia@v2
@@ -61,11 +73,11 @@ jobs:
6173
if: matrix.arch == 'x86'
6274
- uses: julia-actions/julia-runtest@v1
6375
with:
64-
coverage: ${{ matrix.version == '1' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64' }}
76+
coverage: ${{ matrix.version == '1.10' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64' }}
6577
- uses: julia-actions/julia-processcoverage@v1
66-
if: matrix.version == '1' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64'
78+
if: matrix.version == '1.10' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64'
6779
- uses: codecov/codecov-action@v5
68-
if: matrix.version == '1' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64'
80+
if: matrix.version == '1.10' && matrix.os == 'ubuntu-latest' && matrix.arch == 'x64'
6981
with:
7082
files: lcov.info
7183
env:

src/Simulation/Simulation.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ function _calculate_potential!( sim::Simulation{T, CS}, potential_type::UnionAll
962962
end
963963
refine!(sim, ElectricPotential, max_diffs, min_tick_distance)
964964
nt = guess_nt ? _guess_optimal_number_of_threads_for_SOR(size(sim.electric_potential.grid), max_nthreads[iref+1], CS) : max_nthreads[iref+1]
965-
verbose && println("Grid size: $(size(sim.electric_potential.data)) - $(onCPU ? "using $(nt) threads now" : "GPU"):")
965+
verbose && println("Grid size: $(size(sim.electric_potential.data)) - $(onCPU ? "using $(nt) threads now" : "GPU")")
966966
update_till_convergence!( sim, potential_type, convergence_limit,
967967
n_iterations_between_checks = n_iterations_between_checks,
968968
max_n_iterations = max_n_iterations,
@@ -976,7 +976,7 @@ function _calculate_potential!( sim::Simulation{T, CS}, potential_type::UnionAll
976976
max_diffs = abs.(ref_limits)
977977
refine!(sim, WeightingPotential, contact_id, max_diffs, min_tick_distance)
978978
nt = guess_nt ? _guess_optimal_number_of_threads_for_SOR(size(sim.weighting_potentials[contact_id].grid), max_nthreads[iref+1], CS) : max_nthreads[iref+1]
979-
verbose && println("Grid size: $(size(sim.weighting_potentials[contact_id].data)) - $(onCPU ? "using $(nt) threads now" : "GPU"):")
979+
verbose && println("Grid size: $(size(sim.weighting_potentials[contact_id].data)) - $(onCPU ? "using $(nt) threads now" : "GPU")")
980980
update_till_convergence!( sim, potential_type, contact_id, convergence_limit,
981981
n_iterations_between_checks = n_iterations_between_checks,
982982
max_n_iterations = max_n_iterations,

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LegendHDF5IO = "c9265ca6-b027-5446-b1a4-febfa8dd10b0"
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
88
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
99
RadiationDetectorSignals = "bf2c0563-65cf-5db2-a620-ceb7de82658c"
10+
SolidStateDetectors = "71e43887-2bd9-5f77-aebd-47f656f0a3f0"
1011
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
1112
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1213
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using Test
44
using SolidStateDetectors
55

6+
@info "Running tests with $(Base.Threads.nthreads()) Julia threads active."
7+
68
include("test_utils.jl")
79

810
@timed_testset "Comparison to analytic solutions" begin

test/test_real_detectors.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using Unitful
99

1010
T = Float32
1111

12-
@timed_testset "Simulate example detector: Inverted Coax" begin
12+
@timed_testset "Inverted Coax" begin
1313
sim = Simulation{T}(SSD_examples[:InvertedCoax])
1414
timed_simulate!(sim, convergence_limit = 1e-6, device_array_type = device_array_type, refinement_limits = [0.2, 0.1, 0.05, 0.03, 0.02, 0.01], verbose = false)
1515
evt = Event(CartesianPoint.([CylindricalPoint{T}(20e-3, deg2rad(10), 10e-3 )]))
@@ -35,7 +35,7 @@ T = Float32
3535
timed_calculate_electric_potential!(sim, depletion_handling = true)
3636
@test is_depleted(sim.point_types)
3737
end
38-
@timed_testset "Simulate example detector: Inverted Coax (in cryostat)" begin
38+
@timed_testset "Inverted Coax (in cryostat)" begin
3939
sim = Simulation{T}(SSD_examples[:InvertedCoaxInCryostat])
4040
timed_simulate!(sim, convergence_limit = 1e-6, device_array_type = device_array_type, refinement_limits = [0.2, 0.1], verbose = false)
4141
evt = Event(CartesianPoint.([CylindricalPoint{T}(20e-3, deg2rad(10), 10e-3 )]))
@@ -48,7 +48,7 @@ end
4848
@info signalsum
4949
@test isapprox( signalsum, T(2), atol = 5e-3 )
5050
end
51-
# @timed_testset "Simulate example detector: Coax" begin
51+
# @timed_testset "Coax" begin
5252
# sim = Simulation{T}(SSD_examples[:Coax])
5353
# timed_calculate_electric_potential!(sim, convergence_limit = 1e-6, device_array_type = device_array_type, refinement_limits = [0.2, 0.1], verbose = false)
5454
# timed_calculate_electric_field!(sim)
@@ -67,7 +67,7 @@ end
6767
# @info signalsum
6868
# @test isapprox( signalsum, T(2), atol = 5e-3 )
6969
# end
70-
@timed_testset "Simulate example detector: BEGe" begin
70+
@timed_testset "BEGe" begin
7171
sim = Simulation{T}(SSD_examples[:BEGe])
7272
timed_calculate_electric_potential!(sim, convergence_limit = 1e-6, device_array_type = device_array_type, refinement_limits = [0.2, 0.1], verbose = false)
7373
timed_calculate_electric_field!(sim)
@@ -99,7 +99,7 @@ end
9999
end
100100
@test isapprox(timed_estimate_depletion_voltage(sim, verbose = false), 0u"V", atol = 0.2u"V") # This detector has no impurity profile
101101
end
102-
@timed_testset "Simulate example detector: HexagonalPrism" begin
102+
@timed_testset "HexagonalPrism" begin
103103
sim = Simulation{T}(SSD_examples[:Hexagon])
104104
timed_simulate!(sim, convergence_limit = 1e-6, device_array_type = device_array_type, refinement_limits = [0.2, 0.1, 0.05, 0.02], verbose = false)
105105
evt = Event([CartesianPoint{T}(0, 5e-4, 1e-3)])
@@ -113,7 +113,7 @@ end
113113
@test isapprox( signalsum, T(2), atol = 5e-3 )
114114
@test isapprox(timed_estimate_depletion_voltage(sim, verbose = false), T(-13.15)*u"V", atol = 1.0u"V")
115115
end
116-
@timed_testset "Simulate example detector: CGD" begin
116+
@timed_testset "CGD" begin
117117
sim = Simulation{T}(SSD_examples[:CGD])
118118
timed_simulate!(sim, convergence_limit = 1e-6, device_array_type = device_array_type, refinement_limits = [0.2, 0.1], verbose = false)
119119
evt = Event([CartesianPoint{T}(0,2e-3,0)])
@@ -128,7 +128,7 @@ end
128128
nt = NamedTuple(sim)
129129
@test sim == Simulation(nt)
130130
end
131-
@timed_testset "Simulate example detector: Spherical" begin
131+
@timed_testset "Spherical" begin
132132
sim = Simulation{T}(SSD_examples[:Spherical])
133133
timed_simulate!(sim, convergence_limit = 1e-5, device_array_type = device_array_type, refinement_limits = [0.2, 0.1], verbose = false)
134134
evt = Event([CartesianPoint{T}(0,0,0)])
@@ -141,7 +141,7 @@ end
141141
@info signalsum
142142
@test isapprox( signalsum, T(2), atol = 5e-3 )
143143
end
144-
@timed_testset "Simulate example detector: Toroidal" begin
144+
@timed_testset "Toroidal" begin
145145
sim = Simulation{T}(SSD_examples[:CoaxialTorus])
146146
timed_simulate!(sim, convergence_limit = 1e-5, device_array_type = device_array_type, refinement_limits = [0.2, 0.1, 0.05, 0.02, 0.01],
147147
max_tick_distance = 0.5u"mm", verbose = false)
@@ -155,7 +155,7 @@ end
155155
@info signalsum
156156
@test isapprox( signalsum, T(2), atol = 5e-3 )
157157
end
158-
@timed_testset "Simulate example detector: Coaxial for partial phi range" begin
158+
@timed_testset "Coaxial for partial phi range" begin
159159
sim = Simulation{T}(SSD_examples[:Cone2D])
160160
timed_calculate_electric_potential!(sim, convergence_limit = 1e-6, device_array_type = device_array_type, refinement_limits = missing, verbose = false)
161161

@@ -169,7 +169,7 @@ end
169169
idx = findall(pt -> SolidStateDetectors.is_pn_junction_point_type(pt), sim.point_types.data)
170170
@test maximum(abs.(sim_alt.electric_potential.data[idx] .- sim.electric_potential.data[idx])) .< T(0.2)
171171
end
172-
@timed_testset "Simulate example detector: SigGen PPC" begin
172+
@timed_testset "SigGen PPC" begin
173173
sim = Simulation{T}(SSD_examples[:SigGen])
174174
timed_simulate!(sim, convergence_limit = 1e-6, device_array_type = device_array_type, refinement_limits = [0.2, 0.1], verbose = false)
175175
evt = Event(CartesianPoint.([CylindricalPoint{T}(20e-3, deg2rad(10), 10e-3 )]))

0 commit comments

Comments
 (0)