From 8e39c05efde5fbe2be412193e1c97743417dfa4b Mon Sep 17 00:00:00 2001 From: Chen Yu Date: Fri, 5 Apr 2024 11:39:01 +0800 Subject: [PATCH] Get the l2 cache size via environment variable on confidential VM The CPUID(leaf:2 or leaf:0x80000006) is not supported on some confidential VMs. As a result the get_l2_size() returns the default 512M which brings performance issues. Introduce the environment variable OPENBLAS_L2_SIZE provided by the user to get the l2 cache size. Suggested-by: "Keshavamurthy, Anil S" Signed-off-by: Chen Yu --- kernel/setparam-ref.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/setparam-ref.c b/kernel/setparam-ref.c index 4c361f155..180268e2c 100644 --- a/kernel/setparam-ref.c +++ b/kernel/setparam-ref.c @@ -1248,6 +1248,10 @@ static __inline__ int get_l2_size(void){ int eax, ebx, ecx, edx, l2; + l2 = readenv_atoi("OPENBLAS_L2_SIZE"); + if (l2 != 0) + return l2; + cpuid(0x80000006, &eax, &ebx, &ecx, &edx); l2 = BITMASK(ecx, 16, 0xffff);