riscv: Add bfloat16 instruction support
Subsystems (3)
cover riscv: Add bfloat16 instruction support
Add description for the BFloat16 precision Floating-Point ISA extension, (Zfbfmin, Zvfbfmin, Zvfbfwma). which was ratified in commit 4dc23d62 ("Added Chapter title to BF16") of the riscv-isa-manual.
Inochi Amaoto (3):
dt-bindings: riscv: add bfloat16 ISA extension description
riscv: add ISA extension parsing for bfloat16 ISA extension
riscv: hwprobe: export bfloat16 ISA extension
Documentation/arch/riscv/hwprobe.rst | 12 +++++ .../devicetree/bindings/riscv/extensions.yaml | 45 +++++++++++++++++++ arch/riscv/include/asm/hwcap.h | 3 ++ arch/riscv/include/uapi/asm/hwprobe.h | 3 ++ arch/riscv/kernel/cpufeature.c | 3 ++ 5 files changed, 66 insertions(+)
--
2.47.0
PATCH 1/3 dt-bindings: riscv: add bfloat16 ISA extension description
Add description for the BFloat16 precision Floating-Point ISA extension, (Zfbfmin, Zvfbfmin, Zvfbfwma). which was ratified in commit 4dc23d62 ("Added Chapter title to BF16") of the riscv-isa-manual.
--- .../devicetree/bindings/riscv/extensions.yaml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +45 -0
@@ -277,6 +277,12 @@ properties: instructions, as ratified in commit 056b6ff ("Zfa is ratified") of riscv-isa-manual. + - const: zfbfmin + description: + The standard Zfbfmin extension which provides minimal support for + 16-bit half-precision brain floating-point instructions, as ratified + in commit 4dc23d62 ("Added Chapter title to BF16") of riscv-isa-manual. + - const: zfh description: The standard Zfh extension for 16-bit half-precision binary
@@ -467,6 +473,18 @@ properties: in commit 6f702a2 ("Vector extensions are now ratified") of riscv-v-spec. + - const: zvfbfmin + description: + The standard Zvfbfmin extension for minimal support for vectored + 16-bit half-precision brain floating-point instructions, as ratified + in commit 4dc23d62 ("Added Chapter title to BF16") of riscv-isa-manual. + + - const: zvfbfwma + description: + The standard Zvfbfwma extension for vectored half-precision brain + floating-point widening multiply-accumulate instructions, as ratified + in commit 4dc23d62 ("Added Chapter title to BF16") of riscv-isa-manual. + - const: zvfh description: The standard Zvfh extension for vectored half-precision
@@ -605,6 +623,33 @@ properties: then: contains: const: zca + # Zfbfmin depends on F + - if: + contains: + const: zfbfmin + then: + contains: + const: f + # Zvfbfmin depends on V or Zve32f + - if: + contains: + const: zvfbfmin + then: + oneOf: + - contains: + const: v + - contains: + const: zve32f + # Zvfbfwma depends on Zfbfmin and Zvfbfmin + - if: + contains: + const: zvfbfwma + then: + allOf: + - contains: + const: zfbfmin + - contains: + const: zvfbfmin allOf: # Zcf extension does not exist on rv64
Signature · 1 line
2.47.0
PATCH 2/3 riscv: add ISA extension parsing for bfloat16 ISA extension
In reply to Inochi AmaotoAdd parsing for Zfbmin, Zvfbfmin, Zvfbfwma ISA extension which were ratified in 4dc23d62 ("Added Chapter title to BF16") of the riscv-isa-manual.
--- arch/riscv/include/asm/hwcap.h | 3 +++ arch/riscv/kernel/cpufeature.c | 3 +++ 2 files changed, 6 insertions(+)
arch/riscv/include/asm/hwcap.h +3 -0
@@ -93,6 +93,9 @@#define RISCV_ISA_EXT_ZCMOP 84#define RISCV_ISA_EXT_ZAWRS 85#define RISCV_ISA_EXT_SVVPTC 86 +#define RISCV_ISA_EXT_ZFBFMIN 87 +#define RISCV_ISA_EXT_ZVFBFMIN 88 +#define RISCV_ISA_EXT_ZVFBFWMA 89#define RISCV_ISA_EXT_XLINUXENVCFG 127
arch/riscv/kernel/cpufeature.c +3 -0
@@ -325,6 +325,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_DATA (zacas,RISCV_ISA_EXT_ZACAS ),__RISCV_ISA_EXT_DATA (zawrs,RISCV_ISA_EXT_ZAWRS ),__RISCV_ISA_EXT_DATA (zfa,RISCV_ISA_EXT_ZFA ), +__RISCV_ISA_EXT_DATA (zfbfmin,RISCV_ISA_EXT_ZFBFMIN ),__RISCV_ISA_EXT_DATA (zfh,RISCV_ISA_EXT_ZFH ),__RISCV_ISA_EXT_DATA (zfhmin,RISCV_ISA_EXT_ZFHMIN ), __RISCV_ISA_EXT_DATA(zca, RISCV_ISA_EXT_ZCA),
@@ -357,6 +358,8 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_SUPERSET (zve64d,RISCV_ISA_EXT_ZVE64D , riscv_zve64d_exts),__RISCV_ISA_EXT_SUPERSET (zve64f,RISCV_ISA_EXT_ZVE64F , riscv_zve64f_exts),__RISCV_ISA_EXT_SUPERSET (zve64x,RISCV_ISA_EXT_ZVE64X , riscv_zve64x_exts), +__RISCV_ISA_EXT_DATA (zvfbfmin,RISCV_ISA_EXT_ZVFBFMIN ), +__RISCV_ISA_EXT_DATA (zvfbfwma,RISCV_ISA_EXT_ZVFBFWMA ),__RISCV_ISA_EXT_DATA (zvfh,RISCV_ISA_EXT_ZVFH ),__RISCV_ISA_EXT_DATA (zvfhmin,RISCV_ISA_EXT_ZVFHMIN ), __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),
Signature · 1 line
2.47.0
PATCH 3/3 riscv: hwprobe: export bfloat16 ISA extension
In reply to Inochi AmaotoExport Zfbmin, Zvfbfmin, Zvfbfwma ISA extension through hwprobe.
--- Documentation/arch/riscv/hwprobe.rst | 12 ++++++++++++ arch/riscv/include/uapi/asm/hwprobe.h | 3 +++ 2 files changed, 15 insertions(+)
Documentation/arch/riscv/hwprobe.rst +12 -0
@@ -239,6 +239,18 @@ The following keys are defined: ratified in commit 98918c844281 ("Merge pull request #1217 from riscv/zawrs") of riscv-isa-manual. + * :c:macro:`RISCV_HWPROBE_EXT_ZFBFMIN`: The Zfbfmin extension is supported as + defined in the RISC-V ISA manual starting from commit 4dc23d6229de + ("Added Chapter title to BF16"). + + * :c:macro:`RISCV_HWPROBE_EXT_ZVFBFMIN`: The Zvfbfmin extension is supported as + defined in the RISC-V ISA manual starting from commit 4dc23d6229de + ("Added Chapter title to BF16"). + + * :c:macro:`RISCV_HWPROBE_EXT_ZVFBFWMA`: The Zvfbfwma extension is supported as + defined in the RISC-V ISA manual starting from commit 4dc23d6229de + ("Added Chapter title to BF16"). + * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: Deprecated. Returns similar values to :c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`, but the key was mistakenly classified as a bitmask rather than a value.
arch/riscv/include/uapi/asm/hwprobe.h +3 -0
@@ -72,6 +72,9 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_EXT_ZCF (1ULL << 46)#define RISCV_HWPROBE_EXT_ZCMOP (1ULL << 47)#define RISCV_HWPROBE_EXT_ZAWRS (1ULL << 48) +#define RISCV_HWPROBE_EXT_ZFBFMIN (1ULL << 49) +#define RISCV_HWPROBE_EXT_ZVFBFMIN (1ULL << 50) +#define RISCV_HWPROBE_EXT_ZVFBFWMA (1ULL << 51)#define RISCV_HWPROBE_KEY_CPUPERF_0 5#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
Signature · 1 line
2.47.0
Re: [PATCH 3/3] riscv: hwprobe: export bfloat16 ISA extension
Quoted 36 lines · Inochi Amaoto
Export Zfbmin, Zvfbfmin, Zvfbfwma ISA extension through hwprobe.
Signed-off-by Inochi Amaoto <[email protected]>--- Documentation/arch/riscv/hwprobe.rst | 12 ++++++++++++ arch/riscv/include/uapi/asm/hwprobe.h | 3 +++ 2 files changed, 15 insertions(+)Documentation/arch/riscv/hwprobe.rst +12
-0@@ -239,6 +239,18 @@ The following keys are defined: ratified in commit 98918c844281 ("Merge pull request #1217 from riscv/zawrs") of riscv-isa-manual. + * :c:macro:`RISCV_HWPROBE_EXT_ZFBFMIN`: The Zfbfmin extension is supported as + defined in the RISC-V ISA manual starting from commit 4dc23d6229de + ("Added Chapter title to BF16"). + + * :c:macro:`RISCV_HWPROBE_EXT_ZVFBFMIN`: The Zvfbfmin extension is supported as + defined in the RISC-V ISA manual starting from commit 4dc23d6229de + ("Added Chapter title to BF16"). + + * :c:macro:`RISCV_HWPROBE_EXT_ZVFBFWMA`: The Zvfbfwma extension is supported as + defined in the RISC-V ISA manual starting from commit 4dc23d6229de + ("Added Chapter title to BF16"). + * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: Deprecated. Returns similar values to :c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`, but the key was mistakenly classified as a bitmask rather than a value.arch/riscv/include/uapi/asm/hwprobe.h +0
-0
arch/riscv/include/uapi/asm/hwprobe.h struct riscv_hwprobe { · line 77
Quoted 6 lines
arch/riscv/include/uapi/asm/hwprobe.h +3
-0@@ -72,6 +72,9 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_EXT_ZCF (1ULL << 46)#define RISCV_HWPROBE_EXT_ZCMOP (1ULL << 47)#define RISCV_HWPROBE_EXT_ZAWRS (1ULL << 48) +#define RISCV_HWPROBE_EXT_ZFBFMIN (1ULL << 49) +#define RISCV_HWPROBE_EXT_ZVFBFMIN (1ULL << 50) +#define RISCV_HWPROBE_EXT_ZVFBFWMA (1ULL << 51)
Hi Inochi,
These should be added as well in sys_hwprobe.c (see hwprobe_isa_ext0()).
Thanks,
Clément
Quoted 3 lines
arch/riscv/include/uapi/asm/hwprobe.h +0
-0#define RISCV_HWPROBE_KEY_CPUPERF_0 5#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
Re: [PATCH 3/3] riscv: hwprobe: export bfloat16 ISA extension
Quoted 48 lines · Clément Léger
Quoted 36 lines · Inochi Amaoto
Export Zfbmin, Zvfbfmin, Zvfbfwma ISA extension through hwprobe.
Signed-off-by Inochi Amaoto <[email protected]>--- Documentation/arch/riscv/hwprobe.rst | 12 ++++++++++++ arch/riscv/include/uapi/asm/hwprobe.h | 3 +++ 2 files changed, 15 insertions(+)Documentation/arch/riscv/hwprobe.rst +12
-0@@ -239,6 +239,18 @@ The following keys are defined: ratified in commit 98918c844281 ("Merge pull request #1217 from riscv/zawrs") of riscv-isa-manual. + * :c:macro:`RISCV_HWPROBE_EXT_ZFBFMIN`: The Zfbfmin extension is supported as + defined in the RISC-V ISA manual starting from commit 4dc23d6229de + ("Added Chapter title to BF16"). + + * :c:macro:`RISCV_HWPROBE_EXT_ZVFBFMIN`: The Zvfbfmin extension is supported as + defined in the RISC-V ISA manual starting from commit 4dc23d6229de + ("Added Chapter title to BF16"). + + * :c:macro:`RISCV_HWPROBE_EXT_ZVFBFWMA`: The Zvfbfwma extension is supported as + defined in the RISC-V ISA manual starting from commit 4dc23d6229de + ("Added Chapter title to BF16"). + * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: Deprecated. Returns similar values to :c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`, but the key was mistakenly classified as a bitmask rather than a value.arch/riscv/include/uapi/asm/hwprobe.h +0
-0arch/riscv/include/uapi/asm/hwprobe.h struct riscv_hwprobe { · line 77
Quoted 6 lines
arch/riscv/include/uapi/asm/hwprobe.h +3
-0@@ -72,6 +72,9 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_EXT_ZCF (1ULL << 46)#define RISCV_HWPROBE_EXT_ZCMOP (1ULL << 47)#define RISCV_HWPROBE_EXT_ZAWRS (1ULL << 48) +#define RISCV_HWPROBE_EXT_ZFBFMIN (1ULL << 49) +#define RISCV_HWPROBE_EXT_ZVFBFMIN (1ULL << 50) +#define RISCV_HWPROBE_EXT_ZVFBFWMA (1ULL << 51)Hi Inochi,
Quoted 6 lines
These should be added as well in
sys_hwprobe.c(seehwprobe_isa_ext0()).Thanks,
Clément
OK, I will add it, thanks for the reminder.
Regards,
Inochi