diff --git a/doc/src/devdocs/subarrays.md b/doc/src/devdocs/subarrays.md index dee9547fb1efd..8b28661e932c8 100644 --- a/doc/src/devdocs/subarrays.md +++ b/doc/src/devdocs/subarrays.md @@ -19,14 +19,14 @@ julia> A = rand(2,3,4); julia> S1 = view(A, :, 1, 2:3) 2×2 view(::Array{Float64, 3}, :, 1, 2:3) with eltype Float64: - 0.166507 0.97397 - 0.754392 0.831383 + 0.442623 0.0530526 + 0.201893 0.504489 julia> S2 = view(A, 1, :, 2:3) 3×2 view(::Array{Float64, 3}, 1, :, 2:3) with eltype Float64: - 0.166507 0.97397 - 0.518957 0.0705793 - 0.503714 0.825124 + 0.442623 0.0530526 + 0.720089 0.661983 + 0.0939203 0.457032 ``` ```@meta DocTestSetup = nothing diff --git a/doc/src/manual/performance-tips.md b/doc/src/manual/performance-tips.md index 7d1f448456167..c0ec3c5224d1d 100644 --- a/doc/src/manual/performance-tips.md +++ b/doc/src/manual/performance-tips.md @@ -77,12 +77,12 @@ julia> function sum_global() end; julia> @time sum_global() - 0.026328 seconds (9.30 k allocations: 416.747 KiB, 36.50% gc time, 99.48% compilation time) -508.39048990953665 + 0.026174 seconds (9.07 k allocations: 373.448 KiB, 98.80% compilation time) +496.44917496523266 julia> @time sum_global() - 0.000075 seconds (3.49 k allocations: 70.156 KiB) -508.39048990953665 + 0.000116 seconds (3.49 k allocations: 70.156 KiB) +496.44917496523266 ``` On the first call (`@time sum_global()`) the function gets compiled. (If you've not yet used [`@time`](@ref) @@ -113,12 +113,12 @@ julia> function sum_arg(x) end; julia> @time sum_arg(x) - 0.010298 seconds (4.23 k allocations: 226.021 KiB, 99.81% compilation time) -508.39048990953665 + 0.009579 seconds (3.96 k allocations: 200.171 KiB, 99.77% compilation time) +496.44917496523266 julia> @time sum_arg(x) 0.000005 seconds (1 allocation: 16 bytes) -508.39048990953665 +496.44917496523266 ``` The 1 allocation seen is from running the `@time` macro itself in global scope. If we instead run @@ -129,7 +129,7 @@ julia> time_sum(x) = @time sum_arg(x); julia> time_sum(x) 0.000001 seconds -508.39048990953665 +496.44917496523266 ``` In some situations, your function may need to allocate memory as part of its operation, and this diff --git a/src/task.c b/src/task.c index 88d4eac0863c9..d133b24fc727b 100644 --- a/src/task.c +++ b/src/task.c @@ -667,7 +667,7 @@ JL_DLLEXPORT uint64_t jl_tasklocal_genrandom(jl_task_t *task) JL_NOTSAFEPOINT uint64_t s2 = task->rngState2; uint64_t s3 = task->rngState3; - uint64_t t = s0 << 17; + uint64_t t = s1 << 17; uint64_t tmp = s0 + s3; uint64_t res = ((tmp << 23) | (tmp >> 41)) + s0; s2 ^= s0; diff --git a/stdlib/LinearAlgebra/test/dense.jl b/stdlib/LinearAlgebra/test/dense.jl index 57cb06786e994..c6bdb1403a9db 100644 --- a/stdlib/LinearAlgebra/test/dense.jl +++ b/stdlib/LinearAlgebra/test/dense.jl @@ -22,10 +22,10 @@ Random.seed!(1234323) @testset "for $elty" for elty in (Float32, Float64, ComplexF32, ComplexF64) ainit = convert(Matrix{elty}, ainit) for a in (copy(ainit), view(ainit, 1:n, 1:n)) - @test cond(a,1) ≈ 50.60863783272028 atol=0.5 - @test cond(a,2) ≈ 23.059634761613314 atol=0.5 - @test cond(a,Inf) ≈ 45.12503933120795 atol=0.4 - @test cond(a[:,1:5]) ≈ 5.719500544258695 atol=0.01 + @test cond(a,1) ≈ 855.6103637603965 atol=0.5 + @test cond(a,2) ≈ 570.5296048445405 atol=0.5 + @test cond(a,Inf) ≈ 1210.8340599789594 atol=0.4 + @test cond(a[:,1:5]) ≈ 12.140520859885147 atol=0.01 @test_throws ArgumentError cond(a,3) end end diff --git a/stdlib/LinearAlgebra/test/uniformscaling.jl b/stdlib/LinearAlgebra/test/uniformscaling.jl index c043db07d2eff..360645a6d56cd 100644 --- a/stdlib/LinearAlgebra/test/uniformscaling.jl +++ b/stdlib/LinearAlgebra/test/uniformscaling.jl @@ -141,7 +141,7 @@ end end @testset "arithmetic with Number" begin - α = randn() + α = rand() @test α + I == α + 1 @test I + α == α + 1 @test α - I == α - 1 diff --git a/stdlib/Random/src/Xoshiro.jl b/stdlib/Random/src/Xoshiro.jl index 40da3c5ff1722..6c565401bb754 100644 --- a/stdlib/Random/src/Xoshiro.jl +++ b/stdlib/Random/src/Xoshiro.jl @@ -54,7 +54,7 @@ rng_native_52(::Xoshiro) = UInt64 @inline function rand(rng::Xoshiro, ::SamplerType{UInt64}) s0, s1, s2, s3 = rng.s0, rng.s1, rng.s2, rng.s3 tmp = s0 + s3 - res = tmp << 23 | tmp >> 41 + res = ((tmp << 23) | (tmp >> 41)) + s0 t = s1 << 17 s2 = xor(s2, s0) s3 = xor(s3, s1) diff --git a/stdlib/Random/src/XoshiroSimd.jl b/stdlib/Random/src/XoshiroSimd.jl index e115533bb6fef..9fb03f9572688 100644 --- a/stdlib/Random/src/XoshiroSimd.jl +++ b/stdlib/Random/src/XoshiroSimd.jl @@ -158,7 +158,7 @@ end i = 0 while i+8 <= len - res = _rotl23(_plus(s0,s3)) + res = _plus(_rotl23(_plus(s0,s3)),s0) unsafe_store!(reinterpret(Ptr{UInt64}, dst + i), f(res, T)) t = _shl17(s1) s2 = _xor(s2, s0) @@ -170,7 +170,7 @@ end i += 8 end if i < len - res = _rotl23(_plus(s0,s3)) + res = _plus(_rotl23(_plus(s0,s3)),s0) t = _shl17(s1) s2 = _xor(s2, s0) s3 = _xor(s3, s1) @@ -200,7 +200,7 @@ end i = 0 while i+8 <= len - res = _rotl23(_plus(s0,s3)) + res = _plus(_rotl23(_plus(s0,s3)),s0) shift = 0 while i+8 <= len && shift < 8 resLoc = _and(_lshr(res, shift), 0x0101010101010101) @@ -219,7 +219,7 @@ end end if i < len # we may overgenerate some bytes here, if len mod 64 <= 56 and len mod 8 != 0 - res = _rotl23(_plus(s0,s3)) + res = _plus(_rotl23(_plus(s0,s3)),s0) resLoc = _and(res, 0x0101010101010101) ref = Ref(resLoc) ccall(:memcpy, Ptr{Cvoid}, (Ptr{UInt8}, Ptr{UInt64}, Csize_t), dst+i, ref, len-i) @@ -245,7 +245,7 @@ end i = 0 while i + 8*N <= len - res = _rotl23(_plus(s0,s3)) + res = _plus(_rotl23(_plus(s0,s3)),s0) t = _shl17(s1) s2 = _xor(s2, s0) s3 = _xor(s3, s1) @@ -264,7 +264,7 @@ end msk = ntuple(i->VecElement(0x0101010101010101), Val(N)) i = 0 while i + 64*N <= len - res = _rotl23(_plus(s0,s3)) + res = _plus(_rotl23(_plus(s0,s3)),s0) t = _shl17(s1) s2 = _xor(s2, s0) s3 = _xor(s3, s1) diff --git a/stdlib/SparseArrays/src/sparsematrix.jl b/stdlib/SparseArrays/src/sparsematrix.jl index af5eb4e4ab726..c9a6c8dc98010 100644 --- a/stdlib/SparseArrays/src/sparsematrix.jl +++ b/stdlib/SparseArrays/src/sparsematrix.jl @@ -1647,8 +1647,8 @@ julia> sprand(Bool, 2, 2, 0.5) julia> sprand(Float64, 3, 0.75) 3-element SparseVector{Float64, Int64} with 2 stored entries: - [1] = 0.523355 - [2] = 0.0890391 + [1] = 0.787459 + [2] = 0.544574 ``` """ function sprand(r::AbstractRNG, m::Integer, n::Integer, density::AbstractFloat, rfn::Function, ::Type{T}=eltype(rfn(r, 1))) where T