Skip to content

Commit

Permalink
Merge branch 'master' into source-build--gmp
Browse files Browse the repository at this point in the history
  • Loading branch information
inkydragon committed Jul 7, 2022
2 parents ccb6e41 + f7e0c7e commit fc243f7
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/jl_uv.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void JL_UV_LOCK(void)
}
else {
jl_atomic_fetch_add_relaxed(&jl_uv_n_waiters, 1);
jl_fence(); // [^store_buffering_2]
jl_wake_libuv();
JL_LOCK(&jl_uv_mutex);
jl_atomic_fetch_add_relaxed(&jl_uv_n_waiters, -1);
Expand Down
11 changes: 9 additions & 2 deletions src/partr.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ static const int16_t sleeping = 1;
// * Enqueuer:
// * 2: `jl_atomic_load_relaxed(&ptls->sleep_check_state)` in `jl_wakeup_thread` returns `not_sleeping`
// i.e., the dequeuer misses the enqueue and enqueuer misses the sleep state transition.

// [^store_buffering_2]: and also
// * Enqueuer:
// * 1a: `jl_atomic_store_relaxed(jl_uv_n_waiters, 1)` in `JL_UV_LOCK`
// * 1b: "cheap read" of `handle->pending` in `uv_async_send` (via `JL_UV_LOCK`) loads `0`
// * Dequeuer:
// * 2a: store `2` to `handle->pending` in `uv_async_send` (via `JL_UV_LOCK` in `jl_task_get_next`)
// * 2b: `jl_atomic_load_relaxed(jl_uv_n_waiters)` in `jl_task_get_next` returns `0`
// i.e., the dequeuer misses the `n_waiters` is set and enqueuer misses the `uv_stop` flag (in `signal_async`) transition to cleared

JULIA_DEBUG_SLEEPWAKE(
uint64_t wakeup_enter;
Expand Down Expand Up @@ -276,7 +283,7 @@ static int may_sleep(jl_ptls_t ptls) JL_NOTSAFEPOINT
// by the thread itself. As a result, if this returns false, it will
// continue returning false. If it returns true, we know the total
// modification order of the fences.
jl_fence(); // [^store_buffering_1]
jl_fence(); // [^store_buffering_1] [^store_buffering_2]
return jl_atomic_load_relaxed(&ptls->sleep_check_state) == sleeping;
}

Expand Down
52 changes: 42 additions & 10 deletions stdlib/LinearAlgebra/src/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1540,11 +1540,27 @@ for (mfname, elty) in ((:dsymm_,:Float64),
require_one_based_indexing(A, B, C)
m, n = size(C)
j = checksquare(A)
if j != (side == 'L' ? m : n)
throw(DimensionMismatch(lazy"A has size $(size(A)), C has size ($m,$n)"))
end
if size(B,2) != n
throw(DimensionMismatch(lazy"B has second dimension $(size(B,2)) but needs to match second dimension of C, $n"))
M, N = size(B)
if side == 'L'
if j != m
throw(DimensionMismatch(lazy"A has first dimension $j but needs to match first dimension of C, $m"))
end
if N != n
throw(DimensionMismatch(lazy"B has second dimension $N but needs to match second dimension of C, $n"))
end
if j != M
throw(DimensionMismatch(lazy"A has second dimension $j but needs to match first dimension of B, $M"))
end
else
if j != n
throw(DimensionMismatch(lazy"B has second dimension $j but needs to match second dimension of C, $n"))
end
if N != j
throw(DimensionMismatch(lazy"A has second dimension $N but needs to match first dimension of B, $j"))
end
if M != m
throw(DimensionMismatch(lazy"A has first dimension $M but needs to match first dimension of C, $m"))
end
end
chkstride1(A)
chkstride1(B)
Expand Down Expand Up @@ -1614,11 +1630,27 @@ for (mfname, elty) in ((:zhemm_,:ComplexF64),
require_one_based_indexing(A, B, C)
m, n = size(C)
j = checksquare(A)
if j != (side == 'L' ? m : n)
throw(DimensionMismatch(lazy"A has size $(size(A)), C has size ($m,$n)"))
end
if size(B,2) != n
throw(DimensionMismatch(lazy"B has second dimension $(size(B,2)) but needs to match second dimension of C, $n"))
M, N = size(B)
if side == 'L'
if j != m
throw(DimensionMismatch(lazy"A has first dimension $j but needs to match first dimension of C, $m"))
end
if N != n
throw(DimensionMismatch(lazy"B has second dimension $N but needs to match second dimension of C, $n"))
end
if j != M
throw(DimensionMismatch(lazy"A has second dimension $j but needs to match first dimension of B, $M"))
end
else
if j != n
throw(DimensionMismatch(lazy"B has second dimension $j but needs to match second dimension of C, $n"))
end
if N != j
throw(DimensionMismatch(lazy"A has second dimension $N but needs to match first dimension of B, $j"))
end
if M != m
throw(DimensionMismatch(lazy"A has first dimension $M but needs to match first dimension of C, $m"))
end
end
chkstride1(A)
chkstride1(B)
Expand Down
8 changes: 8 additions & 0 deletions stdlib/LinearAlgebra/test/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,19 @@ Random.seed!(100)
@test_throws DimensionMismatch BLAS.symm('R','U',Cmn,Cnn)
@test_throws DimensionMismatch BLAS.symm!('L','U',one(elty),Asymm,Cnn,one(elty),Cmn)
@test_throws DimensionMismatch BLAS.symm!('L','U',one(elty),Asymm,Cnn,one(elty),Cnm)
@test_throws DimensionMismatch BLAS.symm!('L','U',one(elty),Asymm,Cmn,one(elty),Cnn)
@test_throws DimensionMismatch BLAS.symm!('R','U',one(elty),Asymm,Cnm,one(elty),Cmn)
@test_throws DimensionMismatch BLAS.symm!('R','U',one(elty),Asymm,Cnn,one(elty),Cnm)
@test_throws DimensionMismatch BLAS.symm!('R','U',one(elty),Asymm,Cmn,one(elty),Cnn)
if elty <: BlasComplex
@test_throws DimensionMismatch BLAS.hemm('L','U',Cnm,Cnn)
@test_throws DimensionMismatch BLAS.hemm('R','U',Cmn,Cnn)
@test_throws DimensionMismatch BLAS.hemm!('L','U',one(elty),Aherm,Cnn,one(elty),Cmn)
@test_throws DimensionMismatch BLAS.hemm!('L','U',one(elty),Aherm,Cnn,one(elty),Cnm)
@test_throws DimensionMismatch BLAS.hemm!('L','U',one(elty),Aherm,Cmn,one(elty),Cnn)
@test_throws DimensionMismatch BLAS.hemm!('R','U',one(elty),Aherm,Cnm,one(elty),Cmn)
@test_throws DimensionMismatch BLAS.hemm!('R','U',one(elty),Aherm,Cnn,one(elty),Cnm)
@test_throws DimensionMismatch BLAS.hemm!('R','U',one(elty),Aherm,Cmn,one(elty),Cnn)
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions stdlib/LinearAlgebra/test/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ end
C = zeros(eltya,n,n)
@test Hermitian(aherm) * a aherm * a
@test a * Hermitian(aherm) a * aherm
# rectangular multiplication
@test [a; a] * Hermitian(aherm) [a; a] * aherm
@test Hermitian(aherm) * [a a] aherm * [a a]
@test Hermitian(aherm) * Hermitian(aherm) aherm*aherm
@test_throws DimensionMismatch Hermitian(aherm) * Vector{eltya}(undef, n+1)
LinearAlgebra.mul!(C,a,Hermitian(aherm))
Expand All @@ -360,6 +363,9 @@ end
@test Symmetric(asym) * Symmetric(asym) asym*asym
@test Symmetric(asym) * a asym * a
@test a * Symmetric(asym) a * asym
# rectangular multiplication
@test Symmetric(asym) * [a a] asym * [a a]
@test [a; a] * Symmetric(asym) [a; a] * asym
@test_throws DimensionMismatch Symmetric(asym) * Vector{eltya}(undef, n+1)
LinearAlgebra.mul!(C,a,Symmetric(asym))
@test C a*asym
Expand Down

0 comments on commit fc243f7

Please sign in to comment.