-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Resolve artifact ambiguities using shortest match #48749
Conversation
Pkg.jl test failure fixed in: JuliaLang/Pkg.jl#3384 |
Would this solve ziotom78/Ducc0.jl#4 with JuliaRegistries/General#78531? |
Yes, it would allow a default match. For the particular case of using Base.BinaryPlatforms, Base.BinaryPlatforms.CPUID, Test
# Build mapping of march strings (assuming all march names are unique across all archs)
# to sets of strings they are compatible with.
const march_compatibility = Dict{String,Set{String}}()
for (arch, marchs) in CPUID.ISAs_by_family
for (march, isa) in marchs
march_compatibility[march] = Set{String}()
for (m, i) in marchs
if i <= isa
push!(march_compatibility[march], m)
end
end
end
end
function compare_march(a::String, b::String, a_requested::Bool, b_requested::Bool)
# If both a and b requested, fall back to simple equality
if a_requested && b_requested
return a == b
end
# Otherwise, say that the comparison matches as long as the two
if a_requested
return a ∈ keys(march_compatibility) && b ∈ march_compatibility[a]
else
return b ∈ keys(march_compatibility) && a ∈ march_compatibility[b]
end
end Here's a simple test suite: host = HostPlatform()
host["march"] = "haswell"
Base.BinaryPlatforms.set_compare_strategy!(host, "march", compare_march)
p = Platform(arch(host), os(host); :march => "skylake")
@test !platforms_match(host, p)
@test !platforms_match(p, host)
p = Platform(arch(host), os(host); :march => "haswell")
@test platforms_match(host, p)
@test platforms_match(p, host)
p = Platform(arch(host), os(host); :march => "nehalem")
@test platforms_match(host, p)
@test platforms_match(p, host)
p = Platform(arch(host), os(host); :march => "x86_64")
@test platforms_match(host, p)
@test platforms_match(p, host)
p = Platform(arch(host), os(host); :march => "armv7l")
@test !platforms_match(host, p)
@test !platforms_match(p, host) Note to self; we should change the march names generated by BB to be the same as in |
This is a temporary workaround until JuliaLang/julia#48749 is resolved.
Bump |
a275169
to
4ce024f
Compare
This changes the behavior of `select_platform()` to resolve ambiguities using a two-step process. Previously, we would simply sort the resultant triplets and return the last one (so as to provide asemi- arbitrary stability, and also to prefer higher version numbers over lower version numbers in tags). However, with the proliferation of tags (and especially the new `sanitize=memory` tags) we need a way to exclude these "extra" tags when our `HostPlatform()` does not have them. This new matching algorithm excludes candidates from matching with the platform if there are other candidates with fewer total tags. This results in a "simplest match first" behavior, which better represents the intent of tags in the first place.
4ce024f
to
99938fc
Compare
I feel like this is fundamentally flawed. Edit: for the benefit of future readers, this PR was meant to address #42299 (comment) |
This changes the behavior of
select_platform()
to resolve ambiguities using a two-step process. Previously, we would simply sort the resultant triplets and return the last one (so as to provide asemi- arbitrary stability, and also to prefer higher version numbers over lower version numbers in tags). However, with the proliferation of tags (and especially the newsanitize=memory
tags) we need a way to exclude these "extra" tags when ourHostPlatform()
does not have them.This new matching algorithm excludes candidates from matching with the platform if there are other candidates with fewer total tags. This results in a "simplest match first" behavior, which better represents the intent of tags in the first place.