QEMU PRIP 2 - support for MIPS SIMD Architecture

From PRPL
Jump to: navigation, search
  • MIPS SIMD Architecture is now available in the upstream and prpl QEMU from v2.2.0

User stories[edit]

  • As a QEMU user I can run programs containing the MSA instructions.
  • As a QEMU user I am able to obtain tools featured MIPS32 R5/R6 ISA and/or MIPS64 R6 ISA that interoperate successfully with the MSA features.
  • As a QEMU user I am able to obtain and run MSA-enhanced Linux kernel.

Proposal[edit]

The MSA adds new instructions to the MIPS Architecture that allow efficient parallel processing of vector operations. The MIPS SIMD Architecture details: http://www.imgtec.com/mips/architectures/simd.asp

Implementation details[edit]

The patchset containing the MSA can be found in the QEMU email archives: http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg02190.html

  • New MSA op codes and decoder is added to target-mips/translate.c.
  • Majority of the MSA instructions is implemented via helper function in the new file target-mips/msa_helper.c.
  • The mips32r5-generic is the only core which defines the MSA module from the patchset but it can be added to any core implementing the MSA in the future.
  • LSA instruction is not included in the patchset as Release 6 implements it.
  • The MSA floating-point is compliant with the IEEE Standard for Floating-Point Arithmetic 754TM-2008. However the patchset is not set up with the IEEE-2008 option as QEMU softfloat for MIPS has not been updated yet.

Example[edit]

Sourcery CodeBench Lite 2014.05-27 for MIPS GNU/Linux (available here) can be used for building a program with inline MSA assembly:

#include <stdio.h>
int main()
{
    char a = 1;
    char b = 2;
    int result;

    __asm__  ("fill.b $w0,%1\n"
              "fill.b $w1,%2\n"
              "addv.b $w2,$w0,$w1\n"
              "copy_s.w %0,$w2[3]\n"
              : "=r" (result) : "r" (a), "r" (b));

    printf("result: %08x\n", result);
    return 0;
}

Building the program:

mips-linux-gnu-gcc main.c -EL -mips32r2 -static -Wa,-mmsa

Running on QEMU with MSA module:

qemu-mipsel -cpu mips32r5-generic a.out

Validation[edit]

  • The user should be able to build programs using MSA ISA with with commonly available high-level compilers like GCC and successfully run the program under QEMU Linux user mode emulation.
  • The user should be able to build programs using pThread enabled code where multiple threads use MSA ISA under QEMU Linux user mode emulation.
  • The user should be able to obtain a MSA-enhanced Linux kernel and run it under QEMU system mode emulation with multiple MSA ISA tasks in parallel with context switching ongoing between them managed by the Linux kernel.

Considerations[edit]