util/cpu: Remove util_cpu_caps_t::family

This had two uses, neither of them very good. On s390x we used it to
store the fact of our s390-ness, which we can replace with
DETECT_ARCH_S390. On x64 we used it to communicate AMD-Zen-ness to the
L3 topology detection code, which we can replace with a local parameter.

Reviewed-by: Marek Olšák <maraeo@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34820>
This commit is contained in:
Adam Jackson 2025-05-05 10:30:23 -04:00 committed by Marge Bot
parent 6abae1d42b
commit 1ef9cd3504
5 changed files with 12 additions and 42 deletions

View file

@ -1891,7 +1891,7 @@ arch_rounding_available(const struct lp_type type)
return true;
else if (util_get_cpu_caps()->has_neon)
return true;
else if (util_get_cpu_caps()->family == CPU_S390X)
else if (DETECT_ARCH_S390 == true)
return true;
return false;
@ -2003,7 +2003,7 @@ lp_build_round_arch(struct lp_build_context *bld,
enum lp_build_round_mode mode)
{
if (util_get_cpu_caps()->has_sse4_1 || util_get_cpu_caps()->has_neon ||
util_get_cpu_caps()->family == CPU_S390X) {
DETECT_ARCH_S390 == true) {
LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
const char *intrinsic_root;

View file

@ -818,11 +818,11 @@ update_cache_sha1_cpu(struct mesa_sha1 *ctx)
const struct util_cpu_caps_t *cpu_caps = util_get_cpu_caps();
/*
* Don't need the cpu cache affinity stuff. The rest
* is contained in first 5 dwords.
* is contained in first 4 dwords.
*/
STATIC_ASSERT(offsetof(struct util_cpu_caps_t, num_L3_caches)
== 5 * sizeof(uint32_t));
_mesa_sha1_update(ctx, cpu_caps, 5 * sizeof(uint32_t));
== 4 * sizeof(uint32_t));
_mesa_sha1_update(ctx, cpu_caps, 4 * sizeof(uint32_t));
}

View file

@ -480,7 +480,7 @@ test_unary(unsigned verbose, FILE *fp, const struct unary_test_t *test, unsigned
if (test->ref == &nearbyintf && length == 2 &&
!util_get_cpu_caps()->has_neon &&
util_get_cpu_caps()->family != CPU_S390X &&
DETECT_ARCH_S390 == false &&
!(util_get_cpu_caps()->has_sse4_1 && LLVM_VERSION_MAJOR >= 8) &&
ref != roundf(testval)) {
/* FIXME: The generic (non SSE) path in lp_build_iround, which is

View file

@ -498,7 +498,7 @@ check_os_loongarch64_support(void)
static void
get_cpu_topology(void)
get_cpu_topology(bool zen)
{
/* Default. This is OK if L3 is not present or there is only one. */
util_cpu_caps.num_L3_caches = 1;
@ -541,8 +541,7 @@ get_cpu_topology(void)
#if DETECT_ARCH_X86 || DETECT_ARCH_X86_64
/* AMD Zen */
if (util_cpu_caps.family >= CPU_AMD_ZEN1_ZEN2 &&
util_cpu_caps.family < CPU_AMD_LAST) {
if (zen) {
uint32_t regs[4];
uint32_t saved_mask[UTIL_MAX_CPUS / 32] = {0};
@ -752,6 +751,7 @@ _util_cpu_detect_once(void)
{
int available_cpus = 0;
int total_cpus = 0;
bool zen = false;
memset(&util_cpu_caps, 0, sizeof util_cpu_caps);
@ -863,20 +863,8 @@ _util_cpu_detect_once(void)
if (util_cpu_caps.x86_cpu_type == 0xf)
util_cpu_caps.x86_cpu_type += ((regs2[0] >> 20) & 0xff);
switch (util_cpu_caps.x86_cpu_type) {
case 0x17:
util_cpu_caps.family = CPU_AMD_ZEN1_ZEN2;
break;
case 0x18:
util_cpu_caps.family = CPU_AMD_ZEN_HYGON;
break;
case 0x19:
util_cpu_caps.family = CPU_AMD_ZEN3;
break;
default:
if (util_cpu_caps.x86_cpu_type > 0x19)
util_cpu_caps.family = CPU_AMD_ZEN_NEXT;
}
if (util_cpu_caps.x86_cpu_type >= 0x17)
zen = true;
/* general feature flags */
util_cpu_caps.has_sse = (regs2[3] >> 25) & 1; /* 0x2000000 */
@ -953,16 +941,12 @@ _util_cpu_detect_once(void)
check_os_loongarch64_support();
#endif /* DETECT_ARCH_LOONGARCH64 */
#if DETECT_ARCH_S390
util_cpu_caps.family = CPU_S390X;
#endif
check_cpu_caps_override();
/* max_vector_bits should be checked after cpu caps override */
check_max_vector_bits();
get_cpu_topology();
get_cpu_topology(zen);
if (debug_get_option_dump_cpu()) {
printf("util_cpu_caps.nr_cpus = %u\n", util_cpu_caps.nr_cpus);

View file

@ -49,18 +49,6 @@
extern "C" {
#endif
enum cpu_family {
CPU_UNKNOWN,
CPU_AMD_ZEN1_ZEN2,
CPU_AMD_ZEN_HYGON,
CPU_AMD_ZEN3,
CPU_AMD_ZEN_NEXT,
CPU_AMD_LAST,
CPU_S390X,
};
typedef uint32_t util_affinity_mask[UTIL_MAX_CPUS / 32];
struct util_cpu_caps_t {
@ -81,8 +69,6 @@ struct util_cpu_caps_t {
*/
int16_t max_cpus;
enum cpu_family family;
/* Feature flags */
int x86_cpu_type;
unsigned cacheline;