[libre-riscv-dev] [isa-dev] FP reciprocal sqrt extension proposal

Jacob Lifshay programmerjake at gmail.com
Sun Jul 14 07:41:15 BST 2019


All of the opcodes in the table should have started with frsqrt instead of 
fsqrt

On Saturday, July 13, 2019 at 11:39:03 PM UTC-7, Jacob Lifshay wrote:
>
> On Sat, Jul 13, 2019 at 10:30 AM Aneesh Raveendran <aneeshr2020 at gmail.com> 
> wrote:
> >
> > Hi all,
> >     Myself Aneesh Raveendran. I worked on RISC-V floating point 
> co-processor. I have few doubts regarding floating point reciprocal 
> square-root.
> >
> > 1. In which application/bench marking suites will infer floating point 
> reciprocal square-root operations?
> reciprocal sqrt is used a lot in 3D graphics for normalizing vectors -- 
> the pseudocode for normalizing 3D a vector is:
> fn normalize(x: float, y: float, z: float) -> (float, float, float) {
>     let sum_of_squares = x * x + y * y + z * z;
>     let factor = rsqrt(sum_of_squares);
>     return (factor * x, factor * y, factor * z);
> }
>
> It can also be used in machine learning to normalize 1-hot output vectors, 
> though would not be particularly performance critical for that particular 
> usecase.
> > 2. If this instruction is proposing, what could be the possible 
> instruction formats? (opcodes, f7, f5 field values )
> The proposed instructions are:
> +----------+---------+-------+-----+--------+----+---------+
> | Mnemonic | funct7  | rs2   | rs1 | funct3 | rd | opcode  |
> +==========+=========+=======+=====+========+====+=========+
> | fsqrt.s  | 0111100 | 00000 | rs1 | rm     | rd | 1010011 |
> +----------+---------+-------+-----+--------+----+---------+
> | fsqrt.d  | 0111101 | 00000 | rs1 | rm     | rd | 1010011 |
> +----------+---------+-------+-----+--------+----+---------+
> | fsqrt.q  | 0111110 | 00000 | rs1 | rm     | rd | 1010011 |
> +----------+---------+-------+-----+--------+----+---------+
> | fsqrt.h  | 0111111 | 00000 | rs1 | rm     | rd | 1010011 |
> +----------+---------+-------+-----+--------+----+---------+
>
> > 3. Any testsuites are available to verify the functional correctness of 
> the module?
> mpfr implements reciprocal sqrt, however it doesn't support all of 
> RISC-V's rounding modes and may be missing support for other features 
> needed for testing.
> Softfloat doesn't currently implement rsqrt.
> I have not researched other softfloat libraries yet.
>
> Jacob Lifshay
>


More information about the libre-riscv-dev mailing list