Skip to content

Commit

Permalink
Merge branch 'master' into mg/update-suite-sparse
Browse files Browse the repository at this point in the history
  • Loading branch information
ViralBShah authored Jan 3, 2024
2 parents 7d718ca + 3279a1f commit 832c882
Show file tree
Hide file tree
Showing 17 changed files with 188 additions and 43 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ Standard library changes
* Structured matrices now retain either the axes of the parent (for `Symmetric`/`Hermitian`/`AbstractTriangular`/`UpperHessenberg`), or that of the principal diagonal (for banded matrices) ([#52480]).
* `bunchkaufman` and `bunchkaufman!` now work for any `AbstractFloat`, `Rational` and their complex variants. `bunchkaufman` now supports `Integer` types, by making an internal conversion to `Rational{BigInt}`. Added new function `inertia` that computes the inertia of the diagonal factor given by the `BunchKaufman` factorization object of a real symmetric or Hermitian matrix. For complex symmetric matrices, `inertia` only computes the number of zero eigenvalues of the diagonal factor ([#51487]).

#### Logging
* New `@create_log_macro` macro for creating new log macros like `@info`, `@warn` etc. For instance
`@create_log_macro MyLog 1500 :magenta` will create `@mylog` to be used like `@mylog "hello"` which
will show as `┌ MyLog: hello` etc. ([#52196])

#### Printf

#### Profile
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,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.9.4
git checkout v1.10.0

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

Expand Down
9 changes: 5 additions & 4 deletions THIRDPARTY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The Julia language is licensed under the MIT License (see [LICENSE.md](./LICENSE.md) ). The "language" consists
of the compiler (the contents of src/), most of the standard library (base/),
of the compiler (the contents of `src/`), most of the standard library (`base/` and `stdlib/`),
and some utilities (most of the rest of the files in this repository). See below
for exceptions.

Expand All @@ -26,7 +26,8 @@ own licenses:

and optionally:

- [ITTAPI](https://github.com/intel/ittapi/blob/master/LICENSES/BSD-3-Clause.txt) [BSD-3]
- [LibTracyClient](https://github.com/wolfpld/tracy/blob/master/LICENSE) [BSD-3]
- [ITTAPI](https://github.com/intel/ittapi/tree/master/LICENSES) [BSD-3 AND GPL2]

Julia's `stdlib` uses the following external libraries, which have their own licenses:

Expand All @@ -47,8 +48,8 @@ Julia's `stdlib` uses the following external libraries, which have their own lic

Julia's build process uses the following external tools:

- [PATCHELF](https://nixos.org/patchelf.html)
- [OBJCONV](https://www.agner.org/optimize/#objconv)
- [PATCHELF](https://github.com/NixOS/patchelf/blob/master/COPYING) [GPL3]
- [OBJCONV](https://www.agner.org/optimize/#objconv) [GPL3]
- [LIBWHICH](https://github.com/vtjnash/libwhich/blob/master/LICENSE) [MIT]

Julia bundles the following external programs and libraries:
Expand Down
2 changes: 2 additions & 0 deletions base/div.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ See also [`fld`](@ref) and [`cld`](@ref), which are special cases of this functi
# Examples:
```jldoctest
julia> div(4, 3, RoundToZero) # Matches div(4, 3)
1
julia> div(4, 3, RoundDown) # Matches fld(4, 3)
1
julia> div(4, 3, RoundUp) # Matches cld(4, 3)
Expand Down
7 changes: 4 additions & 3 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2568,7 +2568,7 @@ This can be used to reduce package load times. Cache files are stored in
`DEPOT_PATH[1]/compiled`. See [Module initialization and precompilation](@ref)
for important notes.
"""
function compilecache(pkg::PkgId, internal_stderr::IO = stderr, internal_stdout::IO = stdout; reasons::Union{Dict{String,Int},Nothing}=nothing)
function compilecache(pkg::PkgId, internal_stderr::IO = stderr, internal_stdout::IO = stdout; reasons::Union{Dict{String,Int},Nothing}=Dict{String,Int}())
@nospecialize internal_stderr internal_stdout
path = locate_package(pkg)
path === nothing && throw(ArgumentError("$pkg not found during precompilation"))
Expand All @@ -2578,7 +2578,7 @@ end
const MAX_NUM_PRECOMPILE_FILES = Ref(10)

function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, internal_stdout::IO = stdout,
keep_loaded_modules::Bool = true; reasons::Union{Dict{String,Int},Nothing}=nothing)
keep_loaded_modules::Bool = true; reasons::Union{Dict{String,Int},Nothing}=Dict{String,Int}())

@nospecialize internal_stderr internal_stdout
# decide where to put the resulting cache file
Expand Down Expand Up @@ -3320,11 +3320,12 @@ function list_reasons(reasons::Dict{String,Int})
isempty(reasons) && return ""
return "(cache misses: $(join(("$k ($v)" for (k,v) in reasons), ", ")))"
end
list_reasons(::Nothing) = ""

# returns true if it "cachefile.ji" is stale relative to "modpath.jl" and build_id for modkey
# otherwise returns the list of dependencies to also check
@constprop :none function stale_cachefile(modpath::String, cachefile::String; ignore_loaded::Bool = false, reasons=nothing)
return stale_cachefile(PkgId(""), UInt128(0), modpath, cachefile; ignore_loaded)
return stale_cachefile(PkgId(""), UInt128(0), modpath, cachefile; ignore_loaded, reasons)
end
@constprop :none function stale_cachefile(modkey::PkgId, build_id::UInt128, modpath::String, cachefile::String;
ignore_loaded::Bool = false, reasons::Union{Dict{String,Int},Nothing}=nothing)
Expand Down
2 changes: 2 additions & 0 deletions base/lock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ available.
When this function returns, the `lock` has been released, so the caller should
not attempt to `unlock` it.
See also: [`@lock`](@ref).
!!! compat "Julia 1.7"
Using a [`Channel`](@ref) as the second argument requires Julia 1.7 or later.
"""
Expand Down
18 changes: 11 additions & 7 deletions base/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,18 @@ const AboveMaxLevel = LogLevel( 1000001)
# Global log limiting mechanism for super fast but inflexible global log limiting.
const _min_enabled_level = Ref{LogLevel}(Debug)

# stored as LogLevel => (name, color)
const custom_log_levels = Dict{LogLevel,Tuple{Symbol,Union{Symbol,Int}}}()

function show(io::IO, level::LogLevel)
if level == BelowMinLevel print(io, "BelowMinLevel")
elseif level == Debug print(io, "Debug")
elseif level == Info print(io, "Info")
elseif level == Warn print(io, "Warn")
elseif level == Error print(io, "Error")
elseif level == AboveMaxLevel print(io, "AboveMaxLevel")
else print(io, "LogLevel($(level.level))")
if haskey(custom_log_levels, level) print(io, custom_log_levels[level][1])
elseif level == BelowMinLevel print(io, "BelowMinLevel")
elseif level == Debug print(io, "Debug")
elseif level == Info print(io, "Info")
elseif level == Warn print(io, "Warn")
elseif level == Error print(io, "Error")
elseif level == AboveMaxLevel print(io, "AboveMaxLevel")
else print(io, "LogLevel($(level.level))")
end
end

Expand Down
2 changes: 2 additions & 0 deletions doc/src/base/math.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ Base.fma
Base.muladd
Base.inv(::Number)
Base.div
Base.div(::Any, ::Any, ::RoundingMode)
Base.fld
Base.cld
Base.mod
Base.rem
Base.rem(::Any, ::Any, ::RoundingMode)
Base.rem2pi
Base.Math.mod2pi
Base.divrem
Expand Down
36 changes: 36 additions & 0 deletions julia.spdx.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,32 @@
"copyrightText": "Copyright © 2014-2019 by Steven G. Johnson, Jiahao Chen, Tony Kelman, Jonas Fonseca, and other contributors listed in the git history.",
"summary": "utf8proc is a small, clean C library that provides Unicode normalization, case-folding, and other operations for data in the UTF-8 encoding."
},
{
"name": "LibTracyClient",
"SPDXID": "SPDXRef-LibTracyClient",
"downloadLocation": "git+https://github.com/wolfpld/tracy.git",
"filesAnalyzed": false,
"homepage": "https://github.com/wolfpld/tracy",
"sourceInfo": "The git hash of the version in use can be found in the file deps/libtracyclient.version",
"licenseConcluded": "BSD-3-Clause",
"licenseDeclared": "BSD-3-Clause",
"copyrightText": "Copyright (c) 2017-2024, Bartosz Taudul <[email protected]>",
"summary": "A real time, nanosecond resolution, remote telemetry, hybrid frame and sampling profiler for games and other applications.",
"comment": "LibTracyClient is an optional dependency that is not built by default"
},
{
"name": "ittapi",
"SPDXID": "SPDXRef-ittapi",
"downloadLocation": "git+https://github.com/intel/ittapi.git",
"filesAnalyzed": false,
"homepage": "https://github.com/intel/ittapi",
"sourceInfo": "The git hash of the version in use can be found in the file deps/ittapi.version",
"licenseConcluded": "BSD-3-Clause AND GPL-2.0-only",
"licenseDeclared": "BSD-3-Clause AND GPL-2.0-only",
"copyrightText": "Copyright (c) 2019 Intel Corporation",
"summary": "The Instrumentation and Tracing Technology (ITT) API enables your application to generate and control the collection of trace data during its execution across different Intel tools.",
"comment": "ITTAPI is an optional dependency that is not built by default"
},
{
"name": "7-Zip",
"SPDXID": "SPDXRef-7zip",
Expand Down Expand Up @@ -581,6 +607,16 @@
"relationshipType": "BUILD_DEPENDENCY_OF",
"relatedSpdxElement": "SPDXRef-JuliaMain"
},
{
"spdxElementId": "SPDXRef-LibTracyClient",
"relationshipType": "OPTIONAL_DEPENDENCY_OF",
"relatedSpdxElement": "SPDXRef-JuliaMain"
},
{
"spdxElementId": "SPDXRef-ittapi",
"relationshipType": "OPTIONAL_DEPENDENCY_OF",
"relatedSpdxElement": "SPDXRef-JuliaMain"
},
{
"spdxElementId": "SPDXRef-7zip",
"relationshipType": "RUNTIME_DEPENDENCY_OF",
Expand Down
29 changes: 14 additions & 15 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3428,8 +3428,7 @@ f(x) = yt(x)
(define (type-for-closure-parameterized name P names fields types super)
(let ((n (length P))
(s (make-ssavalue)))
`((thunk
(lambda ()
`((thunk ,(linearize `(lambda ()
(() () 0 ())
(block (global ,name) (const ,name)
,@(map (lambda (p n) `(= ,p (call (core TypeVar) ',n (core Any)))) P names)
Expand All @@ -3440,22 +3439,22 @@ f(x) = yt(x)
(call (core _setsuper!) ,s ,super)
(= (outerref ,name) ,s)
(call (core _typebody!) ,s (call (core svec) ,@types))
(return (null))))))))
(return (null)))))))))

(define (type-for-closure name fields super)
(let ((s (make-ssavalue)))
`((thunk (lambda ()
(() () 0 ())
(block (global ,name) (const ,name)
(= ,s (call (core _structtype) (thismodule) (inert ,name) (call (core svec))
(call (core svec) ,@(map quotify fields))
(call (core svec))
(false) ,(length fields)))
(call (core _setsuper!) ,s ,super)
(= (outerref ,name) ,s)
(call (core _typebody!) ,s
(call (core svec) ,@(map (lambda (v) '(core Box)) fields)))
(return (null))))))))
`((thunk ,(linearize `(lambda ()
(() () 0 ())
(block (global ,name) (const ,name)
(= ,s (call (core _structtype) (thismodule) (inert ,name) (call (core svec))
(call (core svec) ,@(map quotify fields))
(call (core svec))
(false) ,(length fields)))
(call (core _setsuper!) ,s ,super)
(= (outerref ,name) ,s)
(call (core _typebody!) ,s
(call (core svec) ,@(map (lambda (v) '(core Box)) fields)))
(return (null)))))))))

;; better versions of above, but they get handled wrong in many places
;; need to fix that in order to handle #265 fully (and use the definitions)
Expand Down
14 changes: 13 additions & 1 deletion stdlib/Logging/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ automatically extracted. Let's examine the user-defined data first:
* The *log level* is a broad category for the message that is used for early
filtering. There are several standard levels of type [`LogLevel`](@ref);
user-defined levels are also possible.
Each is distinct in purpose:
Each built-in log level is distinct in purpose:
- [`Logging.Debug`](@ref) (log level -1000) is information intended for the developer of
the program. These events are disabled by default.
- [`Logging.Info`](@ref) (log level 0) is for general information to the user.
Expand All @@ -70,6 +70,17 @@ automatically extracted. Let's examine the user-defined data first:
Often this log-level is unneeded as throwing an exception can convey
all the required information.

You can create logging macros for custom log levels. For instance:
```julia-repl
julia> using Logging
julia> @create_log_macro MyLog 200 :magenta
@mylog (macro with 1 method)
julia> @mylog "hello"
[ MyLog: hello
```
* The *message* is an object describing the event. By convention
`AbstractString`s passed as messages are assumed to be in markdown format.
Other types will be displayed using `print(io, obj)` or `string(obj)` for
Expand Down Expand Up @@ -298,6 +309,7 @@ Logging.Debug
Logging.Info
Logging.Warn
Logging.Error
Logging.@create_log_macro
```

### [Processing events with AbstractLogger](@id AbstractLogger-interface)
Expand Down
1 change: 1 addition & 0 deletions stdlib/Logging/src/ConsoleLogger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ end
showvalue(io, ex::Exception) = showerror(io, ex)

function default_logcolor(level::LogLevel)
level in keys(custom_log_levels) ? custom_log_levels[level][2] :
level < Info ? Base.debug_color() :
level < Warn ? Base.info_color() :
level < Error ? Base.warn_color() :
Expand Down
37 changes: 37 additions & 0 deletions stdlib/Logging/src/Logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ for sym in [
Symbol("@warn"),
Symbol("@error"),
Symbol("@logmsg"),
:custom_log_levels,
:with_logger,
:current_logger,
:global_logger,
Expand All @@ -29,6 +30,41 @@ for sym in [
@eval const $sym = Base.CoreLogging.$sym
end

"""
@create_log_macro(name::Symbol, level::Int, color::Union{Int,Symbol})
Creates a custom log macro like `@info`, `@warn` etc. with a given `name`, `level` and
`color`. The macro created is named with the lowercase form of `name` but the given form
is used for the printing.
The available color keys can be seen by typing `Base.text_colors` in the help mode of the REPL
```julia-repl
julia> @create_log_macro(:MyLog, 200, :magenta)
@mylog (macro with 1 method)
julia> @mylog "hello"
[ MyLog: hello
```
"""
macro create_log_macro(name, level, color)
macro_name = Symbol(lowercase(string(name)))
macro_string = QuoteNode(name)
loglevel = LogLevel(level)
if loglevel in (BelowMinLevel, Debug, Info, Warn, Error, AboveMaxLevel)
throw(ArgumentError("Cannot use the same log level as a built in log macro"))
end
if haskey(custom_log_levels, loglevel)
throw(ArgumentError("Custom log macro already exists for given log level"))
end
quote
$(custom_log_levels)[$(esc(loglevel))] = ($(macro_string), $(esc(color)))
macro $(esc(macro_name))(exs...)
$(Base.CoreLogging.logmsg_code)(($(Base.CoreLogging.@_sourceinfo))..., $(esc(loglevel)), exs...)
end
end
end

# LogLevel aliases (re-)documented here (JuliaLang/julia#40978)
"""
Debug
Expand Down Expand Up @@ -67,6 +103,7 @@ export
@warn,
@error,
@logmsg,
@create_log_macro,
with_logger,
current_logger,
global_logger,
Expand Down
20 changes: 14 additions & 6 deletions stdlib/Logging/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import Logging: min_enabled_level, shouldlog, handle_message
@noinline func1() = backtrace()

# see "custom log macro" testset
CustomLog = LogLevel(-500)
macro customlog(exs...) Base.CoreLogging.logmsg_code((Base.CoreLogging.@_sourceinfo)..., esc(CustomLog), exs...) end
@create_log_macro CustomLog1 -500 :magenta
@create_log_macro CustomLog2 1500 1

@testset "Logging" begin

Expand Down Expand Up @@ -280,16 +280,24 @@ end
end

@testset "custom log macro" begin
@test_logs (CustomLog, "a") min_level=CustomLog @customlog "a"
llevel = LogLevel(-500)

@test_logs (llevel, "foo") min_level=llevel @customlog1 "foo"

buf = IOBuffer()
io = IOContext(buf, :displaysize=>(30,80), :color=>false)
logger = ConsoleLogger(io, CustomLog)
logger = ConsoleLogger(io, llevel)

with_logger(logger) do
@customlog1 "foo"
end
@test occursin("CustomLog1: foo", String(take!(buf)))


with_logger(logger) do
@customlog "a"
@customlog2 "hello"
end
@test occursin("LogLevel(-500): a", String(take!(buf)))
@test occursin("CustomLog2: hello", String(take!(buf)))
end

end
Loading

0 comments on commit 832c882

Please sign in to comment.