-
Notifications
You must be signed in to change notification settings - Fork 8
Add Preference to disable runtime invalidation #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
723446a
bbd20e1
c118075
bddfae2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ jobs: | |
| fail-fast: false | ||
| matrix: | ||
| version: | ||
| - '1.5' | ||
| - '1.10' | ||
| - '1' | ||
| - 'nightly' | ||
| os: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,17 +39,22 @@ function set_features!() | |
| end | ||
| Libc.free(features_cstring) | ||
| end | ||
| set_features!() | ||
|
|
||
|
|
||
| if build_cpu_target == "native" | ||
| set_features!() | ||
| end | ||
|
|
||
| function reset_features!() | ||
| features, features_cstring = feature_string() | ||
| for ext ∈ features | ||
| feature, has = process_feature(ext) | ||
| if _has_feature(feature) ≠ has | ||
| @debug "Defining $(has ? "presence" : "absense") of feature $feature." | ||
| set_feature(feature, has) | ||
| if allow_eval | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code doesn't execute if there's a preference right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Depends on which preference you mean Are you saying you don't think this guard is necessary? |
||
| @debug "Defining $(has ? "presence" : "absense") of feature $feature." | ||
| set_feature(feature, has) | ||
| else | ||
| @warn "Runtime invalidation was disabled, but the CPU info is out-of-date.\nWill continue with incorrect CPU feature flag: $ext." | ||
topolarity marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| end | ||
| end | ||
| end | ||
| Libc.free(features_cstring) | ||
|
|
@@ -58,8 +63,16 @@ end | |
| register_size(::Type{T}) where {T} = register_size() | ||
| register_size(::Type{T}) where {T<:Union{Signed,Unsigned}} = simd_integer_register_size() | ||
|
|
||
| function define_cpu_name() | ||
| function redefine_cpu_name() | ||
| cpu = QuoteNode(Symbol(get_cpu_name())) | ||
| @eval cpu_name() = Val{$cpu}() | ||
| if allow_eval | ||
| @eval cpu_name() = Val{$cpu}() | ||
| else | ||
| @warn "Runtime invalidation was disabled, but the CPU info is out-of-date.\nWill continue with incorrect CPU name (from build time)." | ||
| end | ||
| end | ||
|
|
||
| let _cpu = QuoteNode(Symbol(build_cpu_target == "native" ? | ||
| get_cpu_name() : build_cpu_target)) | ||
| @eval cpu_name() = Val{$_cpu}() | ||
| end | ||
| define_cpu_name() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,18 +32,26 @@ fast_int64_to_double() = has_feature(Val(:x86_64_avx512dq)) | |
|
|
||
| fast_half() = False() | ||
|
|
||
| @noinline function setfeaturefalse(s) | ||
| @inline function setfeaturefalse(s) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why the inlining switch?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was to improve inferrability - |
||
| if has_feature(Val(s)) === True() | ||
| @eval has_feature(::Val{$(QuoteNode(s))}) = False() | ||
| if allow_eval | ||
| @eval has_feature(::Val{$(QuoteNode(s))}) = False() | ||
| else | ||
| @warn "Runtime invalidation was disabled, but the CPU info is out-of-date.\nWill continue with incorrect CPU feature flag: $s." | ||
| end | ||
| end | ||
| end | ||
| @noinline function setfeaturetrue(s) | ||
| @inline function setfeaturetrue(s) | ||
| if has_feature(Val(s)) === False() | ||
| @eval has_feature(::Val{$(QuoteNode(s))}) = True() | ||
| if allow_eval | ||
| @eval has_feature(::Val{$(QuoteNode(s))}) = True() | ||
| else | ||
| @warn "Runtime invalidation was disabled, but the CPU info is out-of-date.\nWill continue with incorrect CPU feature flag: $s." | ||
| end | ||
| end | ||
| end | ||
|
|
||
| function make_generic(target) | ||
| function make_generic_x86(target) | ||
| if occursin("tigerlake", target) || occursin("znver4", target) || occursin("sapphirerapids", target) | ||
| # most feature-complete architectures we use | ||
| setfeaturetrue(:x86_64_avx512ifma) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not to check that
--trimis enabled in JLOptions ?everyone who will use it with trim will have to find out this culprit themself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main thinking is that this preference is usable by more than just JuliaC.jl, since some users may wish to be opt-in to error / warn on invalidation storms from this package. JuliaC.jl can set this preference automatically, so the end-user experience is the same.
Also technically checking
JLOptionsat pre-compilation time won't detect--trimproperly, but something like JuliaLang/JuliaC.jl#31 would work