Skip to content

Commit

Permalink
Merge branch 'master' into jishnub/_zero_missing
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub authored Oct 18, 2024
2 parents d01e1a1 + f1990e2 commit 8dd4751
Show file tree
Hide file tree
Showing 133 changed files with 4,154 additions and 2,491 deletions.
13 changes: 12 additions & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,12 @@ endif

#If nothing is set default to native unless we are cross-compiling
ifeq ($(MARCH)$(MCPU)$(MTUNE)$(JULIA_CPU_TARGET)$(XC_HOST),)
ifeq ($(ARCH),aarch64) #ARM recommends only setting MCPU for AArch64
ifeq ($(ARCH),aarch64)
# ARM recommends only setting MCPU for AArch64
MCPU=native
else ifneq (,$(findstring riscv64,$(ARCH)))
# RISC-V doesn't have a native option
$(error Building for RISC-V requires a specific MARCH to be set))
else
MARCH=native
MTUNE=native
Expand Down Expand Up @@ -995,6 +999,9 @@ endif
ifneq (,$(findstring arm,$(ARCH)))
DIST_ARCH:=arm
endif
ifneq (,$(findstring riscv64,$(ARCH)))
DIST_ARCH:=riscv64
endif

JULIA_BINARYDIST_FILENAME := julia-$(JULIA_COMMIT)-$(DIST_OS)$(DIST_ARCH)
endif
Expand All @@ -1018,8 +1025,12 @@ ifneq ($(MARCH),)
CC += -march=$(MARCH)
CXX += -march=$(MARCH)
FC += -march=$(MARCH)
# On RISC-V, don't forward the MARCH ISA string to JULIA_CPU_TARGET,
# as it's always incompatible with LLVM's CPU target name parser.
ifeq (,$(findstring riscv64,$(ARCH)))
JULIA_CPU_TARGET ?= $(MARCH)
endif
endif

# Set MCPU-specific flags
ifneq ($(MCPU),)
Expand Down
12 changes: 11 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ variables. ([#53742]).
Multi-threading changes
-----------------------

* New types are defined to handle the pattern of code that must run once per process, called
a `OncePerProcess{T}` type, which allows defining a function that should be run exactly once
the first time it is called, and then always return the same result value of type `T`
every subsequent time afterwards. There are also `OncePerThread{T}` and `OncePerTask{T}` types for
similar usage with threads or tasks. ([#TBD])

Build system changes
--------------------

Expand Down Expand Up @@ -139,7 +145,9 @@ Standard library changes
* The number of default BLAS threads now respects process affinity, instead of
using total number of logical threads available on the system ([#55574]).
* A new function `zeroslike` is added that is used to generate the zero elements for matrix-valued banded matrices.
Custom array types may specialize this function to return an appropriate result. ([#55252])
Custom array types may specialize this function to return an appropriate result ([#55252]).
* The matrix multiplication `A * B` calls `matprod_dest(A, B, T::Type)` to generate the destination.
This function is now public ([#55537]).

#### Logging

Expand All @@ -165,6 +173,8 @@ Standard library changes
- the REPL will now warn if it detects a name is being accessed from a module which does not define it (nor has a submodule which defines it),
and for which the name is not public in that module. For example, `map` is defined in Base, and executing `LinearAlgebra.map`
in the REPL will now issue a warning the first time occurs. ([#54872])
- When an object is printed automatically (by being returned in the REPL), its display is now truncated after printing 20 KiB.
This does not affect manual calls to `show`, `print`, and so forth. ([#53959])

#### SuiteSparse

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ and then use the command prompt to change into the resulting julia directory. By
Julia. However, most users should use the [most recent stable version](https://github.com/JuliaLang/julia/releases)
of Julia. You can get this version by running:

git checkout v1.10.5
git checkout v1.11.1

To build the `julia` executable, run `make` from within the julia directory.

Expand Down
1 change: 1 addition & 0 deletions base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ include("essentials.jl")
include("ctypes.jl")
include("gcutils.jl")
include("generator.jl")
include("runtime_internals.jl")
include("reflection.jl")
include("options.jl")

Expand Down
4 changes: 2 additions & 2 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -999,11 +999,11 @@ function setindex!(A::Array{T}, x, i1::Int, i2::Int, I::Int...) where {T}
x = x isa T ? x : convert(T, x)::T
return _setindex!(A, x, i1, i2, I...)
end
function _setindex!(A::Array{T}, x, i1::Int, i2::Int, I::Int...) where {T}
function _setindex!(A::Array{T}, x::T, i1::Int, i2::Int, I::Int...) where {T}
@inline
@_noub_if_noinbounds_meta
@boundscheck checkbounds(A, i1, i2, I...) # generally _to_linear_index requires bounds checking
memoryrefset!(memoryrefnew(A.ref, _to_linear_index(A, i1, i2, I...), false), x isa T ? x : convert(T,x)::T, :not_atomic, false)
memoryrefset!(memoryrefnew(A.ref, _to_linear_index(A, i1, i2, I...), false), x, :not_atomic, false)
return A
end

Expand Down
16 changes: 11 additions & 5 deletions base/arrayshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,12 @@ typeinfo_eltype(typeinfo::Type{<:AbstractArray{T}}) where {T} = eltype(typeinfo)
typeinfo_eltype(typeinfo::Type{<:AbstractDict{K,V}}) where {K,V} = eltype(typeinfo)
typeinfo_eltype(typeinfo::Type{<:AbstractSet{T}}) where {T} = eltype(typeinfo)

# This is a fancy way to make de-specialize a call to `typeinfo_implicit(T)`
# which is unfortunately invalidated by Dates
# (https://github.com/JuliaLang/julia/issues/56080)
#
# This makes the call less efficient, but avoids being invalidated by Dates.
_typeinfo_implicit(@nospecialize(T)) = Base.invoke_in_world(Base.tls_world_age(), typeinfo_implicit, T)::Bool

# types that can be parsed back accurately from their un-decorated representations
function typeinfo_implicit(@nospecialize(T))
Expand All @@ -553,9 +559,9 @@ function typeinfo_implicit(@nospecialize(T))
return true
end
return isconcretetype(T) &&
((T <: Array && typeinfo_implicit(eltype(T))) ||
((T <: Tuple || T <: NamedTuple || T <: Pair) && all(typeinfo_implicit, fieldtypes(T))) ||
(T <: AbstractDict && typeinfo_implicit(keytype(T)) && typeinfo_implicit(valtype(T))))
((T <: Array && _typeinfo_implicit(eltype(T))) ||
((T <: Tuple || T <: NamedTuple || T <: Pair) && all(_typeinfo_implicit, fieldtypes(T))) ||
(T <: AbstractDict && _typeinfo_implicit(keytype(T)) && _typeinfo_implicit(valtype(T))))
end

# X not constrained, can be any iterable (cf. show_vector)
Expand All @@ -573,7 +579,7 @@ function typeinfo_prefix(io::IO, X)
if X isa AbstractDict
if eltype_X == eltype_ctx
sprint(show_type_name, typeof(X).name; context=io), false
elseif !isempty(X) && typeinfo_implicit(keytype(X)) && typeinfo_implicit(valtype(X))
elseif !isempty(X) && _typeinfo_implicit(keytype(X)) && _typeinfo_implicit(valtype(X))
sprint(show_type_name, typeof(X).name; context=io), true
else
sprint(print, typeof(X); context=io), false
Expand All @@ -582,7 +588,7 @@ function typeinfo_prefix(io::IO, X)
# Types hard-coded here are those which are created by default for a given syntax
if eltype_X == eltype_ctx
"", false
elseif !isempty(X) && typeinfo_implicit(eltype_X)
elseif !isempty(X) && _typeinfo_implicit(eltype_X)
"", true
elseif print_without_params(eltype_X)
sprint(show_type_name, unwrap_unionall(eltype_X).name; context=io), false # Print "Array" rather than "Array{T,N}"
Expand Down
5 changes: 4 additions & 1 deletion base/binaryplatforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ const arch_mapping = Dict(
"armv7l" => "arm(v7l)?", # if we just see `arm-linux-gnueabihf`, we assume it's `armv7l`
"armv6l" => "armv6l",
"powerpc64le" => "p(ower)?pc64le",
"riscv64" => "riscv64",
"riscv64" => "(rv64|riscv64)",
)
# Keep this in sync with `CPUID.ISAs_by_family`
# These are the CPUID side of the microarchitectures targeted by GCC flags in BinaryBuilder.jl
Expand Down Expand Up @@ -631,6 +631,9 @@ const arch_march_isa_mapping = let
"a64fx" => get_set("aarch64", "a64fx"),
"apple_m1" => get_set("aarch64", "apple_m1"),
],
"riscv64" => [
"riscv64" => get_set("riscv64", "riscv64")
],
"powerpc64le" => [
"power8" => get_set("powerpc64le", "power8"),
],
Expand Down
5 changes: 3 additions & 2 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2681,7 +2681,7 @@ function abstract_call(interp::AbstractInterpreter, arginfo::ArgInfo, sv::Infere
end
si = StmtInfo(!unused)
call = abstract_call(interp, arginfo, si, sv)::Future
Future{Nothing}(call, interp, sv) do call, interp, sv
Future{Any}(call, interp, sv) do call, interp, sv
# this only is needed for the side-effect, sequenced before any task tries to consume the return value,
# which this will do even without returning this Future
sv.stmt_info[sv.currpc] = call.info
Expand Down Expand Up @@ -2833,7 +2833,7 @@ function abstract_eval_new_opaque_closure(interp::AbstractInterpreter, e::Expr,
pushfirst!(argtypes, rt.env)
callinfo = abstract_call_opaque_closure(interp, rt,
ArgInfo(nothing, argtypes), StmtInfo(true), sv, #=check=#false)::Future
Future{Nothing}(callinfo, interp, sv) do callinfo, interp, sv
Future{Any}(callinfo, interp, sv) do callinfo, interp, sv
sv.stmt_info[sv.currpc] = OpaqueClosureCreateInfo(callinfo)
nothing
end
Expand Down Expand Up @@ -3775,6 +3775,7 @@ function typeinf(interp::AbstractInterpreter, frame::InferenceState)
takeprev = 0
while takenext >= frame.frameid
callee = takenext == 0 ? frame : callstack[takenext]::InferenceState
interp = callee.interp
if !isempty(callstack)
if length(callstack) - frame.frameid >= minwarn
topmethod = callstack[1].linfo
Expand Down
4 changes: 4 additions & 0 deletions base/compiler/cicache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ end

function setindex!(cache::InternalCodeCache, ci::CodeInstance, mi::MethodInstance)
@assert ci.owner === cache.owner
m = mi.def
if isa(m, Method) && m.module != Core
ccall(:jl_push_newly_inferred, Cvoid, (Any,), ci)
end
ccall(:jl_mi_cache_insert, Cvoid, (Any, Any), mi, ci)
return cache
end
Expand Down
43 changes: 1 addition & 42 deletions base/compiler/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,53 +38,12 @@ convert(::Type{T}, x::T) where {T} = x
# Note that `@assume_effects` is available only after loading namedtuple.jl.
abstract type MethodTableView end
abstract type AbstractInterpreter end
struct EffectsOverride
consistent::Bool
effect_free::Bool
nothrow::Bool
terminates_globally::Bool
terminates_locally::Bool
notaskstate::Bool
inaccessiblememonly::Bool
noub::Bool
noub_if_noinbounds::Bool
consistent_overlay::Bool
nortcall::Bool
end
function EffectsOverride(
override::EffectsOverride =
EffectsOverride(false, false, false, false, false, false, false, false, false, false, false);
consistent::Bool = override.consistent,
effect_free::Bool = override.effect_free,
nothrow::Bool = override.nothrow,
terminates_globally::Bool = override.terminates_globally,
terminates_locally::Bool = override.terminates_locally,
notaskstate::Bool = override.notaskstate,
inaccessiblememonly::Bool = override.inaccessiblememonly,
noub::Bool = override.noub,
noub_if_noinbounds::Bool = override.noub_if_noinbounds,
consistent_overlay::Bool = override.consistent_overlay,
nortcall::Bool = override.nortcall)
return EffectsOverride(
consistent,
effect_free,
nothrow,
terminates_globally,
terminates_locally,
notaskstate,
inaccessiblememonly,
noub,
noub_if_noinbounds,
consistent_overlay,
nortcall)
end
const NUM_EFFECTS_OVERRIDES = 11 # sync with julia.h

# essential files and libraries
include("essentials.jl")
include("ctypes.jl")
include("generator.jl")
include("reflection.jl")
include("runtime_internals.jl")
include("options.jl")

ntuple(f, ::Val{0}) = ()
Expand Down
31 changes: 0 additions & 31 deletions base/compiler/effects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -355,36 +355,5 @@ function decode_effects(e::UInt32)
_Bool((e >> 14) & 0x01))
end

function encode_effects_override(eo::EffectsOverride)
e = 0x0000
eo.consistent && (e |= (0x0001 << 0))
eo.effect_free && (e |= (0x0001 << 1))
eo.nothrow && (e |= (0x0001 << 2))
eo.terminates_globally && (e |= (0x0001 << 3))
eo.terminates_locally && (e |= (0x0001 << 4))
eo.notaskstate && (e |= (0x0001 << 5))
eo.inaccessiblememonly && (e |= (0x0001 << 6))
eo.noub && (e |= (0x0001 << 7))
eo.noub_if_noinbounds && (e |= (0x0001 << 8))
eo.consistent_overlay && (e |= (0x0001 << 9))
eo.nortcall && (e |= (0x0001 << 10))
return e
end

function decode_effects_override(e::UInt16)
return EffectsOverride(
!iszero(e & (0x0001 << 0)),
!iszero(e & (0x0001 << 1)),
!iszero(e & (0x0001 << 2)),
!iszero(e & (0x0001 << 3)),
!iszero(e & (0x0001 << 4)),
!iszero(e & (0x0001 << 5)),
!iszero(e & (0x0001 << 6)),
!iszero(e & (0x0001 << 7)),
!iszero(e & (0x0001 << 8)),
!iszero(e & (0x0001 << 9)),
!iszero(e & (0x0001 << 10)))
end

decode_statement_effects_override(ssaflag::UInt32) =
decode_effects_override(UInt16((ssaflag >> NUM_IR_FLAGS) & (1 << NUM_EFFECTS_OVERRIDES - 1)))
36 changes: 25 additions & 11 deletions base/compiler/inferencestate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1128,24 +1128,35 @@ end
"""
Future{T}
Delayed return value for a value of type `T`, similar to RefValue{T}, but
explicitly represents completed as a `Bool` rather than as `isdefined`.
Set once with `f[] = v` and accessed with `f[]` afterwards.
Assign-once delayed return value for a value of type `T`, similar to RefValue{T}.
Can be constructed in one of three ways:
Can also be constructed with the `completed` flag value and a closure to
produce `x`, as well as the additional arguments to avoid always capturing the
same couple of values.
1. With an immediate as `Future{T}(val)`
2. As an assign-once storage location with `Future{T}()`. Assigned (once) using `f[] = val`.
3. As a delayed computation with `Future{T}(callback, dep, interp, sv)` to have
`sv` arrange to call the `callback` with the result of `dep` when it is ready.
Use `isready` to check if the value is ready, and `getindex` to get the value.
"""
struct Future{T}
later::Union{Nothing,RefValue{T}}
now::Union{Nothing,T}
Future{T}() where {T} = new{T}(RefValue{T}(), nothing)
function Future{T}() where {T}
later = RefValue{T}()
@assert !isassigned(later) "Future{T}() is not allowed for inlinealloc T"
new{T}(later, nothing)
end
Future{T}(x) where {T} = new{T}(nothing, x)
Future(x::T) where {T} = new{T}(nothing, x)
end
isready(f::Future) = f.later === nothing
isready(f::Future) = f.later === nothing || isassigned(f.later)
getindex(f::Future{T}) where {T} = (later = f.later; later === nothing ? f.now::T : later[])
setindex!(f::Future, v) = something(f.later)[] = v
function setindex!(f::Future, v)
later = something(f.later)
@assert !isassigned(later)
later[] = v
return f
end
convert(::Type{Future{T}}, x) where {T} = Future{T}(x) # support return type conversion
convert(::Type{Future{T}}, x::Future) where {T} = x::Future{T}
function Future{T}(f, immediate::Bool, interp::AbstractInterpreter, sv::AbsIntState) where {T}
Expand Down Expand Up @@ -1176,7 +1187,6 @@ function Future{T}(f, prev::Future{S}, interp::AbstractInterpreter, sv::AbsIntSt
end
end


"""
doworkloop(args...)
Expand All @@ -1189,12 +1199,16 @@ Each task will be run repeatedly when returning `false`, until it returns `true`
function doworkloop(interp::AbstractInterpreter, sv::AbsIntState)
tasks = sv.tasks
prev = length(tasks)
prevcallstack = length(sv.callstack)
prev == 0 && return false
task = pop!(tasks)
completed = task(interp, sv)
tasks = sv.tasks # allow dropping gc root over the previous call
completed isa Bool || throw(TypeError(:return, "", Bool, task)) # print the task on failure as part of the error message, instead of just "@ workloop:line"
completed || push!(tasks, task)
if !completed
@assert (length(tasks) >= prev || length(sv.callstack) > prevcallstack) "Task did not complete, but also did not create any child tasks"
push!(tasks, task)
end
# efficient post-order visitor: items pushed are executed in reverse post order such
# that later items are executed before earlier ones, but are fully executed
# (including any dependencies scheduled by them) before going on to the next item
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ function refine_effects!(interp::AbstractInterpreter, opt::OptimizationState, sv
if !is_effect_free(sv.result.ipo_effects) && sv.all_effect_free && !isempty(sv.ea_analysis_pending)
ir = sv.ir
nargs = Int(opt.src.nargs)
estate = EscapeAnalysis.analyze_escapes(ir, nargs, optimizer_lattice(interp), GetNativeEscapeCache(interp))
estate = EscapeAnalysis.analyze_escapes(ir, nargs, optimizer_lattice(interp), get_escape_cache(interp))
argescapes = EscapeAnalysis.ArgEscapeCache(estate)
stack_analysis_result!(sv.result, argescapes)
validate_mutable_arg_escapes!(estate, sv)
Expand Down
Loading

0 comments on commit 8dd4751

Please sign in to comment.