Skip to content
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

return architecture levels for micromamba #2921

Merged
merged 6 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion libmamba/src/core/virtual_packages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,33 @@ namespace mamba
return res;
}

std::string get_archspec_x86_64()
{
#if (defined(__GNUC__) || defined(__clang__)) && __x86_64__
/* if (__builtin_cpu_supports ("x86-64-v4")) */
if (__builtin_cpu_supports("avx512f") && __builtin_cpu_supports("avx512bw")
&& __builtin_cpu_supports("avx512cd") && __builtin_cpu_supports("avx512dq")
&& __builtin_cpu_supports("avx512vl"))
{
return "x86_64-v4";
}
/* if (__builtin_cpu_supports ("x86-64-v3")) */
if (__builtin_cpu_supports("avx") && __builtin_cpu_supports("avx2")
&& __builtin_cpu_supports("bmi") && __builtin_cpu_supports("bmi2")
&& __builtin_cpu_supports("fma"))
{
return "x86_64-v3";
}
/* if (__builtin_cpu_supports ("x86-64-v2")) */
if (__builtin_cpu_supports("popcnt") && __builtin_cpu_supports("sse3")
&& __builtin_cpu_supports("ssse3") && __builtin_cpu_supports("sse4.1")
&& __builtin_cpu_supports("sse4.2"))
{
return "x86_64-v2";
}
#endif
return "x86_64";
}
std::vector<PackageInfo> dist_packages(const Context& context)
{
LOG_DEBUG << "Loading distribution virtual packages";
Expand Down Expand Up @@ -222,7 +249,7 @@ namespace mamba

if (arch == "64")
{
arch = "x86_64";
arch = get_archspec_x86_64();
}
else if (arch == "32")
{
Expand Down
2 changes: 1 addition & 1 deletion libmamba/tests/src/core/test_virtual_packages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace mamba
}
#if __x86_64__ || defined(_WIN64)
CHECK_EQ(pkgs.back().name, "__archspec");
CHECK_EQ(pkgs.back().build_string, "x86_64");
CHECK_EQ(pkgs.back().build_string.find("x86_64"), 0);
#endif

// This is bad design, tests should not interfer
Expand Down