Skip to content

Commit 929304e

Browse files
committed
bash script for multi-thread testset
1 parent 3975b5d commit 929304e

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

benchmarks/code_20210923.jl

+22-20
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,26 @@ using YaoLocations
66
using BQCESubroutine: threaded_basic_broutine!
77
using Polyester
88

9-
@testset "BX N=$N" for N in [1, 2, 3, 4, 5, 15, 20]
10-
for i in 1:N
11-
st = rand(Float64, 1<<N);
12-
locs = BQCESubroutine.Locations(i);
13-
st0 = broutine!(copy(st), Val(:X), locs);
14-
st1 = broutine!(copy(st), [0 1; 1 0], locs);
15-
@test st0 st1
16-
end
17-
end;
9+
@testset "nthreads=$(Threads.nthreads())" begin
10+
@testset "BX N=$N" for N in [1:10..., 15, 20]
11+
for i in 1:N
12+
st = rand(Float64, 1<<N);
13+
locs = BQCESubroutine.Locations(i);
14+
st0 = broutine!(copy(st), Val(:X), locs);
15+
st1 = broutine!(copy(st), [0 1; 1 0], locs);
16+
@test st0 st1
17+
end
18+
end;
1819

19-
@testset "BPSWAP N=$N" for N in [2, 3, 4, 5, 15, 20]
20-
for i in 1:N, j in i+1:N
21-
st = rand(ComplexF64, 1<<N);
22-
locs = BQCESubroutine.Locations([i, j]);
23-
θ = 2π * rand();
24-
st0 = broutine!(copy(st), Val(:PSWAP), locs, θ);
25-
st1 = broutine!(copy(st), BQCESubroutine.BPSWAP(θ), locs);
26-
#println("N=$N, i=$i, j=$j, |err|=", norm(st0-st1))
27-
@test st0 st1
28-
end
29-
end;
20+
@testset "BPSWAP N=$N" for N in [2:10..., 15, 20]
21+
for i in 1:N, j in i+1:N
22+
st = rand(ComplexF64, 1<<N);
23+
locs = BQCESubroutine.Locations([i, j]);
24+
θ = 2π * rand();
25+
st0 = broutine!(copy(st), Val(:PSWAP), locs, θ);
26+
st1 = broutine!(copy(st), BQCESubroutine.BPSWAP(θ), locs);
27+
#println("N=$N, i=$i, j=$j, |err|=", norm(st0-st1))
28+
@test st0 st1
29+
end
30+
end;
31+
end;

benchmarks/code_20210923.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
for i in {1..64}
3+
do
4+
JULIA_NUM_THREADS=$i julia --project=@. code_20210923.jl
5+
done

0 commit comments

Comments
 (0)