From 3116749717203ce8a4774d3d655b35eb3b61ef12 Mon Sep 17 00:00:00 2001 From: Chip Kerchner Date: Tue, 23 Sep 2025 15:02:20 +0000 Subject: [PATCH 1/3] Disable bf16 flags on RISC-V unless BUILD_BFLOAT16=1 --- driver/others/dynamic_riscv64.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/driver/others/dynamic_riscv64.c b/driver/others/dynamic_riscv64.c index aa82845d4b..4106a045e4 100644 --- a/driver/others/dynamic_riscv64.c +++ b/driver/others/dynamic_riscv64.c @@ -99,6 +99,9 @@ struct riscv_hwprobe { #define RISCV_HWPROBE_IMA_V (1 << 2) #define RISCV_HWPROBE_EXT_ZFH (1 << 27) #define RISCV_HWPROBE_EXT_ZVFH (1 << 30) +#define RISCV_HWPROBE_EXT_ZFBFMIN (1 << 52) +#define RISCV_HWPROBE_EXT_ZVFBFMIN (1 << 53) +#define RISCV_HWPROBE_EXT_ZVFBFWMA (1 << 54) #ifndef NR_riscv_hwprobe #ifndef NR_arch_specific_syscall @@ -170,6 +173,8 @@ static gotoblas_t* get_coretype(void) { if (ret == 0) { #if defined(BUILD_HFLOAT16) vector_mask = (RISCV_HWPROBE_IMA_V | RISCV_HWPROBE_EXT_ZFH | RISCV_HWPROBE_EXT_ZVFH); +#elif defined(BUILD_BFLOAT16) + vector_mask = (RISCV_HWPROBE_IMA_V | RISCV_HWPROBE_EXT_ZFBFMIN | RISCV_HWPROBE_EXT_ZVFBFMIN | RISCV_HWPROBE_EXT_ZVFBFWMA); #else vector_mask = RISCV_HWPROBE_IMA_V; #endif @@ -180,6 +185,10 @@ static gotoblas_t* get_coretype(void) { snprintf(coremsg, sizeof(coremsg), "Cpu support for Zfh+Zvfh extensions required due to BUILD_HFLOAT16=1\n"); openblas_warning(1, coremsg); return NULL; +#elif defined(BUILD_BFLOAT16) + snprintf(coremsg, sizeof(coremsg), "Cpu support for Zfbfmin+Zvfbfmin+Zvfbfwma extensions required due to BUILD_BFLOAT16=1\n"); + openblas_warning(1, coremsg); + return NULL; #else if (!(getauxval(AT_HWCAP) & DETECT_RISCV64_HWCAP_ISA_V)) return NULL; From 9427eaf4c4375c534e75064fe0215651298d6182 Mon Sep 17 00:00:00 2001 From: Chip Kerchner Date: Tue, 23 Sep 2025 20:24:40 +0000 Subject: [PATCH 2/3] Reduce flags for BF16 to only needed ones. --- Makefile.riscv64 | 2 +- driver/others/dynamic_riscv64.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile.riscv64 b/Makefile.riscv64 index cffc77e803..d8da98d5f0 100644 --- a/Makefile.riscv64 +++ b/Makefile.riscv64 @@ -11,7 +11,7 @@ ifeq ($(BUILD_HFLOAT16), 1) RISCV64_OPT := $(RISCV64_OPT)_zvfh_zfh endif ifeq ($(BUILD_BFLOAT16), 1) -RISCV64_OPT := $(RISCV64_OPT)_zfbfmin_zvfbfmin_zvfbfwma +RISCV64_OPT := $(RISCV64_OPT)_zvfbfwma endif ifeq ($(CORE), RISCV64_ZVL256B) CCOMMON_OPT += -march=$(RISCV64_OPT)_zvl256b -mabi=lp64d diff --git a/driver/others/dynamic_riscv64.c b/driver/others/dynamic_riscv64.c index 4106a045e4..2498046648 100644 --- a/driver/others/dynamic_riscv64.c +++ b/driver/others/dynamic_riscv64.c @@ -99,8 +99,6 @@ struct riscv_hwprobe { #define RISCV_HWPROBE_IMA_V (1 << 2) #define RISCV_HWPROBE_EXT_ZFH (1 << 27) #define RISCV_HWPROBE_EXT_ZVFH (1 << 30) -#define RISCV_HWPROBE_EXT_ZFBFMIN (1 << 52) -#define RISCV_HWPROBE_EXT_ZVFBFMIN (1 << 53) #define RISCV_HWPROBE_EXT_ZVFBFWMA (1 << 54) #ifndef NR_riscv_hwprobe @@ -174,7 +172,7 @@ static gotoblas_t* get_coretype(void) { #if defined(BUILD_HFLOAT16) vector_mask = (RISCV_HWPROBE_IMA_V | RISCV_HWPROBE_EXT_ZFH | RISCV_HWPROBE_EXT_ZVFH); #elif defined(BUILD_BFLOAT16) - vector_mask = (RISCV_HWPROBE_IMA_V | RISCV_HWPROBE_EXT_ZFBFMIN | RISCV_HWPROBE_EXT_ZVFBFMIN | RISCV_HWPROBE_EXT_ZVFBFWMA); + vector_mask = (RISCV_HWPROBE_IMA_V | RISCV_HWPROBE_EXT_ZVFBFWMA); #else vector_mask = RISCV_HWPROBE_IMA_V; #endif From fc7d6e65a1ba9c7b33a80a03932e2f6d64f220bf Mon Sep 17 00:00:00 2001 From: Chip Kerchner Date: Tue, 23 Sep 2025 20:26:44 +0000 Subject: [PATCH 3/3] Change BF16 warning message. --- driver/others/dynamic_riscv64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/others/dynamic_riscv64.c b/driver/others/dynamic_riscv64.c index 2498046648..726f76d790 100644 --- a/driver/others/dynamic_riscv64.c +++ b/driver/others/dynamic_riscv64.c @@ -184,7 +184,7 @@ static gotoblas_t* get_coretype(void) { openblas_warning(1, coremsg); return NULL; #elif defined(BUILD_BFLOAT16) - snprintf(coremsg, sizeof(coremsg), "Cpu support for Zfbfmin+Zvfbfmin+Zvfbfwma extensions required due to BUILD_BFLOAT16=1\n"); + snprintf(coremsg, sizeof(coremsg), "Cpu support for Zvfbfwma extensions required due to BUILD_BFLOAT16=1\n"); openblas_warning(1, coremsg); return NULL; #else